From d21c0783633680be1ddbc2d73db52e094ab3fa02 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Wed, 15 Aug 2018 16:19:54 -0700 Subject: [PATCH 01/16] Test for existence of diagnostic when running tests --- src/testRunner/unittests/convertToAsyncFunction.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/testRunner/unittests/convertToAsyncFunction.ts b/src/testRunner/unittests/convertToAsyncFunction.ts index f39b8080ed2..f3bdc889c34 100644 --- a/src/testRunner/unittests/convertToAsyncFunction.ts +++ b/src/testRunner/unittests/convertToAsyncFunction.ts @@ -362,11 +362,11 @@ interface Array {}` const diagnostics = languageService.getSuggestionDiagnostics(f.path); const diagnostic = find(diagnostics, diagnostic => diagnostic.messageText === description.message); - assert.isNotNull(diagnostic); + assert.exists(diagnostic); const actions = codefix.getFixes(context); const action = find(actions, action => action.description === description.message)!; - assert.isNotNull(action); + assert.exists(action); const data: string[] = []; data.push(`// ==ORIGINAL==`); From cc4e1f833e1d15535e6aff11f12fa13973c9728f Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Thu, 16 Aug 2018 08:53:48 -0700 Subject: [PATCH 02/16] Look for correct description --- src/testRunner/unittests/convertToAsyncFunction.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/testRunner/unittests/convertToAsyncFunction.ts b/src/testRunner/unittests/convertToAsyncFunction.ts index f3bdc889c34..a1e8169e45d 100644 --- a/src/testRunner/unittests/convertToAsyncFunction.ts +++ b/src/testRunner/unittests/convertToAsyncFunction.ts @@ -319,7 +319,7 @@ interface String { charAt: any; } interface Array {}` }; - function testConvertToAsyncFunction(caption: string, text: string, baselineFolder: string, description: DiagnosticMessage, includeLib?: boolean) { + function testConvertToAsyncFunction(caption: string, text: string, baselineFolder: string, diagnosticDescription: DiagnosticMessage, codeFixDescription: DiagnosticMessage, includeLib?: boolean) { const t = getTest(text); const selectionRange = t.ranges.get("selection")!; if (!selectionRange) { @@ -361,11 +361,11 @@ interface Array {}` }; const diagnostics = languageService.getSuggestionDiagnostics(f.path); - const diagnostic = find(diagnostics, diagnostic => diagnostic.messageText === description.message); + const diagnostic = find(diagnostics, diagnostic => diagnostic.messageText === diagnosticDescription.message); assert.exists(diagnostic); const actions = codefix.getFixes(context); - const action = find(actions, action => action.description === description.message)!; + const action = find(actions, action => action.description === codeFixDescription.message)!; assert.exists(action); const data: string[] = []; @@ -380,7 +380,7 @@ interface Array {}` const diagProgram = makeProgram({ path, content: newText }, includeLib)!; assert.isFalse(hasSyntacticDiagnostics(diagProgram)); - Harness.Baseline.runBaseline(`${baselineFolder}/${caption}${extension}`, data.join(newLineCharacter)); + Harness.Baseline.runBaseline(`${baselineFolder}/${caption}${extension}`, () => data.join(newLineCharacter)); } function makeProgram(f: { path: string, content: string }, includeLib?: boolean) { @@ -1182,7 +1182,7 @@ function [#|f|]() { }); function _testConvertToAsyncFunction(caption: string, text: string) { - testConvertToAsyncFunction(caption, text, "convertToAsyncFunction", Diagnostics.Convert_to_async_function, /*includeLib*/ true); + testConvertToAsyncFunction(caption, text, "convertToAsyncFunction", Diagnostics.This_may_be_converted_to_an_async_function, Diagnostics.Convert_to_async_function, /*includeLib*/ true); } function _testConvertToAsyncFunctionFailed(caption: string, text: string) { From 158f0b0c0b9f7a14b4af10041c033418ce96e61a Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Tue, 28 Aug 2018 14:28:11 -0700 Subject: [PATCH 03/16] Allow codefix to apply to function expression in variable declaration --- src/services/codefixes/convertToAsyncFunction.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/services/codefixes/convertToAsyncFunction.ts b/src/services/codefixes/convertToAsyncFunction.ts index 195586c6b6e..1650baac0ea 100644 --- a/src/services/codefixes/convertToAsyncFunction.ts +++ b/src/services/codefixes/convertToAsyncFunction.ts @@ -42,7 +42,16 @@ namespace ts.codefix { function convertToAsyncFunction(changes: textChanges.ChangeTracker, sourceFile: SourceFile, position: number, checker: TypeChecker, context: CodeFixContextBase): void { // get the function declaration - returns a promise - const functionToConvert: FunctionLikeDeclaration = getContainingFunction(getTokenAtPosition(sourceFile, position)) as FunctionLikeDeclaration; + const tokenAtPosition = getTokenAtPosition(sourceFile, position); + let functionToConvert: FunctionLikeDeclaration; + if (isIdentifier(tokenAtPosition) && isVariableDeclaration(tokenAtPosition.parent) && + tokenAtPosition.parent.initializer && isFunctionLikeDeclaration(tokenAtPosition.parent.initializer)) { + functionToConvert = tokenAtPosition.parent.initializer; + } + else { + functionToConvert = getContainingFunction(getTokenAtPosition(sourceFile, position)) as FunctionLikeDeclaration; + } + if (!functionToConvert) { return; } From 3ad6a66e69bc31d780eb1bef19dbdbf2f70c2893 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Tue, 28 Aug 2018 14:28:58 -0700 Subject: [PATCH 04/16] Add tests and validate diagnostic spans --- .../unittests/convertToAsyncFunction.ts | 16 ++++++++++++++++ ...tToAsyncFunction_ArrowFunctionNoAnnotation.js | 11 +++++++++++ ...tToAsyncFunction_ArrowFunctionNoAnnotation.ts | 11 +++++++++++ ...oAsyncFunction_basicNoReturnTypeAnnotation.js | 11 +++++++++++ ...oAsyncFunction_basicNoReturnTypeAnnotation.ts | 11 +++++++++++ ...rtToAsyncFunction_simpleFunctionExpression.js | 12 ++++++++++++ ...rtToAsyncFunction_simpleFunctionExpression.ts | 12 ++++++++++++ 7 files changed, 84 insertions(+) create mode 100644 tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.js create mode 100644 tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.ts create mode 100644 tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.js create mode 100644 tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.ts create mode 100644 tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.js create mode 100644 tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.ts diff --git a/src/testRunner/unittests/convertToAsyncFunction.ts b/src/testRunner/unittests/convertToAsyncFunction.ts index a1e8169e45d..186b9059a3d 100644 --- a/src/testRunner/unittests/convertToAsyncFunction.ts +++ b/src/testRunner/unittests/convertToAsyncFunction.ts @@ -363,6 +363,8 @@ interface Array {}` const diagnostics = languageService.getSuggestionDiagnostics(f.path); const diagnostic = find(diagnostics, diagnostic => diagnostic.messageText === diagnosticDescription.message); assert.exists(diagnostic); + assert.equal(diagnostic!.start, context.span.start); + assert.equal(diagnostic!.length, context.span.length); const actions = codefix.getFixes(context); const action = find(actions, action => action.description === codeFixDescription.message)!; @@ -423,6 +425,10 @@ interface Array {}` _testConvertToAsyncFunction("convertToAsyncFunction_basic", ` function [#|f|](): Promise{ return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +}`); + _testConvertToAsyncFunction("convertToAsyncFunction_basicNoReturnTypeAnnotation", ` +function [#|f|]() { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); }`); _testConvertToAsyncFunction("convertToAsyncFunction_basicWithComments", ` function [#|f|](): Promise{ @@ -436,6 +442,10 @@ function [#|f|](): Promise{ _testConvertToAsyncFunction("convertToAsyncFunction_ArrowFunction", ` [#|():Promise => {|] return fetch('https://typescriptlang.org').then(result => console.log(result)); +}`); + _testConvertToAsyncFunction("convertToAsyncFunction_ArrowFunctionNoAnnotation", ` +[#|() => {|] + return fetch('https://typescriptlang.org').then(result => console.log(result)); }`); _testConvertToAsyncFunction("convertToAsyncFunction_Catch", ` function [#|f|]():Promise { @@ -1178,6 +1188,12 @@ function [#|f|]() { } `); + _testConvertToAsyncFunction("convertToAsyncFunction_simpleFunctionExpression", ` +const [#|foo|] = function () { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} +`); + }); diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.js new file mode 100644 index 00000000000..500d546971b --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.js @@ -0,0 +1,11 @@ +// ==ORIGINAL== + +/*[#|*/() => {/*|]*/ + return fetch('https://typescriptlang.org').then(result => console.log(result)); +} +// ==ASYNC FUNCTION::Convert to async function== + +async () => { + const result = await fetch('https://typescriptlang.org'); + return console.log(result); +} \ No newline at end of file diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.ts new file mode 100644 index 00000000000..500d546971b --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ArrowFunctionNoAnnotation.ts @@ -0,0 +1,11 @@ +// ==ORIGINAL== + +/*[#|*/() => {/*|]*/ + return fetch('https://typescriptlang.org').then(result => console.log(result)); +} +// ==ASYNC FUNCTION::Convert to async function== + +async () => { + const result = await fetch('https://typescriptlang.org'); + return console.log(result); +} \ No newline at end of file diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.js new file mode 100644 index 00000000000..8aec78c6670 --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.js @@ -0,0 +1,11 @@ +// ==ORIGINAL== + +function /*[#|*/f/*|]*/() { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} +// ==ASYNC FUNCTION::Convert to async function== + +async function f() { + const result = await fetch('https://typescriptlang.org'); + console.log(result); +} \ No newline at end of file diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.ts new file mode 100644 index 00000000000..8aec78c6670 --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_basicNoReturnTypeAnnotation.ts @@ -0,0 +1,11 @@ +// ==ORIGINAL== + +function /*[#|*/f/*|]*/() { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} +// ==ASYNC FUNCTION::Convert to async function== + +async function f() { + const result = await fetch('https://typescriptlang.org'); + console.log(result); +} \ No newline at end of file diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.js new file mode 100644 index 00000000000..a92497ca937 --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.js @@ -0,0 +1,12 @@ +// ==ORIGINAL== + +const /*[#|*/foo/*|]*/ = function () { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} + +// ==ASYNC FUNCTION::Convert to async function== + +const foo = async function () { + const result = await fetch('https://typescriptlang.org'); + console.log(result); +} diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.ts new file mode 100644 index 00000000000..a92497ca937 --- /dev/null +++ b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_simpleFunctionExpression.ts @@ -0,0 +1,12 @@ +// ==ORIGINAL== + +const /*[#|*/foo/*|]*/ = function () { + return fetch('https://typescriptlang.org').then(result => { console.log(result) }); +} + +// ==ASYNC FUNCTION::Convert to async function== + +const foo = async function () { + const result = await fetch('https://typescriptlang.org'); + console.log(result); +} From 97e539339ddf175269b223fbbef7523aa791d6a0 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Tue, 28 Aug 2018 14:37:09 -0700 Subject: [PATCH 05/16] Add comment explaining special casing --- src/services/codefixes/convertToAsyncFunction.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/codefixes/convertToAsyncFunction.ts b/src/services/codefixes/convertToAsyncFunction.ts index 1650baac0ea..6162e311266 100644 --- a/src/services/codefixes/convertToAsyncFunction.ts +++ b/src/services/codefixes/convertToAsyncFunction.ts @@ -44,6 +44,8 @@ namespace ts.codefix { // get the function declaration - returns a promise const tokenAtPosition = getTokenAtPosition(sourceFile, position); let functionToConvert: FunctionLikeDeclaration; + + // if the parent of a FunctionLikeDeclaration is a variable declaration, the convertToAsync diagnostic will be reported on the variable name if (isIdentifier(tokenAtPosition) && isVariableDeclaration(tokenAtPosition.parent) && tokenAtPosition.parent.initializer && isFunctionLikeDeclaration(tokenAtPosition.parent.initializer)) { functionToConvert = tokenAtPosition.parent.initializer; From bb892d951d59496566d38e117cad3cfe038569e8 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Wed, 29 Aug 2018 15:54:19 -0700 Subject: [PATCH 06/16] Use non-diagnostics-producing typechecker to get type --- src/services/suggestionDiagnostics.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts index 51a1701c351..167bcb6bbac 100644 --- a/src/services/suggestionDiagnostics.ts +++ b/src/services/suggestionDiagnostics.ts @@ -3,7 +3,7 @@ namespace ts { export function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): DiagnosticWithLocation[] { program.getSemanticDiagnostics(sourceFile, cancellationToken); const diags: DiagnosticWithLocation[] = []; - const checker = program.getDiagnosticsProducingTypeChecker(); + const checker = program.getTypeChecker(); if (sourceFile.commonJsModuleIndicator && (programContainsEs6Modules(program) || compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) && @@ -115,11 +115,12 @@ namespace ts { function addConvertToAsyncFunctionDiagnostics(node: FunctionLikeDeclaration, checker: TypeChecker, diags: DiagnosticWithLocation[]): void { - const functionType = node.type ? checker.getTypeFromTypeNode(node.type) : undefined; - if (isAsyncFunction(node) || !node.body || !functionType) { + if (isAsyncFunction(node) || !node.body) { return; } + const functionType = checker.getTypeAtLocation(node); + const callSignatures = checker.getSignaturesOfType(functionType, SignatureKind.Call); const returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; From f4765a6ea3435f8d6691325c7a19d3be4db243c8 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Fri, 24 Aug 2018 09:05:13 -0700 Subject: [PATCH 07/16] Fix error introduced by rebase --- src/testRunner/unittests/convertToAsyncFunction.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testRunner/unittests/convertToAsyncFunction.ts b/src/testRunner/unittests/convertToAsyncFunction.ts index 186b9059a3d..99788e1310e 100644 --- a/src/testRunner/unittests/convertToAsyncFunction.ts +++ b/src/testRunner/unittests/convertToAsyncFunction.ts @@ -382,7 +382,7 @@ interface Array {}` const diagProgram = makeProgram({ path, content: newText }, includeLib)!; assert.isFalse(hasSyntacticDiagnostics(diagProgram)); - Harness.Baseline.runBaseline(`${baselineFolder}/${caption}${extension}`, () => data.join(newLineCharacter)); + Harness.Baseline.runBaseline(`${baselineFolder}/${caption}${extension}`, data.join(newLineCharacter)); } function makeProgram(f: { path: string, content: string }, includeLib?: boolean) { From 496b18ef5e1187d03311b0f98772cf64c9637551 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 30 Aug 2018 11:38:34 -0700 Subject: [PATCH 08/16] Report file change detected only once when save takes place multiple times before timeout --- src/compiler/tsbuild.ts | 7 ++++++- src/testRunner/unittests/tsbuildWatchMode.ts | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 95beb65e28e..4ddda98a41f 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -507,6 +507,7 @@ namespace ts { const configFileCache = createConfigFileCache(host); let context = createBuildContext(defaultOptions); let timerToBuildInvalidatedProject: any; + let reportFileChangeDetected = false; const existingWatchersForWildcards = createMap(); return { @@ -584,7 +585,7 @@ namespace ts { } function invalidateProjectAndScheduleBuilds(resolved: ResolvedConfigFileName) { - reportWatchStatus(Diagnostics.File_change_detected_Starting_incremental_compilation); + reportFileChangeDetected = true; invalidateProject(resolved); scheduleBuildInvalidatedProject(); } @@ -817,6 +818,10 @@ namespace ts { function buildInvalidatedProject() { timerToBuildInvalidatedProject = undefined; + if (reportFileChangeDetected) { + reportFileChangeDetected = false; + reportWatchStatus(Diagnostics.File_change_detected_Starting_incremental_compilation); + } const buildProject = context.getNextInvalidatedProject(); buildSomeProjects(p => p === buildProject); if (context.hasPendingInvalidatedProjects()) { diff --git a/src/testRunner/unittests/tsbuildWatchMode.ts b/src/testRunner/unittests/tsbuildWatchMode.ts index b7884350061..daa1276e023 100644 --- a/src/testRunner/unittests/tsbuildWatchMode.ts +++ b/src/testRunner/unittests/tsbuildWatchMode.ts @@ -112,9 +112,22 @@ export class someClass { }`); // Another change requeues and builds it verifyChange(core[1].content); + // Two changes together report only single time message: File change detected. Starting incremental compilation... + const outputFileStamps = getOutputFileStamps(host); + const change1 = `${core[1].content} +export class someClass { }`; + host.writeFile(core[1].path, change1); + host.writeFile(core[1].path, `${change1} +export class someClass2 { }`); + verifyChangeAfterTimeout(outputFileStamps); + function verifyChange(coreContent: string) { const outputFileStamps = getOutputFileStamps(host); host.writeFile(core[1].path, coreContent); + verifyChangeAfterTimeout(outputFileStamps); + } + + function verifyChangeAfterTimeout(outputFileStamps: OutputFileStamp[]) { host.checkTimeoutQueueLengthAndRun(1); // Builds core const changedCore = getOutputFileStamps(host); verifyChangedFiles(changedCore, outputFileStamps, [ From 65fa0128bb7a28e7db8fa5bec14f0f3806d867ab Mon Sep 17 00:00:00 2001 From: Sam Lanning Date: Thu, 30 Aug 2018 14:03:51 -0700 Subject: [PATCH 09/16] Add test for ts.equalOwnProperties --- src/testRunner/tsconfig.json | 1 + src/testRunner/unittests/compilerCore.ts | 33 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/testRunner/unittests/compilerCore.ts diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index fa7900f1ca3..27dca8296ed 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -46,6 +46,7 @@ "unittests/cancellableLanguageServiceOperations.ts", "unittests/commandLineParsing.ts", "unittests/compileOnSave.ts", + "unittests/compilerCore.ts", "unittests/configurationExtension.ts", "unittests/convertCompilerOptionsFromJson.ts", "unittests/convertToAsyncFunction.ts", diff --git a/src/testRunner/unittests/compilerCore.ts b/src/testRunner/unittests/compilerCore.ts new file mode 100644 index 00000000000..27f5cdc0887 --- /dev/null +++ b/src/testRunner/unittests/compilerCore.ts @@ -0,0 +1,33 @@ +namespace ts { + describe("compilerCore", () => { + describe("equalOwnProperties", () => { + it("correctly equates objects", () => { + assert.isTrue(equalOwnProperties({}, {})); + assert.isTrue(equalOwnProperties({ a: 1 }, { a: 1 })); + assert.isTrue(equalOwnProperties({ a: 1, b: 2 }, { b: 2, a: 1 })); + }); + it("correctly identifies unmatched objects", () => { + assert.isFalse(equalOwnProperties({}, { a: 1 }), "missing left property"); + assert.isFalse(equalOwnProperties({ a: 1 }, {}), "missing right property"); + assert.isFalse(equalOwnProperties({ a: 1 }, { a: 2 }), "differing property"); + }); + it("correctly identifies undefined vs hasOwnProperty", () => { + assert.isFalse(equalOwnProperties({}, { a: undefined }), "missing left property"); + assert.isFalse(equalOwnProperties({ a: undefined }, {}), "missing right property"); + }); + it("truthiness", () => { + const trythyTest = (l: any, r: any) => !!l === !!r; + assert.isFalse(equalOwnProperties({}, { a: 1 }, trythyTest), "missing left truthy property"); + assert.isFalse(equalOwnProperties({}, { a: 0 }, trythyTest), "missing left falsey property"); + assert.isFalse(equalOwnProperties({ a: 1 }, {}, trythyTest), "missing right truthy property"); + assert.isFalse(equalOwnProperties({ a: 0 }, {}, trythyTest), "missing right falsey property"); + assert.isTrue(equalOwnProperties({ a: 1 }, { a: "foo" }, trythyTest), "valid equality"); + }); + it("all equal", () => { + assert.isFalse(equalOwnProperties({}, { a: 1 }, () => true), "missing left property"); + assert.isFalse(equalOwnProperties({ a: 1 }, {}, () => true), "missing right property"); + assert.isTrue(equalOwnProperties({ a: 1 }, { a: 2 }, () => true), "valid equality"); + }); + }); + }); +} From 2c41d8b44e5ade83c8e5391f4bdcc48e151d4bce Mon Sep 17 00:00:00 2001 From: Sam Lanning Date: Thu, 30 Aug 2018 14:08:24 -0700 Subject: [PATCH 10/16] Fix equalOwnProperties equalOwnProperties would incorrectly report two map-like objects as equal in the case where a property defined in `left` was not defined in `right` and whose value was considered "equal" to undefined by the equalityComparer. This bug was found by an alert on LGTM.com --- src/compiler/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 1eaab5b1b59..d5caadf079a 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1272,7 +1272,7 @@ namespace ts { if (!left || !right) return false; for (const key in left) { if (hasOwnProperty.call(left, key)) { - if (!hasOwnProperty.call(right, key) === undefined) return false; + if (!hasOwnProperty.call(right, key)) return false; if (!equalityComparer(left[key], right[key])) return false; } } From 64bbf8925cc91e4fd528584ab9984b7a13f014f0 Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Thu, 30 Aug 2018 16:53:46 -0700 Subject: [PATCH 11/16] Allow for undefined in type --- src/services/codefixes/convertToAsyncFunction.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/codefixes/convertToAsyncFunction.ts b/src/services/codefixes/convertToAsyncFunction.ts index 6162e311266..76cdf471466 100644 --- a/src/services/codefixes/convertToAsyncFunction.ts +++ b/src/services/codefixes/convertToAsyncFunction.ts @@ -43,7 +43,7 @@ namespace ts.codefix { function convertToAsyncFunction(changes: textChanges.ChangeTracker, sourceFile: SourceFile, position: number, checker: TypeChecker, context: CodeFixContextBase): void { // get the function declaration - returns a promise const tokenAtPosition = getTokenAtPosition(sourceFile, position); - let functionToConvert: FunctionLikeDeclaration; + let functionToConvert: FunctionLikeDeclaration | undefined; // if the parent of a FunctionLikeDeclaration is a variable declaration, the convertToAsync diagnostic will be reported on the variable name if (isIdentifier(tokenAtPosition) && isVariableDeclaration(tokenAtPosition.parent) && @@ -51,7 +51,7 @@ namespace ts.codefix { functionToConvert = tokenAtPosition.parent.initializer; } else { - functionToConvert = getContainingFunction(getTokenAtPosition(sourceFile, position)) as FunctionLikeDeclaration; + functionToConvert = tryCast(getContainingFunction(getTokenAtPosition(sourceFile, position)), isFunctionLikeDeclaration); } if (!functionToConvert) { From cc3d0113332793625e5f60a705944b778af48c40 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 31 Aug 2018 07:45:34 -0700 Subject: [PATCH 12/16] Infer this parameters (#26800) Previously we didn't. I can't remember why, probably because I overlooked it in the initial PR. --- src/compiler/checker.ts | 8 ++++ tests/baselines/reference/inferThisType.js | 15 +++++++ .../baselines/reference/inferThisType.symbols | 45 +++++++++++++++++++ tests/baselines/reference/inferThisType.types | 34 ++++++++++++++ .../types/thisType/inferThisType.ts | 10 +++++ 5 files changed, 112 insertions(+) create mode 100644 tests/baselines/reference/inferThisType.js create mode 100644 tests/baselines/reference/inferThisType.symbols create mode 100644 tests/baselines/reference/inferThisType.types create mode 100644 tests/cases/conformance/types/thisType/inferThisType.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ebd849a7844..25f8483a40a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13074,6 +13074,14 @@ namespace ts { const paramCount = targetRestType ? Math.min(targetCount - 1, sourceCount) : sourceRestType ? targetCount : Math.min(sourceCount, targetCount); + + const sourceThisType = getThisTypeOfSignature(source); + if (sourceThisType) { + const targetThisType = getThisTypeOfSignature(target); + if (targetThisType) { + callback(sourceThisType, targetThisType); + } + } for (let i = 0; i < paramCount; i++) { callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } diff --git a/tests/baselines/reference/inferThisType.js b/tests/baselines/reference/inferThisType.js new file mode 100644 index 00000000000..68018970847 --- /dev/null +++ b/tests/baselines/reference/inferThisType.js @@ -0,0 +1,15 @@ +//// [inferThisType.ts] +declare function f(g: (this: T) => void): T +declare function h(this: number): void; +f(h) + +// works with infer types as well +type Check = T extends (this: infer U, ...args: any[]) => any ? string : unknown; +type r1 = Check<(this: number) => void>; // should be string + +type This = T extends (this: infer U, ...args: any[]) => any ? U : unknown; +type r2 = This<(this: number) => void>; // should be number + + +//// [inferThisType.js] +f(h); diff --git a/tests/baselines/reference/inferThisType.symbols b/tests/baselines/reference/inferThisType.symbols new file mode 100644 index 00000000000..8e4b56c67a0 --- /dev/null +++ b/tests/baselines/reference/inferThisType.symbols @@ -0,0 +1,45 @@ +=== tests/cases/conformance/types/thisType/inferThisType.ts === +declare function f(g: (this: T) => void): T +>f : Symbol(f, Decl(inferThisType.ts, 0, 0)) +>T : Symbol(T, Decl(inferThisType.ts, 0, 19)) +>g : Symbol(g, Decl(inferThisType.ts, 0, 22)) +>this : Symbol(this, Decl(inferThisType.ts, 0, 26)) +>T : Symbol(T, Decl(inferThisType.ts, 0, 19)) +>T : Symbol(T, Decl(inferThisType.ts, 0, 19)) + +declare function h(this: number): void; +>h : Symbol(h, Decl(inferThisType.ts, 0, 46)) +>this : Symbol(this, Decl(inferThisType.ts, 1, 19)) + +f(h) +>f : Symbol(f, Decl(inferThisType.ts, 0, 0)) +>h : Symbol(h, Decl(inferThisType.ts, 0, 46)) + +// works with infer types as well +type Check = T extends (this: infer U, ...args: any[]) => any ? string : unknown; +>Check : Symbol(Check, Decl(inferThisType.ts, 2, 4)) +>T : Symbol(T, Decl(inferThisType.ts, 5, 11)) +>T : Symbol(T, Decl(inferThisType.ts, 5, 11)) +>this : Symbol(this, Decl(inferThisType.ts, 5, 27)) +>U : Symbol(U, Decl(inferThisType.ts, 5, 38)) +>args : Symbol(args, Decl(inferThisType.ts, 5, 41)) + +type r1 = Check<(this: number) => void>; // should be string +>r1 : Symbol(r1, Decl(inferThisType.ts, 5, 84)) +>Check : Symbol(Check, Decl(inferThisType.ts, 2, 4)) +>this : Symbol(this, Decl(inferThisType.ts, 6, 17)) + +type This = T extends (this: infer U, ...args: any[]) => any ? U : unknown; +>This : Symbol(This, Decl(inferThisType.ts, 6, 40)) +>T : Symbol(T, Decl(inferThisType.ts, 8, 10)) +>T : Symbol(T, Decl(inferThisType.ts, 8, 10)) +>this : Symbol(this, Decl(inferThisType.ts, 8, 27)) +>U : Symbol(U, Decl(inferThisType.ts, 8, 38)) +>args : Symbol(args, Decl(inferThisType.ts, 8, 41)) +>U : Symbol(U, Decl(inferThisType.ts, 8, 38)) + +type r2 = This<(this: number) => void>; // should be number +>r2 : Symbol(r2, Decl(inferThisType.ts, 8, 79)) +>This : Symbol(This, Decl(inferThisType.ts, 6, 40)) +>this : Symbol(this, Decl(inferThisType.ts, 9, 16)) + diff --git a/tests/baselines/reference/inferThisType.types b/tests/baselines/reference/inferThisType.types new file mode 100644 index 00000000000..3676c7bf3da --- /dev/null +++ b/tests/baselines/reference/inferThisType.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/types/thisType/inferThisType.ts === +declare function f(g: (this: T) => void): T +>f : (g: (this: T) => void) => T +>g : (this: T) => void +>this : T + +declare function h(this: number): void; +>h : (this: number) => void +>this : number + +f(h) +>f(h) : number +>f : (g: (this: T) => void) => T +>h : (this: number) => void + +// works with infer types as well +type Check = T extends (this: infer U, ...args: any[]) => any ? string : unknown; +>Check : Check +>this : U +>args : any[] + +type r1 = Check<(this: number) => void>; // should be string +>r1 : string +>this : number + +type This = T extends (this: infer U, ...args: any[]) => any ? U : unknown; +>This : This +>this : U +>args : any[] + +type r2 = This<(this: number) => void>; // should be number +>r2 : number +>this : number + diff --git a/tests/cases/conformance/types/thisType/inferThisType.ts b/tests/cases/conformance/types/thisType/inferThisType.ts new file mode 100644 index 00000000000..7dc0c1e941a --- /dev/null +++ b/tests/cases/conformance/types/thisType/inferThisType.ts @@ -0,0 +1,10 @@ +declare function f(g: (this: T) => void): T +declare function h(this: number): void; +f(h) + +// works with infer types as well +type Check = T extends (this: infer U, ...args: any[]) => any ? string : unknown; +type r1 = Check<(this: number) => void>; // should be string + +type This = T extends (this: infer U, ...args: any[]) => any ? U : unknown; +type r2 = This<(this: number) => void>; // should be number From c929e7431080803b66119bb80423dbcc84cdaac6 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 31 Aug 2018 07:46:16 -0700 Subject: [PATCH 13/16] Add [Constructor]Parameter types to lib.d.ts (#26243) --- src/lib/es5.d.ts | 10 + .../genericRestParameters1.errors.txt | 25 ++- .../reference/genericRestParameters1.js | 19 +- .../reference/genericRestParameters1.symbols | 189 +++++++++--------- .../reference/genericRestParameters1.types | 15 +- .../genericRestParameters2.errors.txt | 85 ++++++++ .../reference/genericRestParameters2.js | 11 +- .../reference/genericRestParameters2.symbols | 109 +++++----- .../reference/genericRestParameters2.types | 9 +- tests/baselines/reference/genericRestTypes.js | 1 - .../reference/genericRestTypes.symbols | 67 +++---- .../reference/genericRestTypes.types | 5 - .../parameterListAsTupleType.errors.txt | 35 ++++ .../reference/parameterListAsTupleType.js | 52 +++++ .../parameterListAsTupleType.symbols | 63 ++++++ .../reference/parameterListAsTupleType.types | 61 ++++++ tests/cases/compiler/genericRestTypes.ts | 1 - .../compiler/parameterListAsTupleType.ts | 23 +++ .../types/rest/genericRestParameters1.ts | 10 +- .../types/rest/genericRestParameters2.ts | 6 +- 20 files changed, 538 insertions(+), 258 deletions(-) create mode 100644 tests/baselines/reference/genericRestParameters2.errors.txt create mode 100644 tests/baselines/reference/parameterListAsTupleType.errors.txt create mode 100644 tests/baselines/reference/parameterListAsTupleType.js create mode 100644 tests/baselines/reference/parameterListAsTupleType.symbols create mode 100644 tests/baselines/reference/parameterListAsTupleType.types create mode 100644 tests/cases/compiler/parameterListAsTupleType.ts diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index c00f37c260d..015eec5c3e0 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1378,6 +1378,16 @@ type Extract = T extends U ? T : never; */ type NonNullable = T extends null | undefined ? never : T; +/** + * Obtain the parameters of a function type in a tuple + */ +type Parameters any> = T extends (...args: infer P) => any ? P : never; + +/** + * Obtain the parameters of a constructor function type in a tuple + */ +type ConstructorParameters any> = T extends new (...args: infer P) => any ? P : never; + /** * Obtain the return type of a function type */ diff --git a/tests/baselines/reference/genericRestParameters1.errors.txt b/tests/baselines/reference/genericRestParameters1.errors.txt index 2f314387424..fe45ef518ed 100644 --- a/tests/baselines/reference/genericRestParameters1.errors.txt +++ b/tests/baselines/reference/genericRestParameters1.errors.txt @@ -1,11 +1,15 @@ tests/cases/conformance/types/rest/genericRestParameters1.ts(22,1): error TS2556: Expected 3 arguments, but got 1 or more. tests/cases/conformance/types/rest/genericRestParameters1.ts(31,1): error TS2556: Expected 3 arguments, but got 1 or more. -tests/cases/conformance/types/rest/genericRestParameters1.ts(166,1): error TS2322: Type '(a: never) => void' is not assignable to type '(...args: any[]) => void'. +tests/cases/conformance/types/rest/genericRestParameters1.ts(133,40): error TS2344: Type '(...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. +tests/cases/conformance/types/rest/genericRestParameters1.ts(134,51): error TS2344: Type 'new (...args: T) => void' does not satisfy the constraint 'new (...args: any[]) => any'. +tests/cases/conformance/types/rest/genericRestParameters1.ts(135,23): error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'. + Type 'Function' provides no match for the signature '(...args: any[]): any'. +tests/cases/conformance/types/rest/genericRestParameters1.ts(164,1): error TS2322: Type '(a: never) => void' is not assignable to type '(...args: any[]) => void'. Types of parameters 'a' and 'args' are incompatible. Type 'any' is not assignable to type 'never'. -==== tests/cases/conformance/types/rest/genericRestParameters1.ts (3 errors) ==== +==== tests/cases/conformance/types/rest/genericRestParameters1.ts (6 errors) ==== declare let f1: (...x: [number, string, boolean]) => void; declare let f2: (x0: number, x1: string, x2: boolean) => void; @@ -136,17 +140,22 @@ tests/cases/conformance/types/rest/genericRestParameters1.ts(166,1): error TS232 const c30 = f30(42, x => "" + x, x => x + 1); // [(x: number) => string, (x: number) => number] - type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; - type T01 = Parameters<(x: number, y: string, z: boolean) => void>; type T02 = Parameters<(...args: [number, string, boolean]) => void>; - type T03 = Parameters void>; - type T04 = Parameters void>; + type T03 = ConstructorParameters void>; + type T04 = ConstructorParameters void>; type T05 = Parameters<(...args: T[]) => void>; - type T06 = Parameters void>; + type T06 = ConstructorParameters void>; type T07 = Parameters<(...args: T) => void>; - type T08 = Parameters void>; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2344: Type '(...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. + type T08 = ConstructorParameters void>; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2344: Type 'new (...args: T) => void' does not satisfy the constraint 'new (...args: any[]) => any'. type T09 = Parameters; + ~~~~~~~~ +!!! error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'. +!!! error TS2344: Type 'Function' provides no match for the signature '(...args: any[]): any'. type Record1 = { move: [number, 'left' | 'right']; diff --git a/tests/baselines/reference/genericRestParameters1.js b/tests/baselines/reference/genericRestParameters1.js index d41565e4c6a..3d8703213ac 100644 --- a/tests/baselines/reference/genericRestParameters1.js +++ b/tests/baselines/reference/genericRestParameters1.js @@ -125,16 +125,14 @@ declare function f30 any)[]>(x: T, ...args: U): U; const c30 = f30(42, x => "" + x, x => x + 1); // [(x: number) => string, (x: number) => number] -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; - type T01 = Parameters<(x: number, y: string, z: boolean) => void>; type T02 = Parameters<(...args: [number, string, boolean]) => void>; -type T03 = Parameters void>; -type T04 = Parameters void>; +type T03 = ConstructorParameters void>; +type T04 = ConstructorParameters void>; type T05 = Parameters<(...args: T[]) => void>; -type T06 = Parameters void>; +type T06 = ConstructorParameters void>; type T07 = Parameters<(...args: T) => void>; -type T08 = Parameters void>; +type T08 = ConstructorParameters void>; type T09 = Parameters; type Record1 = { @@ -327,15 +325,14 @@ declare const g22: (z?: boolean | undefined) => string[]; declare const g23: () => string[]; declare function f30 any)[]>(x: T, ...args: U): U; declare const c30: [(x: number) => string, (x: number) => number]; -declare type Parameters = T extends ((...args: infer U) => any) | (new (...args: infer U) => any) ? U : any[]; declare type T01 = Parameters<(x: number, y: string, z: boolean) => void>; declare type T02 = Parameters<(...args: [number, string, boolean]) => void>; -declare type T03 = Parameters void>; -declare type T04 = Parameters void>; +declare type T03 = ConstructorParameters void>; +declare type T04 = ConstructorParameters void>; declare type T05 = Parameters<(...args: T[]) => void>; -declare type T06 = Parameters void>; +declare type T06 = ConstructorParameters void>; declare type T07 = Parameters<(...args: T) => void>; -declare type T08 = Parameters void>; +declare type T08 = ConstructorParameters void>; declare type T09 = Parameters; declare type Record1 = { move: [number, 'left' | 'right']; diff --git a/tests/baselines/reference/genericRestParameters1.symbols b/tests/baselines/reference/genericRestParameters1.symbols index 87ddbfcf6fe..4b0dae51150 100644 --- a/tests/baselines/reference/genericRestParameters1.symbols +++ b/tests/baselines/reference/genericRestParameters1.symbols @@ -494,160 +494,149 @@ const c30 = f30(42, x => "" + x, x => x + 1); // [(x: number) => string, (x: nu >x : Symbol(x, Decl(genericRestParameters1.ts, 124, 32)) >x : Symbol(x, Decl(genericRestParameters1.ts, 124, 32)) -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 126, 16)) ->Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 126, 16)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 126, 50)) ->U : Symbol(U, Decl(genericRestParameters1.ts, 126, 64), Decl(genericRestParameters1.ts, 126, 97)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 126, 83)) ->U : Symbol(U, Decl(genericRestParameters1.ts, 126, 64), Decl(genericRestParameters1.ts, 126, 97)) ->U : Symbol(U, Decl(genericRestParameters1.ts, 126, 64), Decl(genericRestParameters1.ts, 126, 97)) - type T01 = Parameters<(x: number, y: string, z: boolean) => void>; ->T01 : Symbol(T01, Decl(genericRestParameters1.ts, 126, 121)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->x : Symbol(x, Decl(genericRestParameters1.ts, 128, 23)) ->y : Symbol(y, Decl(genericRestParameters1.ts, 128, 33)) ->z : Symbol(z, Decl(genericRestParameters1.ts, 128, 44)) +>T01 : Symbol(T01, Decl(genericRestParameters1.ts, 124, 45)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(genericRestParameters1.ts, 126, 23)) +>y : Symbol(y, Decl(genericRestParameters1.ts, 126, 33)) +>z : Symbol(z, Decl(genericRestParameters1.ts, 126, 44)) type T02 = Parameters<(...args: [number, string, boolean]) => void>; ->T02 : Symbol(T02, Decl(genericRestParameters1.ts, 128, 66)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 129, 23)) +>T02 : Symbol(T02, Decl(genericRestParameters1.ts, 126, 66)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 127, 23)) -type T03 = Parameters void>; ->T03 : Symbol(T03, Decl(genericRestParameters1.ts, 129, 68)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->x : Symbol(x, Decl(genericRestParameters1.ts, 130, 27)) ->y : Symbol(y, Decl(genericRestParameters1.ts, 130, 37)) ->z : Symbol(z, Decl(genericRestParameters1.ts, 130, 48)) +type T03 = ConstructorParameters void>; +>T03 : Symbol(T03, Decl(genericRestParameters1.ts, 127, 68)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(genericRestParameters1.ts, 128, 38)) +>y : Symbol(y, Decl(genericRestParameters1.ts, 128, 48)) +>z : Symbol(z, Decl(genericRestParameters1.ts, 128, 59)) -type T04 = Parameters void>; ->T04 : Symbol(T04, Decl(genericRestParameters1.ts, 130, 70)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 131, 27)) +type T04 = ConstructorParameters void>; +>T04 : Symbol(T04, Decl(genericRestParameters1.ts, 128, 81)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 129, 38)) type T05 = Parameters<(...args: T[]) => void>; ->T05 : Symbol(T05, Decl(genericRestParameters1.ts, 131, 72)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 132, 9)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 132, 26)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 132, 9)) +>T05 : Symbol(T05, Decl(genericRestParameters1.ts, 129, 83)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 130, 9)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 130, 26)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 130, 9)) -type T06 = Parameters void>; ->T06 : Symbol(T06, Decl(genericRestParameters1.ts, 132, 49)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 133, 9)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 133, 30)) +type T06 = ConstructorParameters void>; +>T06 : Symbol(T06, Decl(genericRestParameters1.ts, 130, 49)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 131, 9)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 131, 41)) type T07 = Parameters<(...args: T) => void>; ->T07 : Symbol(T07, Decl(genericRestParameters1.ts, 133, 52)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 134, 9)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 134, 40)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 134, 9)) +>T07 : Symbol(T07, Decl(genericRestParameters1.ts, 131, 63)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 132, 9)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 132, 40)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 132, 9)) -type T08 = Parameters void>; ->T08 : Symbol(T08, Decl(genericRestParameters1.ts, 134, 61)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 135, 9)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 135, 44)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 135, 9)) +type T08 = ConstructorParameters void>; +>T08 : Symbol(T08, Decl(genericRestParameters1.ts, 132, 61)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 133, 9)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 133, 55)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 133, 9)) type T09 = Parameters; ->T09 : Symbol(T09, Decl(genericRestParameters1.ts, 135, 65)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters1.ts, 124, 45)) +>T09 : Symbol(T09, Decl(genericRestParameters1.ts, 133, 76)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) type Record1 = { ->Record1 : Symbol(Record1, Decl(genericRestParameters1.ts, 136, 32)) +>Record1 : Symbol(Record1, Decl(genericRestParameters1.ts, 134, 32)) move: [number, 'left' | 'right']; ->move : Symbol(move, Decl(genericRestParameters1.ts, 138, 16)) +>move : Symbol(move, Decl(genericRestParameters1.ts, 136, 16)) jump: [number, 'up' | 'down']; ->jump : Symbol(jump, Decl(genericRestParameters1.ts, 139, 35)) +>jump : Symbol(jump, Decl(genericRestParameters1.ts, 137, 35)) stop: string; ->stop : Symbol(stop, Decl(genericRestParameters1.ts, 140, 32)) +>stop : Symbol(stop, Decl(genericRestParameters1.ts, 138, 32)) done: []; ->done : Symbol(done, Decl(genericRestParameters1.ts, 141, 15)) +>done : Symbol(done, Decl(genericRestParameters1.ts, 139, 15)) } type EventType = { ->EventType : Symbol(EventType, Decl(genericRestParameters1.ts, 143, 1)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) +>EventType : Symbol(EventType, Decl(genericRestParameters1.ts, 141, 1)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) emit(e: K, ...payload: T[K] extends any[] ? T[K] : [T[K]]): void; ->emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) ->K : Symbol(K, Decl(genericRestParameters1.ts, 146, 7)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) ->e : Symbol(e, Decl(genericRestParameters1.ts, 146, 36)) ->K : Symbol(K, Decl(genericRestParameters1.ts, 146, 7)) ->payload : Symbol(payload, Decl(genericRestParameters1.ts, 146, 41)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) ->K : Symbol(K, Decl(genericRestParameters1.ts, 146, 7)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) ->K : Symbol(K, Decl(genericRestParameters1.ts, 146, 7)) ->T : Symbol(T, Decl(genericRestParameters1.ts, 145, 15)) ->K : Symbol(K, Decl(genericRestParameters1.ts, 146, 7)) +>emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) +>K : Symbol(K, Decl(genericRestParameters1.ts, 144, 7)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) +>e : Symbol(e, Decl(genericRestParameters1.ts, 144, 36)) +>K : Symbol(K, Decl(genericRestParameters1.ts, 144, 7)) +>payload : Symbol(payload, Decl(genericRestParameters1.ts, 144, 41)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) +>K : Symbol(K, Decl(genericRestParameters1.ts, 144, 7)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) +>K : Symbol(K, Decl(genericRestParameters1.ts, 144, 7)) +>T : Symbol(T, Decl(genericRestParameters1.ts, 143, 15)) +>K : Symbol(K, Decl(genericRestParameters1.ts, 144, 7)) } declare var events: EventType; ->events : Symbol(events, Decl(genericRestParameters1.ts, 149, 11)) ->EventType : Symbol(EventType, Decl(genericRestParameters1.ts, 143, 1)) ->Record1 : Symbol(Record1, Decl(genericRestParameters1.ts, 136, 32)) +>events : Symbol(events, Decl(genericRestParameters1.ts, 147, 11)) +>EventType : Symbol(EventType, Decl(genericRestParameters1.ts, 141, 1)) +>Record1 : Symbol(Record1, Decl(genericRestParameters1.ts, 134, 32)) events.emit('move', 10, 'left'); ->events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) ->events : Symbol(events, Decl(genericRestParameters1.ts, 149, 11)) ->emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) +>events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) +>events : Symbol(events, Decl(genericRestParameters1.ts, 147, 11)) +>emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) events.emit('jump', 20, 'up'); ->events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) ->events : Symbol(events, Decl(genericRestParameters1.ts, 149, 11)) ->emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) +>events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) +>events : Symbol(events, Decl(genericRestParameters1.ts, 147, 11)) +>emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) events.emit('stop', 'Bye!'); ->events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) ->events : Symbol(events, Decl(genericRestParameters1.ts, 149, 11)) ->emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) +>events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) +>events : Symbol(events, Decl(genericRestParameters1.ts, 147, 11)) +>emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) events.emit('done'); ->events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) ->events : Symbol(events, Decl(genericRestParameters1.ts, 149, 11)) ->emit : Symbol(emit, Decl(genericRestParameters1.ts, 145, 21)) +>events.emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) +>events : Symbol(events, Decl(genericRestParameters1.ts, 147, 11)) +>emit : Symbol(emit, Decl(genericRestParameters1.ts, 143, 21)) // Repro from #25871 declare var ff1: (... args: any[]) => void; ->ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 157, 11)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 157, 18)) +>ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 155, 11)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 155, 18)) declare var ff2: () => void; ->ff2 : Symbol(ff2, Decl(genericRestParameters1.ts, 159, 11)) +>ff2 : Symbol(ff2, Decl(genericRestParameters1.ts, 157, 11)) declare var ff3: (...args: []) => void; ->ff3 : Symbol(ff3, Decl(genericRestParameters1.ts, 160, 11)) ->args : Symbol(args, Decl(genericRestParameters1.ts, 160, 18)) +>ff3 : Symbol(ff3, Decl(genericRestParameters1.ts, 158, 11)) +>args : Symbol(args, Decl(genericRestParameters1.ts, 158, 18)) declare var ff4: (a: never) => void; ->ff4 : Symbol(ff4, Decl(genericRestParameters1.ts, 161, 11)) ->a : Symbol(a, Decl(genericRestParameters1.ts, 161, 18)) +>ff4 : Symbol(ff4, Decl(genericRestParameters1.ts, 159, 11)) +>a : Symbol(a, Decl(genericRestParameters1.ts, 159, 18)) ff1 = ff2; ->ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 157, 11)) ->ff2 : Symbol(ff2, Decl(genericRestParameters1.ts, 159, 11)) +>ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 155, 11)) +>ff2 : Symbol(ff2, Decl(genericRestParameters1.ts, 157, 11)) ff1 = ff3; ->ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 157, 11)) ->ff3 : Symbol(ff3, Decl(genericRestParameters1.ts, 160, 11)) +>ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 155, 11)) +>ff3 : Symbol(ff3, Decl(genericRestParameters1.ts, 158, 11)) ff1 = ff4; // Error ->ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 157, 11)) ->ff4 : Symbol(ff4, Decl(genericRestParameters1.ts, 161, 11)) +>ff1 : Symbol(ff1, Decl(genericRestParameters1.ts, 155, 11)) +>ff4 : Symbol(ff4, Decl(genericRestParameters1.ts, 159, 11)) diff --git a/tests/baselines/reference/genericRestParameters1.types b/tests/baselines/reference/genericRestParameters1.types index 625edcc4d84..497561c8a98 100644 --- a/tests/baselines/reference/genericRestParameters1.types +++ b/tests/baselines/reference/genericRestParameters1.types @@ -664,11 +664,6 @@ const c30 = f30(42, x => "" + x, x => x + 1); // [(x: number) => string, (x: nu >x : number >1 : 1 -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; ->Parameters : Parameters ->args : U ->args : U - type T01 = Parameters<(x: number, y: string, z: boolean) => void>; >T01 : [number, string, boolean] >x : number @@ -679,13 +674,13 @@ type T02 = Parameters<(...args: [number, string, boolean]) => void>; >T02 : [number, string, boolean] >args : [number, string, boolean] -type T03 = Parameters void>; +type T03 = ConstructorParameters void>; >T03 : [number, string, boolean] >x : number >y : string >z : boolean -type T04 = Parameters void>; +type T04 = ConstructorParameters void>; >T04 : [number, string, boolean] >args : [number, string, boolean] @@ -693,7 +688,7 @@ type T05 = Parameters<(...args: T[]) => void>; >T05 : T[] >args : T[] -type T06 = Parameters void>; +type T06 = ConstructorParameters void>; >T06 : [] >args : [] @@ -701,12 +696,12 @@ type T07 = Parameters<(...args: T) => void>; >T07 : T >args : T -type T08 = Parameters void>; +type T08 = ConstructorParameters void>; >T08 : T >args : T type T09 = Parameters; ->T09 : any[] +>T09 : never type Record1 = { >Record1 : Record1 diff --git a/tests/baselines/reference/genericRestParameters2.errors.txt b/tests/baselines/reference/genericRestParameters2.errors.txt new file mode 100644 index 00000000000..5035544c51f --- /dev/null +++ b/tests/baselines/reference/genericRestParameters2.errors.txt @@ -0,0 +1,85 @@ +tests/cases/conformance/types/rest/genericRestParameters2.ts(71,40): error TS2344: Type '(x: string, ...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. + + +==== tests/cases/conformance/types/rest/genericRestParameters2.ts (1 errors) ==== + declare const t1: [number, string, ...boolean[]]; + declare const t2: [string, ...boolean[]]; + declare const t3: [...boolean[]]; + declare const t4: []; + + declare let f00: (...x: [number, string, boolean]) => void; + declare let f01: (a: number, ...x: [string, boolean]) => void; + declare let f02: (a: number, b: string, ...x: [boolean]) => void; + declare let f03: (a: number, b: string, c: boolean) => void; + declare let f04: (a: number, b: string, c: boolean, ...x: []) => void; + + declare let f10: (...x: [number, string, ...boolean[]]) => void; + declare let f11: (a: number, ...x: [string, ...boolean[]]) => void; + declare let f12: (a: number, b: string, ...x: [...boolean[]]) => void; + declare let f13: (a: number, b: string, ...c: boolean[]) => void; + + declare const ns: [number, string]; + declare const sn: [string, number]; + + f10(42, "hello"); + f10(42, "hello", true); + f10(42, "hello", true, false); + f10(t1[0], t1[1], t1[2], t1[3]); + f10(...t1); + f10(42, ...t2); + f10(42, "hello", ...t3); + f10(42, "hello", true, ...t4); + f10(42, "hello", true, ...t4, false, ...t3); + + f11(42, "hello"); + f11(42, "hello", true); + f11(42, "hello", true, false); + f11(t1[0], t1[1], t1[2], t1[3]); + f11(...t1); + f11(42, ...t2); + f11(42, "hello", ...t3); + f11(42, "hello", true, ...t4); + f11(42, "hello", true, ...t4, false, ...t3); + + f12(42, "hello"); + f12(42, "hello", true); + f12(42, "hello", true, false); + f12(t1[0], t1[1], t1[2], t1[3]); + f12(...t1); + f12(42, ...t2); + f12(42, "hello", ...t3); + f12(42, "hello", true, ...t4); + f12(42, "hello", true, ...t4, false, ...t3); + + f13(42, "hello"); + f13(42, "hello", true); + f13(42, "hello", true, false); + f13(t1[0], t1[1], t1[2], t1[3]); + f13(...t1); + f13(42, ...t2); + f13(42, "hello", ...t3); + f13(42, "hello", true, ...t4); + f13(42, "hello", true, ...t4, false, ...t3); + + declare const f20: (...args: T) => T; + + f20(...t1); + f20(42, ...t2); + f20(42, "hello", ...t3); + f20(42, "hello", ...t2, true); + + type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; + type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; + type T03 = ConstructorParameters void>; + type T04 = ConstructorParameters void>; + type T05 = Parameters<(x: string, ...args: T) => void>; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2344: Type '(x: string, ...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. + type T06 = T05<[number, ...boolean[]]>; + + type P1 = T extends (head: infer A, ...tail: infer B) => any ? { head: A, tail: B } : any[]; + + type T10 = P1<(x: number, y: string, ...z: boolean[]) => void>; + type T11 = P1<(...z: number[]) => void>; + type T12 = P1<(x: number, y: number) => void>; + \ No newline at end of file diff --git a/tests/baselines/reference/genericRestParameters2.js b/tests/baselines/reference/genericRestParameters2.js index 143a4a62f52..3c00a7c2a3a 100644 --- a/tests/baselines/reference/genericRestParameters2.js +++ b/tests/baselines/reference/genericRestParameters2.js @@ -65,12 +65,10 @@ f20(42, ...t2); f20(42, "hello", ...t3); f20(42, "hello", ...t2, true); -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; - type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; -type T03 = Parameters void>; -type T04 = Parameters void>; +type T03 = ConstructorParameters void>; +type T04 = ConstructorParameters void>; type T05 = Parameters<(x: string, ...args: T) => void>; type T06 = T05<[number, ...boolean[]]>; @@ -142,11 +140,10 @@ declare let f13: (a: number, b: string, ...c: boolean[]) => void; declare const ns: [number, string]; declare const sn: [string, number]; declare const f20: (...args: T) => T; -declare type Parameters = T extends ((...args: infer U) => any) | (new (...args: infer U) => any) ? U : any[]; declare type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; declare type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; -declare type T03 = Parameters void>; -declare type T04 = Parameters void>; +declare type T03 = ConstructorParameters void>; +declare type T04 = ConstructorParameters void>; declare type T05 = Parameters<(x: string, ...args: T) => void>; declare type T06 = T05<[number, ...boolean[]]>; declare type P1 = T extends (head: infer A, ...tail: infer B) => any ? { diff --git a/tests/baselines/reference/genericRestParameters2.symbols b/tests/baselines/reference/genericRestParameters2.symbols index 164d08d132e..1dd27d4f890 100644 --- a/tests/baselines/reference/genericRestParameters2.symbols +++ b/tests/baselines/reference/genericRestParameters2.symbols @@ -245,82 +245,71 @@ f20(42, "hello", ...t2, true); >f20 : Symbol(f20, Decl(genericRestParameters2.ts, 59, 13)) >t2 : Symbol(t2, Decl(genericRestParameters2.ts, 1, 13)) -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 66, 16)) ->Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 66, 16)) ->args : Symbol(args, Decl(genericRestParameters2.ts, 66, 50)) ->U : Symbol(U, Decl(genericRestParameters2.ts, 66, 64), Decl(genericRestParameters2.ts, 66, 97)) ->args : Symbol(args, Decl(genericRestParameters2.ts, 66, 83)) ->U : Symbol(U, Decl(genericRestParameters2.ts, 66, 64), Decl(genericRestParameters2.ts, 66, 97)) ->U : Symbol(U, Decl(genericRestParameters2.ts, 66, 64), Decl(genericRestParameters2.ts, 66, 97)) - type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; ->T01 : Symbol(T01, Decl(genericRestParameters2.ts, 66, 121)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->x : Symbol(x, Decl(genericRestParameters2.ts, 68, 23)) ->y : Symbol(y, Decl(genericRestParameters2.ts, 68, 33)) ->z : Symbol(z, Decl(genericRestParameters2.ts, 68, 44)) +>T01 : Symbol(T01, Decl(genericRestParameters2.ts, 64, 30)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(genericRestParameters2.ts, 66, 23)) +>y : Symbol(y, Decl(genericRestParameters2.ts, 66, 33)) +>z : Symbol(z, Decl(genericRestParameters2.ts, 66, 44)) type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; ->T02 : Symbol(T02, Decl(genericRestParameters2.ts, 68, 71)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->args : Symbol(args, Decl(genericRestParameters2.ts, 69, 23)) +>T02 : Symbol(T02, Decl(genericRestParameters2.ts, 66, 71)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters2.ts, 67, 23)) -type T03 = Parameters void>; ->T03 : Symbol(T03, Decl(genericRestParameters2.ts, 69, 73)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->x : Symbol(x, Decl(genericRestParameters2.ts, 70, 27)) ->y : Symbol(y, Decl(genericRestParameters2.ts, 70, 37)) ->z : Symbol(z, Decl(genericRestParameters2.ts, 70, 48)) +type T03 = ConstructorParameters void>; +>T03 : Symbol(T03, Decl(genericRestParameters2.ts, 67, 73)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(genericRestParameters2.ts, 68, 38)) +>y : Symbol(y, Decl(genericRestParameters2.ts, 68, 48)) +>z : Symbol(z, Decl(genericRestParameters2.ts, 68, 59)) -type T04 = Parameters void>; ->T04 : Symbol(T04, Decl(genericRestParameters2.ts, 70, 75)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->args : Symbol(args, Decl(genericRestParameters2.ts, 71, 27)) +type T04 = ConstructorParameters void>; +>T04 : Symbol(T04, Decl(genericRestParameters2.ts, 68, 86)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>args : Symbol(args, Decl(genericRestParameters2.ts, 69, 38)) type T05 = Parameters<(x: string, ...args: T) => void>; ->T05 : Symbol(T05, Decl(genericRestParameters2.ts, 71, 77)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 72, 9)) ->Parameters : Symbol(Parameters, Decl(genericRestParameters2.ts, 64, 30)) ->x : Symbol(x, Decl(genericRestParameters2.ts, 72, 40)) ->args : Symbol(args, Decl(genericRestParameters2.ts, 72, 50)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 72, 9)) +>T05 : Symbol(T05, Decl(genericRestParameters2.ts, 69, 88)) +>T : Symbol(T, Decl(genericRestParameters2.ts, 70, 9)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(genericRestParameters2.ts, 70, 40)) +>args : Symbol(args, Decl(genericRestParameters2.ts, 70, 50)) +>T : Symbol(T, Decl(genericRestParameters2.ts, 70, 9)) type T06 = T05<[number, ...boolean[]]>; ->T06 : Symbol(T06, Decl(genericRestParameters2.ts, 72, 72)) ->T05 : Symbol(T05, Decl(genericRestParameters2.ts, 71, 77)) +>T06 : Symbol(T06, Decl(genericRestParameters2.ts, 70, 72)) +>T05 : Symbol(T05, Decl(genericRestParameters2.ts, 69, 88)) type P1 = T extends (head: infer A, ...tail: infer B) => any ? { head: A, tail: B } : any[]; ->P1 : Symbol(P1, Decl(genericRestParameters2.ts, 73, 39)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 75, 8)) +>P1 : Symbol(P1, Decl(genericRestParameters2.ts, 71, 39)) +>T : Symbol(T, Decl(genericRestParameters2.ts, 73, 8)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(genericRestParameters2.ts, 75, 8)) ->head : Symbol(head, Decl(genericRestParameters2.ts, 75, 41)) ->A : Symbol(A, Decl(genericRestParameters2.ts, 75, 52)) ->tail : Symbol(tail, Decl(genericRestParameters2.ts, 75, 55)) ->B : Symbol(B, Decl(genericRestParameters2.ts, 75, 70)) ->head : Symbol(head, Decl(genericRestParameters2.ts, 75, 84)) ->A : Symbol(A, Decl(genericRestParameters2.ts, 75, 52)) ->tail : Symbol(tail, Decl(genericRestParameters2.ts, 75, 93)) ->B : Symbol(B, Decl(genericRestParameters2.ts, 75, 70)) +>T : Symbol(T, Decl(genericRestParameters2.ts, 73, 8)) +>head : Symbol(head, Decl(genericRestParameters2.ts, 73, 41)) +>A : Symbol(A, Decl(genericRestParameters2.ts, 73, 52)) +>tail : Symbol(tail, Decl(genericRestParameters2.ts, 73, 55)) +>B : Symbol(B, Decl(genericRestParameters2.ts, 73, 70)) +>head : Symbol(head, Decl(genericRestParameters2.ts, 73, 84)) +>A : Symbol(A, Decl(genericRestParameters2.ts, 73, 52)) +>tail : Symbol(tail, Decl(genericRestParameters2.ts, 73, 93)) +>B : Symbol(B, Decl(genericRestParameters2.ts, 73, 70)) type T10 = P1<(x: number, y: string, ...z: boolean[]) => void>; ->T10 : Symbol(T10, Decl(genericRestParameters2.ts, 75, 112)) ->P1 : Symbol(P1, Decl(genericRestParameters2.ts, 73, 39)) ->x : Symbol(x, Decl(genericRestParameters2.ts, 77, 15)) ->y : Symbol(y, Decl(genericRestParameters2.ts, 77, 25)) ->z : Symbol(z, Decl(genericRestParameters2.ts, 77, 36)) +>T10 : Symbol(T10, Decl(genericRestParameters2.ts, 73, 112)) +>P1 : Symbol(P1, Decl(genericRestParameters2.ts, 71, 39)) +>x : Symbol(x, Decl(genericRestParameters2.ts, 75, 15)) +>y : Symbol(y, Decl(genericRestParameters2.ts, 75, 25)) +>z : Symbol(z, Decl(genericRestParameters2.ts, 75, 36)) type T11 = P1<(...z: number[]) => void>; ->T11 : Symbol(T11, Decl(genericRestParameters2.ts, 77, 63)) ->P1 : Symbol(P1, Decl(genericRestParameters2.ts, 73, 39)) ->z : Symbol(z, Decl(genericRestParameters2.ts, 78, 15)) +>T11 : Symbol(T11, Decl(genericRestParameters2.ts, 75, 63)) +>P1 : Symbol(P1, Decl(genericRestParameters2.ts, 71, 39)) +>z : Symbol(z, Decl(genericRestParameters2.ts, 76, 15)) type T12 = P1<(x: number, y: number) => void>; ->T12 : Symbol(T12, Decl(genericRestParameters2.ts, 78, 40)) ->P1 : Symbol(P1, Decl(genericRestParameters2.ts, 73, 39)) ->x : Symbol(x, Decl(genericRestParameters2.ts, 79, 15)) ->y : Symbol(y, Decl(genericRestParameters2.ts, 79, 25)) +>T12 : Symbol(T12, Decl(genericRestParameters2.ts, 76, 40)) +>P1 : Symbol(P1, Decl(genericRestParameters2.ts, 71, 39)) +>x : Symbol(x, Decl(genericRestParameters2.ts, 77, 15)) +>y : Symbol(y, Decl(genericRestParameters2.ts, 77, 25)) diff --git a/tests/baselines/reference/genericRestParameters2.types b/tests/baselines/reference/genericRestParameters2.types index 3c0a7c62877..103b0a0a62f 100644 --- a/tests/baselines/reference/genericRestParameters2.types +++ b/tests/baselines/reference/genericRestParameters2.types @@ -416,11 +416,6 @@ f20(42, "hello", ...t2, true); >t2 : [string, ...boolean[]] >true : true -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; ->Parameters : Parameters ->args : U ->args : U - type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; >T01 : [number, string, ...boolean[]] >x : number @@ -431,13 +426,13 @@ type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; >T02 : [number, string, ...boolean[]] >args : [number, string, ...boolean[]] -type T03 = Parameters void>; +type T03 = ConstructorParameters void>; >T03 : [number, string, ...boolean[]] >x : number >y : string >z : boolean[] -type T04 = Parameters void>; +type T04 = ConstructorParameters void>; >T04 : [number, string, ...boolean[]] >args : [number, string, ...boolean[]] diff --git a/tests/baselines/reference/genericRestTypes.js b/tests/baselines/reference/genericRestTypes.js index f932032af56..5abf8113f38 100644 --- a/tests/baselines/reference/genericRestTypes.js +++ b/tests/baselines/reference/genericRestTypes.js @@ -2,7 +2,6 @@ // Repro from #25793 // Gets the parameters of a function type as a tuple -type Parameters any> = T extends (...args: infer U) => any ? U : never; // Removes the first element from a tuple type Tail = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; diff --git a/tests/baselines/reference/genericRestTypes.symbols b/tests/baselines/reference/genericRestTypes.symbols index 77bc400b5db..c8ab347609c 100644 --- a/tests/baselines/reference/genericRestTypes.symbols +++ b/tests/baselines/reference/genericRestTypes.symbols @@ -2,54 +2,45 @@ // Repro from #25793 // Gets the parameters of a function type as a tuple -type Parameters any> = T extends (...args: infer U) => any ? U : never; ->Parameters : Symbol(Parameters, Decl(genericRestTypes.ts, 0, 0)) ->T : Symbol(T, Decl(genericRestTypes.ts, 3, 16)) ->args : Symbol(args, Decl(genericRestTypes.ts, 3, 27)) ->T : Symbol(T, Decl(genericRestTypes.ts, 3, 16)) ->args : Symbol(args, Decl(genericRestTypes.ts, 3, 64)) ->U : Symbol(U, Decl(genericRestTypes.ts, 3, 78)) ->U : Symbol(U, Decl(genericRestTypes.ts, 3, 78)) - // Removes the first element from a tuple type Tail = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; ->Tail : Symbol(Tail, Decl(genericRestTypes.ts, 3, 101)) ->T : Symbol(T, Decl(genericRestTypes.ts, 5, 10)) ->args : Symbol(args, Decl(genericRestTypes.ts, 5, 31)) ->T : Symbol(T, Decl(genericRestTypes.ts, 5, 10)) ->head : Symbol(head, Decl(genericRestTypes.ts, 5, 61)) ->tail : Symbol(tail, Decl(genericRestTypes.ts, 5, 71)) ->U : Symbol(U, Decl(genericRestTypes.ts, 5, 86)) ->U : Symbol(U, Decl(genericRestTypes.ts, 5, 86)) +>Tail : Symbol(Tail, Decl(genericRestTypes.ts, 0, 0)) +>T : Symbol(T, Decl(genericRestTypes.ts, 4, 10)) +>args : Symbol(args, Decl(genericRestTypes.ts, 4, 31)) +>T : Symbol(T, Decl(genericRestTypes.ts, 4, 10)) +>head : Symbol(head, Decl(genericRestTypes.ts, 4, 61)) +>tail : Symbol(tail, Decl(genericRestTypes.ts, 4, 71)) +>U : Symbol(U, Decl(genericRestTypes.ts, 4, 86)) +>U : Symbol(U, Decl(genericRestTypes.ts, 4, 86)) type MyFunctionType = (foo: number, bar: string) => boolean; ->MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) ->foo : Symbol(foo, Decl(genericRestTypes.ts, 7, 23)) ->bar : Symbol(bar, Decl(genericRestTypes.ts, 7, 35)) +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 4, 110)) +>foo : Symbol(foo, Decl(genericRestTypes.ts, 6, 23)) +>bar : Symbol(bar, Decl(genericRestTypes.ts, 6, 35)) type Explicit = (...args: Tail>) => ReturnType; // (bar: string) => boolean ->Explicit : Symbol(Explicit, Decl(genericRestTypes.ts, 7, 60)) ->args : Symbol(args, Decl(genericRestTypes.ts, 9, 17)) ->Tail : Symbol(Tail, Decl(genericRestTypes.ts, 3, 101)) ->Parameters : Symbol(Parameters, Decl(genericRestTypes.ts, 0, 0)) ->MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) +>Explicit : Symbol(Explicit, Decl(genericRestTypes.ts, 6, 60)) +>args : Symbol(args, Decl(genericRestTypes.ts, 8, 17)) +>Tail : Symbol(Tail, Decl(genericRestTypes.ts, 0, 0)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 4, 110)) >ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) ->MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 4, 110)) type Bind1 any> = (...args: Tail>) => ReturnType; ->Bind1 : Symbol(Bind1, Decl(genericRestTypes.ts, 9, 90)) ->T : Symbol(T, Decl(genericRestTypes.ts, 11, 11)) ->head : Symbol(head, Decl(genericRestTypes.ts, 11, 22)) ->tail : Symbol(tail, Decl(genericRestTypes.ts, 11, 32)) ->args : Symbol(args, Decl(genericRestTypes.ts, 11, 60)) ->Tail : Symbol(Tail, Decl(genericRestTypes.ts, 3, 101)) ->Parameters : Symbol(Parameters, Decl(genericRestTypes.ts, 0, 0)) ->T : Symbol(T, Decl(genericRestTypes.ts, 11, 11)) +>Bind1 : Symbol(Bind1, Decl(genericRestTypes.ts, 8, 90)) +>T : Symbol(T, Decl(genericRestTypes.ts, 10, 11)) +>head : Symbol(head, Decl(genericRestTypes.ts, 10, 22)) +>tail : Symbol(tail, Decl(genericRestTypes.ts, 10, 32)) +>args : Symbol(args, Decl(genericRestTypes.ts, 10, 60)) +>Tail : Symbol(Tail, Decl(genericRestTypes.ts, 0, 0)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(genericRestTypes.ts, 10, 11)) >ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(genericRestTypes.ts, 11, 11)) +>T : Symbol(T, Decl(genericRestTypes.ts, 10, 11)) type Generic = Bind1; // (bar: string) => boolean ->Generic : Symbol(Generic, Decl(genericRestTypes.ts, 11, 107)) ->Bind1 : Symbol(Bind1, Decl(genericRestTypes.ts, 9, 90)) ->MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 5, 110)) +>Generic : Symbol(Generic, Decl(genericRestTypes.ts, 10, 107)) +>Bind1 : Symbol(Bind1, Decl(genericRestTypes.ts, 8, 90)) +>MyFunctionType : Symbol(MyFunctionType, Decl(genericRestTypes.ts, 4, 110)) diff --git a/tests/baselines/reference/genericRestTypes.types b/tests/baselines/reference/genericRestTypes.types index 6fb482799dd..b2fb37871bd 100644 --- a/tests/baselines/reference/genericRestTypes.types +++ b/tests/baselines/reference/genericRestTypes.types @@ -2,11 +2,6 @@ // Repro from #25793 // Gets the parameters of a function type as a tuple -type Parameters any> = T extends (...args: infer U) => any ? U : never; ->Parameters : Parameters ->args : any[] ->args : U - // Removes the first element from a tuple type Tail = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; >Tail : Tail diff --git a/tests/baselines/reference/parameterListAsTupleType.errors.txt b/tests/baselines/reference/parameterListAsTupleType.errors.txt new file mode 100644 index 00000000000..021138ec2ba --- /dev/null +++ b/tests/baselines/reference/parameterListAsTupleType.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/parameterListAsTupleType.ts(8,17): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/parameterListAsTupleType.ts(16,23): error TS2344: Type 'typeof C' does not satisfy the constraint '(...args: any[]) => any'. + Type 'typeof C' provides no match for the signature '(...args: any[]): any'. + + +==== tests/cases/compiler/parameterListAsTupleType.ts (2 errors) ==== + function foo(a: number, b: string) { + return true; + } + type Foops = Parameters; + + const x = (a: number) => 5; + type Xps = Parameters; + const a: Xps = ['should-not-work']; // works, but shouldn't + ~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number'. + function t(...args: Xps) {} // should work + + class C { + constructor(a: number, b: string) { + } + } + + type Cps = Parameters; // should not work + ~~~~~~~~ +!!! error TS2344: Type 'typeof C' does not satisfy the constraint '(...args: any[]) => any'. +!!! error TS2344: Type 'typeof C' provides no match for the signature '(...args: any[]): any'. + type Ccps = ConstructorParameters; // should be [number, string] + + class D { + constructor(a: number, ...rest: string[]) { + } + } + type Dcps = ConstructorParameters; // should be [number, ...string[]] + \ No newline at end of file diff --git a/tests/baselines/reference/parameterListAsTupleType.js b/tests/baselines/reference/parameterListAsTupleType.js new file mode 100644 index 00000000000..0c831e36edb --- /dev/null +++ b/tests/baselines/reference/parameterListAsTupleType.js @@ -0,0 +1,52 @@ +//// [parameterListAsTupleType.ts] +function foo(a: number, b: string) { + return true; +} +type Foops = Parameters; + +const x = (a: number) => 5; +type Xps = Parameters; +const a: Xps = ['should-not-work']; // works, but shouldn't +function t(...args: Xps) {} // should work + +class C { + constructor(a: number, b: string) { + } +} + +type Cps = Parameters; // should not work +type Ccps = ConstructorParameters; // should be [number, string] + +class D { + constructor(a: number, ...rest: string[]) { + } +} +type Dcps = ConstructorParameters; // should be [number, ...string[]] + + +//// [parameterListAsTupleType.js] +function foo(a, b) { + return true; +} +var x = function (a) { return 5; }; +var a = ['should-not-work']; // works, but shouldn't +function t() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } +} // should work +var C = /** @class */ (function () { + function C(a, b) { + } + return C; +}()); +var D = /** @class */ (function () { + function D(a) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + } + return D; +}()); diff --git a/tests/baselines/reference/parameterListAsTupleType.symbols b/tests/baselines/reference/parameterListAsTupleType.symbols new file mode 100644 index 00000000000..fc09e66c180 --- /dev/null +++ b/tests/baselines/reference/parameterListAsTupleType.symbols @@ -0,0 +1,63 @@ +=== tests/cases/compiler/parameterListAsTupleType.ts === +function foo(a: number, b: string) { +>foo : Symbol(foo, Decl(parameterListAsTupleType.ts, 0, 0)) +>a : Symbol(a, Decl(parameterListAsTupleType.ts, 0, 13)) +>b : Symbol(b, Decl(parameterListAsTupleType.ts, 0, 23)) + + return true; +} +type Foops = Parameters; +>Foops : Symbol(Foops, Decl(parameterListAsTupleType.ts, 2, 1)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>foo : Symbol(foo, Decl(parameterListAsTupleType.ts, 0, 0)) + +const x = (a: number) => 5; +>x : Symbol(x, Decl(parameterListAsTupleType.ts, 5, 5)) +>a : Symbol(a, Decl(parameterListAsTupleType.ts, 5, 11)) + +type Xps = Parameters; +>Xps : Symbol(Xps, Decl(parameterListAsTupleType.ts, 5, 27)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>x : Symbol(x, Decl(parameterListAsTupleType.ts, 5, 5)) + +const a: Xps = ['should-not-work']; // works, but shouldn't +>a : Symbol(a, Decl(parameterListAsTupleType.ts, 7, 5)) +>Xps : Symbol(Xps, Decl(parameterListAsTupleType.ts, 5, 27)) + +function t(...args: Xps) {} // should work +>t : Symbol(t, Decl(parameterListAsTupleType.ts, 7, 35)) +>args : Symbol(args, Decl(parameterListAsTupleType.ts, 8, 11)) +>Xps : Symbol(Xps, Decl(parameterListAsTupleType.ts, 5, 27)) + +class C { +>C : Symbol(C, Decl(parameterListAsTupleType.ts, 8, 27)) + + constructor(a: number, b: string) { +>a : Symbol(a, Decl(parameterListAsTupleType.ts, 11, 16)) +>b : Symbol(b, Decl(parameterListAsTupleType.ts, 11, 26)) + } +} + +type Cps = Parameters; // should not work +>Cps : Symbol(Cps, Decl(parameterListAsTupleType.ts, 13, 1)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>C : Symbol(C, Decl(parameterListAsTupleType.ts, 8, 27)) + +type Ccps = ConstructorParameters; // should be [number, string] +>Ccps : Symbol(Ccps, Decl(parameterListAsTupleType.ts, 15, 32)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>C : Symbol(C, Decl(parameterListAsTupleType.ts, 8, 27)) + +class D { +>D : Symbol(D, Decl(parameterListAsTupleType.ts, 16, 44)) + + constructor(a: number, ...rest: string[]) { +>a : Symbol(a, Decl(parameterListAsTupleType.ts, 19, 16)) +>rest : Symbol(rest, Decl(parameterListAsTupleType.ts, 19, 26)) + } +} +type Dcps = ConstructorParameters; // should be [number, ...string[]] +>Dcps : Symbol(Dcps, Decl(parameterListAsTupleType.ts, 21, 1)) +>ConstructorParameters : Symbol(ConstructorParameters, Decl(lib.es5.d.ts, --, --)) +>D : Symbol(D, Decl(parameterListAsTupleType.ts, 16, 44)) + diff --git a/tests/baselines/reference/parameterListAsTupleType.types b/tests/baselines/reference/parameterListAsTupleType.types new file mode 100644 index 00000000000..3bb861f5a1d --- /dev/null +++ b/tests/baselines/reference/parameterListAsTupleType.types @@ -0,0 +1,61 @@ +=== tests/cases/compiler/parameterListAsTupleType.ts === +function foo(a: number, b: string) { +>foo : (a: number, b: string) => boolean +>a : number +>b : string + + return true; +>true : true +} +type Foops = Parameters; +>Foops : [number, string] +>foo : (a: number, b: string) => boolean + +const x = (a: number) => 5; +>x : (a: number) => number +>(a: number) => 5 : (a: number) => number +>a : number +>5 : 5 + +type Xps = Parameters; +>Xps : [number] +>x : (a: number) => number + +const a: Xps = ['should-not-work']; // works, but shouldn't +>a : [number] +>['should-not-work'] : [string] +>'should-not-work' : "should-not-work" + +function t(...args: Xps) {} // should work +>t : (a: number) => void +>args : [number] + +class C { +>C : C + + constructor(a: number, b: string) { +>a : number +>b : string + } +} + +type Cps = Parameters; // should not work +>Cps : never +>C : typeof C + +type Ccps = ConstructorParameters; // should be [number, string] +>Ccps : [number, string] +>C : typeof C + +class D { +>D : D + + constructor(a: number, ...rest: string[]) { +>a : number +>rest : string[] + } +} +type Dcps = ConstructorParameters; // should be [number, ...string[]] +>Dcps : [number, ...string[]] +>D : typeof D + diff --git a/tests/cases/compiler/genericRestTypes.ts b/tests/cases/compiler/genericRestTypes.ts index cdfbd54f70d..78eb9b53f70 100644 --- a/tests/cases/compiler/genericRestTypes.ts +++ b/tests/cases/compiler/genericRestTypes.ts @@ -3,7 +3,6 @@ // Repro from #25793 // Gets the parameters of a function type as a tuple -type Parameters any> = T extends (...args: infer U) => any ? U : never; // Removes the first element from a tuple type Tail = ((...args: T) => any) extends ((head: any, ...tail: infer U) => any) ? U : never; diff --git a/tests/cases/compiler/parameterListAsTupleType.ts b/tests/cases/compiler/parameterListAsTupleType.ts new file mode 100644 index 00000000000..6bd4579298b --- /dev/null +++ b/tests/cases/compiler/parameterListAsTupleType.ts @@ -0,0 +1,23 @@ +function foo(a: number, b: string) { + return true; +} +type Foops = Parameters; + +const x = (a: number) => 5; +type Xps = Parameters; +const a: Xps = ['should-not-work']; // works, but shouldn't +function t(...args: Xps) {} // should work + +class C { + constructor(a: number, b: string) { + } +} + +type Cps = Parameters; // should not work +type Ccps = ConstructorParameters; // should be [number, string] + +class D { + constructor(a: number, ...rest: string[]) { + } +} +type Dcps = ConstructorParameters; // should be [number, ...string[]] diff --git a/tests/cases/conformance/types/rest/genericRestParameters1.ts b/tests/cases/conformance/types/rest/genericRestParameters1.ts index ac8434dc5b2..6572512cbfb 100644 --- a/tests/cases/conformance/types/rest/genericRestParameters1.ts +++ b/tests/cases/conformance/types/rest/genericRestParameters1.ts @@ -127,16 +127,14 @@ declare function f30 any)[]>(x: T, ...args: U): U; const c30 = f30(42, x => "" + x, x => x + 1); // [(x: number) => string, (x: number) => number] -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; - type T01 = Parameters<(x: number, y: string, z: boolean) => void>; type T02 = Parameters<(...args: [number, string, boolean]) => void>; -type T03 = Parameters void>; -type T04 = Parameters void>; +type T03 = ConstructorParameters void>; +type T04 = ConstructorParameters void>; type T05 = Parameters<(...args: T[]) => void>; -type T06 = Parameters void>; +type T06 = ConstructorParameters void>; type T07 = Parameters<(...args: T) => void>; -type T08 = Parameters void>; +type T08 = ConstructorParameters void>; type T09 = Parameters; type Record1 = { diff --git a/tests/cases/conformance/types/rest/genericRestParameters2.ts b/tests/cases/conformance/types/rest/genericRestParameters2.ts index 1dc0d231dd2..12b9c4f8f1d 100644 --- a/tests/cases/conformance/types/rest/genericRestParameters2.ts +++ b/tests/cases/conformance/types/rest/genericRestParameters2.ts @@ -67,12 +67,10 @@ f20(42, ...t2); f20(42, "hello", ...t3); f20(42, "hello", ...t2, true); -type Parameters = T extends ((...args: infer U) => any) | (new(...args: infer U) => any) ? U : any[]; - type T01 = Parameters<(x: number, y: string, ...z: boolean[]) => void>; type T02 = Parameters<(...args: [number, string, ...boolean[]]) => void>; -type T03 = Parameters void>; -type T04 = Parameters void>; +type T03 = ConstructorParameters void>; +type T04 = ConstructorParameters void>; type T05 = Parameters<(x: string, ...args: T) => void>; type T06 = T05<[number, ...boolean[]]>; From 718c2cce9a279290cdbd4f0902df8ff94c115845 Mon Sep 17 00:00:00 2001 From: csigs Date: Fri, 31 Aug 2018 16:10:42 +0000 Subject: [PATCH 14/16] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 20276 ++++++++-------- 1 file changed, 10138 insertions(+), 10138 deletions(-) diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 98bdf52817b..9d03da8d9b3 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1,10139 +1,10139 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - or -. For example '{0}' or '{1}'.]]> - - 또는 - 형식이어야 합니다. 예를 들어 '{0}' 또는 '{1}'입니다.]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - type.]]> - - 형식이어야 합니다.]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ()' instead.]]> - - ()'를 사용하세요.]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + or -. For example '{0}' or '{1}'.]]> + + 또는 - 형식이어야 합니다. 예를 들어 '{0}' 또는 '{1}'입니다.]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + type.]]> + + 형식이어야 합니다.]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ()' instead.]]> + + ()'를 사용하세요.]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 183072b30e9335d3495be8909ccf590ea4457807 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 31 Aug 2018 13:06:22 -0700 Subject: [PATCH 15/16] Revert #26762, #26726, and #26317 in preparation for a clean PR fixing all the issues. --- src/compiler/checker.ts | 18 ++++------ .../genericRestParameters1.errors.txt | 8 +++++ .../genericRestParameters2.errors.txt | 6 ++++ ...ializersForwardReferencing1_es6.errors.txt | 15 +++++++- ...nitializersForwardReferencing1_es6.symbols | 8 ++--- ...rInitializersForwardReferencing1_es6.types | 34 +++++++++---------- 6 files changed, 55 insertions(+), 34 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 25f8483a40a..da1af15dfa4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1211,23 +1211,17 @@ namespace ts { // local types not visible outside the function body : false; } - if (meaning & SymbolFlags.Value && result.flags & SymbolFlags.Variable) { - // expression inside parameter will lookup as normal variable scope when targeting es2015+ - if (compilerOptions.target && compilerOptions.target >= ScriptTarget.ES2015 && isParameter(lastLocation) && !isParameterPropertyDeclaration(lastLocation) && result.valueDeclaration.pos > lastLocation.end) { - useResult = false; - } - else if (result.flags & SymbolFlags.FunctionScopedVariable) { - // parameters are visible only inside function body, parameter list and return type - // technically for parameter list case here we might mix parameters and variables declared in function, - // however it is detected separately when checking initializers of parameters - // to make sure that they reference no variables declared after them. - useResult = + if (meaning & SymbolFlags.Value && result.flags & SymbolFlags.FunctionScopedVariable) { + // parameters are visible only inside function body, parameter list and return type + // technically for parameter list case here we might mix parameters and variables declared in function, + // however it is detected separately when checking initializers of parameters + // to make sure that they reference no variables declared after them. + useResult = lastLocation.kind === SyntaxKind.Parameter || ( lastLocation === (location).type && !!findAncestor(result.valueDeclaration, isParameter) ); - } } } else if (location.kind === SyntaxKind.ConditionalType) { diff --git a/tests/baselines/reference/genericRestParameters1.errors.txt b/tests/baselines/reference/genericRestParameters1.errors.txt index fe45ef518ed..6b6d7f60845 100644 --- a/tests/baselines/reference/genericRestParameters1.errors.txt +++ b/tests/baselines/reference/genericRestParameters1.errors.txt @@ -1,7 +1,11 @@ tests/cases/conformance/types/rest/genericRestParameters1.ts(22,1): error TS2556: Expected 3 arguments, but got 1 or more. tests/cases/conformance/types/rest/genericRestParameters1.ts(31,1): error TS2556: Expected 3 arguments, but got 1 or more. tests/cases/conformance/types/rest/genericRestParameters1.ts(133,40): error TS2344: Type '(...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. + Types of parameters 'args' and 'args' are incompatible. + Type 'any[]' is not assignable to type 'T'. tests/cases/conformance/types/rest/genericRestParameters1.ts(134,51): error TS2344: Type 'new (...args: T) => void' does not satisfy the constraint 'new (...args: any[]) => any'. + Types of parameters 'args' and 'args' are incompatible. + Type 'any[]' is not assignable to type 'T'. tests/cases/conformance/types/rest/genericRestParameters1.ts(135,23): error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'. Type 'Function' provides no match for the signature '(...args: any[]): any'. tests/cases/conformance/types/rest/genericRestParameters1.ts(164,1): error TS2322: Type '(a: never) => void' is not assignable to type '(...args: any[]) => void'. @@ -149,9 +153,13 @@ tests/cases/conformance/types/rest/genericRestParameters1.ts(164,1): error TS232 type T07 = Parameters<(...args: T) => void>; ~~~~~~~~~~~~~~~~~~~~ !!! error TS2344: Type '(...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. +!!! error TS2344: Types of parameters 'args' and 'args' are incompatible. +!!! error TS2344: Type 'any[]' is not assignable to type 'T'. type T08 = ConstructorParameters void>; ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2344: Type 'new (...args: T) => void' does not satisfy the constraint 'new (...args: any[]) => any'. +!!! error TS2344: Types of parameters 'args' and 'args' are incompatible. +!!! error TS2344: Type 'any[]' is not assignable to type 'T'. type T09 = Parameters; ~~~~~~~~ !!! error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'. diff --git a/tests/baselines/reference/genericRestParameters2.errors.txt b/tests/baselines/reference/genericRestParameters2.errors.txt index 5035544c51f..d6d3de9f322 100644 --- a/tests/baselines/reference/genericRestParameters2.errors.txt +++ b/tests/baselines/reference/genericRestParameters2.errors.txt @@ -1,4 +1,7 @@ tests/cases/conformance/types/rest/genericRestParameters2.ts(71,40): error TS2344: Type '(x: string, ...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. + Types of parameters 'x' and 'args' are incompatible. + Type 'any[]' is not assignable to type '[string, ...any[]]'. + Property '0' is missing in type 'any[]'. ==== tests/cases/conformance/types/rest/genericRestParameters2.ts (1 errors) ==== @@ -75,6 +78,9 @@ tests/cases/conformance/types/rest/genericRestParameters2.ts(71,40): error TS234 type T05 = Parameters<(x: string, ...args: T) => void>; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2344: Type '(x: string, ...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. +!!! error TS2344: Types of parameters 'x' and 'args' are incompatible. +!!! error TS2344: Type 'any[]' is not assignable to type '[string, ...any[]]'. +!!! error TS2344: Property '0' is missing in type 'any[]'. type T06 = T05<[number, ...boolean[]]>; type P1 = T extends (head: infer A, ...tail: infer B) => any ? { head: A, tail: B } : any[]; diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt index 90390fbe3a4..ce4368081f1 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt @@ -1,21 +1,31 @@ +tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(3,20): error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(8,27): error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(13,20): error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(21,18): error TS2372: Parameter 'a' cannot be referenced in its initializer. tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(25,22): error TS2372: Parameter 'async' cannot be referenced in its initializer. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(29,15): error TS2448: Block-scoped variable 'foo' used before its declaration. -==== tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts (2 errors) ==== +==== tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts (6 errors) ==== let foo: string = ""; function f1 (bar = foo) { // unexpected compiler error; works at runtime + ~~~ +!!! error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. var foo: number = 2; return bar; // returns 1 } function f2 (bar = (baz = foo) => baz) { // unexpected compiler error; works at runtime + ~~~ +!!! error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. var foo: number = 2; return bar(); // returns 1 } function f3 (bar = foo, foo = 2) { // correct compiler error, error at runtime + ~~~ +!!! error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. return bar; } @@ -36,6 +46,9 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.t } function f7({[foo]: bar}: any[]) { + ~~~ +!!! error TS2448: Block-scoped variable 'foo' used before its declaration. +!!! related TS2728 tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts:30:9: 'foo' is declared here. let foo: number = 2; } diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols index c0d42ab8b11..b44c91e8afd 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.symbols @@ -5,7 +5,7 @@ let foo: string = ""; function f1 (bar = foo) { // unexpected compiler error; works at runtime >f1 : Symbol(f1, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 21)) >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 2, 13)) ->foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 3, 7)) var foo: number = 2; >foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 3, 7)) @@ -18,7 +18,7 @@ function f2 (bar = (baz = foo) => baz) { // unexpected compiler error; works at >f2 : Symbol(f2, Decl(parameterInitializersForwardReferencing1_es6.ts, 5, 1)) >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 7, 13)) >baz : Symbol(baz, Decl(parameterInitializersForwardReferencing1_es6.ts, 7, 20)) ->foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 8, 7)) >baz : Symbol(baz, Decl(parameterInitializersForwardReferencing1_es6.ts, 7, 20)) var foo: number = 2; @@ -31,7 +31,7 @@ function f2 (bar = (baz = foo) => baz) { // unexpected compiler error; works at function f3 (bar = foo, foo = 2) { // correct compiler error, error at runtime >f3 : Symbol(f3, Decl(parameterInitializersForwardReferencing1_es6.ts, 10, 1)) >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 12, 13)) ->foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 12, 23)) >foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 12, 23)) return bar; @@ -68,7 +68,7 @@ function f6 (async = async) { function f7({[foo]: bar}: any[]) { >f7 : Symbol(f7, Decl(parameterInitializersForwardReferencing1_es6.ts, 26, 1)) ->foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(parameterInitializersForwardReferencing1_es6.ts, 29, 7)) >bar : Symbol(bar, Decl(parameterInitializersForwardReferencing1_es6.ts, 28, 13)) let foo: number = 2; diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types index 009ec47ddb8..a58d19c5755 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.types @@ -4,44 +4,44 @@ let foo: string = ""; >"" : "" function f1 (bar = foo) { // unexpected compiler error; works at runtime ->f1 : (bar?: string) => string ->bar : string ->foo : string +>f1 : (bar?: number) => number +>bar : number +>foo : number var foo: number = 2; >foo : number >2 : 2 return bar; // returns 1 ->bar : string +>bar : number } function f2 (bar = (baz = foo) => baz) { // unexpected compiler error; works at runtime ->f2 : (bar?: (baz?: string) => string) => string ->bar : (baz?: string) => string ->(baz = foo) => baz : (baz?: string) => string ->baz : string ->foo : string ->baz : string +>f2 : (bar?: (baz?: number) => number) => number +>bar : (baz?: number) => number +>(baz = foo) => baz : (baz?: number) => number +>baz : number +>foo : number +>baz : number var foo: number = 2; >foo : number >2 : 2 return bar(); // returns 1 ->bar() : string ->bar : (baz?: string) => string +>bar() : number +>bar : (baz?: number) => number } function f3 (bar = foo, foo = 2) { // correct compiler error, error at runtime ->f3 : (bar?: string, foo?: number) => string ->bar : string ->foo : string +>f3 : (bar?: number, foo?: number) => number +>bar : number +>foo : number >foo : number >2 : 2 return bar; ->bar : string +>bar : number } function f4 (foo, bar = foo) { @@ -74,7 +74,7 @@ function f6 (async = async) { function f7({[foo]: bar}: any[]) { >f7 : ({ [foo]: bar }: any[]) => void ->foo : string +>foo : number >bar : any let foo: number = 2; From e6a4e90cae051aafddab85cc868b57a327b3a861 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 31 Aug 2018 13:39:15 -0700 Subject: [PATCH 16/16] Update baselines to fix build (#26822) We started elaborating more errors in the 3 weeks since this PR was opened. --- .../baselines/reference/genericRestParameters1.errors.txt | 8 ++++++++ .../baselines/reference/genericRestParameters2.errors.txt | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/tests/baselines/reference/genericRestParameters1.errors.txt b/tests/baselines/reference/genericRestParameters1.errors.txt index fe45ef518ed..6b6d7f60845 100644 --- a/tests/baselines/reference/genericRestParameters1.errors.txt +++ b/tests/baselines/reference/genericRestParameters1.errors.txt @@ -1,7 +1,11 @@ tests/cases/conformance/types/rest/genericRestParameters1.ts(22,1): error TS2556: Expected 3 arguments, but got 1 or more. tests/cases/conformance/types/rest/genericRestParameters1.ts(31,1): error TS2556: Expected 3 arguments, but got 1 or more. tests/cases/conformance/types/rest/genericRestParameters1.ts(133,40): error TS2344: Type '(...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. + Types of parameters 'args' and 'args' are incompatible. + Type 'any[]' is not assignable to type 'T'. tests/cases/conformance/types/rest/genericRestParameters1.ts(134,51): error TS2344: Type 'new (...args: T) => void' does not satisfy the constraint 'new (...args: any[]) => any'. + Types of parameters 'args' and 'args' are incompatible. + Type 'any[]' is not assignable to type 'T'. tests/cases/conformance/types/rest/genericRestParameters1.ts(135,23): error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'. Type 'Function' provides no match for the signature '(...args: any[]): any'. tests/cases/conformance/types/rest/genericRestParameters1.ts(164,1): error TS2322: Type '(a: never) => void' is not assignable to type '(...args: any[]) => void'. @@ -149,9 +153,13 @@ tests/cases/conformance/types/rest/genericRestParameters1.ts(164,1): error TS232 type T07 = Parameters<(...args: T) => void>; ~~~~~~~~~~~~~~~~~~~~ !!! error TS2344: Type '(...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. +!!! error TS2344: Types of parameters 'args' and 'args' are incompatible. +!!! error TS2344: Type 'any[]' is not assignable to type 'T'. type T08 = ConstructorParameters void>; ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2344: Type 'new (...args: T) => void' does not satisfy the constraint 'new (...args: any[]) => any'. +!!! error TS2344: Types of parameters 'args' and 'args' are incompatible. +!!! error TS2344: Type 'any[]' is not assignable to type 'T'. type T09 = Parameters; ~~~~~~~~ !!! error TS2344: Type 'Function' does not satisfy the constraint '(...args: any[]) => any'. diff --git a/tests/baselines/reference/genericRestParameters2.errors.txt b/tests/baselines/reference/genericRestParameters2.errors.txt index 5035544c51f..d6d3de9f322 100644 --- a/tests/baselines/reference/genericRestParameters2.errors.txt +++ b/tests/baselines/reference/genericRestParameters2.errors.txt @@ -1,4 +1,7 @@ tests/cases/conformance/types/rest/genericRestParameters2.ts(71,40): error TS2344: Type '(x: string, ...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. + Types of parameters 'x' and 'args' are incompatible. + Type 'any[]' is not assignable to type '[string, ...any[]]'. + Property '0' is missing in type 'any[]'. ==== tests/cases/conformance/types/rest/genericRestParameters2.ts (1 errors) ==== @@ -75,6 +78,9 @@ tests/cases/conformance/types/rest/genericRestParameters2.ts(71,40): error TS234 type T05 = Parameters<(x: string, ...args: T) => void>; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2344: Type '(x: string, ...args: T) => void' does not satisfy the constraint '(...args: any[]) => any'. +!!! error TS2344: Types of parameters 'x' and 'args' are incompatible. +!!! error TS2344: Type 'any[]' is not assignable to type '[string, ...any[]]'. +!!! error TS2344: Property '0' is missing in type 'any[]'. type T06 = T05<[number, ...boolean[]]>; type P1 = T extends (head: infer A, ...tail: infer B) => any ? { head: A, tail: B } : any[];