-
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
Index signature parameter type allows Enum and type alias = number|strin... #2652
Changes from all commits
ace18ab
8922d4f
aa6a34f
16acc84
f7afb07
98e5e98
6f0472d
567da59
e1f8125
b569615
98f4d87
52aecaa
f27b250
a36e0f4
1d08c72
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.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1446,15 +1446,17 @@ module ts { | |
/* @internal */ | ||
ContainsUndefinedOrNull = 0x00040000, // Type is or contains Undefined or Null type | ||
/* @internal */ | ||
ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type | ||
ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type | ||
ESSymbol = 0x00100000, // Type of symbol primitive introduced in ES6 | ||
Subset = 0x00200000, // Type that has a subset of valid values | ||
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. what does this mean? can you elaborate? |
||
|
||
/* @internal */ | ||
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null, | ||
/* @internal */ | ||
Primitive = String | Number | Boolean | ESSymbol | Void | Undefined | Null | StringLiteral | Enum, | ||
StringLike = String | StringLiteral, | ||
NumberLike = Number | Enum, | ||
SubsetMaybe = Enum | Reference, | ||
ObjectType = Class | Interface | Reference | Tuple | Anonymous, | ||
/* @internal */ | ||
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral | ||
|
@@ -1488,8 +1490,8 @@ module ts { | |
declaredProperties: Symbol[]; // Declared members | ||
declaredCallSignatures: Signature[]; // Declared call signatures | ||
declaredConstructSignatures: Signature[]; // Declared construct signatures | ||
declaredStringIndexType: Type; // Declared string index type | ||
declaredNumberIndexType: Type; // Declared numeric index type | ||
declaredStringIndex: IndexType; // Declared string type | ||
declaredNumberIndex: IndexType; // Declared numeric type | ||
} | ||
|
||
// Type references (TypeFlags.Reference) | ||
|
@@ -1515,15 +1517,32 @@ module ts { | |
resolvedProperties: SymbolTable; // Cache of resolved properties | ||
} | ||
|
||
/* @internal */ | ||
// Resolved object or union type | ||
export enum IndexAlphaNumeric { | ||
NO, | ||
YES, // string & number indexes come from different types | ||
INHERITED // string & number indexes are both from an inherited type | ||
} | ||
|
||
export interface IndexType { | ||
kind: IndexKind // Kind of index | ||
typeOfValue: Type // any | ||
typeOfIndex?: Type // string|number|enum | ||
|
||
// Useful for error reporting | ||
declaredNode?: SignatureDeclaration, // Declaration of [x: typeOfIndex]: typeOfValue | ||
declaredCount?: number // Number of declarations | ||
inherited?: Symbol // Symbol of baseType where inherited | ||
} | ||
|
||
/* @internal */ // Resolved object or union type | ||
export interface ResolvedType extends ObjectType, UnionType { | ||
members: SymbolTable; // Properties by name | ||
properties: Symbol[]; // Properties | ||
callSignatures: Signature[]; // Call signatures of type | ||
constructSignatures: Signature[]; // Construct signatures of type | ||
stringIndexType: Type; // String index type | ||
numberIndexType: Type; // Numeric index type | ||
members: SymbolTable; // Properties by name | ||
properties: Symbol[]; // Properties | ||
callSignatures: Signature[]; // Call signatures of type | ||
constructSignatures: Signature[]; // Construct signatures of type | ||
stringIndex: IndexType; // String index type | ||
numberIndex: IndexType; // Number index type | ||
alphaNumericIndex?: IndexAlphaNumeric // Information about alphanumeric index | ||
} | ||
|
||
// Type parameters (TypeFlags.TypeParameter) | ||
|
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.
Must be 'string', 'number' or an enum 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.
Sorry, I'm missing the difference, unless you want to take out the Oxford comma, in which case I think it's more helpful.
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.
Some of the error messages show: "An index signature parameter type must be 'string', 'number' or Enum"
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.
Ah - the baselines need to be updated since this change.