-
Notifications
You must be signed in to change notification settings - Fork 13k
[WIP] Using overload for JSX stateless function component #11871
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
Changes from 54 commits
618da6f
70ea640
8d02f9c
07c60a3
aeb7a3a
d263318
cd0aabd
9b8b854
6b0d648
fab4a84
790ce8c
999a585
6d283b0
2cb95fc
a7c405e
8d2fcc0
2dc82cd
2a3b43b
2f18a62
5d66909
979f645
df34e29
c38f6c1
5b454e6
33a5d98
f79f6d7
96a4311
8bac89e
cf83268
9a1ed32
40e443c
5eb5000
dd08cc6
ab50bf3
ce4709c
8e4a699
c441f9f
1c4f710
fd0c54c
699db36
5fae439
e182674
df7af98
40b1138
116c878
13e8f7f
ab75ea7
e8c3d62
83abd04
4019265
d9b0b63
6a5de5d
9705791
48f2b78
702efd5
c6a5a56
0027cee
7cb51d3
fb6846d
cbec19a
1c004bf
defc053
4a90614
30afb33
0d4c9fa
9a25fa9
e188191
98062a9
126260b
ed4fead
c52be4a
12bb35a
3f32fa1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,6 +308,7 @@ namespace ts { | |
JsxOpeningElement, | ||
JsxClosingElement, | ||
JsxAttribute, | ||
JsxAttributes, | ||
JsxSpreadAttribute, | ||
JsxExpression, | ||
|
||
|
@@ -705,6 +706,7 @@ namespace ts { | |
// SyntaxKind.BindingElement | ||
// SyntaxKind.Property | ||
// SyntaxKind.PropertyAssignment | ||
// SyntaxKind.JsxAttribute | ||
// SyntaxKind.ShorthandPropertyAssignment | ||
// SyntaxKind.EnumMember | ||
// SyntaxKind.JSDocPropertyTag | ||
|
@@ -1374,7 +1376,7 @@ namespace ts { | |
template: TemplateLiteral; | ||
} | ||
|
||
export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; | ||
export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; | ||
|
||
export interface AsExpression extends Expression { | ||
kind: SyntaxKind.AsExpression; | ||
|
@@ -1403,35 +1405,39 @@ namespace ts { | |
closingElement: JsxClosingElement; | ||
} | ||
|
||
/// Either the opening tag in a <Tag>...</Tag> pair, or the lone <Tag /> in a self-closing form | ||
export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; | ||
|
||
export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; | ||
|
||
export type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; | ||
|
||
export interface JsxAttributes extends ObjectLiteralExpressionBase<JsxAttributeLike> { | ||
} | ||
|
||
/// The opening element of a <Tag>...</Tag> JsxElement | ||
export interface JsxOpeningElement extends Expression { | ||
kind: SyntaxKind.JsxOpeningElement; | ||
tagName: JsxTagNameExpression; | ||
attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>; | ||
attributes: JsxAttributes; | ||
} | ||
|
||
/// A JSX expression of the form <TagName attrs /> | ||
export interface JsxSelfClosingElement extends PrimaryExpression { | ||
kind: SyntaxKind.JsxSelfClosingElement; | ||
tagName: JsxTagNameExpression; | ||
attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>; | ||
attributes: JsxAttributes; | ||
} | ||
|
||
/// Either the opening tag in a <Tag>...</Tag> pair, or the lone <Tag /> in a self-closing form | ||
export type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; | ||
|
||
export type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; | ||
|
||
export interface JsxAttribute extends Node { | ||
kind: SyntaxKind.JsxAttribute; | ||
// @kind(SyntaxKind.JsxAttribute) | ||
export interface JsxAttribute extends ObjectLiteralElement { | ||
name: Identifier; | ||
/// JSX attribute initializers are optional; <X y /> is sugar for <X y={true} /> | ||
initializer?: StringLiteral | JsxExpression; | ||
} | ||
|
||
export interface JsxSpreadAttribute extends Node { | ||
// @kind(SyntaxKind.JsxSpreadAttribute) | ||
export interface JsxSpreadAttribute extends ObjectLiteralElement { | ||
kind: SyntaxKind.JsxSpreadAttribute; | ||
expression: Expression; | ||
} | ||
|
@@ -2298,7 +2304,7 @@ namespace ts { | |
getAliasedSymbol(symbol: Symbol): Symbol; | ||
getExportsOfModule(moduleSymbol: Symbol): Symbol[]; | ||
|
||
getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; | ||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type; | ||
getJsxIntrinsicTagNames(): Symbol[]; | ||
isOptionalParameter(node: ParameterDeclaration): boolean; | ||
getAmbientModules(): Symbol[]; | ||
|
@@ -2669,7 +2675,7 @@ namespace ts { | |
isVisible?: boolean; // Is this node visible | ||
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context | ||
jsxFlags?: JsxFlags; // flags for knowing what kind of element/attributes we're dealing with | ||
resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element | ||
resolvedJsxElementAttributesType?: Type; // resolved element attributes type of a JSX openinglike element | ||
hasSuperCall?: boolean; // recorded result when we try to find super-call. We only try to find one if this flag is undefined, indicating that we haven't made an attempt. | ||
superCall?: ExpressionStatement; // Cached first super-call found in the constructor. Used in checking whether super is called before this-accessing | ||
switchTypes?: Type[]; // Cached array of switch case expression types | ||
|
@@ -2704,6 +2710,8 @@ namespace ts { | |
ContainsObjectLiteral = 1 << 22, // Type is or contains object literal type | ||
/* @internal */ | ||
ContainsAnyFunctionType = 1 << 23, // Type is or contains object literal type | ||
/* @internal */ | ||
JsxAttributes = 1 << 24, // Jsx attributes type | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My preliminary reaction is that JsxAttributes can't produces types that are very different from normal typescript types, so I expect that this flag is not really needed. But I still need to read the rest of the code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, it's because of the ObjectLiteralBase type. Hm. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea the reason I need this flag is because in checking "hasExcessProperties" jsx attributes have different requirement |
||
|
||
/* @internal */ | ||
Nullable = Undefined | Null, | ||
|
@@ -2866,7 +2874,7 @@ namespace ts { | |
|
||
/* @internal */ | ||
// Object literals are initially marked fresh. Freshness disappears following an assignment, | ||
// before a type assertion, or when when an object literal's type is widened. The regular | ||
// before a type assertion, or when an object literal's type is widened. The regular | ||
// version of a fresh type is identical except for the TypeFlags.FreshObjectLiteral flag. | ||
export interface FreshObjectLiteralType extends ResolvedType { | ||
regularType: ResolvedType; // Regular version of fresh 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.
doesn't JsxAttribute still need a
kind: SyntaxKind.JsxAttribute;
?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.
you are right. will fix that
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.
also don't need the
// @kind(...)
any more