-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Master] fix15742 #15789
[Master] fix15742 #15789
Conversation
src/compiler/checker.ts
Outdated
} | ||
return getIntersectionType(propsApprentType); | ||
} | ||
return propsType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if it is not an intersection, you do not want to call getApparentType on it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the special case for intersection types needed? I thought that getApparentType of an intersection type would do the right thing.
src/compiler/checker.ts
Outdated
function getApparentTypeOfJsxPropsType(propsType: Type): Type { | ||
if (propsType) { | ||
if (propsType.flags & TypeFlags.Intersection) { | ||
const propsApprentType: Type[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo:Apparent
src/compiler/checker.ts
Outdated
if (propsType) { | ||
if (propsType.flags & TypeFlags.Intersection) { | ||
const propsApprentType: Type[] = []; | ||
for (const t of (<UnionOrIntersectionType>propsType).types) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't getApparentType
of an intersection type do this loop for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later: no it doesn't. :( You should be able to express this as getIntersectionType(t.types.map(getApparentType)))
though, right?
src/compiler/checker.ts
Outdated
@@ -13548,6 +13548,20 @@ namespace ts { | |||
return _jsxElementChildrenPropertyName; | |||
} | |||
|
|||
function getApparentTypeOfJsxPropsType(propsType: Type): Type { | |||
if (propsType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this better:
if (!propsType) {
return undefined;
}
Never mind, I looked more closely at |
@sandersn I wasn't expected that as well |
@yuit can you please port this to release-2.3 |
never mind, I ported it. |
Fix #15742
Note: There is still an issue when using generic with class see https://github.com/Microsoft/TypeScript/compare/master-fix15742?expand=1#diff-c5ae2fab8e9a760ddeda06b1b9128151
TODO
port to release
add more tests