-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Static types for dynamically named properties #11929
Changes from 17 commits
ad88109
07478aa
c21592e
e7cfbfe
4b50ef3
ece1f19
8d87971
5515dce
550be9c
6c20533
88961cd
2f34f7c
f293744
f9e2085
03f8403
8d9356f
6b28d21
41c2054
663985e
70fc25a
4bbe29a
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 |
---|---|---|
|
@@ -168,6 +168,7 @@ namespace ts { | |
DeclareKeyword, | ||
GetKeyword, | ||
IsKeyword, | ||
KeyOfKeyword, | ||
ModuleKeyword, | ||
NamespaceKeyword, | ||
NeverKeyword, | ||
|
@@ -216,6 +217,8 @@ namespace ts { | |
IntersectionType, | ||
ParenthesizedType, | ||
ThisType, | ||
TypeOperator, | ||
IndexedAccessType, | ||
LiteralType, | ||
// Binding patterns | ||
ObjectBindingPattern, | ||
|
@@ -882,6 +885,18 @@ namespace ts { | |
type: TypeNode; | ||
} | ||
|
||
export interface TypeOperatorNode extends TypeNode { | ||
kind: SyntaxKind.TypeOperator; | ||
operator: SyntaxKind.KeyOfKeyword; | ||
type: TypeNode; | ||
} | ||
|
||
export interface IndexedAccessTypeNode extends TypeNode { | ||
kind: SyntaxKind.IndexedAccessType; | ||
objectType: TypeNode; | ||
indexType: TypeNode; | ||
} | ||
|
||
export interface LiteralTypeNode extends TypeNode { | ||
kind: SyntaxKind.LiteralType; | ||
literal: Expression; | ||
|
@@ -953,10 +968,6 @@ namespace ts { | |
operator: PostfixUnaryOperator; | ||
} | ||
|
||
export interface PostfixExpression extends UnaryExpression { | ||
_postfixExpressionBrand: any; | ||
} | ||
|
||
export interface LeftHandSideExpression extends IncrementExpression { | ||
_leftHandSideExpressionBrand: any; | ||
} | ||
|
@@ -2667,14 +2678,16 @@ namespace ts { | |
Object = 1 << 15, // Object type | ||
Union = 1 << 16, // Union (T | U) | ||
Intersection = 1 << 17, // Intersection (T & U) | ||
Index = 1 << 18, // keyof T | ||
IndexedAccess = 1 << 19, // T[K] | ||
/* @internal */ | ||
FreshLiteral = 1 << 18, // Fresh literal type | ||
FreshLiteral = 1 << 20, // Fresh literal type | ||
/* @internal */ | ||
ContainsWideningType = 1 << 19, // Type is or contains undefined or null widening type | ||
ContainsWideningType = 1 << 21, // Type is or contains undefined or null widening type | ||
/* @internal */ | ||
ContainsObjectLiteral = 1 << 20, // Type is or contains object literal type | ||
ContainsObjectLiteral = 1 << 22, // Type is or contains object literal type | ||
/* @internal */ | ||
ContainsAnyFunctionType = 1 << 21, // Type is or contains object literal type | ||
ContainsAnyFunctionType = 1 << 23, // Type is or contains object literal type | ||
|
||
/* @internal */ | ||
Nullable = Undefined | Null, | ||
|
@@ -2697,7 +2710,7 @@ namespace ts { | |
|
||
// 'Narrowable' types are types where narrowing actually narrows. | ||
// This *should* be every type other than null, undefined, void, and never | ||
Narrowable = Any | StructuredType | TypeParameter | StringLike | NumberLike | BooleanLike | ESSymbol, | ||
Narrowable = Any | StructuredType | TypeParameter | Index | IndexedAccess | StringLike | NumberLike | BooleanLike | ESSymbol, | ||
NotUnionOrUnit = Any | ESSymbol | Object, | ||
/* @internal */ | ||
RequiresWidening = ContainsWideningType | ContainsObjectLiteral, | ||
|
@@ -2860,9 +2873,22 @@ namespace ts { | |
/* @internal */ | ||
resolvedApparentType: Type; | ||
/* @internal */ | ||
resolvedIndexType: IndexType; | ||
/* @internal */ | ||
resolvedIndexedAccessTypes: IndexedAccessType[]; | ||
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. why array instead of map? the array is going to be sparse if indexed with type id. 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. Yes, it will be sparse, in the same way that our |
||
/* @internal */ | ||
isThisType?: boolean; | ||
} | ||
|
||
export interface IndexType extends Type { | ||
type: TypeParameter; | ||
} | ||
|
||
export interface IndexedAccessType extends Type { | ||
objectType: Type; | ||
indexType: TypeParameter; | ||
} | ||
|
||
export const enum SignatureKind { | ||
Call, | ||
Construct, | ||
|
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.
🎉 this is much better now!