-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Fix get symbol at location to behave correctly for parameter assignments and jsx attributes #20706
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 all commits
fdded50
fa85c9b
f53c795
f9e67be
7405a9c
be49853
f947fbf
07c7c6d
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 |
---|---|---|
|
@@ -584,6 +584,40 @@ namespace ts { | |
| JSDocFunctionType | ||
| EndOfFileToken; | ||
|
||
export type HasType = | ||
| SignatureDeclaration | ||
| VariableDeclaration | ||
| ParameterDeclaration | ||
| PropertySignature | ||
| PropertyDeclaration | ||
| TypePredicateNode | ||
| ParenthesizedTypeNode | ||
| TypeOperatorNode | ||
| MappedTypeNode | ||
| AssertionExpression | ||
| TypeAliasDeclaration | ||
| JSDocTypeExpression | ||
| JSDocNonNullableType | ||
| JSDocNullableType | ||
| JSDocOptionalType | ||
| JSDocVariadicType; | ||
|
||
export type HasInitializer = | ||
| HasExpressionInitializer | ||
| ForStatement | ||
| ForInStatement | ||
| ForOfStatement | ||
| JsxAttribute; | ||
|
||
export type HasExpressionInitializer = | ||
| VariableDeclaration | ||
| ParameterDeclaration | ||
| BindingElement | ||
| PropertySignature | ||
| PropertyDeclaration | ||
| PropertyAssignment | ||
| EnumMember; | ||
|
||
/* @internal */ | ||
export type MutableNodeArray<T extends Node> = NodeArray<T> & T[]; | ||
|
||
|
@@ -793,6 +827,9 @@ namespace ts { | |
initializer?: Expression; // Optional initializer | ||
} | ||
|
||
/*@internal*/ | ||
export type BindingElementGrandparent = BindingElement["parent"]["parent"]; | ||
|
||
export interface PropertySignature extends TypeElement, JSDocContainer { | ||
kind: SyntaxKind.PropertySignature; | ||
name: PropertyName; // Declared property name | ||
|
@@ -848,25 +885,18 @@ namespace ts { | |
expression: Expression; | ||
} | ||
|
||
// SyntaxKind.VariableDeclaration | ||
// SyntaxKind.Parameter | ||
// SyntaxKind.BindingElement | ||
// SyntaxKind.Property | ||
// SyntaxKind.PropertyAssignment | ||
// SyntaxKind.JsxAttribute | ||
// SyntaxKind.ShorthandPropertyAssignment | ||
// SyntaxKind.EnumMember | ||
// SyntaxKind.JSDocPropertyTag | ||
// SyntaxKind.JSDocParameterTag | ||
export interface VariableLikeDeclaration extends NamedDeclaration { | ||
propertyName?: PropertyName; | ||
dotDotDotToken?: DotDotDotToken; | ||
name: DeclarationName; | ||
questionToken?: QuestionToken; | ||
exclamationToken?: ExclamationToken; | ||
type?: TypeNode; | ||
initializer?: Expression; | ||
} | ||
export type VariableLikeDeclaration = | ||
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. performance? I remember doing this (or similar) and found it added quite a bit of time to our build. 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. There's no noticeable difference in self-compilation (maybe slightly better? The difference is in the noise.). |
||
| VariableDeclaration | ||
| ParameterDeclaration | ||
| BindingElement | ||
| PropertyDeclaration | ||
| PropertyAssignment | ||
| PropertySignature | ||
| JsxAttribute | ||
| ShorthandPropertyAssignment | ||
| EnumMember | ||
| JSDocPropertyTag | ||
| JSDocParameterTag; | ||
|
||
export interface PropertyLikeDeclaration extends NamedDeclaration { | ||
name: PropertyName; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -453,6 +453,9 @@ declare namespace ts { | |
interface JSDocContainer { | ||
} | ||
type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | EndOfFileToken; | ||
type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; | ||
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. are these aliases meant to be public? I guess maybe they are required for export to services/ 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. I wanted to make them public (like 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. I don't care much either way, just checking. |
||
type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; | ||
type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; | ||
interface NodeArray<T extends Node> extends ReadonlyArray<T>, TextRange { | ||
hasTrailingComma?: boolean; | ||
} | ||
|
@@ -604,15 +607,7 @@ declare namespace ts { | |
kind: SyntaxKind.SpreadAssignment; | ||
expression: Expression; | ||
} | ||
interface VariableLikeDeclaration extends NamedDeclaration { | ||
propertyName?: PropertyName; | ||
dotDotDotToken?: DotDotDotToken; | ||
name: DeclarationName; | ||
questionToken?: QuestionToken; | ||
exclamationToken?: ExclamationToken; | ||
type?: TypeNode; | ||
initializer?: Expression; | ||
} | ||
type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; | ||
interface PropertyLikeDeclaration extends NamedDeclaration { | ||
name: PropertyName; | ||
} | ||
|
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 can't these be shared any more? Are there order conflicts in the current, shared version?
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.
The union won't allow access to properties that don't exist on every node. Also, this is less polymorphic, so should have slightly better performance.