diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0b79a32f337d3..c6d43db5d24db 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7626,7 +7626,13 @@ namespace ts { function getTypeFromTypeCallNode(node: TypeCallTypeNode): Type { const fn = typeNodeToExpression(node.type); - const args = map(node.arguments, typeNodeToExpression); + const args = map(node.arguments, (type: TypeNode) => { + if (type.kind === SyntaxKind.TypeSpread) { + return createSpread(typeNodeToExpression((type as TypeSpreadTypeNode).type)); + } else { + return typeNodeToExpression(type); + } + }); const callExpr = createCall(fn, node.typeArguments, args); return checkExpression(callExpr); } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 12bc3c3796c9b..7c819727de264 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4283,7 +4283,7 @@ namespace ts { function parseTypeArgumentList() { parseExpected(SyntaxKind.OpenParenToken); - const result = parseDelimitedList(ParsingContext.TypeArguments, parseType); + const result = parseDelimitedList(ParsingContext.TypeArguments, parseTupleElement); parseExpected(SyntaxKind.CloseParenToken); return result; } diff --git a/tests/baselines/reference/typeCallSpreads.errors.txt b/tests/baselines/reference/typeCallSpreads.errors.txt new file mode 100644 index 0000000000000..78aed3b1c8f0c --- /dev/null +++ b/tests/baselines/reference/typeCallSpreads.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/typeCallSpreads.ts(2,13): error TS1005: ')' expected. +tests/cases/compiler/typeCallSpreads.ts(2,19): error TS1005: ';' expected. + + +==== tests/cases/compiler/typeCallSpreads.ts (2 errors) ==== + type Fn = (v: T) => T; + type a = Fn(...[1]); + ~~~ +!!! error TS1005: ')' expected. + ~ +!!! error TS1005: ';' expected. + \ No newline at end of file diff --git a/tests/baselines/reference/typeCallSpreads.js b/tests/baselines/reference/typeCallSpreads.js new file mode 100644 index 0000000000000..d89672c327404 --- /dev/null +++ b/tests/baselines/reference/typeCallSpreads.js @@ -0,0 +1,8 @@ +//// [typeCallSpreads.ts] +type Fn = (v: T) => T; +type a = Fn(...[1]); + + +//// [typeCallSpreads.js] +[1]; +; diff --git a/tests/cases/compiler/typeCallSpreads.ts b/tests/cases/compiler/typeCallSpreads.ts new file mode 100644 index 0000000000000..c49622b419927 --- /dev/null +++ b/tests/cases/compiler/typeCallSpreads.ts @@ -0,0 +1,2 @@ +type Fn = (v: T) => T; +type a = Fn(...[1]);