8000 Tuples in rest parameters and spread expressions by ahejlsberg · Pull Request #24897 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content

Tuples in rest parameters and spread expressions #24897

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

Merged
merged 40 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8cd8edb
Allow generic rest parameters and infer tuples when possible
ahejlsberg Jun 7, 2018
43bfccf
Accept new baselines
ahejlsberg Jun 7, 2018
2e04322
Optional elements in tuple types + empty tuple types + other fixes.
ahejlsberg Jun 9, 2018
346276c
Accept new baselines
ahejlsberg Jun 9, 2018
c69e4e7
Expand rest parameter with tuple types when emitting signatures
ahejlsberg Jun 11, 2018
73e008d
Accept new baselines
ahejlsberg Jun 11, 2018
7aee647
Record parameter names in inferred tuple types
ahejlsberg Jun 11, 2018
9ae9371
Fix lint errors
ahejlsberg Jun 11, 2018
e239f86
Flatten spread expressions of tuple types
ahejlsberg Jun 11, 2018
0b0a91a
Accept new baselines
ahejlsberg Jun 11, 2018
5245642
Accept baseline API changes
ahejlsberg Jun 11, 2018
39099a0
Merge branch 'master' into restTuples
ahejlsberg Jun 12, 2018
dee51ed
Accept baseline changes in APIs
ahejlsberg Jun 12, 2018
f93f6ec
Better algorithm for combined co- and contra-variant inferences.
ahejlsberg Jun 12, 2018
6bdedad
Accept new baselines
ahejlsberg Jun 12, 2018
58d5583
Minor fixes
ahejlsberg Jun 13, 2018
cee75aa
Properly widen type element types in inferred rest parameter types
ahejlsberg Jun 14, 2018
0cc0fad
Add tests
ahejlsberg Jun 14, 2018
09f17bc
Accept new baselines
ahejlsberg Jun 14, 2018
f1efd1d
Parsing and rudimentary checking of tuples with rest elements
ahejlsberg Jun 15, 2018
4f99bc1
Merge branch 'master' into restTuples
ahejlsberg Jun 16, 2018
64aabf2
Accept new baselines
ahejlsberg Jun 16, 2018
82448af
Merge branch 'master' into restTuples
ahejlsberg Jun 16, 2018
3f03a37
Infer union types for rest elements in tuples
ahejlsberg Jun 16, 2018
43bac20
Array literals contextually typed by tuple types with rest elements
ahejlsberg Jun 16, 2018
ae859d6
Update destructuring to support optional and rest elements in tuples
ahejlsberg Jun 22, 2018
c231000
Update tests
ahejlsberg Jun 22, 2018
4037d07
Accept new baselines
ahejlsberg Jun 22, 2018
cffa1dd
Accept new baselines
ahejlsberg Jun 22, 2018
0a94f77
Accept new baselines
ahejlsberg Jun 22, 2018
b0d8c65
Merge branch 'master' into restTuples
ahejlsberg Jun 22, 2018
b650d7d
Fix issue
ahejlsberg Jun 22, 2018
88444fe
Accept new baselines
ahejlsberg Jun 22, 2018
28c9f59
Complete support for rest elements in tuples
ahejlsberg Jun 25, 2018
9cd8ead
Update tests
ahejlsberg Jun 25, 2018
3cc3b49
Accept new baselines
ahejlsberg Jun 25, 2018
d7443f0
Contextual typing by tuple rest elements
ahejlsberg Jun 25, 2018
d869e56
Add tests
ahejlsberg Jun 25, 2018
5ef7e9f
Accept new baselines
ahejlsberg Jun 25, 2018
656ccd8
Revert package.json change
ahejlsberg Jun 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Accept new baselines
  • Loading branch information
ahejlsberg committed Jun 9, 2018
commit 346276ce7a6fe49ed31d92289ee02d3ceba94047
7 changes: 0 additions & 7 deletions tests/baselines/reference/TupleType3.errors.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
tests/cases/compiler/anyIndexedAccessArrayNoException.ts(1,12): error TS1122: A tuple type element list cannot be empty.
tests/cases/compiler/anyIndexedAccessArrayNoException.ts(1,12): error TS2538: Type '[]' cannot be used as an index type.


==== tests/cases/compiler/anyIndexedAccessArrayNoException.ts (2 errors) ====
==== tests/cases/compiler/anyIndexedAccessArrayNoException.ts (1 errors) ====
var x: any[[]];
~~
!!! error TS1122: A tuple type element list cannot be empty.
~~
!!! error TS2538: Type '[]' cannot be used as an index type.

296 changes: 153 additions & 143 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,143 +231,144 @@ declare namespace ts {
TypeLiteral = 166,
ArrayType = 167,
TupleType = 168,
UnionType = 169,
IntersectionType = 170,
ConditionalType = 171,
InferType = 172,
ParenthesizedType = 173,
ThisType = 174,
TypeOperator = 175,
IndexedAccessType = 176,
MappedType = 177,
LiteralType = 178,
ImportType = 179,
ObjectBindingPattern = 180,
ArrayBindingPattern = 181,
BindingElement = 182,
ArrayLiteralExpression = 183,
ObjectLiteralExpression = 184,
PropertyAccessExpression = 185,
ElementAccessExpression = 186,
CallExpression = 187,
NewExpression = 188,
TaggedTemplateExpression = 189,
TypeAssertionExpression = 190,
ParenthesizedExpression = 191,
FunctionExpression = 192,
ArrowFunction = 193,
DeleteExpression = 194,
TypeOfExpression = 195,
VoidExpression = 196,
AwaitExpression = 197,
PrefixUnaryExpression = 198,
PostfixUnaryExpression = 199,
BinaryExpression = 200,
ConditionalExpression = 201,
TemplateExpression = 202,
YieldExpression = 203,
SpreadElement = 204,
ClassExpression = 205,
OmittedExpression = 206,
ExpressionWithTypeArguments = 207,
AsExpression = 208,
NonNullExpression = 209,
MetaProperty = 210,
TemplateSpan = 211,
SemicolonClassElement = 212,
Block = 213,
VariableStatement = 214,
EmptyStatement = 215,
ExpressionStatement = 216,
IfStatement = 217,
DoStatement = 218,
WhileStatement = 219,
ForStatement = 220,
ForInStatement = 221,
ForOfStatement = 222,
ContinueStatement = 223,
BreakStatement = 224,
ReturnStatement = 225,
WithStatement = 226,
SwitchStatement = 227,
LabeledStatement = 228,
ThrowStatement = 229,
TryStatement = 230,
DebuggerStatement = 231,
VariableDeclaration = 232,
VariableDeclarationList = 233,
FunctionDeclaration = 234,
ClassDeclaration = 235,
InterfaceDeclaration = 236,
TypeAliasDeclaration = 237,
EnumDeclaration = 238,
ModuleD 8000 eclaration = 239,
ModuleBlock = 240,
CaseBlock = 241,
NamespaceExportDeclaration = 242,
ImportEqualsDeclaration = 243,
ImportDeclaration = 244,
ImportClause = 245,
NamespaceImport = 246,
NamedImports = 247,
ImportSpecifier = 248,
ExportAssignment = 249,
ExportDeclaration = 250,
NamedExports = 251,
ExportSpecifier = 252,
MissingDeclaration = 253,
ExternalModuleReference = 254,
JsxElement = 255,
JsxSelfClosingElement = 256,
JsxOpeningElement = 257,
JsxClosingElement = 258,
JsxFragment = 259,
JsxOpeningFragment = 260,
JsxClosingFragment = 261,
JsxAttribute = 262,
JsxAttributes = 263,
JsxSpreadAttribute = 264,
JsxExpression = 265,
CaseClause = 266,
DefaultClause = 267,
HeritageClause = 268,
CatchClause = 269,
PropertyAssignment = 270,
ShorthandPropertyAssignment = 271,
SpreadAssignment = 272,
EnumMember = 273,
SourceFile = 274,
Bundle = 275,
UnparsedSource = 276,
InputFiles = 277,
JSDocTypeExpression = 278,
JSDocAllType = 279,
JSDocUnknownType = 280,
JSDocNullableType = 281,
JSDocNonNullableType = 282,
JSDocOptionalType = 283,
JSDocFunctionType = 284,
JSDocVariadicType = 285,
JSDocComment = 286,
JSDocTypeLiteral = 287,
JSDocSignature = 288,
JSDocTag = 289,
JSDocAugmentsTag = 290,
JSDocClassTag = 291,
JSDocCallbackTag = 292,
JSDocParameterTag = 293,
JSDocReturnTag = 294,
JSDocTypeTag = 295,
JSDocTemplateTag = 296,
JSDocTypedefTag = 297,
JSDocPropertyTag = 298,
SyntaxList = 299,
NotEmittedStatement = 300,
PartiallyEmittedExpression = 301,
CommaListExpression = 302,
MergeDeclarationMarker = 303,
EndOfDeclarationMarker = 304,
Count = 305,
OptionalType = 169,
UnionType = 170,
IntersectionType = 171,
ConditionalType = 172,
InferType = 173,
ParenthesizedType = 174,
ThisType = 175,
TypeOperator = 176,
IndexedAccessType = 177,
MappedType = 178,
LiteralType = 179,
ImportType = 180,
ObjectBindingPattern = 181,
ArrayBindingPattern = 182,
BindingElement = 183,
ArrayLiteralExpression = 184,
ObjectLiteralExpression = 185,
PropertyAccessExpression = 186,
ElementAccessExpression = 187,
CallExpression = 188,
NewExpression = 189,
TaggedTemplateExpression = 190,
TypeAssertionExpression = 191,
ParenthesizedExpression = 192,
FunctionExpression = 193,
ArrowFunction = 194,
DeleteExpression = 195,
TypeOfExpression = 196,
VoidExpression = 197,
AwaitExpression = 198,
PrefixUnaryExpression = 199,
PostfixUnaryExpression = 200,
BinaryExpression = 201,
ConditionalExpression = 202,
TemplateExpression = 203,
YieldExpression = 204,
SpreadElement = 205,
ClassExpression = 206,
OmittedExpression = 207,
ExpressionWithTypeArguments = 208,
AsExpression = 209,
NonNullExpression = 210,
MetaProperty = 211,
TemplateSpan = 212,
SemicolonClassElement = 213,
Block = 214,
VariableStatement = 215,
EmptyStatement = 216,
ExpressionStatement = 217,
IfStatement = 218,
DoStatement = 219,
WhileStatement = 220,
ForStatement = 221,
ForInStatement = 222,
ForOfStatement = 223,
ContinueStatement = 224,
BreakStatement = 225,
ReturnStatement = 226,
WithStatement = 227,
SwitchStatement = 228,
LabeledStatement = 229,
ThrowStatement = 230,
TryStatement = 231,
DebuggerStatement = 232,
VariableDeclaration = 233,
VariableDeclarationList = 234,
FunctionDeclaration = 235,
ClassDeclaration = 236,
InterfaceDeclaration = 237,
TypeAliasDeclaration = 238,
EnumDeclaration = 239,
ModuleDeclaration = 240,
ModuleBlock = 241,
CaseBlock = 242,
NamespaceExportDeclaration = 243,
ImportEqualsDeclaration = 244,
ImportDeclaration = 245,
ImportClause = 246,
NamespaceImport = 247,
NamedImports = 248,
ImportSpecifier = 249,
ExportAssignment = 250,
ExportDeclaration = 251,
NamedExports = 252,
ExportSpecifier = 253,
MissingDeclaration = 254,
ExternalModuleReference = 255,
JsxElement = 256,
JsxSelfClosingElement = 257,
JsxOpeningElement = 258,
JsxClosingElement = 259,
JsxFragment = 260,
JsxOpeningFragment = 261,
JsxClosingFragment = 262,
JsxAttribute = 263,
JsxAttributes = 264,
JsxSpreadAttribute = 265,
JsxExpression = 266,
CaseClause = 267,
DefaultClause = 268,
HeritageClause = 269,
CatchClause = 270,
PropertyAssignment = 271,
ShorthandPropertyAssignment = 272,
SpreadAssignment = 273,
EnumMember = 274,
SourceFile = 275,
Bundle = 276,
UnparsedSource = 277,
InputFiles = 278,
JSDocTypeExpression = 279,
JSDocAllType = 280,
JSDocUnknownType = 281,
JSDocNullableType = 282,
JSDocNonNullableType = 283,
JSDocOptionalType = 284,
JSDocFunctionType = 285,
JSDocVariadicType = 286,
JSDocComment = 287,
JSDocTypeLiteral = 288,
JSDocSignature = 289,
JSDocTag = 290,
JSDocAugmentsTag = 291,
JSDocClassTag = 292,
JSDocCallbackTag = 293,
JSDocParameterTag = 294,
JSDocReturnTag = 295,
JSDocTypeTag = 296,
JSDocTemplateTag = 297,
JSDocTypedefTag = 298,
JSDocPropertyTag = 299,
SyntaxList = 300,
NotEmittedStatement = 301,
PartiallyEmittedExpression = 302,
CommaListExpression = 303,
MergeDeclarationMarker = 304,
EndOfDeclarationMarker = 305,
Count = 306,
FirstAssignment = 58,
LastAssignment = 70,
FirstCompoundAssignment = 59,
Expand All @@ -379,7 +380,7 @@ declare namespace ts {
FirstFutureReservedWord = 108,
LastFutureReservedWord = 116,
FirstTypeNode = 161,
LastTypeNode = 179,
LastTypeNode = 180,
FirstPunctuation = 17,
LastPunctuation = 70,
FirstToken = 0,
Expand All @@ -393,10 +394,10 @@ declare namespace ts {
FirstBinaryOperator = 27,
LastBinaryOperator = 70,
FirstNode = 146,
FirstJSDocNode = 278,
LastJSDocNode = 298,
FirstJSDocTagNode = 289,
LastJSDocTagNode = 298
FirstJSDocNode = 279,
LastJSDocNode = 299,
FirstJSDocTagNode = 290,
LastJSDocTagNode = 299
}
enum NodeFlags {
None = 0,
Expand Down Expand Up @@ -751,6 +752,10 @@ declare namespace ts {
kind: SyntaxKind.TupleType;
elementTypes: NodeArray<TypeNode>;
}
interface OptionalTypeNode extends TypeNode {
kind: SyntaxKind.OptionalType;
type: TypeNode;
}
type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode;
interface UnionTypeNode extends TypeNode {
kind: SyntaxKind.UnionType;
Expand Down Expand Up @@ -2249,6 +2254,9 @@ declare namespace ts {
}
interface GenericType extends InterfaceType, TypeReference {
}
interface TupleType extends GenericType {
minLength: number;
}
interface UnionOrIntersectionType extends Type {
types: Type[];
}
Expand Down Expand Up @@ -3590,7 +3598,9 @@ declare namespace ts {
function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode;
function createTupleTypeNode(elementTypes: ReadonlyArray<TypeNode>): TupleTypeNode;
function updateTypleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray<TypeNode>): TupleTypeNode;
function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray<TypeNode>): TupleTypeNode;
function createOptionalTypeNode(type: TypeNode): OptionalTypeNode;
function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode;
function createUnionTypeNode(types: ReadonlyArray<TypeNode>): UnionTypeNode;
function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray<TypeNode>): UnionTypeNode;
function createIntersectionTypeNode(types: ReadonlyArray<TypeNode>): IntersectionTypeNode;
Expand Down
Loading
0