You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Issue with 'this' Parameter and JSX Component GenericsΒ #55431
BugA bug in TypeScriptDomain: This-TypingThe issue relates to providing types to thisRescheduledThis issue was previously scheduled to an earlier milestone
declarenamespaceJSX{typeLibraryManagedAttributes<C,P>=ThisParameterType<C>;interfaceIntrinsicElements{div: {};}}functionTest<T>(this: {value: T}){return<div>{this.value }</div>}<Test<number>value={5}/>// value is unknown
π Actual behavior
TypeScript is incorrectly inferring props types for JSX functional components with generic templates when props are derived from the 'this' parameter.
Even when explicitly typed as <number>, the Test component still exhibits the issue where the type of value remains unknown.
π Expected behavior
It should infer the type from the passed data or at least accept that you explicitly type it with <Test<number> ...
Additional information about the issue
If you define a separate variable and assign the component with <Test<number>>, the value prop's type gets correctly inferred as number.
constTypedTest=Test<number>;<TypedTestvalue={5}/>// value is number
BugA bug in TypeScriptDomain: This-TypingThe issue relates to providing types to thisRescheduledThis issue was previously scheduled to an earlier milestone
Activity