From 3b8ad5c870d63d1f3577786f412bdb1d9915155d Mon Sep 17 00:00:00 2001 From: kingwl Date: Wed, 17 Jun 2020 20:50:19 +0800 Subject: [PATCH 01/47] Add outlining spans for call expression or arrow body --- src/services/outliningElementsCollector.ts | 25 +++++++++++++++++++ .../fourslash/outliningSpansForArguments.ts | 18 +++++++++++++ .../outliningSpansForArrowFunctionBody.ts | 15 +++++++++++ 3 files changed, 58 insertions(+) create mode 100644 tests/cases/fourslash/outliningSpansForArguments.ts create mode 100644 tests/cases/fourslash/outliningSpansForArrowFunctionBody.ts diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 6830a6e0b407e..a001d9c68f261 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -227,6 +227,31 @@ namespace ts.OutliningElementsCollector { return spanForTemplateLiteral(n); case SyntaxKind.ArrayBindingPattern: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !isBindingElement(n.parent), SyntaxKind.OpenBracketToken); + case SyntaxKind.ArrowFunction: + return spanForArrowFunction(n); + case SyntaxKind.CallExpression: + return spanForCallExpression(n); + } + + function spanForCallExpression(node: CallExpression): OutliningSpan | undefined { + if (!node.arguments.length) { + return undefined; + } + const openToken = findChildOfKind(node, SyntaxKind.OpenParenToken, sourceFile); + const closeToken = findChildOfKind(node, SyntaxKind.CloseParenToken, sourceFile); + if (!openToken || !closeToken || positionsAreOnSameLine(openToken.pos, closeToken.pos, sourceFile)) { + return undefined; + } + + return spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ false, /*useFullStart*/ true); + } + + function spanForArrowFunction(node: ArrowFunction): OutliningSpan | undefined { + if (isBlock(node.body) || positionsAreOnSameLine(node.body.getFullStart(), node.body.getEnd(), sourceFile)) { + return undefined; + } + const textSpan = createTextSpanFromBounds(node.body.getFullStart(), node.body.getEnd()); + return createOutliningSpan(textSpan, OutliningSpanKind.Code, createTextSpanFromNode(node)); } function spanForJSXElement(node: JsxElement): OutliningSpan | undefined { diff --git a/tests/cases/fourslash/outliningSpansForArguments.ts b/tests/cases/fourslash/outliningSpansForArguments.ts new file mode 100644 index 0000000000000..56c3c21e77a8b --- /dev/null +++ b/tests/cases/fourslash/outliningSpansForArguments.ts @@ -0,0 +1,18 @@ +/// + +//// console.log(123, 456)l; +//// console.log( +//// ); +//// console.log[|( +//// 123, 456 +//// )|]; +//// console.log[|( +//// 123, +//// 456 +//// )|]; +//// () =>[| console.log[|( +//// 123, +//// 456 +//// )|]|]; + +verify.outliningSpansInCurrentFile(test.ranges()); diff --git a/tests/cases/fourslash/outliningSpansForArrowFunctionBody.ts b/tests/cases/fourslash/outliningSpansForArrowFunctionBody.ts new file mode 100644 index 0000000000000..7dfc6e8ec2735 --- /dev/null +++ b/tests/cases/fourslash/outliningSpansForArrowFunctionBody.ts @@ -0,0 +1,15 @@ +/// + +//// () => 42; +//// () => ( 42 ); +//// () =>[| { +//// 42 +//// }|]; +//// () =>[| ( +//// 42 +//// )|]; +//// () =>[| "foo" + +//// "bar" + +//// "baz"|]; + +verify.outliningSpansInCurrentFile(test.ranges()); From 98a74ddfe8b1cc20cafdb319c93d79024ca015dc Mon Sep 17 00:00:00 2001 From: kingwl Date: Wed, 17 Jun 2020 22:41:08 +0800 Subject: [PATCH 02/47] Update baseline --- tests/cases/fourslash/getOutliningSpans.ts | 4 +- .../getOutliningSpansDepthChainedCalls.ts | 144 +++++++++--------- .../fourslash/outliningSpansForFunction.ts | 34 ++--- 3 files changed, 91 insertions(+), 91 deletions(-) diff --git a/tests/cases/fourslash/getOutliningSpans.ts b/tests/cases/fourslash/getOutliningSpans.ts index bec0f4f0d3b29..f8bc10ad95544 100644 --- a/tests/cases/fourslash/getOutliningSpans.ts +++ b/tests/cases/fourslash/getOutliningSpans.ts @@ -106,14 +106,14 @@ ////function f(x: number[], y: number[])[| { //// return 3; ////}|] -////f( +////f[|( ////// single line array literal span won't render in VS //// [|[0]|], //// [|[ //// 1, //// 2 //// ]|] -////); +////)|]; verify.outliningSpansInCurrentFile(test.ranges(), "code"); diff --git a/tests/cases/fourslash/getOutliningSpansDepthChainedCalls.ts b/tests/cases/fourslash/getOutliningSpansDepthChainedCalls.ts index 9fc8c50dd7044..2dc01223c9a1d 100644 --- a/tests/cases/fourslash/getOutliningSpansDepthChainedCalls.ts +++ b/tests/cases/fourslash/getOutliningSpansDepthChainedCalls.ts @@ -4,113 +4,113 @@ ////declare var router: any; ////router -//// .get("/", async(ctx) =>[|{ +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) -//// .get("/", async(ctx) =>[|{ +//// }|])|] +//// .get[|("/", async(ctx) =>[|{ //// ctx.body = "base"; -//// }|]) -//// .post("/a", async(ctx) =>[|{ +//// }|])|] +//// .post[|("/a", async(ctx) =>[|{ //// //a -//// }|]) +//// }|])|] verify.outliningSpansInCurrentFile(test.ranges()); diff --git a/tests/cases/fourslash/outliningSpansForFunction.ts b/tests/cases/fourslash/outliningSpansForFunction.ts index f46886b73068d..4fdf10f2c96b6 100644 --- a/tests/cases/fourslash/outliningSpansForFunction.ts +++ b/tests/cases/fourslash/outliningSpansForFunction.ts @@ -5,33 +5,33 @@ //// b: number ////) => { //// return a + b; -////}|] -///// -////(a: number, b: number) => [|{ +////}|]; +//// +////(a: number, b: number) =>[| { //// return a + b; -////}|] +////}|]; //// ////const f1 = function[| ( //// a: number //// b: number ////) { //// return a + b; -////}|] +////}|]; //// ////const f2 = function (a: number, b: number)[| { //// return a + b; -////}|] +////}|]; //// ////function f3[| ( //// a: number //// b: number ////) { //// return a + b; -////}|] +////}|]; //// ////function f4(a: number, b: number)[| { //// return a + b; -////}|] +////}|]; //// ////class Foo[| { //// constructor[|( @@ -52,33 +52,33 @@ //// m1(a: number, b: number)[| { //// return a + b; //// }|] -////}|] +////}|]; //// ////declare function foo(props: any): void; -////foo( +////foo[|( //// a =>[| { //// //// }|] -////) +////)|]; //// -////foo( +////foo[|( //// (a) =>[| { //// //// }|] -////) +////)|]; //// -////foo( +////foo[|( //// (a, b, c) =>[| { //// //// }|] -////) +////)|]; //// -////foo([| +////foo[|([| //// (a, //// b, //// c) => { //// //// }|] -////) +////)|]; verify.outliningSpansInCurrentFile(test.ranges()); From 4d57d591d2a66d1e2b71ad40028a03bbc018ef04 Mon Sep 17 00:00:00 2001 From: kingwl Date: Thu, 18 Jun 2020 10:33:17 +0800 Subject: [PATCH 03/47] Avoid semi --- .../fourslash/outliningSpansForFunction.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/cases/fourslash/outliningSpansForFunction.ts b/tests/cases/fourslash/outliningSpansForFunction.ts index 4fdf10f2c96b6..e89ecd6f843ab 100644 --- a/tests/cases/fourslash/outliningSpansForFunction.ts +++ b/tests/cases/fourslash/outliningSpansForFunction.ts @@ -9,29 +9,29 @@ //// ////(a: number, b: number) =>[| { //// return a + b; -////}|]; +////}|] //// ////const f1 = function[| ( //// a: number //// b: number ////) { //// return a + b; -////}|]; +////}|] //// ////const f2 = function (a: number, b: number)[| { //// return a + b; -////}|]; +////}|] //// ////function f3[| ( //// a: number //// b: number ////) { //// return a + b; -////}|]; +////}|] //// ////function f4(a: number, b: number)[| { //// return a + b; -////}|]; +////}|] //// ////class Foo[| { //// constructor[|( @@ -52,26 +52,26 @@ //// m1(a: number, b: number)[| { //// return a + b; //// }|] -////}|]; +////}|] //// ////declare function foo(props: any): void; ////foo[|( //// a =>[| { //// //// }|] -////)|]; +////)|] //// ////foo[|( //// (a) =>[| { //// //// }|] -////)|]; +////)|] //// ////foo[|( //// (a, b, c) =>[| { //// //// }|] -////)|]; +////)|] //// ////foo[|([| //// (a, @@ -79,6 +79,6 @@ //// c) => { //// //// }|] -////)|]; +////)|] verify.outliningSpansInCurrentFile(test.ranges()); From c75af697afcfcddcbf08366752a8088ff08028e4 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Sun, 28 Jun 2020 10:51:11 +0300 Subject: [PATCH 04/47] fix(29890): wrap variable/method/property to jsx expression --- src/services/refactors/extractSymbol.ts | 19 ++++++---- .../fourslash/extract-const_jsxElement1.ts | 28 ++++++++++++++ .../fourslash/extract-const_jsxElement2.ts | 28 ++++++++++++++ .../fourslash/extract-const_jsxElement3.ts | 35 ++++++++++++++++++ .../fourslash/extract-const_jsxFragment1.ts | 28 ++++++++++++++ .../fourslash/extract-const_jsxFragment2.ts | 28 ++++++++++++++ .../fourslash/extract-const_jsxFragment3.ts | 35 ++++++++++++++++++ .../extract-const_jsxSelfClosingElement1.ts | 28 ++++++++++++++ .../extract-const_jsxSelfClosingElement2.ts | 28 ++++++++++++++ .../extract-const_jsxSelfClosingElement3.ts | 35 ++++++++++++++++++ .../fourslash/extract-method_jsxElement1.ts | 32 ++++++++++++++++ .../fourslash/extract-method_jsxElement2.ts | 31 ++++++++++++++++ .../fourslash/extract-method_jsxElement3.ts | 37 +++++++++++++++++++ .../fourslash/extract-method_jsxFragment1.ts | 32 ++++++++++++++++ .../fourslash/extract-method_jsxFragment2.ts | 31 ++++++++++++++++ .../fourslash/extract-method_jsxFragment3.ts | 37 +++++++++++++++++++ .../extract-method_jsxSelfClosingElement1.ts | 32 ++++++++++++++++ .../extract-method_jsxSelfClosingElement2.ts | 31 ++++++++++++++++ .../extract-method_jsxSelfClosingElement3.ts | 37 +++++++++++++++++++ 19 files changed, 585 insertions(+), 7 deletions(-) create mode 100644 tests/cases/fourslash/extract-const_jsxElement1.ts create mode 100644 tests/cases/fourslash/extract-const_jsxElement2.ts create mode 100644 tests/cases/fourslash/extract-const_jsxElement3.ts create mode 100644 tests/cases/fourslash/extract-const_jsxFragment1.ts create mode 100644 tests/cases/fourslash/extract-const_jsxFragment2.ts create mode 100644 tests/cases/fourslash/extract-const_jsxFragment3.ts create mode 100644 tests/cases/fourslash/extract-const_jsxSelfClosingElement1.ts create mode 100644 tests/cases/fourslash/extract-const_jsxSelfClosingElement2.ts create mode 100644 tests/cases/fourslash/extract-const_jsxSelfClosingElement3.ts create mode 100644 tests/cases/fourslash/extract-method_jsxElement1.ts create mode 100644 tests/cases/fourslash/extract-method_jsxElement2.ts create mode 100644 tests/cases/fourslash/extract-method_jsxElement3.ts create mode 100644 tests/cases/fourslash/extract-method_jsxFragment1.ts create mode 100644 tests/cases/fourslash/extract-method_jsxFragment2.ts create mode 100644 tests/cases/fourslash/extract-method_jsxFragment3.ts create mode 100644 tests/cases/fourslash/extract-method_jsxSelfClosingElement1.ts create mode 100644 tests/cases/fourslash/extract-method_jsxSelfClosingElement2.ts create mode 100644 tests/cases/fourslash/extract-method_jsxSelfClosingElement3.ts diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index 451ac6359b9ab..d3d7660b400f4 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -915,6 +915,9 @@ namespace ts.refactor.extractSymbol { if (range.facts & RangeFacts.IsAsyncFunction) { call = factory.createAwaitExpression(call); } + if (isInJSXContent(node)) { + call = factory.createJsxExpression(/*dotDotDotToken*/ undefined, call); + } if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. @@ -1118,12 +1121,16 @@ namespace ts.refactor.extractSymbol { variableType, initializer); - const localReference = factory.createPropertyAccessExpression( + let localReference: Expression = factory.createPropertyAccessExpression( rangeFacts & RangeFacts.InStaticRegion ? factory.createIdentifier(scope.name!.getText()) // TODO: GH#18217 : factory.createThis(), factory.createIdentifier(localNameText)); + if (isInJSXContent(node)) { + localReference = factory.createJsxExpression(/*dotDotDotToken*/ undefined, localReference); + } + // Declare const maxInsertionPos = node.pos; const nodeToInsertBefore = getNodeToInsertPropertyBefore(maxInsertionPos, scope); @@ -1194,12 +1201,6 @@ namespace ts.refactor.extractSymbol { const renameLocation = getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename, renameLocation, edits }; - function isInJSXContent(node: Node) { - if (!isJsxElement(node)) return false; - if (isJsxElement(node.parent)) return true; - return false; - } - function transformFunctionInitializerAndType(variableType: TypeNode | undefined, initializer: Expression): { variableType: TypeNode | undefined, initializer: Expression } { // If no contextual type exists there is nothing to transfer to the function signature if (variableType === undefined) return { variableType, initializer }; @@ -1953,4 +1954,8 @@ namespace ts.refactor.extractSymbol { return false; } } + + function isInJSXContent(node: Node) { + return (isJsxElement(node) || isJsxSelfClosingElement(node) || isJsxFragment(node)) && isJsxElement(node.parent); + } } diff --git a/tests/cases/fourslash/extract-const_jsxElement1.ts b/tests/cases/fourslash/extract-const_jsxElement1.ts new file mode 100644 index 0000000000000..3018aa0cadd09 --- /dev/null +++ b/tests/cases/fourslash/extract-const_jsxElement1.ts @@ -0,0 +1,28 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*//*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "constant_scope_1", + actionDescription: "Extract to constant in global scope", + newContent: +`const /*RENAME*/newLocal = ; +function Foo() { + return ( +
+ {newLocal} +
+ ); +}` +}); diff --git a/tests/cases/fourslash/extract-const_jsxElement2.ts b/tests/cases/fourslash/extract-const_jsxElement2.ts new file mode 100644 index 0000000000000..eb1bd23473a4a --- /dev/null +++ b/tests/cases/fourslash/extract-const_jsxElement2.ts @@ -0,0 +1,28 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*//*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "constant_scope_0", + actionDescription: "Extract to constant in enclosing scope", + newContent: +`function Foo() { + const /*RENAME*/newLocal = ; + return ( +
+ {newLocal} +
+ ); +}` +}); diff --git a/tests/cases/fourslash/extract-const_jsxElement3.ts b/tests/cases/fourslash/extract-const_jsxElement3.ts new file mode 100644 index 0000000000000..ef9f9ff543411 --- /dev/null +++ b/tests/cases/fourslash/extract-const_jsxElement3.ts @@ -0,0 +1,35 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////declare var React: any; +////class Foo extends React.Component<{}, {}> { +//// render() { +//// return ( +////
+//// /*a*//*b*/ +////
+//// ); +//// } +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "constant_scope_1", + actionDescription: "Extract to readonly field in class 'Foo'", + newContent: +`declare var React: any; +class Foo extends React.Component<{}, {}> { + private readonly newProperty = ; + + render() { + return ( +
+ {this./*RENAME*/newProperty} +
+ ); + } +}` +}); diff --git a/tests/cases/fourslash/extract-const_jsxFragment1.ts b/tests/cases/fourslash/extract-const_jsxFragment1.ts new file mode 100644 index 0000000000000..d67432f382ffd --- /dev/null +++ b/tests/cases/fourslash/extract-const_jsxFragment1.ts @@ -0,0 +1,28 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*/<>/*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "constant_scope_1", + actionDescription: "Extract to constant in global scope", + newContent: +`const /*RENAME*/newLocal = <>; +function Foo() { + return ( +
+ {newLocal} +
+ ); +}` +}); diff --git a/tests/cases/fourslash/extract-const_jsxFragment2.ts b/tests/cases/fourslash/extract-const_jsxFragment2.ts new file mode 100644 index 0000000000000..ba4a67bfa3862 --- /dev/null +++ b/tests/cases/fourslash/extract-const_jsxFragment2.ts @@ -0,0 +1,28 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*/<>/*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "constant_scope_0", + actionDescription: "Extract to constant in enclosing scope", + newContent: +`function Foo() { + const /*RENAME*/newLocal = <>; + return ( +
+ {newLocal} +
+ ); +}` +}); diff --git a/tests/cases/fourslash/extract-const_jsxFragment3.ts b/tests/cases/fourslash/extract-const_jsxFragment3.ts new file mode 100644 index 0000000000000..8a5faf4457f14 --- /dev/null +++ b/tests/cases/fourslash/extract-const_jsxFragment3.ts @@ -0,0 +1,35 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////declare var React: any; +////class Foo extends React.Component<{}, {}> { +//// render() { +//// return ( +////
+//// /*a*/<>/*b*/ +////
+//// ); +//// } +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "constant_scope_1", + actionDescription: "Extract to readonly field in class 'Foo'", + newContent: +`declare var React: any; +class Foo extends React.Component<{}, {}> { + private readonly newProperty = <>; + + render() { + return ( +
+ {this./*RENAME*/newProperty} +
+ ); + } +}` +}); diff --git a/tests/cases/fourslash/extract-const_jsxSelfClosingElement1.ts b/tests/cases/fourslash/extract-const_jsxSelfClosingElement1.ts new file mode 100644 index 0000000000000..0a37c10763c12 --- /dev/null +++ b/tests/cases/fourslash/extract-const_jsxSelfClosingElement1.ts @@ -0,0 +1,28 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*/
/*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "constant_scope_1", + actionDescription: "Extract to constant in global scope", + newContent: +`const /*RENAME*/newLocal =
; +function Foo() { + return ( +
+ {newLocal} +
+ ); +}` +}); diff --git a/tests/cases/fourslash/extract-const_jsxSelfClosingElement2.ts b/tests/cases/fourslash/extract-const_jsxSelfClosingElement2.ts new file mode 100644 index 0000000000000..33dd2c6347b34 --- /dev/null +++ b/tests/cases/fourslash/extract-const_jsxSelfClosingElement2.ts @@ -0,0 +1,28 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*/
/*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "constant_scope_0", + actionDescription: "Extract to constant in enclosing scope", + newContent: +`function Foo() { + const /*RENAME*/newLocal =
; + return ( +
+ {newLocal} +
+ ); +}` +}); diff --git a/tests/cases/fourslash/extract-const_jsxSelfClosingElement3.ts b/tests/cases/fourslash/extract-const_jsxSelfClosingElement3.ts new file mode 100644 index 0000000000000..5d9569819aa0b --- /dev/null +++ b/tests/cases/fourslash/extract-const_jsxSelfClosingElement3.ts @@ -0,0 +1,35 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////declare var React: any; +////class Foo extends React.Component<{}, {}> { +//// render() { +//// return ( +////
+//// /*a*/
/*b*/ +////
+//// ); +//// } +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "constant_scope_1", + actionDescription: "Extract to readonly field in class 'Foo'", + newContent: +`declare var React: any; +class Foo extends React.Component<{}, {}> { + private readonly newProperty =
; + + render() { + return ( +
+ {this./*RENAME*/newProperty} +
+ ); + } +}` +}); diff --git a/tests/cases/fourslash/extract-method_jsxElement1.ts b/tests/cases/fourslash/extract-method_jsxElement1.ts new file mode 100644 index 0000000000000..1c5d2225a3d59 --- /dev/null +++ b/tests/cases/fourslash/extract-method_jsxElement1.ts @@ -0,0 +1,32 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*//*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_1", + actionDescription: "Extract to function in global scope", + newContent: +`function Foo() { + return ( +
+ {newFunction()} +
+ ); +} + +function /*RENAME*/newFunction() { + return ; +} +` +}); diff --git a/tests/cases/fourslash/extract-method_jsxElement2.ts b/tests/cases/fourslash/extract-method_jsxElement2.ts new file mode 100644 index 0000000000000..d02b55e1c13a7 --- /dev/null +++ b/tests/cases/fourslash/extract-method_jsxElement2.ts @@ -0,0 +1,31 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*//*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_0", + actionDescription: "Extract to inner function in function 'Foo'", + newContent: +`function Foo() { + return ( +
+ {newFunction()} +
+ ); + + function /*RENAME*/newFunction() { + return ; + } +}` +}); diff --git a/tests/cases/fourslash/extract-method_jsxElement3.ts b/tests/cases/fourslash/extract-method_jsxElement3.ts new file mode 100644 index 0000000000000..7e0b4cc098ffc --- /dev/null +++ b/tests/cases/fourslash/extract-method_jsxElement3.ts @@ -0,0 +1,37 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////declare var React: any; +////class Foo extends React.Component<{}, {}> { +//// render() { +//// return ( +////
+//// /*a*//*b*/ +////
+//// ); +//// } +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_1", + actionDescription: "Extract to method in class 'Foo'", + newContent: +`declare var React: any; +class Foo extends React.Component<{}, {}> { + render() { + return ( +
+ {this./*RENAME*/newMethod()} +
+ ); + } + + private newMethod() { + return ; + } +}` +}); diff --git a/tests/cases/fourslash/extract-method_jsxFragment1.ts b/tests/cases/fourslash/extract-method_jsxFragment1.ts new file mode 100644 index 0000000000000..30a2426e01d04 --- /dev/null +++ b/tests/cases/fourslash/extract-method_jsxFragment1.ts @@ -0,0 +1,32 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*/<>/*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_1", + actionDescription: "Extract to function in global scope", + newContent: +`function Foo() { + return ( +
+ {newFunction()} +
+ ); +} + +function /*RENAME*/newFunction() { + return <>; +} +` +}); diff --git a/tests/cases/fourslash/extract-method_jsxFragment2.ts b/tests/cases/fourslash/extract-method_jsxFragment2.ts new file mode 100644 index 0000000000000..254924c51ee36 --- /dev/null +++ b/tests/cases/fourslash/extract-method_jsxFragment2.ts @@ -0,0 +1,31 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*/<>/*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_0", + actionDescription: "Extract to inner function in function 'Foo'", + newContent: +`function Foo() { + return ( +
+ {newFunction()} +
+ ); + + function /*RENAME*/newFunction() { + return <>; + } +}` +}); diff --git a/tests/cases/fourslash/extract-method_jsxFragment3.ts b/tests/cases/fourslash/extract-method_jsxFragment3.ts new file mode 100644 index 0000000000000..e8983f6524d3c --- /dev/null +++ b/tests/cases/fourslash/extract-method_jsxFragment3.ts @@ -0,0 +1,37 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////declare var React: any; +////class Foo extends React.Component<{}, {}> { +//// render() { +//// return ( +////
+//// /*a*/<>/*b*/ +////
+//// ); +//// } +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_1", + actionDescription: "Extract to method in class 'Foo'", + newContent: +`declare var React: any; +class Foo extends React.Component<{}, {}> { + render() { + return ( +
+ {this./*RENAME*/newMethod()} +
+ ); + } + + private newMethod() { + return <>; + } +}` +}); diff --git a/tests/cases/fourslash/extract-method_jsxSelfClosingElement1.ts b/tests/cases/fourslash/extract-method_jsxSelfClosingElement1.ts new file mode 100644 index 0000000000000..041b4462bb6f0 --- /dev/null +++ b/tests/cases/fourslash/extract-method_jsxSelfClosingElement1.ts @@ -0,0 +1,32 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*/
/*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_1", + actionDescription: "Extract to function in global scope", + newContent: +`function Foo() { + return ( +
+ {newFunction()} +
+ ); +} + +function /*RENAME*/newFunction() { + return
; +} +` +}); diff --git a/tests/cases/fourslash/extract-method_jsxSelfClosingElement2.ts b/tests/cases/fourslash/extract-method_jsxSelfClosingElement2.ts new file mode 100644 index 0000000000000..de96c61f8f728 --- /dev/null +++ b/tests/cases/fourslash/extract-method_jsxSelfClosingElement2.ts @@ -0,0 +1,31 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////function Foo() { +//// return ( +////
+//// /*a*/
/*b*/ +////
+//// ); +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_0", + actionDescription: "Extract to inner function in function 'Foo'", + newContent: +`function Foo() { + return ( +
+ {newFunction()} +
+ ); + + function /*RENAME*/newFunction() { + return
; + } +}` +}); diff --git a/tests/cases/fourslash/extract-method_jsxSelfClosingElement3.ts b/tests/cases/fourslash/extract-method_jsxSelfClosingElement3.ts new file mode 100644 index 0000000000000..0b6f48253b96a --- /dev/null +++ b/tests/cases/fourslash/extract-method_jsxSelfClosingElement3.ts @@ -0,0 +1,37 @@ +/// + +// @jsx: preserve +// @filename: a.tsx +////declare var React: any; +////class Foo extends React.Component<{}, {}> { +//// render() { +//// return ( +////
+//// /*a*/
/*b*/ +////
+//// ); +//// } +////} + +goTo.file("a.tsx"); +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_1", + actionDescription: "Extract to method in class 'Foo'", + newContent: +`declare var React: any; +class Foo extends React.Component<{}, {}> { + render() { + return ( +
+ {this./*RENAME*/newMethod()} +
+ ); + } + + private newMethod() { + return
; + } +}` +}); From 6ed9d56cca00b5da4cc8149a24a59196fcba35ea Mon Sep 17 00:00:00 2001 From: csigs Date: Sun, 28 Jun 2020 16:10:45 +0000 Subject: [PATCH 05/47] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 13c238a4f8862..8f6ec604a5fea 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4446,6 +4446,9 @@ + + + @@ -9615,12 +9618,18 @@ + + + + + + @@ -10044,12 +10053,18 @@ + + + + + + From 5f04915ccbd1653640a6fe3a426724ee1e0e4ba2 Mon Sep 17 00:00:00 2001 From: csigs Date: Mon, 29 Jun 2020 16:10:37 +0000 Subject: [PATCH 06/47] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index 93e79f13132c4..5a95d97b96c48 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4446,6 +4446,9 @@ + + + @@ -9615,12 +9618,18 @@ + + + + + + @@ -10044,12 +10053,18 @@ + + + + + + From 58ed610ef19f6fbbb100cec60c506752c6ca149a Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 29 Jun 2020 10:08:17 -0700 Subject: [PATCH 07/47] Allow distinct string enum members with identical property names to form unions in mapped types (#39101) --- src/compiler/checker.ts | 42 ++++---- .../mappedTypeOverlappingStringEnumKeys.js | 59 ++++++++++++ ...appedTypeOverlappingStringEnumKeys.symbols | 96 +++++++++++++++++++ .../mappedTypeOverlappingStringEnumKeys.types | 91 ++++++++++++++++++ .../mappedTypeOverlappingStringEnumKeys.ts | 36 +++++++ 5 files changed, 308 insertions(+), 16 deletions(-) create mode 100644 tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.js create mode 100644 tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.symbols create mode 100644 tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.types create mode 100644 tests/cases/conformance/types/mapped/mappedTypeOverlappingStringEnumKeys.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa0091f99523a..bdc844df97039 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10253,22 +10253,32 @@ namespace ts { // Otherwise, for type string create a string index signature. if (isTypeUsableAsPropertyName(t)) { const propName = getPropertyNameFromType(t); - const modifiersProp = getPropertyOfType(modifiersType, propName); - const isOptional = !!(templateModifiers & MappedTypeModifiers.IncludeOptional || - !(templateModifiers & MappedTypeModifiers.ExcludeOptional) && modifiersProp && modifiersProp.flags & SymbolFlags.Optional); - const isReadonly = !!(templateModifiers & MappedTypeModifiers.IncludeReadonly || - !(templateModifiers & MappedTypeModifiers.ExcludeReadonly) && modifiersProp && isReadonlySymbol(modifiersProp)); - const stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & SymbolFlags.Optional; - const prop = createSymbol(SymbolFlags.Property | (isOptional ? SymbolFlags.Optional : 0), propName, - CheckFlags.Mapped | (isReadonly ? CheckFlags.Readonly : 0) | (stripOptional ? CheckFlags.StripOptional : 0)); - prop.mappedType = type; - prop.mapper = templateMapper; - if (modifiersProp) { - prop.syntheticOrigin = modifiersProp; - prop.declarations = modifiersProp.declarations; - } - prop.nameType = t; - members.set(propName, prop); + // String enum members from separate enums with identical values + // are distinct types with the same property name. Make the resulting + // property symbol's name type be the union of those enum member types. + const existingProp = members.get(propName) as MappedSymbol | undefined; + if (existingProp) { + existingProp.nameType = getUnionType([existingProp.nameType!, t]); + existingProp.mapper = appendTypeMapping(type.mapper, typeParameter, existingProp.nameType); + } + else { + const modifiersProp = getPropertyOfType(modifiersType, propName); + const isOptional = !!(templateModifiers & MappedTypeModifiers.IncludeOptional || + !(templateModifiers & MappedTypeModifiers.ExcludeOptional) && modifiersProp && modifiersProp.flags & SymbolFlags.Optional); + const isReadonly = !!(templateModifiers & MappedTypeModifiers.IncludeReadonly || + !(templateModifiers & MappedTypeModifiers.ExcludeReadonly) && modifiersProp && isReadonlySymbol(modifiersProp)); + const stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & SymbolFlags.Optional; + const prop = createSymbol(SymbolFlags.Property | (isOptional ? SymbolFlags.Optional : 0), propName, + CheckFlags.Mapped | (isReadonly ? CheckFlags.Readonly : 0) | (stripOptional ? CheckFlags.StripOptional : 0)); + prop.mappedType = type; + if (modifiersProp) { + prop.syntheticOrigin = modifiersProp; + prop.declarations = modifiersProp.declarations; + } + prop.nameType = t; + prop.mapper = templateMapper; + members.set(propName, prop); + } } else if (t.flags & (TypeFlags.Any | TypeFlags.String | TypeFlags.Number | TypeFlags.Enum)) { const propType = instantiateType(templateType, templateMapper); diff --git a/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.js b/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.js new file mode 100644 index 0000000000000..d25fde357ad66 --- /dev/null +++ b/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.js @@ -0,0 +1,59 @@ +//// [mappedTypeOverlappingStringEnumKeys.ts] +// #37859 + +enum TerrestrialAnimalTypes { + CAT = "cat", + DOG = "dog" +}; + +enum AlienAnimalTypes { + CAT = "cat", +}; + +type AnimalTypes = TerrestrialAnimalTypes | AlienAnimalTypes; + +interface TerrestrialCat { + type: TerrestrialAnimalTypes.CAT; + address: string; +} + +interface AlienCat { + type: AlienAnimalTypes.CAT + planet: string; +} + +type Cats = TerrestrialCat | AlienCat; + +type CatMap = { + [V in AnimalTypes]: Extract[] +}; + +const catMap: CatMap = { + cat: [ + { type: TerrestrialAnimalTypes.CAT, address: "" }, + { type: AlienAnimalTypes.CAT, planet: "" } + ], + dog: [] as never[] +}; + + +//// [mappedTypeOverlappingStringEnumKeys.js] +// #37859 +var TerrestrialAnimalTypes; +(function (TerrestrialAnimalTypes) { + TerrestrialAnimalTypes["CAT"] = "cat"; + TerrestrialAnimalTypes["DOG"] = "dog"; +})(TerrestrialAnimalTypes || (TerrestrialAnimalTypes = {})); +; +var AlienAnimalTypes; +(function (AlienAnimalTypes) { + AlienAnimalTypes["CAT"] = "cat"; +})(AlienAnimalTypes || (AlienAnimalTypes = {})); +; +var catMap = { + cat: [ + { type: TerrestrialAnimalTypes.CAT, address: "" }, + { type: AlienAnimalTypes.CAT, planet: "" } + ], + dog: [] +}; diff --git a/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.symbols b/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.symbols new file mode 100644 index 0000000000000..740cae0d7b953 --- /dev/null +++ b/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.symbols @@ -0,0 +1,96 @@ +=== tests/cases/conformance/types/mapped/mappedTypeOverlappingStringEnumKeys.ts === +// #37859 + +enum TerrestrialAnimalTypes { +>TerrestrialAnimalTypes : Symbol(TerrestrialAnimalTypes, Decl(mappedTypeOverlappingStringEnumKeys.ts, 0, 0)) + + CAT = "cat", +>CAT : Symbol(TerrestrialAnimalTypes.CAT, Decl(mappedTypeOverlappingStringEnumKeys.ts, 2, 29)) + + DOG = "dog" +>DOG : Symbol(TerrestrialAnimalTypes.DOG, Decl(mappedTypeOverlappingStringEnumKeys.ts, 3, 14)) + +}; + +enum AlienAnimalTypes { +>AlienAnimalTypes : Symbol(AlienAnimalTypes, Decl(mappedTypeOverlappingStringEnumKeys.ts, 5, 2)) + + CAT = "cat", +>CAT : Symbol(AlienAnimalTypes.CAT, Decl(mappedTypeOverlappingStringEnumKeys.ts, 7, 23)) + +}; + +type AnimalTypes = TerrestrialAnimalTypes | AlienAnimalTypes; +>AnimalTypes : Symbol(AnimalTypes, Decl(mappedTypeOverlappingStringEnumKeys.ts, 9, 2)) +>TerrestrialAnimalTypes : Symbol(TerrestrialAnimalTypes, Decl(mappedTypeOverlappingStringEnumKeys.ts, 0, 0)) +>AlienAnimalTypes : Symbol(AlienAnimalTypes, Decl(mappedTypeOverlappingStringEnumKeys.ts, 5, 2)) + +interface TerrestrialCat { +>TerrestrialCat : Symbol(TerrestrialCat, Decl(mappedTypeOverlappingStringEnumKeys.ts, 11, 61)) + + type: TerrestrialAnimalTypes.CAT; +>type : Symbol(TerrestrialCat.type, Decl(mappedTypeOverlappingStringEnumKeys.ts, 13, 26)) +>TerrestrialAnimalTypes : Symbol(TerrestrialAnimalTypes, Decl(mappedTypeOverlappingStringEnumKeys.ts, 0, 0)) +>CAT : Symbol(TerrestrialAnimalTypes.CAT, Decl(mappedTypeOverlappingStringEnumKeys.ts, 2, 29)) + + address: string; +>address : Symbol(TerrestrialCat.address, Decl(mappedTypeOverlappingStringEnumKeys.ts, 14, 35)) +} + +interface AlienCat { +>AlienCat : Symbol(AlienCat, Decl(mappedTypeOverlappingStringEnumKeys.ts, 16, 1)) + + type: AlienAnimalTypes.CAT +>type : Symbol(AlienCat.type, Decl(mappedTypeOverlappingStringEnumKeys.ts, 18, 20)) +>AlienAnimalTypes : Symbol(AlienAnimalTypes, Decl(mappedTypeOverlappingStringEnumKeys.ts, 5, 2)) +>CAT : Symbol(AlienAnimalTypes.CAT, Decl(mappedTypeOverlappingStringEnumKeys.ts, 7, 23)) + + planet: string; +>planet : Symbol(AlienCat.planet, Decl(mappedTypeOverlappingStringEnumKeys.ts, 19, 28)) +} + +type Cats = TerrestrialCat | AlienCat; +>Cats : Symbol(Cats, Decl(mappedTypeOverlappingStringEnumKeys.ts, 21, 1)) +>TerrestrialCat : Symbol(TerrestrialCat, Decl(mappedTypeOverlappingStringEnumKeys.ts, 11, 61)) +>AlienCat : Symbol(AlienCat, Decl(mappedTypeOverlappingStringEnumKeys.ts, 16, 1)) + +type CatMap = { +>CatMap : Symbol(CatMap, Decl(mappedTypeOverlappingStringEnumKeys.ts, 23, 38)) + + [V in AnimalTypes]: Extract[] +>V : Symbol(V, Decl(mappedTypeOverlappingStringEnumKeys.ts, 26, 3)) +>AnimalTypes : Symbol(AnimalTypes, Decl(mappedTypeOverlappingStringEnumKeys.ts, 9, 2)) +>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) +>Cats : Symbol(Cats, Decl(mappedTypeOverlappingStringEnumKeys.ts, 21, 1)) +>type : Symbol(type, Decl(mappedTypeOverlappingStringEnumKeys.ts, 26, 37)) +>V : Symbol(V, Decl(mappedTypeOverlappingStringEnumKeys.ts, 26, 3)) + +}; + +const catMap: CatMap = { +>catMap : Symbol(catMap, Decl(mappedTypeOverlappingStringEnumKeys.ts, 29, 5)) +>CatMap : Symbol(CatMap, Decl(mappedTypeOverlappingStringEnumKeys.ts, 23, 38)) + + cat: [ +>cat : Symbol(cat, Decl(mappedTypeOverlappingStringEnumKeys.ts, 29, 24)) + + { type: TerrestrialAnimalTypes.CAT, address: "" }, +>type : Symbol(type, Decl(mappedTypeOverlappingStringEnumKeys.ts, 31, 5)) +>TerrestrialAnimalTypes.CAT : Symbol(TerrestrialAnimalTypes.CAT, Decl(mappedTypeOverlappingStringEnumKeys.ts, 2, 29)) +>TerrestrialAnimalTypes : Symbol(TerrestrialAnimalTypes, Decl(mappedTypeOverlappingStringEnumKeys.ts, 0, 0)) +>CAT : Symbol(TerrestrialAnimalTypes.CAT, Decl(mappedTypeOverlappingStringEnumKeys.ts, 2, 29)) +>address : Symbol(address, Decl(mappedTypeOverlappingStringEnumKeys.ts, 31, 39)) + + { type: AlienAnimalTypes.CAT, planet: "" } +>type : Symbol(type, Decl(mappedTypeOverlappingStringEnumKeys.ts, 32, 5)) +>AlienAnimalTypes.CAT : Symbol(AlienAnimalTypes.CAT, Decl(mappedTypeOverlappingStringEnumKeys.ts, 7, 23)) +>AlienAnimalTypes : Symbol(AlienAnimalTypes, Decl(mappedTypeOverlappingStringEnumKeys.ts, 5, 2)) +>CAT : Symbol(AlienAnimalTypes.CAT, Decl(mappedTypeOverlappingStringEnumKeys.ts, 7, 23)) +>planet : Symbol(planet, Decl(mappedTypeOverlappingStringEnumKeys.ts, 32, 33)) + + ], + dog: [] as never[] +>dog : Symbol(dog, Decl(mappedTypeOverlappingStringEnumKeys.ts, 33, 4)) + +}; + diff --git a/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.types b/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.types new file mode 100644 index 0000000000000..ae58d3f12ddc3 --- /dev/null +++ b/tests/baselines/reference/mappedTypeOverlappingStringEnumKeys.types @@ -0,0 +1,91 @@ +=== tests/cases/conformance/types/mapped/mappedTypeOverlappingStringEnumKeys.ts === +// #37859 + +enum TerrestrialAnimalTypes { +>TerrestrialAnimalTypes : TerrestrialAnimalTypes + + CAT = "cat", +>CAT : TerrestrialAnimalTypes.CAT +>"cat" : "cat" + + DOG = "dog" +>DOG : TerrestrialAnimalTypes.DOG +>"dog" : "dog" + +}; + +enum AlienAnimalTypes { +>AlienAnimalTypes : AlienAnimalTypes + + CAT = "cat", +>CAT : AlienAnimalTypes.CAT +>"cat" : "cat" + +}; + +type AnimalTypes = TerrestrialAnimalTypes | AlienAnimalTypes; +>AnimalTypes : AnimalTypes + +interface TerrestrialCat { + type: TerrestrialAnimalTypes.CAT; +>type : TerrestrialAnimalTypes.CAT +>TerrestrialAnimalTypes : any + + address: string; +>address : string +} + +interface AlienCat { + type: AlienAnimalTypes.CAT +>type : AlienAnimalTypes +>AlienAnimalTypes : any + + planet: string; +>planet : string +} + +type Cats = TerrestrialCat | AlienCat; +>Cats : Cats + +type CatMap = { +>CatMap : CatMap + + [V in AnimalTypes]: Extract[] +>type : V + +}; + +const catMap: CatMap = { +>catMap : CatMap +>{ cat: [ { type: TerrestrialAnimalTypes.CAT, address: "" }, { type: AlienAnimalTypes.CAT, planet: "" } ], dog: [] as never[]} : { cat: ({ type: TerrestrialAnimalTypes.CAT; address: string; } | { type: AlienAnimalTypes.CAT; planet: string; })[]; dog: never[]; } + + cat: [ +>cat : ({ type: TerrestrialAnimalTypes.CAT; address: string; } | { type: AlienAnimalTypes.CAT; planet: string; })[] +>[ { type: TerrestrialAnimalTypes.CAT, address: "" }, { type: AlienAnimalTypes.CAT, planet: "" } ] : ({ type: TerrestrialAnimalTypes.CAT; address: string; } | { type: AlienAnimalTypes.CAT; planet: string; })[] + + { type: TerrestrialAnimalTypes.CAT, address: "" }, +>{ type: TerrestrialAnimalTypes.CAT, address: "" } : { type: TerrestrialAnimalTypes.CAT; address: string; } +>type : TerrestrialAnimalTypes.CAT +>TerrestrialAnimalTypes.CAT : TerrestrialAnimalTypes.CAT +>TerrestrialAnimalTypes : typeof TerrestrialAnimalTypes +>CAT : TerrestrialAnimalTypes.CAT +>address : string +>"" : "" + + { type: AlienAnimalTypes.CAT, planet: "" } +>{ type: AlienAnimalTypes.CAT, planet: "" } : { type: AlienAnimalTypes.CAT; planet: string; } +>type : AlienAnimalTypes.CAT +>AlienAnimalTypes.CAT : AlienAnimalTypes +>AlienAnimalTypes : typeof AlienAnimalTypes +>CAT : AlienAnimalTypes +>planet : string +>"" : "" + + ], + dog: [] as never[] +>dog : never[] +>[] as never[] : never[] +>[] : undefined[] + +}; + diff --git a/tests/cases/conformance/types/mapped/mappedTypeOverlappingStringEnumKeys.ts b/tests/cases/conformance/types/mapped/mappedTypeOverlappingStringEnumKeys.ts new file mode 100644 index 0000000000000..c1ebd4b382c3c --- /dev/null +++ b/tests/cases/conformance/types/mapped/mappedTypeOverlappingStringEnumKeys.ts @@ -0,0 +1,36 @@ +// #37859 + +enum TerrestrialAnimalTypes { + CAT = "cat", + DOG = "dog" +}; + +enum AlienAnimalTypes { + CAT = "cat", +}; + +type AnimalTypes = TerrestrialAnimalTypes | AlienAnimalTypes; + +interface TerrestrialCat { + type: TerrestrialAnimalTypes.CAT; + address: string; +} + +interface AlienCat { + type: AlienAnimalTypes.CAT + planet: string; +} + +type Cats = TerrestrialCat | AlienCat; + +type CatMap = { + [V in AnimalTypes]: Extract[] +}; + +const catMap: CatMap = { + cat: [ + { type: TerrestrialAnimalTypes.CAT, address: "" }, + { type: AlienAnimalTypes.CAT, planet: "" } + ], + dog: [] as never[] +}; From ee5c3fa57df274d824225cc3c17fd2d47cc67f63 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Mon, 29 Jun 2020 20:10:44 +0300 Subject: [PATCH 08/47] fix(39047): handle extra spaces after the catch statement (#39306) --- src/services/formatting/rules.ts | 4 ++-- tests/cases/fourslash/formatCatch.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/formatCatch.ts diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 1f84b04e531f8..f623da539924e 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -348,8 +348,8 @@ namespace ts.formatting { anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], RuleAction.InsertSpace), - // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword], SyntaxKind.OpenBraceToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), + // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. + rule("SpaceAfterTryCatchFinally", [SyntaxKind.TryKeyword, SyntaxKind.CatchKeyword, SyntaxKind.FinallyKeyword], SyntaxKind.OpenBraceToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace), ]; return [ diff --git a/tests/cases/fourslash/formatCatch.ts b/tests/cases/fourslash/formatCatch.ts new file mode 100644 index 0000000000000..fce6cf75df57a --- /dev/null +++ b/tests/cases/fourslash/formatCatch.ts @@ -0,0 +1,16 @@ +/// + +////try { +////} /*0*/catch { +////} +//// +////try { +////} /*1*/catch{ +////} + +format.document(); + +for (const marker of test.markers()) { + goTo.marker(marker); + verify.currentLineContentIs("} catch {"); +} From 99bec5067b84bdfdb81f23d832e5f3e06e73316b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 29 Jun 2020 12:30:23 -0700 Subject: [PATCH 09/47] Use mapped rest type member when expanding rest parameter names (#39317) * Use mapped rest type member when expanding rest parameter names * Add test for #39228 which is also fixed by parameters having unique names --- src/compiler/checker.ts | 6 +- src/harness/fourslashImpl.ts | 3 +- src/harness/fourslashInterfaceImpl.ts | 1 + tests/cases/fourslash/fourslash.ts | 1 + ...ignatureHelpExpandedRestUnlabeledTuples.ts | 36 +++++++ ...ignatureHelpExpandedTuplesArgumentIndex.ts | 94 +++++++++++++++++++ 6 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/signatureHelpExpandedRestUnlabeledTuples.ts create mode 100644 tests/cases/fourslash/signatureHelpExpandedTuplesArgumentIndex.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bdc844df97039..6ebd67e6cfde6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9781,7 +9781,7 @@ namespace ts { const restParams = map(elementTypes, (t, i) => { // Lookup the label from the individual tuple passed in before falling back to the signature `rest` parameter name const tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]); - const name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i); + const name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType); const flags = restType.target.elementFlags[i]; const checkFlags = flags & ElementFlags.Variable ? CheckFlags.RestParameter : flags & ElementFlags.Optional ? CheckFlags.OptionalParameter : 0; @@ -27708,13 +27708,13 @@ namespace ts { return d.name.escapedText; } - function getParameterNameAtPosition(signature: Signature, pos: number) { + function getParameterNameAtPosition(signature: Signature, pos: number, overrideRestType?: Type) { const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return signature.parameters[pos].escapedName; } const restParameter = signature.parameters[paramCount] || unknownSymbol; - const restType = getTypeOfSymbol(restParameter); + const restType = overrideRestType || getTypeOfSymbol(restParameter); if (isTupleType(restType)) { const associatedNames = ((restType).target).labeledElementDeclarations; const index = pos - paramCount; diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index 88ba1fa6508c7..08ed8709fb0e9 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -1426,7 +1426,7 @@ namespace FourSlash { this.raiseError("Could not get a help signature"); } - const selectedItem = help.items[help.selectedItemIndex]; + const selectedItem = help.items[options.overrideSelectedItemIndex ?? help.selectedItemIndex]; // Argument index may exceed number of parameters const currentParameter = selectedItem.parameters[help.argumentIndex] as ts.SignatureHelpParameter | undefined; @@ -1478,6 +1478,7 @@ namespace FourSlash { "isVariadic", "tags", "argumentCount", + "overrideSelectedItemIndex" ]; for (const key in options) { if (!ts.contains(allKeys, key)) { diff --git a/src/harness/fourslashInterfaceImpl.ts b/src/harness/fourslashInterfaceImpl.ts index 3b6b1a9eb2c96..876a5bc37b02b 100644 --- a/src/harness/fourslashInterfaceImpl.ts +++ b/src/harness/fourslashInterfaceImpl.ts @@ -1533,6 +1533,7 @@ namespace FourSlashInterface { /** @default ts.emptyArray */ readonly tags?: readonly ts.JSDocTagInfo[]; readonly triggerReason?: ts.SignatureHelpTriggerReason; + readonly overrideSelectedItemIndex?: number; } export interface VerifyNavigateToOptions { diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 3efb65d1251c7..a1f91482309c6 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -644,6 +644,7 @@ declare namespace FourSlashInterface { isVariadic?: boolean; tags?: ReadonlyArray; triggerReason?: SignatureHelpTriggerReason; + overrideSelectedItemIndex?: number; } export type SignatureHelpTriggerReason = diff --git a/tests/cases/fourslash/signatureHelpExpandedRestUnlabeledTuples.ts b/tests/cases/fourslash/signatureHelpExpandedRestUnlabeledTuples.ts new file mode 100644 index 0000000000000..6ddd19f072829 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpExpandedRestUnlabeledTuples.ts @@ -0,0 +1,36 @@ +/// + +////export function complex(item: string, another: string, ...rest: [] | [object, (err: Error) => void] | [(err: Error) => void, ...object[]]) { +//// +////} +//// +////complex(/*1*/); +////complex("ok", "ok", /*2*/); +////complex("ok", "ok", e => void e, {}, /*3*/); + +verify.signatureHelp( + { + marker: "1", + text: "complex(item: string, another: string): void", + overloadsCount: 3, + parameterCount: 2, + parameterName: "item", + parameterSpan: "item: string", + isVariadic: false, + }, + { + marker: "2", + text: "complex(item: string, another: string, rest_0: object, rest_1: (err: Error) => void): void", + overloadsCount: 3, + parameterCount: 4, + parameterName: "rest_0", + parameterSpan: "rest_0: object", + isVariadic: false, + }, + { + marker: "3", + text: "complex(item: string, another: string, rest_0: (err: Error) => void, ...rest_1: object[]): void", + overloadsCount: 3, + isVariadic: true, + }, +); diff --git a/tests/cases/fourslash/signatureHelpExpandedTuplesArgumentIndex.ts b/tests/cases/fourslash/signatureHelpExpandedTuplesArgumentIndex.ts new file mode 100644 index 0000000000000..5c97b874c63a4 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpExpandedTuplesArgumentIndex.ts @@ -0,0 +1,94 @@ +/// + +////function foo(...args: [string, string] | [number, string, string] +////) { +//// +////} +//// +////foo(123/*1*/,) +////foo(""/*2*/, ""/*3*/) +////foo(123/*4*/, ""/*5*/, ) +////foo(123/*6*/, ""/*7*/, ""/*8*/) + +verify.signatureHelp( + { + marker: "1", + text: "foo(args_0: number, args_1: string, args_2: string): void", + overloadsCount: 2, + parameterCount: 3, + parameterName: "args_0", + parameterSpan: "args_0: number", + isVariadic: false, + overrideSelectedItemIndex: 1 + }, + { + marker: "2", + text: "foo(args_0: string, args_1: string): void", + overloadsCount: 2, + parameterCount: 2, + parameterName: "args_0", + parameterSpan: "args_0: string", + isVariadic: false, + overrideSelectedItemIndex: 0 + }, + { + marker: "3", + text: "foo(args_0: string, args_1: string): void", + overloadsCount: 2, + parameterCount: 2, + parameterName: "args_1", + parameterSpan: "args_1: string", + isVariadic: false, + overrideSelectedItemIndex: 0 + }, + { + marker: "4", + text: "foo(args_0: number, args_1: string, args_2: string): void", + overloadsCount: 2, + parameterCount: 3, + parameterName: "args_0", + parameterSpan: "args_0: number", + isVariadic: false, + overrideSelectedItemIndex: 1 + }, + { + marker: "5", + text: "foo(args_0: number, args_1: string, args_2: string): void", + overloadsCount: 2, + parameterCount: 3, + parameterName: "args_1", + parameterSpan: "args_1: string", + isVariadic: false, + overrideSelectedItemIndex: 1 + }, + { + marker: "6", + text: "foo(args_0: number, args_1: string, args_2: string): void", + overloadsCount: 2, + parameterCount: 3, + parameterName: "args_0", + parameterSpan: "args_0: number", + isVariadic: false, + overrideSelectedItemIndex: 1 + }, + { + marker: "7", + text: "foo(args_0: number, args_1: string, args_2: string): void", + overloadsCount: 2, + parameterCount: 3, + parameterName: "args_1", + parameterSpan: "args_1: string", + isVariadic: false, + overrideSelectedItemIndex: 1 + }, + { + marker: "8", + text: "foo(args_0: number, args_1: string, args_2: string): void", + overloadsCount: 2, + parameterCount: 3, + parameterName: "args_2", + parameterSpan: "args_2: string", + isVariadic: false, + overrideSelectedItemIndex: 1 + }, +); From b448540644d8c089611d50203714201322066a8c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 29 Jun 2020 15:24:32 -0700 Subject: [PATCH 10/47] No speculative inferences for variadic tuples (#39281) * No speculative inferences to types like [...T, U?] * Add tests --- src/compiler/checker.ts | 2 +- .../reference/variadicTuples1.errors.txt | 27 +++++++- tests/baselines/reference/variadicTuples1.js | 34 ++++++++++ .../reference/variadicTuples1.symbols | 63 +++++++++++++++++ .../baselines/reference/variadicTuples1.types | 68 +++++++++++++++++++ .../types/tuple/variadicTuples1.ts | 19 ++++++ 6 files changed, 211 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6ebd67e6cfde6..f702e84f735bb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18462,7 +18462,7 @@ namespace ts { } function getEndLengthOfType(type: Type) { - return isTupleType(type) ? getTypeReferenceArity(type) - findLastIndex(type.target.elementFlags, f => !!(f & ElementFlags.Variable)) - 1 : 0; + return isTupleType(type) ? getTypeReferenceArity(type) - findLastIndex(type.target.elementFlags, f => !(f & ElementFlags.Required)) - 1 : 0; } function getElementTypeOfSliceOfTupleType(type: TupleTypeReference, index: number, endSkipCount = 0, writing = false) { diff --git a/tests/baselines/reference/variadicTuples1.errors.txt b/tests/baselines/reference/variadicTuples1.errors.txt index 6ccc9daa42b4b..eac8f5ef32a5f 100644 --- a/tests/baselines/reference/variadicTuples1.errors.txt +++ b/tests/baselines/reference/variadicTuples1.errors.txt @@ -40,9 +40,11 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(191,5): error TS2322: Typ tests/cases/conformance/types/tuple/variadicTuples1.ts(203,5): error TS2322: Type 'string' is not assignable to type 'keyof [1, 2, ...T]'. Type '"2"' is not assignable to type 'number | "0" | "length" | "toString" | "toLocaleString" | "pop" | "push" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight" | "1"'. tests/cases/conformance/types/tuple/variadicTuples1.ts(333,14): error TS7019: Rest parameter 'x' implicitly has an 'any[]' type. +tests/cases/conformance/types/tuple/variadicTuples1.ts(341,19): error TS2322: Type 'string' is not assignable to type 'number | undefined'. +tests/cases/conformance/types/tuple/variadicTuples1.ts(342,19): error TS2322: Type 'string' is not assignable to type 'number | undefined'. -==== tests/cases/conformance/types/tuple/variadicTuples1.ts (19 errors) ==== +==== tests/cases/conformance/types/tuple/variadicTuples1.ts (21 errors) ==== // Variadics in tuple types type TV0 = [string, ...T]; @@ -438,4 +440,27 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(333,14): error TS7019: Re call(...sa, (...x) => 42); ~~~~ !!! error TS7019: Rest parameter 'x' implicitly has an 'any[]' type. + + // No inference to ending optional elements (except with identical structure) + + declare function f20(args: [...T, number?]): T; + + function f21(args: [...U, number?]) { + let v1 = f20(args); // U + let v2 = f20(["foo", "bar"]); // [] + ~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. + let v3 = f20(["foo", 42]); // [] + ~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. + } + + declare function f22(args: [...T, number]): T; + declare function f22(args: [...T]): T; + + function f23(args: [...U, number]) { + let v1 = f22(args); // U + let v2 = f22(["foo", "bar"]); // [string, string] + let v3 = f22(["foo", 42]); // [string] + } \ No newline at end of file diff --git a/tests/baselines/reference/variadicTuples1.js b/tests/baselines/reference/variadicTuples1.js index c1d364682952b..f7d388ea5ae86 100644 --- a/tests/baselines/reference/variadicTuples1.js +++ b/tests/baselines/reference/variadicTuples1.js @@ -332,6 +332,25 @@ call('hello', 32, (a, b) => 42); // Requires [starting-fixed-part, ...rest-part, ending-fixed-part] tuple structure call(...sa, (...x) => 42); + +// No inference to ending optional elements (except with identical structure) + +declare function f20(args: [...T, number?]): T; + +function f21(args: [...U, number?]) { + let v1 = f20(args); // U + let v2 = f20(["foo", "bar"]); // [] + let v3 = f20(["foo", 42]); // [] +} + +declare function f22(args: [...T, number]): T; +declare function f22(args: [...T]): T; + +function f23(args: [...U, number]) { + let v1 = f22(args); // U + let v2 = f22(["foo", "bar"]); // [string, string] + let v3 = f22(["foo", 42]); // [string] +} //// [variadicTuples1.js] @@ -528,6 +547,16 @@ call.apply(void 0, __spreadArrays(sa, [function () { } return 42; }])); +function f21(args) { + var v1 = f20(args); // U + var v2 = f20(["foo", "bar"]); // [] + var v3 = f20(["foo", 42]); // [] +} +function f23(args) { + var v1 = f22(args); // U + var v2 = f22(["foo", "bar"]); // [string, string] + var v3 = f22(["foo", 42]); // [string] +} //// [variadicTuples1.d.ts] @@ -669,3 +698,8 @@ declare const c22: (...b: string[]) => number; declare function curry2(f: (...args: [...T, ...U]) => R, t: [...T], u: [...U]): R; declare function fn10(a: string, b: number, c: boolean): string[]; declare function call(...args: [...T, (...args: T) => R]): [T, R]; +declare function f20(args: [...T, number?]): T; +declare function f21(args: [...U, number?]): void; +declare function f22(args: [...T, number]): T; +declare function f22(args: [...T]): T; +declare function f23(args: [...U, number]): void; diff --git a/tests/baselines/reference/variadicTuples1.symbols b/tests/baselines/reference/variadicTuples1.symbols index fe83d5f0bd7cc..0f6c900fb6cdf 100644 --- a/tests/baselines/reference/variadicTuples1.symbols +++ b/tests/baselines/reference/variadicTuples1.symbols @@ -1141,3 +1141,66 @@ call(...sa, (...x) => 42); >sa : Symbol(sa, Decl(variadicTuples1.ts, 29, 13)) >x : Symbol(x, Decl(variadicTuples1.ts, 332, 13)) +// No inference to ending optional elements (except with identical structure) + +declare function f20(args: [...T, number?]): T; +>f20 : Symbol(f20, Decl(variadicTuples1.ts, 332, 26)) +>T : Symbol(T, Decl(variadicTuples1.ts, 336, 21)) +>args : Symbol(args, Decl(variadicTuples1.ts, 336, 47)) +>T : Symbol(T, Decl(variadicTuples1.ts, 336, 21)) +>T : Symbol(T, Decl(variadicTuples1.ts, 336, 21)) + +function f21(args: [...U, number?]) { +>f21 : Symbol(f21, Decl(variadicTuples1.ts, 336, 73)) +>U : Symbol(U, Decl(variadicTuples1.ts, 338, 13)) +>args : Symbol(args, Decl(variadicTuples1.ts, 338, 33)) +>U : Symbol(U, Decl(variadicTuples1.ts, 338, 13)) + + let v1 = f20(args); // U +>v1 : Symbol(v1, Decl(variadicTuples1.ts, 339, 7)) +>f20 : Symbol(f20, Decl(variadicTuples1.ts, 332, 26)) +>args : Symbol(args, Decl(variadicTuples1.ts, 338, 33)) + + let v2 = f20(["foo", "bar"]); // [] +>v2 : Symbol(v2, Decl(variadicTuples1.ts, 340, 7)) +>f20 : Symbol(f20, Decl(variadicTuples1.ts, 332, 26)) + + let v3 = f20(["foo", 42]); // [] +>v3 : Symbol(v3, Decl(variadicTuples1.ts, 341, 7)) +>f20 : Symbol(f20, Decl(variadicTuples1.ts, 332, 26)) +} + +declare function f22(args: [...T, number]): T; +>f22 : Symbol(f22, Decl(variadicTuples1.ts, 342, 1), Decl(variadicTuples1.ts, 344, 72)) +>T : Symbol(T, Decl(variadicTuples1.ts, 344, 21)) +>args : Symbol(args, Decl(variadicTuples1.ts, 344, 47)) +>T : Symbol(T, Decl(variadicTuples1.ts, 344, 21)) +>T : Symbol(T, Decl(variadicTuples1.ts, 344, 21)) + +declare function f22(args: [...T]): T; +>f22 : Symbol(f22, Decl(variadicTuples1.ts, 342, 1), Decl(variadicTuples1.ts, 344, 72)) +>T : Symbol(T, Decl(variadicTuples1.ts, 345, 21)) +>args : Symbol(args, Decl(variadicTuples1.ts, 345, 47)) +>T : Symbol(T, Decl(variadicTuples1.ts, 345, 21)) +>T : Symbol(T, Decl(variadicTuples1.ts, 345, 21)) + +function f23(args: [...U, number]) { +>f23 : Symbol(f23, Decl(variadicTuples1.ts, 345, 64)) +>U : Symbol(U, Decl(variadicTuples1.ts, 347, 13)) +>args : Symbol(args, Decl(variadicTuples1.ts, 347, 33)) +>U : Symbol(U, Decl(variadicTuples1.ts, 347, 13)) + + let v1 = f22(args); // U +>v1 : Symbol(v1, Decl(variadicTuples1.ts, 348, 7)) +>f22 : Symbol(f22, Decl(variadicTuples1.ts, 342, 1), Decl(variadicTuples1.ts, 344, 72)) +>args : Symbol(args, Decl(variadicTuples1.ts, 347, 33)) + + let v2 = f22(["foo", "bar"]); // [string, string] +>v2 : Symbol(v2, Decl(variadicTuples1.ts, 349, 7)) +>f22 : Symbol(f22, Decl(variadicTuples1.ts, 342, 1), Decl(variadicTuples1.ts, 344, 72)) + + let v3 = f22(["foo", 42]); // [string] +>v3 : Symbol(v3, Decl(variadicTuples1.ts, 350, 7)) +>f22 : Symbol(f22, Decl(variadicTuples1.ts, 342, 1), Decl(variadicTuples1.ts, 344, 72)) +} + diff --git a/tests/baselines/reference/variadicTuples1.types b/tests/baselines/reference/variadicTuples1.types index 9c78c1f88ac89..0c24e873ef8b5 100644 --- a/tests/baselines/reference/variadicTuples1.types +++ b/tests/baselines/reference/variadicTuples1.types @@ -1186,3 +1186,71 @@ call(...sa, (...x) => 42); >x : any[] >42 : 42 +// No inference to ending optional elements (except with identical structure) + +declare function f20(args: [...T, number?]): T; +>f20 : (args: [...T, number?]) => T +>args : [...T, (number | undefined)?] + +function f21(args: [...U, number?]) { +>f21 : (args: [...U, number?]) => void +>args : [...U, (number | undefined)?] + + let v1 = f20(args); // U +>v1 : U +>f20(args) : U +>f20 : (args: [...T, (number | undefined)?]) => T +>args : [...U, (number | undefined)?] + + let v2 = f20(["foo", "bar"]); // [] +>v2 : [] +>f20(["foo", "bar"]) : [] +>f20 : (args: [...T, (number | undefined)?]) => T +>["foo", "bar"] : [string, string] +>"foo" : "foo" +>"bar" : "bar" + + let v3 = f20(["foo", 42]); // [] +>v3 : [] +>f20(["foo", 42]) : [] +>f20 : (args: [...T, (number | undefined)?]) => T +>["foo", 42] : [string, number] +>"foo" : "foo" +>42 : 42 +} + +declare function f22(args: [...T, number]): T; +>f22 : { (args: [...T, number]): T; (args: [...T]): T; } +>args : [...T, number] + +declare function f22(args: [...T]): T; +>f22 : { (args: [...T, number]): T; (args: [...T]): T; } +>args : [...T] + +function f23(args: [...U, number]) { +>f23 : (args: [...U, number]) => void +>args : [...U, number] + + let v1 = f22(args); // U +>v1 : U +>f22(args) : U +>f22 : { (args: [...T, number]): T; (args: [...T]): T; } +>args : [...U, number] + + let v2 = f22(["foo", "bar"]); // [string, string] +>v2 : [string, string] +>f22(["foo", "bar"]) : [string, string] +>f22 : { (args: [...T, number]): T; (args: [...T]): T; } +>["foo", "bar"] : [string, string] +>"foo" : "foo" +>"bar" : "bar" + + let v3 = f22(["foo", 42]); // [string] +>v3 : [string] +>f22(["foo", 42]) : [string] +>f22 : { (args: [...T, number]): T; (args: [...T]): T; } +>["foo", 42] : [string, number] +>"foo" : "foo" +>42 : 42 +} + diff --git a/tests/cases/conformance/types/tuple/variadicTuples1.ts b/tests/cases/conformance/types/tuple/variadicTuples1.ts index 036c65469c32f..07732a0a5a726 100644 --- a/tests/cases/conformance/types/tuple/variadicTuples1.ts +++ b/tests/cases/conformance/types/tuple/variadicTuples1.ts @@ -334,3 +334,22 @@ call('hello', 32, (a, b) => 42); // Requires [starting-fixed-part, ...rest-part, ending-fixed-part] tuple structure call(...sa, (...x) => 42); + +// No inference to ending optional elements (except with identical structure) + +declare function f20(args: [...T, number?]): T; + +function f21(args: [...U, number?]) { + let v1 = f20(args); // U + let v2 = f20(["foo", "bar"]); // [] + let v3 = f20(["foo", 42]); // [] +} + +declare function f22(args: [...T, number]): T; +declare function f22(args: [...T]): T; + +function f23(args: [...U, number]) { + let v1 = f22(args); // U + let v2 = f22(["foo", "bar"]); // [string, string] + let v3 = f22(["foo", 42]); // [string] +} From 9458f8acabedd00b034d0bc25da0121b3885a89b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 29 Jun 2020 15:25:00 -0700 Subject: [PATCH 11/47] Consistent narrowing to 'never' in conditional and switch statements (#39191) * Allow unions and unit types to narrow to 'never' * Remove odd check for TypeFlags.NotUnionOrUnit * Accept new baselines * Accept new API baselines --- src/compiler/checker.ts | 12 +++-------- src/compiler/types.ts | 1 - .../reference/api/tsserverlibrary.d.ts | 1 - tests/baselines/reference/api/typescript.d.ts | 1 - .../reference/discriminatedUnionTypes1.types | 2 +- ...equalityWithIntersectionTypes01.errors.txt | 17 +--------------- .../equalityWithIntersectionTypes01.types | 20 +++++++++---------- 7 files changed, 15 insertions(+), 39 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f702e84f735bb..3ad58313c4cc8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20580,7 +20580,7 @@ namespace ts { } function createFlowType(type: Type, incomplete: boolean): FlowType { - return incomplete ? { flags: 0, type } : type; + return incomplete ? { flags: 0, type: type.flags & TypeFlags.Never ? silentNeverType : type } : type; } // An evolving array type tracks the element types that have so far been seen in an @@ -21168,9 +21168,7 @@ namespace ts { if (narrowedType === nonEvolvingType) { return flowType; } - const incomplete = isIncomplete(flowType); - const resultType = incomplete && narrowedType.flags & TypeFlags.Never ? silentNeverType : narrowedType; - return createFlowType(resultType, incomplete); + return createFlowType(narrowedType, isIncomplete(flowType)); } function getTypeAtSwitchClause(flow: FlowSwitchClause): FlowType { @@ -21508,15 +21506,11 @@ namespace ts { assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined; return getTypeWithFacts(type, facts); } - if (type.flags & TypeFlags.NotUnionOrUnit) { - return type; - } if (assumeTrue) { const filterFn: (t: Type) => boolean = operator === SyntaxKind.EqualsEqualsToken ? (t => areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType)) : t => areTypesComparable(t, valueType); - const narrowedType = filterType(type, filterFn); - return narrowedType.flags & TypeFlags.Never ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); } if (isUnitType(valueType)) { const regularType = getRegularTypeOfLiteralType(valueType); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 05ad94c7599f1..ce1162933e4e5 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4861,7 +4861,6 @@ namespace ts { // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never Narrowable = Any | Unknown | StructuredOrInstantiable | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive, - NotUnionOrUnit = Any | Unknown | ESSymbol | Object | NonPrimitive, /* @internal */ NotPrimitiveUnion = Any | Unknown | Enum | Void | Never | StructuredOrInstantiable, // The following flags are aggregated during union and intersection type construction diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 72100cfc28940..e19dcd382c20d 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2459,7 +2459,6 @@ declare namespace ts { Instantiable = 63176704, StructuredOrInstantiable = 66846720, Narrowable = 133970943, - NotUnionOrUnit = 67637251, } export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; export interface Type { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 8ed116b6b1d38..aa014fb458411 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2459,7 +2459,6 @@ declare namespace ts { Instantiable = 63176704, StructuredOrInstantiable = 66846720, Narrowable = 133970943, - NotUnionOrUnit = 67637251, } export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; export interface Type { diff --git a/tests/baselines/reference/discriminatedUnionTypes1.types b/tests/baselines/reference/discriminatedUnionTypes1.types index 462d8a23432b4..7c8c6c48171ba 100644 --- a/tests/baselines/reference/discriminatedUnionTypes1.types +++ b/tests/baselines/reference/discriminatedUnionTypes1.types @@ -320,7 +320,7 @@ function f3(m: Message) { >"X" : "X" m; // never ->m : Message +>m : never } } diff --git a/tests/baselines/reference/equalityWithIntersectionTypes01.errors.txt b/tests/baselines/reference/equalityWithIntersectionTypes01.errors.txt index d9cbc5c767d09..243c85819f57d 100644 --- a/tests/baselines/reference/equalityWithIntersectionTypes01.errors.txt +++ b/tests/baselines/reference/equalityWithIntersectionTypes01.errors.txt @@ -1,14 +1,9 @@ tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(17,5): error TS2367: This condition will always return 'false' since the types 'I1 & I3' and 'I2' have no overlap. tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(17,16): error TS2367: This condition will always return 'false' since the types 'I2' and 'I1 & I3' have no overlap. tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(19,10): error TS2367: This condition will always return 'true' since the types 'I1 & I3' and 'I2' have no overlap. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(19,21): error TS2367: This condition will always return 'true' since the types 'I2' and 'I1 & I3' have no overlap. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(21,10): error TS2367: This condition will always return 'false' since the types 'I1 & I3' and 'I2' have no overlap. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(21,20): error TS2367: This condition will always return 'false' since the types 'I2' and 'I1 & I3' have no overlap. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(23,10): error TS2367: This condition will always return 'true' since the types 'I1 & I3' and 'I2' have no overlap. -tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts(23,20): error TS2367: This condition will always return 'true' since the types 'I2' and 'I1 & I3' have no overlap. -==== tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts (8 errors) ==== +==== tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersectionTypes01.ts (3 errors) ==== interface I1 { p1: number } @@ -34,18 +29,8 @@ tests/cases/conformance/types/typeRelationships/comparable/equalityWithIntersect else if (y !== z || z !== y) { ~~~~~~~ !!! error TS2367: This condition will always return 'true' since the types 'I1 & I3' and 'I2' have no overlap. - ~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'I2' and 'I1 & I3' have no overlap. } else if (y == z || z == y) { - ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'I1 & I3' and 'I2' have no overlap. - ~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'I2' and 'I1 & I3' have no overlap. } else if (y != z || z != y) { - ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'I1 & I3' and 'I2' have no overlap. - ~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'I2' and 'I1 & I3' have no overlap. } \ No newline at end of file diff --git a/tests/baselines/reference/equalityWithIntersectionTypes01.types b/tests/baselines/reference/equalityWithIntersectionTypes01.types index e2d3f98618342..4736f662ca50e 100644 --- a/tests/baselines/reference/equalityWithIntersectionTypes01.types +++ b/tests/baselines/reference/equalityWithIntersectionTypes01.types @@ -47,24 +47,24 @@ else if (y !== z || z !== y) { >y : I1 & I3 >z : I2 >z !== y : boolean ->z : I2 ->y : I1 & I3 +>z : never +>y : never } else if (y == z || z == y) { >y == z || z == y : boolean >y == z : boolean ->y : I1 & I3 ->z : I2 +>y : never +>z : never >z == y : boolean ->z : I2 ->y : I1 & I3 +>z : never +>y : never } else if (y != z || z != y) { >y != z || z != y : boolean >y != z : boolean ->y : I1 & I3 ->z : I2 +>y : never +>z : never >z != y : boolean ->z : I2 ->y : I1 & I3 +>z : never +>y : never } From 126a95b37c3d81f8a600ddf50fb33c289674f696 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Mon, 29 Jun 2020 15:45:33 -0700 Subject: [PATCH 12/47] Delete lib/diagnosticMessages.generated.json The values are baked in - only the localized json files are needed in the LKG. --- lib/diagnosticMessages.generated.json | 1047 ------------------------- 1 file changed, 1047 deletions(-) delete mode 100644 lib/diagnosticMessages.generated.json diff --git a/lib/diagnosticMessages.generated.json b/lib/diagnosticMessages.generated.json deleted file mode 100644 index 7bb74d31a4ee2..0000000000000 --- a/lib/diagnosticMessages.generated.json +++ /dev/null @@ -1,1047 +0,0 @@ -{ - "Unterminated_string_literal_1002" : "Unterminated string literal.", - "Identifier_expected_1003" : "Identifier expected.", - "_0_expected_1005" : "'{0}' expected.", - "A_file_cannot_have_a_reference_to_itself_1006" : "A file cannot have a reference to itself.", - "Trailing_comma_not_allowed_1009" : "Trailing comma not allowed.", - "Asterisk_Slash_expected_1010" : "'*/' expected.", - "An_element_access_expression_should_take_an_argument_1011" : "An element access expression should take an argument.", - "Unexpected_token_1012" : "Unexpected token.", - "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013" : "A rest parameter or binding pattern may not have a trailing comma.", - "A_rest_parameter_must_be_last_in_a_parameter_list_1014" : "A rest parameter must be last in a parameter list.", - "Parameter_cannot_have_question_mark_and_initializer_1015" : "Parameter cannot have question mark and initializer.", - "A_required_parameter_cannot_follow_an_optional_parameter_1016" : "A required parameter cannot follow an optional parameter.", - "An_index_signature_cannot_have_a_rest_parameter_1017" : "An index signature cannot have a rest parameter.", - "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018" : "An index signature parameter cannot have an accessibility modifier.", - "An_index_signature_parameter_cannot_have_a_question_mark_1019" : "An index signature parameter cannot have a question mark.", - "An_index_signature_parameter_cannot_have_an_initializer_1020" : "An index signature parameter cannot have an initializer.", - "An_index_signature_must_have_a_type_annotation_1021" : "An index signature must have a type annotation.", - "An_index_signature_parameter_must_have_a_type_annotation_1022" : "An index signature parameter must have a type annotation.", - "An_index_signature_parameter_type_must_be_string_or_number_1023" : "An index signature parameter type must be 'string' or 'number'.", - "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024" : "'readonly' modifier can only appear on a property declaration or index signature.", - "Accessibility_modifier_already_seen_1028" : "Accessibility modifier already seen.", - "_0_modifier_must_precede_1_modifier_1029" : "'{0}' modifier must precede '{1}' modifier.", - "_0_modifier_already_seen_1030" : "'{0}' modifier already seen.", - "_0_modifier_cannot_appear_on_a_class_element_1031" : "'{0}' modifier cannot appear on a class element.", - "super_must_be_followed_by_an_argument_list_or_member_access_1034" : "'super' must be followed by an argument list or member access.", - "Only_ambient_modules_can_use_quoted_names_1035" : "Only ambient modules can use quoted names.", - "Statements_are_not_allowed_in_ambient_contexts_1036" : "Statements are not allowed in ambient contexts.", - "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038" : "A 'declare' modifier cannot be used in an already ambient context.", - "Initializers_are_not_allowed_in_ambient_contexts_1039" : "Initializers are not allowed in ambient contexts.", - "_0_modifier_cannot_be_used_in_an_ambient_context_1040" : "'{0}' modifier cannot be used in an ambient context.", - "_0_modifier_cannot_be_used_with_a_class_declaration_1041" : "'{0}' modifier cannot be used with a class declaration.", - "_0_modifier_cannot_be_used_here_1042" : "'{0}' modifier cannot be used here.", - "_0_modifier_cannot_appear_on_a_data_property_1043" : "'{0}' modifier cannot appear on a data property.", - "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044" : "'{0}' modifier cannot appear on a module or namespace element.", - "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045" : "A '{0}' modifier cannot be used with an interface declaration.", - "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046" : "A 'declare' modifier is required for a top level declaration in a .d.ts file.", - "A_rest_parameter_cannot_be_optional_1047" : "A rest parameter cannot be optional.", - "A_rest_parameter_cannot_have_an_initializer_1048" : "A rest parameter cannot have an initializer.", - "A_set_accessor_must_have_exactly_one_parameter_1049" : "A 'set' accessor must have exactly one parameter.", - "A_set_accessor_cannot_have_an_optional_parameter_1051" : "A 'set' accessor cannot have an optional parameter.", - "A_set_accessor_parameter_cannot_have_an_initializer_1052" : "A 'set' accessor parameter cannot have an initializer.", - "A_set_accessor_cannot_have_rest_parameter_1053" : "A 'set' accessor cannot have rest parameter.", - "A_get_accessor_cannot_have_parameters_1054" : "A 'get' accessor cannot have parameters.", - "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055" : "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.", - "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056" : "Accessors are only available when targeting ECMAScript 5 and higher.", - "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057" : "An async function or method must have a valid awaitable return type.", - "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058" : "The return type of an async function must either be a valid promise or must not contain a callable 'then' member.", - "A_promise_must_have_a_then_method_1059" : "A promise must have a 'then' method.", - "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060" : "The first parameter of the 'then' method of a promise must be a callback.", - "Enum_member_must_have_initializer_1061" : "Enum member must have initializer.", - "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062" : "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method.", - "An_export_assignment_cannot_be_used_in_a_namespace_1063" : "An export assignment cannot be used in a namespace.", - "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064" : "The return type of an async function or method must be the global Promise type.", - "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066" : "In ambient enum declarations member initializer must be constant expression.", - "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068" : "Unexpected token. A constructor, method, accessor, or property was expected.", - "_0_modifier_cannot_appear_on_a_type_member_1070" : "'{0}' modifier cannot appear on a type member.", - "_0_modifier_cannot_appear_on_an_index_signature_1071" : "'{0}' modifier cannot appear on an index signature.", - "A_0_modifier_cannot_be_used_with_an_import_declaration_1079" : "A '{0}' modifier cannot be used with an import declaration.", - "Invalid_reference_directive_syntax_1084" : "Invalid 'reference' directive syntax.", - "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085" : "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'.", - "An_accessor_cannot_be_declared_in_an_ambient_context_1086" : "An accessor cannot be declared in an ambient context.", - "_0_modifier_cannot_appear_on_a_constructor_declaration_1089" : "'{0}' modifier cannot appear on a constructor declaration.", - "_0_modifier_cannot_appear_on_a_parameter_1090" : "'{0}' modifier cannot appear on a parameter.", - "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091" : "Only a single variable declaration is allowed in a 'for...in' statement.", - "Type_parameters_cannot_appear_on_a_constructor_declaration_1092" : "Type parameters cannot appear on a constructor declaration.", - "Type_annotation_cannot_appear_on_a_constructor_declaration_1093" : "Type annotation cannot appear on a constructor declaration.", - "An_accessor_cannot_have_type_parameters_1094" : "An accessor cannot have type parameters.", - "A_set_accessor_cannot_have_a_return_type_annotation_1095" : "A 'set' accessor cannot have a return type annotation.", - "An_index_signature_must_have_exactly_one_parameter_1096" : "An index signature must have exactly one parameter.", - "_0_list_cannot_be_empty_1097" : "'{0}' list cannot be empty.", - "Type_parameter_list_cannot_be_empty_1098" : "Type parameter list cannot be empty.", - "Type_argument_list_cannot_be_empty_1099" : "Type argument list cannot be empty.", - "Invalid_use_of_0_in_strict_mode_1100" : "Invalid use of '{0}' in strict mode.", - "with_statements_are_not_allowed_in_strict_mode_1101" : "'with' statements are not allowed in strict mode.", - "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102" : "'delete' cannot be called on an identifier in strict mode.", - "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103" : "A 'for-await-of' statement is only allowed within an async function or async generator.", - "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104" : "A 'continue' statement can only be used within an enclosing iteration statement.", - "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105" : "A 'break' statement can only be used within an enclosing iteration or switch statement.", - "Jump_target_cannot_cross_function_boundary_1107" : "Jump target cannot cross function boundary.", - "A_return_statement_can_only_be_used_within_a_function_body_1108" : "A 'return' statement can only be used within a function body.", - "Expression_expected_1109" : "Expression expected.", - "Type_expected_1110" : "Type expected.", - "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113" : "A 'default' clause cannot appear more than once in a 'switch' statement.", - "Duplicate_label_0_1114" : "Duplicate label '{0}'.", - "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115" : "A 'continue' statement can only jump to a label of an enclosing iteration statement.", - "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116" : "A 'break' statement can only jump to a label of an enclosing statement.", - "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117" : "An object literal cannot have multiple properties with the same name in strict mode.", - "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118" : "An object literal cannot have multiple get/set accessors with the same name.", - "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119" : "An object literal cannot have property and accessor with the same name.", - "An_export_assignment_cannot_have_modifiers_1120" : "An export assignment cannot have modifiers.", - "Octal_literals_are_not_allowed_in_strict_mode_1121" : "Octal literals are not allowed in strict mode.", - "A_tuple_type_element_list_cannot_be_empty_1122" : "A tuple type element list cannot be empty.", - "Variable_declaration_list_cannot_be_empty_1123" : "Variable declaration list cannot be empty.", - "Digit_expected_1124" : "Digit expected.", - "Hexadecimal_digit_expected_1125" : "Hexadecimal digit expected.", - "Unexpected_end_of_text_1126" : "Unexpected end of text.", - "Invalid_character_1127" : "Invalid character.", - "Declaration_or_statement_expected_1128" : "Declaration or statement expected.", - "Statement_expected_1129" : "Statement expected.", - "case_or_default_expected_1130" : "'case' or 'default' expected.", - "Property_or_signature_expected_1131" : "Property or signature expected.", - "Enum_member_expected_1132" : "Enum member expected.", - "Variable_declaration_expected_1134" : "Variable declaration expected.", - "Argument_expression_expected_1135" : "Argument expression expected.", - "Property_assignment_expected_1136" : "Property assignment expected.", - "Expression_or_comma_expected_1137" : "Expression or comma expected.", - "Parameter_declaration_expected_1138" : "Parameter declaration expected.", - "Type_parameter_declaration_expected_1139" : "Type parameter declaration expected.", - "Type_argument_expected_1140" : "Type argument expected.", - "String_literal_expected_1141" : "String literal expected.", - "Line_break_not_permitted_here_1142" : "Line break not permitted here.", - "or_expected_1144" : "'{' or ';' expected.", - "Declaration_expected_1146" : "Declaration expected.", - "Import_declarations_in_a_namespace_cannot_reference_a_module_1147" : "Import declarations in a namespace cannot reference a module.", - "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148" : "Cannot use imports, exports, or module augmentations when '--module' is 'none'.", - "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149" : "File name '{0}' differs from already included file name '{1}' only in casing.", - "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150" : "'new T[]' cannot be used to create an array. Use 'new Array()' instead.", - "const_declarations_must_be_initialized_1155" : "'const' declarations must be initialized.", - "const_declarations_can_only_be_declared_inside_a_block_1156" : "'const' declarations can only be declared inside a block.", - "let_declarations_can_only_be_declared_inside_a_block_1157" : "'let' declarations can only be declared inside a block.", - "Unterminated_template_literal_1160" : "Unterminated template literal.", - "Unterminated_regular_expression_literal_1161" : "Unterminated regular expression literal.", - "An_object_member_cannot_be_declared_optional_1162" : "An object member cannot be declared optional.", - "A_yield_expression_is_only_allowed_in_a_generator_body_1163" : "A 'yield' expression is only allowed in a generator body.", - "Computed_property_names_are_not_allowed_in_enums_1164" : "Computed property names are not allowed in enums.", - "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165" : "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type.", - "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166" : "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type.", - "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168" : "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type.", - "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169" : "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.", - "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170" : "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.", - "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171" : "A comma expression is not allowed in a computed property name.", - "extends_clause_already_seen_1172" : "'extends' clause already seen.", - "extends_clause_must_precede_implements_clause_1173" : "'extends' clause must precede 'implements' clause.", - "Classes_can_only_extend_a_single_class_1174" : "Classes can only extend a single class.", - "implements_clause_already_seen_1175" : "'implements' clause already seen.", - "Interface_declaration_cannot_have_implements_clause_1176" : "Interface declaration cannot have 'implements' clause.", - "Binary_digit_expected_1177" : "Binary digit expected.", - "Octal_digit_expected_1178" : "Octal digit expected.", - "Unexpected_token_expected_1179" : "Unexpected token. '{' expected.", - "Property_destructuring_pattern_expected_1180" : "Property destructuring pattern expected.", - "Array_element_destructuring_pattern_expected_1181" : "Array element destructuring pattern expected.", - "A_destructuring_declaration_must_have_an_initializer_1182" : "A destructuring declaration must have an initializer.", - "An_implementation_cannot_be_declared_in_ambient_contexts_1183" : "An implementation cannot be declared in ambient contexts.", - "Modifiers_cannot_appear_here_1184" : "Modifiers cannot appear here.", - "Merge_conflict_marker_encountered_1185" : "Merge conflict marker encountered.", - "A_rest_element_cannot_have_an_initializer_1186" : "A rest element cannot have an initializer.", - "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187" : "A parameter property may not be declared using a binding pattern.", - "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188" : "Only a single variable declaration is allowed in a 'for...of' statement.", - "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189" : "The variable declaration of a 'for...in' statement cannot have an initializer.", - "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190" : "The variable declaration of a 'for...of' statement cannot have an initializer.", - "An_import_declaration_cannot_have_modifiers_1191" : "An import declaration cannot have modifiers.", - "Module_0_has_no_default_export_1192" : "Module '{0}' has no default export.", - "An_export_declaration_cannot_have_modifiers_1193" : "An export declaration cannot have modifiers.", - "Export_declarations_are_not_permitted_in_a_namespace_1194" : "Export declarations are not permitted in a namespace.", - "Catch_clause_variable_cannot_have_a_type_annotation_1196" : "Catch clause variable cannot have a type annotation.", - "Catch_clause_variable_cannot_have_an_initializer_1197" : "Catch clause variable cannot have an initializer.", - "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198" : "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive.", - "Unterminated_Unicode_escape_sequence_1199" : "Unterminated Unicode escape sequence.", - "Line_terminator_not_permitted_before_arrow_1200" : "Line terminator not permitted before arrow.", - "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202" : "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.", - "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203" : "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.", - "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205" : "Cannot re-export a type when the '--isolatedModules' flag is provided.", - "Decorators_are_not_valid_here_1206" : "Decorators are not valid here.", - "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207" : "Decorators cannot be applied to multiple get/set accessors of the same name.", - "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208" : "Cannot compile namespaces when the '--isolatedModules' flag is provided.", - "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209" : "Ambient const enums are not allowed when the '--isolatedModules' flag is provided.", - "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210" : "Invalid use of '{0}'. Class definitions are automatically in strict mode.", - "A_class_declaration_without_the_default_modifier_must_have_a_name_1211" : "A class declaration without the 'default' modifier must have a name.", - "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212" : "Identifier expected. '{0}' is a reserved word in strict mode.", - "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213" : "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode.", - "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214" : "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode.", - "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215" : "Invalid use of '{0}'. Modules are automatically in strict mode.", - "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216" : "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules.", - "Export_assignment_is_not_supported_when_module_flag_is_system_1218" : "Export assignment is not supported when '--module' flag is 'system'.", - "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219" : "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.", - "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220" : "Generators are only available when targeting ECMAScript 2015 or higher.", - "Generators_are_not_allowed_in_an_ambient_context_1221" : "Generators are not allowed in an ambient context.", - "An_overload_signature_cannot_be_declared_as_a_generator_1222" : "An overload signature cannot be declared as a generator.", - "_0_tag_already_specified_1223" : "'{0}' tag already specified.", - "Signature_0_must_be_a_type_predicate_1224" : "Signature '{0}' must be a type predicate.", - "Cannot_find_parameter_0_1225" : "Cannot find parameter '{0}'.", - "Type_predicate_0_is_not_assignable_to_1_1226" : "Type predicate '{0}' is not assignable to '{1}'.", - "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227" : "Parameter '{0}' is not in the same position as parameter '{1}'.", - "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228" : "A type predicate is only allowed in return type position for functions and methods.", - "A_type_predicate_cannot_reference_a_rest_parameter_1229" : "A type predicate cannot reference a rest parameter.", - "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230" : "A type predicate cannot reference element '{0}' in a binding pattern.", - "An_export_assignment_can_only_be_used_in_a_module_1231" : "An export assignment can only be used in a module.", - "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232" : "An import declaration can only be used in a namespace or module.", - "An_export_declaration_can_only_be_used_in_a_module_1233" : "An export declaration can only be used in a module.", - "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234" : "An ambient module declaration is only allowed at the top level in a file.", - "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235" : "A namespace declaration is only allowed in a namespace or module.", - "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236" : "The return type of a property decorator function must be either 'void' or 'any'.", - "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237" : "The return type of a parameter decorator function must be either 'void' or 'any'.", - "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238" : "Unable to resolve signature of class decorator when called as an expression.", - "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239" : "Unable to resolve signature of parameter decorator when called as an expression.", - "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240" : "Unable to resolve signature of property decorator when called as an expression.", - "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241" : "Unable to resolve signature of method decorator when called as an expression.", - "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242" : "'abstract' modifier can only appear on a class, method, or property declaration.", - "_0_modifier_cannot_be_used_with_1_modifier_1243" : "'{0}' modifier cannot be used with '{1}' modifier.", - "Abstract_methods_can_only_appear_within_an_abstract_class_1244" : "Abstract methods can only appear within an abstract class.", - "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245" : "Method '{0}' cannot have an implementation because it is marked abstract.", - "An_interface_property_cannot_have_an_initializer_1246" : "An interface property cannot have an initializer.", - "A_type_literal_property_cannot_have_an_initializer_1247" : "A type literal property cannot have an initializer.", - "A_class_member_cannot_have_the_0_keyword_1248" : "A class member cannot have the '{0}' keyword.", - "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249" : "A decorator can only decorate a method implementation, not an overload.", - "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250" : "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'.", - "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251" : "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode.", - "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252" : "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode.", - "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253" : "'{0}' tag cannot be used independently as a top level JSDoc tag.", - "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_1254" : "A 'const' initializer in an ambient context must be a string or numeric literal.", - "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255" : "A definite assignment assertion '!' is not permitted in this context.", - "with_statements_are_not_allowed_in_an_async_function_block_1300" : "'with' statements are not allowed in an async function block.", - "await_expression_is_only_allowed_within_an_async_function_1308" : "'await' expression is only allowed within an async function.", - "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" : "'=' can only be used in an object literal property inside a destructuring assignment.", - "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313" : "The body of an 'if' statement cannot be the empty statement.", - "Global_module_exports_may_only_appear_in_module_files_1314" : "Global module exports may only appear in module files.", - "Global_module_exports_may_only_appear_in_declaration_files_1315" : "Global module exports may only appear in declaration files.", - "Global_module_exports_may_only_appear_at_top_level_1316" : "Global module exports may only appear at top level.", - "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317" : "A parameter property cannot be declared using a rest parameter.", - "An_abstract_accessor_cannot_have_an_implementation_1318" : "An abstract accessor cannot have an implementation.", - "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319" : "A default export can only be used in an ECMAScript-style module.", - "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320" : "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member.", - "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321" : "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member.", - "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322" : "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member.", - "Dynamic_import_cannot_be_used_when_targeting_ECMAScript_2015_modules_1323" : "Dynamic import cannot be used when targeting ECMAScript 2015 modules.", - "Dynamic_import_must_have_one_specifier_as_an_argument_1324" : "Dynamic import must have one specifier as an argument.", - "Specifier_of_dynamic_import_cannot_be_spread_element_1325" : "Specifier of dynamic import cannot be spread element.", - "Dynamic_import_cannot_have_type_arguments_1326" : "Dynamic import cannot have type arguments", - "String_literal_with_double_quotes_expected_1327" : "String literal with double quotes expected.", - "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328" : "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal.", - "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329" : "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?", - "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330" : "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'.", - "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331" : "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'.", - "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332" : "A variable whose type is a 'unique symbol' type must be 'const'.", - "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333" : "'unique symbol' types may not be used on a variable declaration with a binding name.", - "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334" : "'unique symbol' types are only allowed on variables in a variable statement.", - "unique_symbol_types_are_not_allowed_here_1335" : "'unique symbol' types are not allowed here.", - "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336" : "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead.", - "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337" : "An index signature parameter type cannot be a union type. Consider using a mapped object type instead.", - "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338" : "'infer' declarations are only permitted in the 'extends' clause of a conditional type.", - "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339" : "Module '{0}' does not refer to a value, but is used as a value here.", - "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340" : "Module '{0}' does not refer to a type, but is used as a type here.", - "Type_arguments_cannot_be_used_here_1342" : "Type arguments cannot be used here.", - "The_import_meta_meta_property_is_only_allowed_using_ESNext_for_the_target_and_module_compiler_option_1343" : "The 'import.meta' meta-property is only allowed using 'ESNext' for the 'target' and 'module' compiler options.", - "Duplicate_identifier_0_2300" : "Duplicate identifier '{0}'.", - "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301" : "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor.", - "Static_members_cannot_reference_class_type_parameters_2302" : "Static members cannot reference class type parameters.", - "Circular_definition_of_import_alias_0_2303" : "Circular definition of import alias '{0}'.", - "Cannot_find_name_0_2304" : "Cannot find name '{0}'.", - "Module_0_has_no_exported_member_1_2305" : "Module '{0}' has no exported member '{1}'.", - "File_0_is_not_a_module_2306" : "File '{0}' is not a module.", - "Cannot_find_module_0_2307" : "Cannot find module '{0}'.", - "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308" : "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity.", - "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309" : "An export assignment cannot be used in a module with other exported elements.", - "Type_0_recursively_references_itself_as_a_base_type_2310" : "Type '{0}' recursively references itself as a base type.", - "A_class_may_only_extend_another_class_2311" : "A class may only extend another class.", - "An_interface_may_only_extend_a_class_or_another_interface_2312" : "An interface may only extend a class or another interface.", - "Type_parameter_0_has_a_circular_constraint_2313" : "Type parameter '{0}' has a circular constraint.", - "Generic_type_0_requires_1_type_argument_s_2314" : "Generic type '{0}' requires {1} type argument(s).", - "Type_0_is_not_generic_2315" : "Type '{0}' is not generic.", - "Global_type_0_must_be_a_class_or_interface_type_2316" : "Global type '{0}' must be a class or interface type.", - "Global_type_0_must_have_1_type_parameter_s_2317" : "Global type '{0}' must have {1} type parameter(s).", - "Cannot_find_global_type_0_2318" : "Cannot find global type '{0}'.", - "Named_property_0_of_types_1_and_2_are_not_identical_2319" : "Named property '{0}' of types '{1}' and '{2}' are not identical.", - "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320" : "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'.", - "Excessive_stack_depth_comparing_types_0_and_1_2321" : "Excessive stack depth comparing types '{0}' and '{1}'.", - "Type_0_is_not_assignable_to_type_1_2322" : "Type '{0}' is not assignable to type '{1}'.", - "Cannot_redeclare_exported_variable_0_2323" : "Cannot redeclare exported variable '{0}'.", - "Property_0_is_missing_in_type_1_2324" : "Property '{0}' is missing in type '{1}'.", - "Property_0_is_private_in_type_1_but_not_in_type_2_2325" : "Property '{0}' is private in type '{1}' but not in type '{2}'.", - "Types_of_property_0_are_incompatible_2326" : "Types of property '{0}' are incompatible.", - "Property_0_is_optional_in_type_1_but_required_in_type_2_2327" : "Property '{0}' is optional in type '{1}' but required in type '{2}'.", - "Types_of_parameters_0_and_1_are_incompatible_2328" : "Types of parameters '{0}' and '{1}' are incompatible.", - "Index_signature_is_missing_in_type_0_2329" : "Index signature is missing in type '{0}'.", - "Index_signatures_are_incompatible_2330" : "Index signatures are incompatible.", - "this_cannot_be_referenced_in_a_module_or_namespace_body_2331" : "'this' cannot be referenced in a module or namespace body.", - "this_cannot_be_referenced_in_current_location_2332" : "'this' cannot be referenced in current location.", - "this_cannot_be_referenced_in_constructor_arguments_2333" : "'this' cannot be referenced in constructor arguments.", - "this_cannot_be_referenced_in_a_static_property_initializer_2334" : "'this' cannot be referenced in a static property initializer.", - "super_can_only_be_referenced_in_a_derived_class_2335" : "'super' can only be referenced in a derived class.", - "super_cannot_be_referenced_in_constructor_arguments_2336" : "'super' cannot be referenced in constructor arguments.", - "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337" : "Super calls are not permitted outside constructors or in nested functions inside constructors.", - "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338" : "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.", - "Property_0_does_not_exist_on_type_1_2339" : "Property '{0}' does not exist on type '{1}'.", - "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340" : "Only public and protected methods of the base class are accessible via the 'super' keyword.", - "Property_0_is_private_and_only_accessible_within_class_1_2341" : "Property '{0}' is private and only accessible within class '{1}'.", - "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342" : "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.", - "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343" : "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'.", - "Type_0_does_not_satisfy_the_constraint_1_2344" : "Type '{0}' does not satisfy the constraint '{1}'.", - "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345" : "Argument of type '{0}' is not assignable to parameter of type '{1}'.", - "Call_target_does_not_contain_any_signatures_2346" : "Call target does not contain any signatures.", - "Untyped_function_calls_may_not_accept_type_arguments_2347" : "Untyped function calls may not accept type arguments.", - "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348" : "Value of type '{0}' is not callable. Did you mean to include 'new'?", - "Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatur_2349" : "Cannot invoke an expression whose type lacks a call signature. Type '{0}' has no compatible call signatures.", - "Only_a_void_function_can_be_called_with_the_new_keyword_2350" : "Only a void function can be called with the 'new' keyword.", - "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351" : "Cannot use 'new' with an expression whose type lacks a call or construct signature.", - "Type_0_cannot_be_converted_to_type_1_2352" : "Type '{0}' cannot be converted to type '{1}'.", - "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353" : "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'.", - "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354" : "This syntax requires an imported helper but module '{0}' cannot be found.", - "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355" : "A function whose declared type is neither 'void' nor 'any' must return a value.", - "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356" : "An arithmetic operand must be of type 'any', 'number' or an enum type.", - "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357" : "The operand of an increment or decrement operator must be a variable or a property access.", - "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358" : "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.", - "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359" : "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type.", - "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360" : "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'.", - "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361" : "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter.", - "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362" : "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363" : "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.", - "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364" : "The left-hand side of an assignment expression must be a variable or a property access.", - "Operator_0_cannot_be_applied_to_types_1_and_2_2365" : "Operator '{0}' cannot be applied to types '{1}' and '{2}'.", - "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366" : "Function lacks ending return statement and return type does not include 'undefined'.", - "Type_parameter_name_cannot_be_0_2368" : "Type parameter name cannot be '{0}'.", - "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369" : "A parameter property is only allowed in a constructor implementation.", - "A_rest_parameter_must_be_of_an_array_type_2370" : "A rest parameter must be of an array type.", - "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371" : "A parameter initializer is only allowed in a function or constructor implementation.", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372" : "Parameter '{0}' cannot be referenced in its initializer.", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373" : "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.", - "Duplicate_string_index_signature_2374" : "Duplicate string index signature.", - "Duplicate_number_index_signature_2375" : "Duplicate number index signature.", - "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376" : "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.", - "Constructors_for_derived_classes_must_contain_a_super_call_2377" : "Constructors for derived classes must contain a 'super' call.", - "A_get_accessor_must_return_a_value_2378" : "A 'get' accessor must return a value.", - "Getter_and_setter_accessors_do_not_agree_in_visibility_2379" : "Getter and setter accessors do not agree in visibility.", - "get_and_set_accessor_must_have_the_same_type_2380" : "'get' and 'set' accessor must have the same type.", - "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381" : "A signature with an implementation cannot use a string literal type.", - "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382" : "Specialized overload signature is not assignable to any non-specialized signature.", - "Overload_signatures_must_all_be_exported_or_non_exported_2383" : "Overload signatures must all be exported or non-exported.", - "Overload_signatures_must_all_be_ambient_or_non_ambient_2384" : "Overload signatures must all be ambient or non-ambient.", - "Overload_signatures_must_all_be_public_private_or_protected_2385" : "Overload signatures must all be public, private or protected.", - "Overload_signatures_must_all_be_optional_or_required_2386" : "Overload signatures must all be optional or required.", - "Function_overload_must_be_static_2387" : "Function overload must be static.", - "Function_overload_must_not_be_static_2388" : "Function overload must not be static.", - "Function_implementation_name_must_be_0_2389" : "Function implementation name must be '{0}'.", - "Constructor_implementation_is_missing_2390" : "Constructor implementation is missing.", - "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391" : "Function implementation is missing or not immediately following the declaration.", - "Multiple_constructor_implementations_are_not_allowed_2392" : "Multiple constructor implementations are not allowed.", - "Duplicate_function_implementation_2393" : "Duplicate function implementation.", - "Overload_signature_is_not_compatible_with_function_implementation_2394" : "Overload signature is not compatible with function implementation.", - "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395" : "Individual declarations in merged declaration '{0}' must be all exported or all local.", - "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396" : "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters.", - "Declaration_name_conflicts_with_built_in_global_identifier_0_2397" : "Declaration name conflicts with built-in global identifier '{0}'.", - "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399" : "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference.", - "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400" : "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference.", - "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401" : "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference.", - "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402" : "Expression resolves to '_super' that compiler uses to capture base class reference.", - "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403" : "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'.", - "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404" : "The left-hand side of a 'for...in' statement cannot use a type annotation.", - "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405" : "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.", - "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406" : "The left-hand side of a 'for...in' statement must be a variable or a property access.", - "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_2407" : "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type '{0}'.", - "Setters_cannot_return_a_value_2408" : "Setters cannot return a value.", - "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409" : "Return type of constructor signature must be assignable to the instance type of the class.", - "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410" : "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'.", - "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411" : "Property '{0}' of type '{1}' is not assignable to string index type '{2}'.", - "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412" : "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'.", - "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413" : "Numeric index type '{0}' is not assignable to string index type '{1}'.", - "Class_name_cannot_be_0_2414" : "Class name cannot be '{0}'.", - "Class_0_incorrectly_extends_base_class_1_2415" : "Class '{0}' incorrectly extends base class '{1}'.", - "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416" : "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'.", - "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417" : "Class static side '{0}' incorrectly extends base class static side '{1}'.", - "Class_0_incorrectly_implements_interface_1_2420" : "Class '{0}' incorrectly implements interface '{1}'.", - "A_class_may_only_implement_another_class_or_interface_2422" : "A class may only implement another class or interface.", - "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423" : "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor.", - "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424" : "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property.", - "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425" : "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function.", - "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426" : "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function.", - "Interface_name_cannot_be_0_2427" : "Interface name cannot be '{0}'.", - "All_declarations_of_0_must_have_identical_type_parameters_2428" : "All declarations of '{0}' must have identical type parameters.", - "Interface_0_incorrectly_extends_interface_1_2430" : "Interface '{0}' incorrectly extends interface '{1}'.", - "Enum_name_cannot_be_0_2431" : "Enum name cannot be '{0}'.", - "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432" : "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element.", - "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433" : "A namespace declaration cannot be in a different file from a class or function with which it is merged.", - "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434" : "A namespace declaration cannot be located prior to a class or function with which it is merged.", - "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435" : "Ambient modules cannot be nested in other modules or namespaces.", - "Ambient_module_declaration_cannot_specify_relative_module_name_2436" : "Ambient module declaration cannot specify relative module name.", - "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437" : "Module '{0}' is hidden by a local declaration with the same name.", - "Import_name_cannot_be_0_2438" : "Import name cannot be '{0}'.", - "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439" : "Import or export declaration in an ambient module declaration cannot reference module through relative module name.", - "Import_declaration_conflicts_with_local_declaration_of_0_2440" : "Import declaration conflicts with local declaration of '{0}'.", - "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441" : "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module.", - "Types_have_separate_declarations_of_a_private_property_0_2442" : "Types have separate declarations of a private property '{0}'.", - "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443" : "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'.", - "Property_0_is_protected_in_type_1_but_public_in_type_2_2444" : "Property '{0}' is protected in type '{1}' but public in type '{2}'.", - "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445" : "Property '{0}' is protected and only accessible within class '{1}' and its subclasses.", - "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446" : "Property '{0}' is protected and only accessible through an instance of class '{1}'.", - "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447" : "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead.", - "Block_scoped_variable_0_used_before_its_declaration_2448" : "Block-scoped variable '{0}' used before its declaration.", - "Class_0_used_before_its_declaration_2449" : "Class '{0}' used before its declaration.", - "Enum_0_used_before_its_declaration_2450" : "Enum '{0}' used before its declaration.", - "Cannot_redeclare_block_scoped_variable_0_2451" : "Cannot redeclare block-scoped variable '{0}'.", - "An_enum_member_cannot_have_a_numeric_name_2452" : "An enum member cannot have a numeric name.", - "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453" : "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly.", - "Variable_0_is_used_before_being_assigned_2454" : "Variable '{0}' is used before being assigned.", - "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455" : "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'.", - "Type_alias_0_circularly_references_itself_2456" : "Type alias '{0}' circularly references itself.", - "Type_alias_name_cannot_be_0_2457" : "Type alias name cannot be '{0}'.", - "An_AMD_module_cannot_have_multiple_name_assignments_2458" : "An AMD module cannot have multiple name assignments.", - "Type_0_has_no_property_1_and_no_string_index_signature_2459" : "Type '{0}' has no property '{1}' and no string index signature.", - "Type_0_has_no_property_1_2460" : "Type '{0}' has no property '{1}'.", - "Type_0_is_not_an_array_type_2461" : "Type '{0}' is not an array type.", - "A_rest_element_must_be_last_in_a_destructuring_pattern_2462" : "A rest element must be last in a destructuring pattern.", - "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463" : "A binding pattern parameter cannot be optional in an implementation signature.", - "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464" : "A computed property name must be of type 'string', 'number', 'symbol', or 'any'.", - "this_cannot_be_referenced_in_a_computed_property_name_2465" : "'this' cannot be referenced in a computed property name.", - "super_cannot_be_referenced_in_a_computed_property_name_2466" : "'super' cannot be referenced in a computed property name.", - "A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type_2467" : "A computed property name cannot reference a type parameter from its containing type.", - "Cannot_find_global_value_0_2468" : "Cannot find global value '{0}'.", - "The_0_operator_cannot_be_applied_to_type_symbol_2469" : "The '{0}' operator cannot be applied to type 'symbol'.", - "Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" : "'Symbol' reference does not refer to the global Symbol constructor object.", - "A_computed_property_name_of_the_form_0_must_be_of_type_symbol_2471" : "A computed property name of the form '{0}' must be of type 'symbol'.", - "Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher_2472" : "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher.", - "Enum_declarations_must_all_be_const_or_non_const_2473" : "Enum declarations must all be const or non-const.", - "In_const_enum_declarations_member_initializer_must_be_constant_expression_2474" : "In 'const' enum declarations member initializer must be constant expression.", - "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475" : "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query.", - "A_const_enum_member_can_only_be_accessed_using_a_string_literal_2476" : "A const enum member can only be accessed using a string literal.", - "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477" : "'const' enum member initializer was evaluated to a non-finite value.", - "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478" : "'const' enum member initializer was evaluated to disallowed value 'NaN'.", - "Property_0_does_not_exist_on_const_enum_1_2479" : "Property '{0}' does not exist on 'const' enum '{1}'.", - "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480" : "'let' is not allowed to be used as a name in 'let' or 'const' declarations.", - "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481" : "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'.", - "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483" : "The left-hand side of a 'for...of' statement cannot use a type annotation.", - "Export_declaration_conflicts_with_exported_declaration_of_0_2484" : "Export declaration conflicts with exported declaration of '{0}'.", - "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487" : "The left-hand side of a 'for...of' statement must be a variable or a property access.", - "Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator_2488" : "Type '{0}' must have a '[Symbol.iterator]()' method that returns an iterator.", - "An_iterator_must_have_a_next_method_2489" : "An iterator must have a 'next()' method.", - "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490" : "The type returned by the 'next()' method of an iterator must have a 'value' property.", - "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491" : "The left-hand side of a 'for...in' statement cannot be a destructuring pattern.", - "Cannot_redeclare_identifier_0_in_catch_clause_2492" : "Cannot redeclare identifier '{0}' in catch clause.", - "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493" : "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'.", - "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494" : "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher.", - "Type_0_is_not_an_array_type_or_a_string_type_2495" : "Type '{0}' is not an array type or a string type.", - "The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_stand_2496" : "The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5. Consider using a standard function expression.", - "Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct_2497" : "Module '{0}' resolves to a non-module entity and cannot be imported using this construct.", - "Module_0_uses_export_and_cannot_be_used_with_export_Asterisk_2498" : "Module '{0}' uses 'export =' and cannot be used with 'export *'.", - "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499" : "An interface can only extend an identifier/qualified-name with optional type arguments.", - "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500" : "A class can only implement an identifier/qualified-name with optional type arguments.", - "A_rest_element_cannot_contain_a_binding_pattern_2501" : "A rest element cannot contain a binding pattern.", - "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502" : "'{0}' is referenced directly or indirectly in its own type annotation.", - "Cannot_find_namespace_0_2503" : "Cannot find namespace '{0}'.", - "Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_2504" : "Type '{0}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.", - "A_generator_cannot_have_a_void_type_annotation_2505" : "A generator cannot have a 'void' type annotation.", - "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506" : "'{0}' is referenced directly or indirectly in its own base expression.", - "Type_0_is_not_a_constructor_function_type_2507" : "Type '{0}' is not a constructor function type.", - "No_base_constructor_has_the_specified_number_of_type_arguments_2508" : "No base constructor has the specified number of type arguments.", - "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509" : "Base constructor return type '{0}' is not a class or interface type.", - "Base_constructors_must_all_have_the_same_return_type_2510" : "Base constructors must all have the same return type.", - "Cannot_create_an_instance_of_an_abstract_class_2511" : "Cannot create an instance of an abstract class.", - "Overload_signatures_must_all_be_abstract_or_non_abstract_2512" : "Overload signatures must all be abstract or non-abstract.", - "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513" : "Abstract method '{0}' in class '{1}' cannot be accessed via super expression.", - "Classes_containing_abstract_methods_must_be_marked_abstract_2514" : "Classes containing abstract methods must be marked abstract.", - "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515" : "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'.", - "All_declarations_of_an_abstract_method_must_be_consecutive_2516" : "All declarations of an abstract method must be consecutive.", - "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517" : "Cannot assign an abstract constructor type to a non-abstract constructor type.", - "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518" : "A 'this'-based type guard is not compatible with a parameter-based type guard.", - "An_async_iterator_must_have_a_next_method_2519" : "An async iterator must have a 'next()' method.", - "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520" : "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.", - "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521" : "Expression resolves to variable declaration '{0}' that compiler uses to support async functions.", - "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_usi_2522" : "The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method.", - "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523" : "'yield' expressions cannot be used in a parameter initializer.", - "await_expressions_cannot_be_used_in_a_parameter_initializer_2524" : "'await' expressions cannot be used in a parameter initializer.", - "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525" : "Initializer provides no value for this binding element and the binding element has no default value.", - "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526" : "A 'this' type is available only in a non-static member of a class or interface.", - "The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary_2527" : "The inferred type of '{0}' references an inaccessible '{1}' type. A type annotation is necessary.", - "A_module_cannot_have_multiple_default_exports_2528" : "A module cannot have multiple default exports.", - "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_func_2529" : "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module containing async functions.", - "Property_0_is_incompatible_with_index_signature_2530" : "Property '{0}' is incompatible with index signature.", - "Object_is_possibly_null_2531" : "Object is possibly 'null'.", - "Object_is_possibly_undefined_2532" : "Object is possibly 'undefined'.", - "Object_is_possibly_null_or_undefined_2533" : "Object is possibly 'null' or 'undefined'.", - "A_function_returning_never_cannot_have_a_reachable_end_point_2534" : "A function returning 'never' cannot have a reachable end point.", - "Enum_type_0_has_members_with_initializers_that_are_not_literals_2535" : "Enum type '{0}' has members with initializers that are not literals.", - "Type_0_cannot_be_used_to_index_type_1_2536" : "Type '{0}' cannot be used to index type '{1}'.", - "Type_0_has_no_matching_index_signature_for_type_1_2537" : "Type '{0}' has no matching index signature for type '{1}'.", - "Type_0_cannot_be_used_as_an_index_type_2538" : "Type '{0}' cannot be used as an index type.", - "Cannot_assign_to_0_because_it_is_not_a_variable_2539" : "Cannot assign to '{0}' because it is not a variable.", - "Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property_2540" : "Cannot assign to '{0}' because it is a constant or a read-only property.", - "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541" : "The target of an assignment must be a variable or a property access.", - "Index_signature_in_type_0_only_permits_reading_2542" : "Index signature in type '{0}' only permits reading.", - "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543" : "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference.", - "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544" : "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference.", - "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545" : "A mixin class must have a constructor with a single rest parameter of type 'any[]'.", - "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546" : "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'.", - "The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value__2547" : "The type returned by the 'next()' method of an async iterator must be a promise for a type with a 'value' property.", - "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548" : "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator.", - "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549" : "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator.", - "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550" : "Generic type instantiation is excessively deep and possibly infinite.", - "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551" : "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?", - "Cannot_find_name_0_Did_you_mean_1_2552" : "Cannot find name '{0}'. Did you mean '{1}'?", - "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553" : "Computed values are not permitted in an enum with string valued members.", - "Expected_0_arguments_but_got_1_2554" : "Expected {0} arguments, but got {1}.", - "Expected_at_least_0_arguments_but_got_1_2555" : "Expected at least {0} arguments, but got {1}.", - "Expected_0_arguments_but_got_1_or_more_2556" : "Expected {0} arguments, but got {1} or more.", - "Expected_at_least_0_arguments_but_got_1_or_more_2557" : "Expected at least {0} arguments, but got {1} or more.", - "Expected_0_type_arguments_but_got_1_2558" : "Expected {0} type arguments, but got {1}.", - "Type_0_has_no_properties_in_common_with_type_1_2559" : "Type '{0}' has no properties in common with type '{1}'.", - "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560" : "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?", - "Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_writ_2561" : "Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?", - "Base_class_expressions_cannot_reference_class_type_parameters_2562" : "Base class expressions cannot reference class type parameters.", - "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563" : "The containing function or module body is too large for control flow analysis.", - "Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor_2564" : "Property '{0}' has no initializer and is not definitely assigned in the constructor.", - "Property_0_is_used_before_being_assigned_2565" : "Property '{0}' is used before being assigned.", - "A_rest_element_cannot_have_a_property_name_2566" : "A rest element cannot have a property name.", - "Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations_2567" : "Enum declarations can only merge with namespace or other enum declarations.", - "Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators_2568" : "Type '{0}' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators.", - "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569" : "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.", - "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570" : "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?", - "JSX_element_attributes_type_0_may_not_be_a_union_type_2600" : "JSX element attributes type '{0}' may not be a union type.", - "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601" : "The return type of a JSX element constructor must return an object type.", - "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602" : "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist.", - "Property_0_in_type_1_is_not_assignable_to_type_2_2603" : "Property '{0}' in type '{1}' is not assignable to type '{2}'.", - "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604" : "JSX element type '{0}' does not have any construct or call signatures.", - "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605" : "JSX element type '{0}' is not a constructor function for JSX elements.", - "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606" : "Property '{0}' of JSX spread attribute is not assignable to target property.", - "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607" : "JSX element class does not support attributes because it does not have a '{0}' property.", - "The_global_type_JSX_0_may_not_have_more_than_one_property_2608" : "The global type 'JSX.{0}' may not have more than one property.", - "JSX_spread_child_must_be_an_array_type_2609" : "JSX spread child must be an array type.", - "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649" : "Cannot augment module '{0}' with value exports because it resolves to a non-module entity.", - "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" : "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.", - "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652" : "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.", - "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653" : "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'.", - "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654" : "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.", - "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656" : "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition.", - "JSX_expressions_must_have_one_parent_element_2657" : "JSX expressions must have one parent element.", - "Type_0_provides_no_match_for_the_signature_1_2658" : "Type '{0}' provides no match for the signature '{1}'.", - "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659" : "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher.", - "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660" : "'super' can only be referenced in members of derived classes or object literal expressions.", - "Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module_2661" : "Cannot export '{0}'. Only local declarations can be exported from a module.", - "Cannot_find_name_0_Did_you_mean_the_static_member_1_0_2662" : "Cannot find name '{0}'. Did you mean the static member '{1}.{0}'?", - "Cannot_find_name_0_Did_you_mean_the_instance_member_this_0_2663" : "Cannot find name '{0}'. Did you mean the instance member 'this.{0}'?", - "Invalid_module_name_in_augmentation_module_0_cannot_be_found_2664" : "Invalid module name in augmentation, module '{0}' cannot be found.", - "Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augm_2665" : "Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented.", - "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666" : "Exports and export assignments are not permitted in module augmentations.", - "Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_mod_2667" : "Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.", - "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668" : "'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.", - "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669" : "Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.", - "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670" : "Augmentations for the global scope should have 'declare' modifier unless they appear in already ambient context.", - "Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity_2671" : "Cannot augment module '{0}' because it resolves to a non-module entity.", - "Cannot_assign_a_0_constructor_type_to_a_1_constructor_type_2672" : "Cannot assign a '{0}' constructor type to a '{1}' constructor type.", - "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673" : "Constructor of class '{0}' is private and only accessible within the class declaration.", - "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674" : "Constructor of class '{0}' is protected and only accessible within the class declaration.", - "Cannot_extend_a_class_0_Class_constructor_is_marked_as_private_2675" : "Cannot extend a class '{0}'. Class constructor is marked as private.", - "Accessors_must_both_be_abstract_or_non_abstract_2676" : "Accessors must both be abstract or non-abstract.", - "A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type_2677" : "A type predicate's type must be assignable to its parameter's type.", - "Type_0_is_not_comparable_to_type_1_2678" : "Type '{0}' is not comparable to type '{1}'.", - "A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void_2679" : "A function that is called with the 'new' keyword cannot have a 'this' type that is 'void'.", - "A_0_parameter_must_be_the_first_parameter_2680" : "A '{0}' parameter must be the first parameter.", - "A_constructor_cannot_have_a_this_parameter_2681" : "A constructor cannot have a 'this' parameter.", - "get_and_set_accessor_must_have_the_same_this_type_2682" : "'get' and 'set' accessor must have the same 'this' type.", - "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683" : "'this' implicitly has type 'any' because it does not have a type annotation.", - "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684" : "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'.", - "The_this_types_of_each_signature_are_incompatible_2685" : "The 'this' types of each signature are incompatible.", - "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686" : "'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead.", - "All_declarations_of_0_must_have_identical_modifiers_2687" : "All declarations of '{0}' must have identical modifiers.", - "Cannot_find_type_definition_file_for_0_2688" : "Cannot find type definition file for '{0}'.", - "Cannot_extend_an_interface_0_Did_you_mean_implements_2689" : "Cannot extend an interface '{0}'. Did you mean 'implements'?", - "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691" : "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead.", - "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692" : "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible.", - "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693" : "'{0}' only refers to a type, but is being used as a value here.", - "Namespace_0_has_no_exported_member_1_2694" : "Namespace '{0}' has no exported member '{1}'.", - "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695" : "Left side of comma operator is unused and has no side effects.", - "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696" : "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?", - "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697" : "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.", - "Spread_types_may_only_be_created_from_object_types_2698" : "Spread types may only be created from object types.", - "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699" : "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'.", - "Rest_types_may_only_be_created_from_object_types_2700" : "Rest types may only be created from object types.", - "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701" : "The target of an object rest assignment must be a variable or a property access.", - "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702" : "'{0}' only refers to a type, but is being used as a namespace here.", - "The_operand_of_a_delete_operator_must_be_a_property_reference_2703" : "The operand of a delete operator must be a property reference.", - "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704" : "The operand of a delete operator cannot be a read-only property.", - "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705" : "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.", - "Required_type_parameters_may_not_follow_optional_type_parameters_2706" : "Required type parameters may not follow optional type parameters.", - "Generic_type_0_requires_between_1_and_2_type_arguments_2707" : "Generic type '{0}' requires between {1} and {2} type arguments.", - "Cannot_use_namespace_0_as_a_value_2708" : "Cannot use namespace '{0}' as a value.", - "Cannot_use_namespace_0_as_a_type_2709" : "Cannot use namespace '{0}' as a type.", - "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710" : "'{0}' are specified twice. The attribute named '{0}' will be overwritten.", - "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711" : "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.", - "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712" : "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.", - "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713" : "Cannot access '{0}.{1}' because '{0}' is a type, but not a namespace. Did you mean to retrieve the type of the property '{1}' in '{0}' with '{0}[\"{1}\"]'?", - "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714" : "The expression of an export assignment must be an identifier or qualified name in an ambient context.", - "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715" : "Abstract property '{0}' in class '{1}' cannot be accessed in the constructor.", - "Type_parameter_0_has_a_circular_default_2716" : "Type parameter '{0}' has a circular default.", - "Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_t_2717" : "Subsequent property declarations must have the same type. Property '{0}' must be of type '{1}', but here has type '{2}'.", - "Duplicate_declaration_0_2718" : "Duplicate declaration '{0}'.", - "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_2719" : "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated.", - "Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclas_2720" : "Class '{0}' incorrectly implements class '{1}'. Did you mean to extend '{1}' and inherit its members as a subclass?", - "Cannot_invoke_an_object_which_is_possibly_null_2721" : "Cannot invoke an object which is possibly 'null'.", - "Cannot_invoke_an_object_which_is_possibly_undefined_2722" : "Cannot invoke an object which is possibly 'undefined'.", - "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723" : "Cannot invoke an object which is possibly 'null' or 'undefined'.", - "Module_0_has_no_exported_member_1_Did_you_mean_2_2724" : "Module '{0}' has no exported member '{1}'. Did you mean '{2}'?", - "Import_declaration_0_is_using_private_name_1_4000" : "Import declaration '{0}' is using private name '{1}'.", - "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002" : "Type parameter '{0}' of exported class has or is using private name '{1}'.", - "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004" : "Type parameter '{0}' of exported interface has or is using private name '{1}'.", - "Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4006" : "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'.", - "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008" : "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'.", - "Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4010" : "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'.", - "Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4012" : "Type parameter '{0}' of public method from exported class has or is using private name '{1}'.", - "Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4014" : "Type parameter '{0}' of method from exported interface has or is using private name '{1}'.", - "Type_parameter_0_of_exported_function_has_or_is_using_private_name_1_4016" : "Type parameter '{0}' of exported function has or is using private name '{1}'.", - "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019" : "Implements clause of exported class '{0}' has or is using private name '{1}'.", - "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020" : "'extends' clause of exported class '{0}' has or is using private name '{1}'.", - "extends_clause_of_exported_interface_0_has_or_is_using_private_name_1_4022" : "'extends' clause of exported interface '{0}' has or is using private name '{1}'.", - "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023" : "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named.", - "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024" : "Exported variable '{0}' has or is using name '{1}' from private module '{2}'.", - "Exported_variable_0_has_or_is_using_private_name_1_4025" : "Exported variable '{0}' has or is using private name '{1}'.", - "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot__4026" : "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.", - "Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4027" : "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'.", - "Public_static_property_0_of_exported_class_has_or_is_using_private_name_1_4028" : "Public static property '{0}' of exported class has or is using private name '{1}'.", - "Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_name_4029" : "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.", - "Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4030" : "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'.", - "Public_property_0_of_exported_class_has_or_is_using_private_name_1_4031" : "Public property '{0}' of exported class has or is using private name '{1}'.", - "Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4032" : "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'.", - "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033" : "Property '{0}' of exported interface has or is using private name '{1}'.", - "Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_mod_4034" : "Parameter type of public static setter '{0}' from exported class has or is using name '{1}' from private module '{2}'.", - "Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1_4035" : "Parameter type of public static setter '{0}' from exported class has or is using private name '{1}'.", - "Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2_4036" : "Parameter type of public setter '{0}' from exported class has or is using name '{1}' from private module '{2}'.", - "Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1_4037" : "Parameter type of public setter '{0}' from exported class has or is using private name '{1}'.", - "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_modul_4038" : "Return type of public static getter '{0}' from exported class has or is using name '{1}' from external module {2} but cannot be named.", - "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_4039" : "Return type of public static getter '{0}' from exported class has or is using name '{1}' from private module '{2}'.", - "Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1_4040" : "Return type of public static getter '{0}' from exported class has or is using private name '{1}'.", - "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_4041" : "Return type of public getter '{0}' from exported class has or is using name '{1}' from external module {2} but cannot be named.", - "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2_4042" : "Return type of public getter '{0}' from exported class has or is using name '{1}' from private module '{2}'.", - "Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1_4043" : "Return type of public getter '{0}' from exported class has or is using private name '{1}'.", - "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_mod_4044" : "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'.", - "Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0_4045" : "Return type of constructor signature from exported interface has or is using private name '{0}'.", - "Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4046" : "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'.", - "Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0_4047" : "Return type of call signature from exported interface has or is using private name '{0}'.", - "Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4048" : "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'.", - "Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0_4049" : "Return type of index signature from exported interface has or is using private name '{0}'.", - "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module__4050" : "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named.", - "Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4051" : "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'.", - "Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0_4052" : "Return type of public static method from exported class has or is using private name '{0}'.", - "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_c_4053" : "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named.", - "Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1_4054" : "Return type of public method from exported class has or is using name '{0}' from private module '{1}'.", - "Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0_4055" : "Return type of public method from exported class has or is using private name '{0}'.", - "Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1_4056" : "Return type of method from exported interface has or is using name '{0}' from private module '{1}'.", - "Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0_4057" : "Return type of method from exported interface has or is using private name '{0}'.", - "Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named_4058" : "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named.", - "Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1_4059" : "Return type of exported function has or is using name '{0}' from private module '{1}'.", - "Return_type_of_exported_function_has_or_is_using_private_name_0_4060" : "Return type of exported function has or is using private name '{0}'.", - "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_can_4061" : "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named.", - "Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2_4062" : "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'.", - "Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1_4063" : "Parameter '{0}' of constructor from exported class has or is using private name '{1}'.", - "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_mod_4064" : "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'.", - "Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1_4065" : "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'.", - "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4066" : "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'.", - "Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4067" : "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'.", - "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module__4068" : "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named.", - "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4069" : "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'.", - "Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1_4070" : "Parameter '{0}' of public static method from exported class has or is using private name '{1}'.", - "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_c_4071" : "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named.", - "Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2_4072" : "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'.", - "Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1_4073" : "Parameter '{0}' of public method from exported class has or is using private name '{1}'.", - "Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4074" : "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'.", - "Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1_4075" : "Parameter '{0}' of method from exported interface has or is using private name '{1}'.", - "Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4076" : "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named.", - "Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2_4077" : "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'.", - "Parameter_0_of_exported_function_has_or_is_using_private_name_1_4078" : "Parameter '{0}' of exported function has or is using private name '{1}'.", - "Exported_type_alias_0_has_or_is_using_private_name_1_4081" : "Exported type alias '{0}' has or is using private name '{1}'.", - "Default_export_of_the_module_has_or_is_using_private_name_0_4082" : "Default export of the module has or is using private name '{0}'.", - "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083" : "Type parameter '{0}' of exported type alias has or is using private name '{1}'.", - "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090" : "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.", - "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091" : "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'.", - "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092" : "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'.", - "Property_0_of_exported_class_expression_may_not_be_private_or_protected_4094" : "Property '{0}' of exported class expression may not be private or protected.", - "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_4095" : "Public static method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.", - "Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4096" : "Public static method '{0}' of exported class has or is using name '{1}' from private module '{2}'.", - "Public_static_method_0_of_exported_class_has_or_is_using_private_name_1_4097" : "Public static method '{0}' of exported class has or is using private name '{1}'.", - "Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4098" : "Public method '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.", - "Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2_4099" : "Public method '{0}' of exported class has or is using name '{1}' from private module '{2}'.", - "Public_method_0_of_exported_class_has_or_is_using_private_name_1_4100" : "Public method '{0}' of exported class has or is using private name '{1}'.", - "Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4101" : "Method '{0}' of exported interface has or is using name '{1}' from private module '{2}'.", - "Method_0_of_exported_interface_has_or_is_using_private_name_1_4102" : "Method '{0}' of exported interface has or is using private name '{1}'.", - "The_current_host_does_not_support_the_0_option_5001" : "The current host does not support the '{0}' option.", - "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009" : "Cannot find the common subdirectory path for the input files.", - "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010" : "File specification cannot end in a recursive directory wildcard ('**'): '{0}'.", - "Cannot_read_file_0_Colon_1_5012" : "Cannot read file '{0}': {1}.", - "Failed_to_parse_file_0_Colon_1_5014" : "Failed to parse file '{0}': {1}.", - "Unknown_compiler_option_0_5023" : "Unknown compiler option '{0}'.", - "Compiler_option_0_requires_a_value_of_type_1_5024" : "Compiler option '{0}' requires a value of type {1}.", - "Could_not_write_file_0_Colon_1_5033" : "Could not write file '{0}': {1}.", - "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042" : "Option 'project' cannot be mixed with source files on a command line.", - "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047" : "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher.", - "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051" : "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.", - "Option_0_cannot_be_specified_without_specifying_option_1_5052" : "Option '{0}' cannot be specified without specifying option '{1}'.", - "Option_0_cannot_be_specified_with_option_1_5053" : "Option '{0}' cannot be specified with option '{1}'.", - "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054" : "A 'tsconfig.json' file is already defined at: '{0}'.", - "Cannot_write_file_0_because_it_would_overwrite_input_file_5055" : "Cannot write file '{0}' because it would overwrite input file.", - "Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files_5056" : "Cannot write file '{0}' because it would be overwritten by multiple input files.", - "Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0_5057" : "Cannot find a tsconfig.json file at the specified directory: '{0}'.", - "The_specified_path_does_not_exist_Colon_0_5058" : "The specified path does not exist: '{0}'.", - "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059" : "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier.", - "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060" : "Option 'paths' cannot be used without specifying '--baseUrl' option.", - "Pattern_0_can_have_at_most_one_Asterisk_character_5061" : "Pattern '{0}' can have at most one '*' character.", - "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062" : "Substitution '{0}' in pattern '{1}' in can have at most one '*' character.", - "Substitutions_for_pattern_0_should_be_an_array_5063" : "Substitutions for pattern '{0}' should be an array.", - "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064" : "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'.", - "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065" : "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'.", - "Substitutions_for_pattern_0_shouldn_t_be_an_empty_array_5066" : "Substitutions for pattern '{0}' shouldn't be an empty array.", - "Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name_5067" : "Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name.", - "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068" : "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.", - "Option_0_cannot_be_specified_without_specifying_option_1_or_option_2_5069" : "Option '{0}' cannot be specified without specifying option '{1}' or option '{2}'.", - "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000" : "Generates a sourcemap for each corresponding '.d.ts' file.", - "Concatenate_and_emit_output_to_single_file_6001" : "Concatenate and emit output to single file.", - "Generates_corresponding_d_ts_file_6002" : "Generates corresponding '.d.ts' file.", - "Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations_6003" : "Specify the location where debugger should locate map files instead of generated locations.", - "Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations_6004" : "Specify the location where debugger should locate TypeScript files instead of source locations.", - "Watch_input_files_6005" : "Watch input files.", - "Redirect_output_structure_to_the_directory_6006" : "Redirect output structure to the directory.", - "Do_not_erase_const_enum_declarations_in_generated_code_6007" : "Do not erase const enum declarations in generated code.", - "Do_not_emit_outputs_if_any_errors_were_reported_6008" : "Do not emit outputs if any errors were reported.", - "Do_not_emit_comments_to_output_6009" : "Do not emit comments to output.", - "Do_not_emit_outputs_6010" : "Do not emit outputs.", - "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011" : "Allow default imports from modules with no default export. This does not affect code emit, just typechecking.", - "Skip_type_checking_of_declaration_files_6012" : "Skip type checking of declaration files.", - "Do_not_resolve_the_real_path_of_symlinks_6013" : "Do not resolve the real path of symlinks.", - "Only_emit_d_ts_declaration_files_6014" : "Only emit '.d.ts' declaration files.", - "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_or_ESNEXT_6015" : "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'.", - "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016" : "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.", - "Print_this_message_6017" : "Print this message.", - "Print_the_compiler_s_version_6019" : "Print the compiler's version.", - "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020" : "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.", - "Syntax_Colon_0_6023" : "Syntax: {0}", - "options_6024" : "options", - "file_6025" : "file", - "Examples_Colon_0_6026" : "Examples: {0}", - "Options_Colon_6027" : "Options:", - "Version_0_6029" : "Version {0}", - "Insert_command_line_options_and_files_from_a_file_6030" : "Insert command line options and files from a file.", - "Starting_compilation_in_watch_mode_6031" : "Starting compilation in watch mode...", - "File_change_detected_Starting_incremental_compilation_6032" : "File change detected. Starting incremental compilation...", - "KIND_6034" : "KIND", - "FILE_6035" : "FILE", - "VERSION_6036" : "VERSION", - "LOCATION_6037" : "LOCATION", - "DIRECTORY_6038" : "DIRECTORY", - "STRATEGY_6039" : "STRATEGY", - "FILE_OR_DIRECTORY_6040" : "FILE OR DIRECTORY", - "Generates_corresponding_map_file_6043" : "Generates corresponding '.map' file.", - "Compiler_option_0_expects_an_argument_6044" : "Compiler option '{0}' expects an argument.", - "Unterminated_quoted_string_in_response_file_0_6045" : "Unterminated quoted string in response file '{0}'.", - "Argument_for_0_option_must_be_Colon_1_6046" : "Argument for '{0}' option must be: {1}.", - "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048" : "Locale must be of the form or -. For example '{0}' or '{1}'.", - "Unsupported_locale_0_6049" : "Unsupported locale '{0}'.", - "Unable_to_open_file_0_6050" : "Unable to open file '{0}'.", - "Corrupted_locale_file_0_6051" : "Corrupted locale file {0}.", - "Raise_error_on_expressions_and_declarations_with_an_implied_any_type_6052" : "Raise error on expressions and declarations with an implied 'any' type.", - "File_0_not_found_6053" : "File '{0}' not found.", - "File_0_has_unsupported_extension_The_only_supported_extensions_are_1_6054" : "File '{0}' has unsupported extension. The only supported extensions are {1}.", - "Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures_6055" : "Suppress noImplicitAny errors for indexing objects lacking index signatures.", - "Do_not_emit_declarations_for_code_that_has_an_internal_annotation_6056" : "Do not emit declarations for code that has an '@internal' annotation.", - "Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir_6058" : "Specify the root directory of input files. Use to control the output directory structure with --outDir.", - "File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files_6059" : "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files.", - "Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix_6060" : "Specify the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix).", - "NEWLINE_6061" : "NEWLINE", - "Option_0_can_only_be_specified_in_tsconfig_json_file_6064" : "Option '{0}' can only be specified in 'tsconfig.json' file.", - "Enables_experimental_support_for_ES7_decorators_6065" : "Enables experimental support for ES7 decorators.", - "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066" : "Enables experimental support for emitting type metadata for decorators.", - "Enables_experimental_support_for_ES7_async_functions_6068" : "Enables experimental support for ES7 async functions.", - "Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6_6069" : "Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6).", - "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070" : "Initializes a TypeScript project and creates a tsconfig.json file.", - "Successfully_created_a_tsconfig_json_file_6071" : "Successfully created a tsconfig.json file.", - "Suppress_excess_property_checks_for_object_literals_6072" : "Suppress excess property checks for object literals.", - "Stylize_errors_and_messages_using_color_and_context_experimental_6073" : "Stylize errors and messages using color and context (experimental).", - "Do_not_report_errors_on_unused_labels_6074" : "Do not report errors on unused labels.", - "Report_error_when_not_all_code_paths_in_function_return_a_value_6075" : "Report error when not all code paths in function return a value.", - "Report_errors_for_fallthrough_cases_in_switch_statement_6076" : "Report errors for fallthrough cases in switch statement.", - "Do_not_report_errors_on_unreachable_code_6077" : "Do not report errors on unreachable code.", - "Disallow_inconsistently_cased_references_to_the_same_file_6078" : "Disallow inconsistently-cased references to the same file.", - "Specify_library_files_to_be_included_in_the_compilation_6079" : "Specify library files to be included in the compilation.", - "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080" : "Specify JSX code generation: 'preserve', 'react-native', or 'react'.", - "File_0_has_an_unsupported_extension_so_skipping_it_6081" : "File '{0}' has an unsupported extension, so skipping it.", - "Only_amd_and_system_modules_are_supported_alongside_0_6082" : "Only 'amd' and 'system' modules are supported alongside --{0}.", - "Base_directory_to_resolve_non_absolute_module_names_6083" : "Base directory to resolve non-absolute module names.", - "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084" : "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit", - "Enable_tracing_of_the_name_resolution_process_6085" : "Enable tracing of the name resolution process.", - "Resolving_module_0_from_1_6086" : "======== Resolving module '{0}' from '{1}'. ========", - "Explicitly_specified_module_resolution_kind_Colon_0_6087" : "Explicitly specified module resolution kind: '{0}'.", - "Module_resolution_kind_is_not_specified_using_0_6088" : "Module resolution kind is not specified, using '{0}'.", - "Module_name_0_was_successfully_resolved_to_1_6089" : "======== Module name '{0}' was successfully resolved to '{1}'. ========", - "Module_name_0_was_not_resolved_6090" : "======== Module name '{0}' was not resolved. ========", - "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091" : "'paths' option is specified, looking for a pattern to match module name '{0}'.", - "Module_name_0_matched_pattern_1_6092" : "Module name '{0}', matched pattern '{1}'.", - "Trying_substitution_0_candidate_module_location_Colon_1_6093" : "Trying substitution '{0}', candidate module location: '{1}'.", - "Resolving_module_name_0_relative_to_base_url_1_2_6094" : "Resolving module name '{0}' relative to base url '{1}' - '{2}'.", - "Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1_6095" : "Loading module as file / folder, candidate module location '{0}', target file type '{1}'.", - "File_0_does_not_exist_6096" : "File '{0}' does not exist.", - "File_0_exist_use_it_as_a_name_resolution_result_6097" : "File '{0}' exist - use it as a name resolution result.", - "Loading_module_0_from_node_modules_folder_target_file_type_1_6098" : "Loading module '{0}' from 'node_modules' folder, target file type '{1}'.", - "Found_package_json_at_0_6099" : "Found 'package.json' at '{0}'.", - "package_json_does_not_have_a_0_field_6100" : "'package.json' does not have a '{0}' field.", - "package_json_has_0_field_1_that_references_2_6101" : "'package.json' has '{0}' field '{1}' that references '{2}'.", - "Allow_javascript_files_to_be_compiled_6102" : "Allow javascript files to be compiled.", - "Option_0_should_have_array_of_strings_as_a_value_6103" : "Option '{0}' should have array of strings as a value.", - "Checking_if_0_is_the_longest_matching_prefix_for_1_2_6104" : "Checking if '{0}' is the longest matching prefix for '{1}' - '{2}'.", - "Expected_type_of_0_field_in_package_json_to_be_string_got_1_6105" : "Expected type of '{0}' field in 'package.json' to be 'string', got '{1}'.", - "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106" : "'baseUrl' option is set to '{0}', using this value to resolve non-relative module name '{1}'.", - "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107" : "'rootDirs' option is set, using it to resolve relative module name '{0}'.", - "Longest_matching_prefix_for_0_is_1_6108" : "Longest matching prefix for '{0}' is '{1}'.", - "Loading_0_from_the_root_dir_1_candidate_location_2_6109" : "Loading '{0}' from the root dir '{1}', candidate location '{2}'.", - "Trying_other_entries_in_rootDirs_6110" : "Trying other entries in 'rootDirs'.", - "Module_resolution_using_rootDirs_has_failed_6111" : "Module resolution using 'rootDirs' has failed.", - "Do_not_emit_use_strict_directives_in_module_output_6112" : "Do not emit 'use strict' directives in module output.", - "Enable_strict_null_checks_6113" : "Enable strict null checks.", - "Unknown_option_excludes_Did_you_mean_exclude_6114" : "Unknown option 'excludes'. Did you mean 'exclude'?", - "Raise_error_on_this_expressions_with_an_implied_any_type_6115" : "Raise error on 'this' expressions with an implied 'any' type.", - "Resolving_type_reference_directive_0_containing_file_1_root_directory_2_6116" : "======== Resolving type reference directive '{0}', containing file '{1}', root directory '{2}'. ========", - "Resolving_using_primary_search_paths_6117" : "Resolving using primary search paths...", - "Resolving_from_node_modules_folder_6118" : "Resolving from node_modules folder...", - "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119" : "======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========", - "Type_reference_directive_0_was_not_resolved_6120" : "======== Type reference directive '{0}' was not resolved. ========", - "Resolving_with_primary_search_path_0_6121" : "Resolving with primary search path '{0}'.", - "Root_directory_cannot_be_determined_skipping_primary_search_paths_6122" : "Root directory cannot be determined, skipping primary search paths.", - "Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set_6123" : "======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========", - "Type_declaration_files_to_be_included_in_compilation_6124" : "Type declaration files to be included in compilation.", - "Looking_up_in_node_modules_folder_initial_location_0_6125" : "Looking up in 'node_modules' folder, initial location '{0}'.", - "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126" : "Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder.", - "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1_6127" : "======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========", - "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128" : "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========", - "Resolving_real_path_for_0_result_1_6130" : "Resolving real path for '{0}', result '{1}'.", - "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131" : "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'.", - "File_name_0_has_a_1_extension_stripping_it_6132" : "File name '{0}' has a '{1}' extension - stripping it.", - "_0_is_declared_but_its_value_is_never_read_6133" : "'{0}' is declared but its value is never read.", - "Report_errors_on_unused_locals_6134" : "Report errors on unused locals.", - "Report_errors_on_unused_parameters_6135" : "Report errors on unused parameters.", - "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136" : "The maximum dependency depth to search under node_modules and load JavaScript files.", - "Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1_6137" : "Cannot import type declaration files. Consider importing '{0}' instead of '{1}'.", - "Property_0_is_declared_but_its_value_is_never_read_6138" : "Property '{0}' is declared but its value is never read.", - "Import_emit_helpers_from_tslib_6139" : "Import emit helpers from 'tslib'.", - "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140" : "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'.", - "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141" : "Parse in strict mode and emit \"use strict\" for each source file.", - "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142" : "Module '{0}' was resolved to '{1}', but '--jsx' is not set.", - "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144" : "Module '{0}' was resolved as locally declared ambient module in file '{1}'.", - "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145" : "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified.", - "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146" : "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'.", - "Resolution_for_module_0_was_found_in_cache_from_location_1_6147" : "Resolution for module '{0}' was found in cache from location '{1}'.", - "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148" : "Directory '{0}' does not exist, skipping all lookups in it.", - "Show_diagnostic_information_6149" : "Show diagnostic information.", - "Show_verbose_diagnostic_information_6150" : "Show verbose diagnostic information.", - "Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file_6151" : "Emit a single file with source maps instead of having a separate file.", - "Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap__6152" : "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set.", - "Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153" : "Transpile each file as a separate module (similar to 'ts.transpileModule').", - "Print_names_of_generated_files_part_of_the_compilation_6154" : "Print names of generated files part of the compilation.", - "Print_names_of_files_part_of_the_compilation_6155" : "Print names of files part of the compilation.", - "The_locale_used_when_displaying_messages_to_the_user_e_g_en_us_6156" : "The locale used when displaying messages to the user (e.g. 'en-us')", - "Do_not_generate_custom_helper_functions_like_extends_in_compiled_output_6157" : "Do not generate custom helper functions like '__extends' in compiled output.", - "Do_not_include_the_default_library_file_lib_d_ts_6158" : "Do not include the default library file (lib.d.ts).", - "Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files_6159" : "Do not add triple-slash references or imported modules to the list of compiled files.", - "Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files_6160" : "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files.", - "List_of_folders_to_include_type_definitions_from_6161" : "List of folders to include type definitions from.", - "Disable_size_limitations_on_JavaScript_projects_6162" : "Disable size limitations on JavaScript projects.", - "The_character_set_of_the_input_files_6163" : "The character set of the input files.", - "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6164" : "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.", - "Do_not_truncate_error_messages_6165" : "Do not truncate error messages.", - "Output_directory_for_generated_declaration_files_6166" : "Output directory for generated declaration files.", - "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167" : "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'.", - "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168" : "List of root folders whose combined content represents the structure of the project at runtime.", - "Show_all_compiler_options_6169" : "Show all compiler options.", - "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170" : "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file", - "Command_line_Options_6171" : "Command-line Options", - "Basic_Options_6172" : "Basic Options", - "Strict_Type_Checking_Options_6173" : "Strict Type-Checking Options", - "Module_Resolution_Options_6174" : "Module Resolution Options", - "Source_Map_Options_6175" : "Source Map Options", - "Additional_Checks_6176" : "Additional Checks", - "Experimental_Options_6177" : "Experimental Options", - "Advanced_Options_6178" : "Advanced Options", - "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179" : "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'.", - "Enable_all_strict_type_checking_options_6180" : "Enable all strict type-checking options.", - "List_of_language_service_plugins_6181" : "List of language service plugins.", - "Scoped_package_detected_looking_in_0_6182" : "Scoped package detected, looking in '{0}'", - "Reusing_resolution_of_module_0_to_file_1_from_old_program_6183" : "Reusing resolution of module '{0}' to file '{1}' from old program.", - "Reusing_module_resolutions_originating_in_0_since_resolutions_are_unchanged_from_old_program_6184" : "Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program.", - "Disable_strict_checking_of_generic_signatures_in_function_types_6185" : "Disable strict checking of generic signatures in function types.", - "Enable_strict_checking_of_function_types_6186" : "Enable strict checking of function types.", - "Enable_strict_checking_of_property_initialization_in_classes_6187" : "Enable strict checking of property initialization in classes.", - "Numeric_separators_are_not_allowed_here_6188" : "Numeric separators are not allowed here.", - "Multiple_consecutive_numeric_separators_are_not_permitted_6189" : "Multiple consecutive numeric separators are not permitted.", - "Found_package_json_at_0_Package_ID_is_1_6190" : "Found 'package.json' at '{0}'. Package ID is '{1}'.", - "Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen_6191" : "Whether to keep outdated console output in watch mode instead of clearing the screen.", - "All_imports_in_import_declaration_are_unused_6192" : "All imports in import declaration are unused.", - "Found_1_error_Watching_for_file_changes_6193" : "Found 1 error. Watching for file changes.", - "Found_0_errors_Watching_for_file_changes_6194" : "Found {0} errors. Watching for file changes.", - "Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols_6195" : "Resolve 'keyof' to string valued property names only (no numbers or symbols).", - "_0_is_declared_but_never_used_6196" : "'{0}' is declared but never used.", - "Variable_0_implicitly_has_an_1_type_7005" : "Variable '{0}' implicitly has an '{1}' type.", - "Parameter_0_implicitly_has_an_1_type_7006" : "Parameter '{0}' implicitly has an '{1}' type.", - "Member_0_implicitly_has_an_1_type_7008" : "Member '{0}' implicitly has an '{1}' type.", - "new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type_7009" : "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.", - "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010" : "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type.", - "Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type_7011" : "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type.", - "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013" : "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type.", - "Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number_7015" : "Element implicitly has an 'any' type because index expression is not of type 'number'.", - "Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type_7016" : "Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type.", - "Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature_7017" : "Element implicitly has an 'any' type because type '{0}' has no index signature.", - "Object_literal_s_property_0_implicitly_has_an_1_type_7018" : "Object literal's property '{0}' implicitly has an '{1}' type.", - "Rest_parameter_0_implicitly_has_an_any_type_7019" : "Rest parameter '{0}' implicitly has an 'any[]' type.", - "Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7020" : "Call signature, which lacks return-type annotation, implicitly has an 'any' return type.", - "_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or__7022" : "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.", - "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023" : "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.", - "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024" : "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.", - "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025" : "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type.", - "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026" : "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists.", - "Unreachable_code_detected_7027" : "Unreachable code detected.", - "Unused_label_7028" : "Unused label.", - "Fallthrough_case_in_switch_7029" : "Fallthrough case in switch.", - "Not_all_code_paths_return_a_value_7030" : "Not all code paths return a value.", - "Binding_element_0_implicitly_has_an_1_type_7031" : "Binding element '{0}' implicitly has an '{1}' type.", - "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032" : "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation.", - "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033" : "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation.", - "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034" : "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined.", - "Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_mod_7035" : "Try `npm install @types/{0}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`", - "Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0_7036" : "Dynamic import's specifier must be of type 'string', but here has type '{0}'.", - "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037" : "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'.", - "A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_7038" : "A namespace-style import cannot be called or constructed, and will cause a failure at runtime.", - "Mapped_object_type_implicitly_has_an_any_template_type_7039" : "Mapped object type implicitly has an 'any' template type.", - "You_cannot_rename_this_element_8000" : "You cannot rename this element.", - "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001" : "You cannot rename elements that are defined in the standard TypeScript library.", - "import_can_only_be_used_in_a_ts_file_8002" : "'import ... =' can only be used in a .ts file.", - "export_can_only_be_used_in_a_ts_file_8003" : "'export=' can only be used in a .ts file.", - "type_parameter_declarations_can_only_be_used_in_a_ts_file_8004" : "'type parameter declarations' can only be used in a .ts file.", - "implements_clauses_can_only_be_used_in_a_ts_file_8005" : "'implements clauses' can only be used in a .ts file.", - "interface_declarations_can_only_be_used_in_a_ts_file_8006" : "'interface declarations' can only be used in a .ts file.", - "module_declarations_can_only_be_used_in_a_ts_file_8007" : "'module declarations' can only be used in a .ts file.", - "type_aliases_can_only_be_used_in_a_ts_file_8008" : "'type aliases' can only be used in a .ts file.", - "_0_can_only_be_used_in_a_ts_file_8009" : "'{0}' can only be used in a .ts file.", - "types_can_only_be_used_in_a_ts_file_8010" : "'types' can only be used in a .ts file.", - "type_arguments_can_only_be_used_in_a_ts_file_8011" : "'type arguments' can only be used in a .ts file.", - "parameter_modifiers_can_only_be_used_in_a_ts_file_8012" : "'parameter modifiers' can only be used in a .ts file.", - "non_null_assertions_can_only_be_used_in_a_ts_file_8013" : "'non-null assertions' can only be used in a .ts file.", - "enum_declarations_can_only_be_used_in_a_ts_file_8015" : "'enum declarations' can only be used in a .ts file.", - "type_assertion_expressions_can_only_be_used_in_a_ts_file_8016" : "'type assertion expressions' can only be used in a .ts file.", - "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017" : "Octal literal types must use ES2015 syntax. Use the syntax '{0}'.", - "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018" : "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'.", - "Report_errors_in_js_files_8019" : "Report errors in .js files.", - "JSDoc_types_can_only_be_used_inside_documentation_comments_8020" : "JSDoc types can only be used inside documentation comments.", - "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021" : "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags.", - "JSDoc_0_is_not_attached_to_a_class_8022" : "JSDoc '@{0}' is not attached to a class.", - "JSDoc_0_1_does_not_match_the_extends_2_clause_8023" : "JSDoc '@{0} {1}' does not match the 'extends {2}' clause.", - "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024" : "JSDoc '@param' tag has name '{0}', but there is no parameter with that name.", - "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025" : "Class declarations cannot have more than one `@augments` or `@extends` tag.", - "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026" : "Expected {0} type arguments; provide these with an '@extends' tag.", - "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027" : "Expected {0}-{1} type arguments; provide these with an '@extends' tag.", - "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028" : "JSDoc '...' may only appear in the last parameter of a signature.", - "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_h_8029" : "JSDoc '@param' tag has name '{0}', but there is no parameter with that name. It would match 'arguments' if it had an array type.", - "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002" : "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.", - "class_expressions_are_not_currently_supported_9003" : "'class' expressions are not currently supported.", - "Language_service_is_disabled_9004" : "Language service is disabled.", - "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000" : "JSX attributes must only be assigned a non-empty 'expression'.", - "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001" : "JSX elements cannot have multiple attributes with the same name.", - "Expected_corresponding_JSX_closing_tag_for_0_17002" : "Expected corresponding JSX closing tag for '{0}'.", - "JSX_attribute_expected_17003" : "JSX attribute expected.", - "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004" : "Cannot use JSX unless the '--jsx' flag is provided.", - "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005" : "A constructor cannot contain a 'super' call when its class extends 'null'.", - "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006" : "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.", - "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007" : "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.", - "JSX_element_0_has_no_corresponding_closing_tag_17008" : "JSX element '{0}' has no corresponding closing tag.", - "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009" : "'super' must be called before accessing 'this' in the constructor of a derived class.", - "Unknown_type_acquisition_option_0_17010" : "Unknown type acquisition option '{0}'.", - "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011" : "'super' must be called before accessing a property of 'super' in the constructor of a derived class.", - "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012" : "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?", - "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013" : "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor.", - "JSX_fragment_has_no_corresponding_closing_tag_17014" : "JSX fragment has no corresponding closing tag.", - "Expected_corresponding_closing_tag_for_JSX_fragment_17015" : "Expected corresponding closing tag for JSX fragment.", - "JSX_fragment_is_not_supported_when_using_jsxFactory_17016" : "JSX fragment is not supported when using --jsxFactory", - "JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma_17017" : "JSX fragment is not supported when using an inline JSX factory pragma", - "Circularity_detected_while_resolving_configuration_Colon_0_18000" : "Circularity detected while resolving configuration: {0}", - "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001" : "A path in an 'extends' option must be relative or rooted, but '{0}' is not.", - "The_files_list_in_config_file_0_is_empty_18002" : "The 'files' list in config file '{0}' is empty.", - "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003" : "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'.", - "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" : "File is a CommonJS module; it may be converted to an ES6 module.", - "This_constructor_function_may_be_converted_to_a_class_declaration_80002" : "This constructor function may be converted to a class declaration.", - "Import_may_be_converted_to_a_default_import_80003" : "Import may be converted to a default import.", - "JSDoc_types_may_be_moved_to_TypeScript_types_80004" : "JSDoc types may be moved to TypeScript types.", - "require_call_may_be_converted_to_an_import_80005" : "'require' call may be converted to an import.", - "Add_missing_super_call_90001" : "Add missing 'super()' call", - "Make_super_call_the_first_statement_in_the_constructor_90002" : "Make 'super()' call the first statement in the constructor", - "Change_extends_to_implements_90003" : "Change 'extends' to 'implements'", - "Remove_declaration_for_Colon_0_90004" : "Remove declaration for: '{0}'", - "Remove_import_from_0_90005" : "Remove import from '{0}'", - "Implement_interface_0_90006" : "Implement interface '{0}'", - "Implement_inherited_abstract_class_90007" : "Implement inherited abstract class", - "Add_0_to_unresolved_variable_90008" : "Add '{0}.' to unresolved variable", - "Import_0_from_module_1_90013" : "Import '{0}' from module \"{1}\"", - "Change_0_to_1_90014" : "Change '{0}' to '{1}'", - "Add_0_to_existing_import_declaration_from_1_90015" : "Add '{0}' to existing import declaration from \"{1}\"", - "Declare_property_0_90016" : "Declare property '{0}'", - "Add_index_signature_for_property_0_90017" : "Add index signature for property '{0}'", - "Disable_checking_for_this_file_90018" : "Disable checking for this file", - "Ignore_this_error_message_90019" : "Ignore this error message", - "Initialize_property_0_in_the_constructor_90020" : "Initialize property '{0}' in the constructor", - "Initialize_static_property_0_90021" : "Initialize static property '{0}'", - "Change_spelling_to_0_90022" : "Change spelling to '{0}'", - "Declare_method_0_90023" : "Declare method '{0}'", - "Declare_static_method_0_90024" : "Declare static method '{0}'", - "Prefix_0_with_an_underscore_90025" : "Prefix '{0}' with an underscore", - "Rewrite_as_the_indexed_access_type_0_90026" : "Rewrite as the indexed access type '{0}'", - "Declare_static_property_0_90027" : "Declare static property '{0}'", - "Call_decorator_expression_90028" : "Call decorator expression", - "Add_async_modifier_to_containing_function_90029" : "Add async modifier to containing function", - "Convert_function_to_an_ES2015_class_95001" : "Convert function to an ES2015 class", - "Convert_function_0_to_class_95002" : "Convert function '{0}' to class", - "Extract_to_0_in_1_95004" : "Extract to {0} in {1}", - "Extract_function_95005" : "Extract function", - "Extract_constant_95006" : "Extract constant", - "Extract_to_0_in_enclosing_scope_95007" : "Extract to {0} in enclosing scope", - "Extract_to_0_in_1_scope_95008" : "Extract to {0} in {1} scope", - "Annotate_with_type_from_JSDoc_95009" : "Annotate with type from JSDoc", - "Annotate_with_types_from_JSDoc_95010" : "Annotate with types from JSDoc", - "Infer_type_of_0_from_usage_95011" : "Infer type of '{0}' from usage", - "Infer_parameter_types_from_usage_95012" : "Infer parameter types from usage", - "Convert_to_default_import_95013" : "Convert to default import", - "Install_0_95014" : "Install '{0}'", - "Replace_import_with_0_95015" : "Replace import with '{0}'.", - "Use_synthetic_default_member_95016" : "Use synthetic 'default' member.", - "Convert_to_ES6_module_95017" : "Convert to ES6 module", - "Add_undefined_type_to_property_0_95018" : "Add 'undefined' type to property '{0}'", - "Add_initializer_to_property_0_95019" : "Add initializer to property '{0}'", - "Add_definite_assignment_assertion_to_property_0_95020" : "Add definite assignment assertion to property '{0}'", - "Add_all_missing_members_95022" : "Add all missing members", - "Infer_all_types_from_usage_95023" : "Infer all types from usage", - "Delete_all_unused_declarations_95024" : "Delete all unused declarations", - "Prefix_all_unused_declarations_with_where_possible_95025" : "Prefix all unused declarations with '_' where possible", - "Fix_all_detected_spelling_errors_95026" : "Fix all detected spelling errors", - "Add_initializers_to_all_uninitialized_properties_95027" : "Add initializers to all uninitialized properties", - "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028" : "Add definite assignment assertions to all uninitialized properties", - "Add_undefined_type_to_all_uninitialized_properties_95029" : "Add undefined type to all uninitialized properties", - "Change_all_jsdoc_style_types_to_TypeScript_95030" : "Change all jsdoc-style types to TypeScript", - "Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types_95031" : "Change all jsdoc-style types to TypeScript (and add '| undefined' to nullable types)", - "Implement_all_unimplemented_interfaces_95032" : "Implement all unimplemented interfaces", - "Install_all_missing_types_packages_95033" : "Install all missing types packages", - "Rewrite_all_as_indexed_access_types_95034" : "Rewrite all as indexed access types", - "Convert_all_to_default_imports_95035" : "Convert all to default imports", - "Make_all_super_calls_the_first_statement_in_their_constructor_95036" : "Make all 'super()' calls the first statement in their constructor", - "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037" : "Add qualifier to all unresolved variables matching a member name", - "Change_all_extended_interfaces_to_implements_95038" : "Change all extended interfaces to 'implements'", - "Add_all_missing_super_calls_95039" : "Add all missing super calls", - "Implement_all_inherited_abstract_classes_95040" : "Implement all inherited abstract classes", - "Add_all_missing_async_modifiers_95041" : "Add all missing 'async' modifiers", - "Add_ts_ignore_to_all_error_messages_95042" : "Add '@ts-ignore' to all error messages", - "Annotate_everything_with_types_from_JSDoc_95043" : "Annotate everything with types from JSDoc", - "Add_to_all_uncalled_decorators_95044" : "Add '()' to all uncalled decorators", - "Convert_all_constructor_functions_to_classes_95045" : "Convert all constructor functions to classes", - "Generate_get_and_set_accessors_95046" : "Generate 'get' and 'set' accessors", - "Convert_require_to_import_95047" : "Convert 'require' to 'import'", - "Convert_all_require_to_import_95048" : "Convert all 'require' to 'import'" -} \ No newline at end of file From 932b314f819df17dca0e8c5d738deba19c9a458b Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Mon, 29 Jun 2020 15:46:41 -0700 Subject: [PATCH 13/47] Delete lib/lib.esnext files no longer found in built/local --- lib/lib.esnext.array.d.ts | 223 ----------- lib/lib.esnext.asynciterable.d.ts | 44 --- lib/lib.esnext.bigint.d.ts | 629 ------------------------------ lib/lib.esnext.symbol.d.ts | 26 -- 4 files changed, 922 deletions(-) delete mode 100644 lib/lib.esnext.array.d.ts delete mode 100644 lib/lib.esnext.asynciterable.d.ts delete mode 100644 lib/lib.esnext.bigint.d.ts delete mode 100644 lib/lib.esnext.symbol.d.ts diff --git a/lib/lib.esnext.array.d.ts b/lib/lib.esnext.array.d.ts deleted file mode 100644 index 6c75122320954..0000000000000 --- a/lib/lib.esnext.array.d.ts +++ /dev/null @@ -1,223 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - - - -/// - - -interface ReadonlyArray { - - /** - * Calls a defined callback function on each element of an array. Then, flattens the result into - * a new array. - * This is identical to a map followed by flat with depth 1. - * - * @param callback A function that accepts up to three arguments. The flatMap method calls the - * callback function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callback function. If - * thisArg is omitted, undefined is used as the this value. - */ - flatMap ( - callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray, - thisArg?: This - ): U[] - - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: - ReadonlyArray | - - ReadonlyArray> | - ReadonlyArray[]> | - ReadonlyArray[][]> | - ReadonlyArray[][][]> | - - ReadonlyArray>> | - ReadonlyArray[][]>> | - ReadonlyArray>[][]> | - ReadonlyArray[]>[]> | - ReadonlyArray>[]> | - ReadonlyArray[]>> | - - ReadonlyArray>>> | - ReadonlyArray[]>>> | - ReadonlyArray>[]>> | - ReadonlyArray>>[]> | - - ReadonlyArray>>>>, - depth: 4): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: - ReadonlyArray | - - ReadonlyArray[][]> | - ReadonlyArray[]> | - ReadonlyArray> | - - ReadonlyArray>> | - ReadonlyArray[]>> | - ReadonlyArray>[]> | - - ReadonlyArray>>>, - depth: 3): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: - ReadonlyArray | - - ReadonlyArray> | - ReadonlyArray[]> | - - ReadonlyArray>>, - depth: 2): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: - ReadonlyArray | - ReadonlyArray>, - depth?: 1 - ): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: - ReadonlyArray, - depth: 0 - ): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. If no depth is provided, flat method defaults to the depth of 1. - * - * @param depth The maximum recursion depth - */ - flat(depth?: number): any[]; - } - -interface Array { - - /** - * Calls a defined callback function on each element of an array. Then, flattens the result into - * a new array. - * This is identical to a map followed by flat with depth 1. - * - * @param callback A function that accepts up to three arguments. The flatMap method calls the - * callback function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callback function. If - * thisArg is omitted, undefined is used as the this value. - */ - flatMap ( - callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray, - thisArg?: This - ): U[] - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: U[][][][][][][][], depth: 7): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: U[][][][][][][], depth: 6): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: U[][][][][][], depth: 5): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: U[][][][][], depth: 4): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: U[][][][], depth: 3): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: U[][][], depth: 2): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: U[][], depth?: 1): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. - * - * @param depth The maximum recursion depth - */ - flat(this: U[], depth: 0): U[]; - - /** - * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. If no depth is provided, flat method defaults to the depth of 1. - * - * @param depth The maximum recursion depth - */ - flat(depth?: number): any[]; -} diff --git a/lib/lib.esnext.asynciterable.d.ts b/lib/lib.esnext.asynciterable.d.ts deleted file mode 100644 index 38e12a7caf638..0000000000000 --- a/lib/lib.esnext.asynciterable.d.ts +++ /dev/null @@ -1,44 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - - - -/// - - -/// -/// - -interface SymbolConstructor { - /** - * A method that returns the default async iterator for an object. Called by the semantics of - * the for-await-of statement. - */ - readonly asyncIterator: symbol; -} - -interface AsyncIterator { - next(value?: any): Promise>; - return?(value?: any): Promise>; - throw?(e?: any): Promise>; -} - -interface AsyncIterable { - [Symbol.asyncIterator](): AsyncIterator; -} - -interface AsyncIterableIterator extends AsyncIterator { - [Symbol.asyncIterator](): AsyncIterableIterator; -} \ No newline at end of file diff --git a/lib/lib.esnext.bigint.d.ts b/lib/lib.esnext.bigint.d.ts deleted file mode 100644 index 50967de98fea7..0000000000000 --- a/lib/lib.esnext.bigint.d.ts +++ /dev/null @@ -1,629 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - - - -/// - - -interface BigInt { - /** - * Returns a string representation of an object. - * @param radix Specifies a radix for converting numeric values to strings. - */ - toString(radix?: number): string; - - /** Returns a string representation appropriate to the host environment's current locale. */ - toLocaleString(): string; - - /** Returns the primitive value of the specified object. */ - valueOf(): bigint; - - readonly [Symbol.toStringTag]: "BigInt"; -} - -interface BigIntConstructor { - (value?: any): bigint; - readonly prototype: BigInt; - - /** - * Interprets the low bits of a BigInt as a 2's-complement signed integer. - * All higher bits are discarded. - * @param bits The number of low bits to use - * @param int The BigInt whose bits to extract - */ - asIntN(bits: number, int: bigint): bigint; - /** - * Interprets the low bits of a BigInt as an unsigned integer. - * All higher bits are discarded. - * @param bits The number of low bits to use - * @param int The BigInt whose bits to extract - */ - asUintN(bits: number, int: bigint): bigint; -} - -declare var BigInt: BigIntConstructor; - -/** - * A typed array of 64-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated, an exception is raised. - */ -interface BigInt64Array { - /** The size in bytes of each element in the array. */ - readonly BYTES_PER_ELEMENT: number; - - /** The ArrayBuffer instance referenced by the array. */ - readonly buffer: ArrayBufferLike; - - /** The length in bytes of the array. */ - readonly byteLength: number; - - /** The offset in bytes of the array. */ - readonly byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): this; - - /** Yields index, value pairs for every entry in the array. */ - entries(): IterableIterator<[number, bigint]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in the array until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: bigint, start?: number, end?: number): this; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: bigint, index: number, array: BigInt64Array) => any, thisArg?: any): BigInt64Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): bigint | undefined; - - /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: bigint, index: number, array: BigInt64Array) => void, thisArg?: any): void; - - /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ - includes(searchElement: bigint, fromIndex?: number): boolean; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: bigint, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** Yields each index in the array. */ - keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: bigint, fromIndex?: number): number; - - /** The length of the array. */ - readonly length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, thisArg?: any): BigInt64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; - - /** Reverses the elements in the array. */ - reverse(): this; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: ArrayLike, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): BigInt64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in the array until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts the array. - * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. - */ - sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this; - - /** - * Gets a new BigInt64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): BigInt64Array; - - /** Converts the array to a string by using the current locale. */ - toLocaleString(): string; - - /** Returns a string representation of the array. */ - toString(): string; - - /** Yields each value in the array. */ - values(): IterableIterator; - - [Symbol.iterator](): IterableIterator; - - readonly [Symbol.toStringTag]: "BigInt64Array"; - - [index: number]: bigint; -} - -interface BigInt64ArrayConstructor { - readonly prototype: BigInt64Array; - new(length?: number): BigInt64Array; - new(array: Iterable): BigInt64Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigInt64Array; - - /** The size in bytes of each element in the array. */ - readonly BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: bigint[]): BigInt64Array; - - /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ - from(arrayLike: ArrayLike): BigInt64Array; - from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array; -} - -declare var BigInt64Array: BigInt64ArrayConstructor; - -/** - * A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated, an exception is raised. - */ -interface BigUint64Array { - /** The size in bytes of each element in the array. */ - readonly BYTES_PER_ELEMENT: number; - - /** The ArrayBuffer instance referenced by the array. */ - readonly buffer: ArrayBufferLike; - - /** The length in bytes of the array. */ - readonly byteLength: number; - - /** The offset in bytes of the array. */ - readonly byteOffset: number; - - /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ - copyWithin(target: number, start: number, end?: number): this; - - /** Yields index, value pairs for every entry in the array. */ - entries(): IterableIterator<[number, bigint]>; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in the array until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; - - /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ - fill(value: bigint, start?: number, end?: number): this; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: bigint, index: number, array: BigUint64Array) => any, thisArg?: any): BigUint64Array; - - /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - find(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): bigint | undefined; - - /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ - findIndex(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): number; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: bigint, index: number, array: BigUint64Array) => void, thisArg?: any): void; - - /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ - includes(searchElement: bigint, fromIndex?: number): boolean; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - indexOf(searchElement: bigint, fromIndex?: number): number; - - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - - /** Yields each index in the array. */ - keys(): IterableIterator; - - /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ - lastIndexOf(searchElement: bigint, fromIndex?: number): number; - - /** The length of the array. */ - readonly length: number; - - /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, thisArg?: any): BigUint64Array; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; - - /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; - - /** Reverses the elements in the array. */ - reverse(): this; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: ArrayLike, offset?: number): void; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): BigUint64Array; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in the array until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; - - /** - * Sorts the array. - * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. - */ - sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this; - - /** - * Gets a new BigUint64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): BigUint64Array; - - /** Converts the array to a string by using the current locale. */ - toLocaleString(): string; - - /** Returns a string representation of the array. */ - toString(): string; - - /** Yields each value in the array. */ - values(): IterableIterator; - - [Symbol.iterator](): IterableIterator; - - readonly [Symbol.toStringTag]: "BigUint64Array"; - - [index: number]: bigint; -} - -interface BigUint64ArrayConstructor { - readonly prototype: BigUint64Array; - new(length?: number): BigUint64Array; - new(array: Iterable): BigUint64Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigUint64Array; - - /** The size in bytes of each element in the array. */ - readonly BYTES_PER_ELEMENT: number; - - /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ - of(...items: bigint[]): BigUint64Array; - - /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ - from(arrayLike: ArrayLike): BigUint64Array; - from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array; -} - -declare var BigUint64Array: BigUint64ArrayConstructor; - -interface DataView { - /** - * Gets the BigInt64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getBigInt64(byteOffset: number, littleEndian?: boolean): bigint; - - /** - * Gets the BigUint64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getBigUint64(byteOffset: number, littleEndian?: boolean): bigint; - - /** - * Stores a BigInt64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void; - - /** - * Stores a BigUint64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ - setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void; -} diff --git a/lib/lib.esnext.symbol.d.ts b/lib/lib.esnext.symbol.d.ts deleted file mode 100644 index 98293eaf5721a..0000000000000 --- a/lib/lib.esnext.symbol.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - - - -/// - - -interface Symbol { - /** - * expose the [[Description]] internal slot of a symbol directly - */ - readonly description: string; -} From 784396ce9594ee49d3c5cdcf785cf194500dfbda Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 29 Jun 2020 17:38:41 -0700 Subject: [PATCH 14/47] Infer implied arity before inferring from 'this' argument (#39328) * Infer implied arity before inferring from 'this' argument * Add regression test --- src/compiler/checker.ts | 15 +++---- .../reference/variadicTuples1.errors.txt | 10 +++++ tests/baselines/reference/variadicTuples1.js | 17 ++++++++ .../reference/variadicTuples1.symbols | 40 +++++++++++++++++++ .../baselines/reference/variadicTuples1.types | 25 ++++++++++++ .../types/tuple/variadicTuples1.ts | 10 +++++ 6 files changed, 110 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3ad58313c4cc8..949af06d12167 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25773,13 +25773,6 @@ namespace ts { } } - const thisType = getThisTypeOfSignature(signature); - if (thisType) { - const thisArgumentNode = getThisArgumentOfCall(node); - const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; - inferTypes(context.inferences, thisArgumentType, thisType); - } - const restType = getNonArrayRestType(signature); const argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; if (restType && restType.flags & TypeFlags.TypeParameter) { @@ -25788,6 +25781,14 @@ namespace ts { info.impliedArity = findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined; } } + + const thisType = getThisTypeOfSignature(signature); + if (thisType) { + const thisArgumentNode = getThisArgumentOfCall(node); + const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; + inferTypes(context.inferences, thisArgumentType, thisType); + } + for (let i = 0; i < argCount; i++) { const arg = args[i]; if (arg.kind !== SyntaxKind.OmittedExpression) { diff --git a/tests/baselines/reference/variadicTuples1.errors.txt b/tests/baselines/reference/variadicTuples1.errors.txt index eac8f5ef32a5f..8468cabd7119b 100644 --- a/tests/baselines/reference/variadicTuples1.errors.txt +++ b/tests/baselines/reference/variadicTuples1.errors.txt @@ -463,4 +463,14 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(342,19): error TS2322: Ty let v2 = f22(["foo", "bar"]); // [string, string] let v3 = f22(["foo", 42]); // [string] } + + // Repro from #39327 + + interface Desc { + readonly f: (...args: A) => T; + bind(this: Desc<[...T, ...U], R>, ...args: T): Desc<[...U], R>; + } + + declare const a: Desc<[string, number, boolean], object>; + const b = a.bind("", 1); // Desc<[boolean], object> \ No newline at end of file diff --git a/tests/baselines/reference/variadicTuples1.js b/tests/baselines/reference/variadicTuples1.js index f7d388ea5ae86..be8cf4838eea3 100644 --- a/tests/baselines/reference/variadicTuples1.js +++ b/tests/baselines/reference/variadicTuples1.js @@ -351,6 +351,16 @@ function f23(args: [...U, number]) { let v2 = f22(["foo", "bar"]); // [string, string] let v3 = f22(["foo", 42]); // [string] } + +// Repro from #39327 + +interface Desc { + readonly f: (...args: A) => T; + bind(this: Desc<[...T, ...U], R>, ...args: T): Desc<[...U], R>; +} + +declare const a: Desc<[string, number, boolean], object>; +const b = a.bind("", 1); // Desc<[boolean], object> //// [variadicTuples1.js] @@ -557,6 +567,7 @@ function f23(args) { var v2 = f22(["foo", "bar"]); // [string, string] var v3 = f22(["foo", 42]); // [string] } +var b = a.bind("", 1); // Desc<[boolean], object> //// [variadicTuples1.d.ts] @@ -703,3 +714,9 @@ declare function f21(args: [...U, number?]): void; declare function f22(args: [...T, number]): T; declare function f22(args: [...T]): T; declare function f23(args: [...U, number]): void; +interface Desc { + readonly f: (...args: A) => T; + bind(this: Desc<[...T, ...U], R>, ...args: T): Desc<[...U], R>; +} +declare const a: Desc<[string, number, boolean], object>; +declare const b: Desc<[boolean], object>; diff --git a/tests/baselines/reference/variadicTuples1.symbols b/tests/baselines/reference/variadicTuples1.symbols index 0f6c900fb6cdf..e7c9db73fc13f 100644 --- a/tests/baselines/reference/variadicTuples1.symbols +++ b/tests/baselines/reference/variadicTuples1.symbols @@ -1204,3 +1204,43 @@ function f23(args: [...U, number]) { >f22 : Symbol(f22, Decl(variadicTuples1.ts, 342, 1), Decl(variadicTuples1.ts, 344, 72)) } +// Repro from #39327 + +interface Desc { +>Desc : Symbol(Desc, Decl(variadicTuples1.ts, 351, 1)) +>A : Symbol(A, Decl(variadicTuples1.ts, 355, 15)) +>T : Symbol(T, Decl(variadicTuples1.ts, 355, 35)) + + readonly f: (...args: A) => T; +>f : Symbol(Desc.f, Decl(variadicTuples1.ts, 355, 40)) +>args : Symbol(args, Decl(variadicTuples1.ts, 356, 17)) +>A : Symbol(A, Decl(variadicTuples1.ts, 355, 15)) +>T : Symbol(T, Decl(variadicTuples1.ts, 355, 35)) + + bind(this: Desc<[...T, ...U], R>, ...args: T): Desc<[...U], R>; +>bind : Symbol(Desc.bind, Decl(variadicTuples1.ts, 356, 34)) +>T : Symbol(T, Decl(variadicTuples1.ts, 357, 9)) +>U : Symbol(U, Decl(variadicTuples1.ts, 357, 29)) +>R : Symbol(R, Decl(variadicTuples1.ts, 357, 50)) +>this : Symbol(this, Decl(variadicTuples1.ts, 357, 54)) +>Desc : Symbol(Desc, Decl(variadicTuples1.ts, 351, 1)) +>T : Symbol(T, Decl(variadicTuples1.ts, 357, 9)) +>U : Symbol(U, Decl(variadicTuples1.ts, 357, 29)) +>R : Symbol(R, Decl(variadicTuples1.ts, 357, 50)) +>args : Symbol(args, Decl(variadicTuples1.ts, 357, 82)) +>T : Symbol(T, Decl(variadicTuples1.ts, 357, 9)) +>Desc : Symbol(Desc, Decl(variadicTuples1.ts, 351, 1)) +>U : Symbol(U, Decl(variadicTuples1.ts, 357, 29)) +>R : Symbol(R, Decl(variadicTuples1.ts, 357, 50)) +} + +declare const a: Desc<[string, number, boolean], object>; +>a : Symbol(a, Decl(variadicTuples1.ts, 360, 13)) +>Desc : Symbol(Desc, Decl(variadicTuples1.ts, 351, 1)) + +const b = a.bind("", 1); // Desc<[boolean], object> +>b : Symbol(b, Decl(variadicTuples1.ts, 361, 5)) +>a.bind : Symbol(Desc.bind, Decl(variadicTuples1.ts, 356, 34)) +>a : Symbol(a, Decl(variadicTuples1.ts, 360, 13)) +>bind : Symbol(Desc.bind, Decl(variadicTuples1.ts, 356, 34)) + diff --git a/tests/baselines/reference/variadicTuples1.types b/tests/baselines/reference/variadicTuples1.types index 0c24e873ef8b5..6882761339374 100644 --- a/tests/baselines/reference/variadicTuples1.types +++ b/tests/baselines/reference/variadicTuples1.types @@ -1254,3 +1254,28 @@ function f23(args: [...U, number]) { >42 : 42 } +// Repro from #39327 + +interface Desc { + readonly f: (...args: A) => T; +>f : (...args: A) => T +>args : A + + bind(this: Desc<[...T, ...U], R>, ...args: T): Desc<[...U], R>; +>bind : (this: Desc<[...T, ...U], R>, ...args: T) => Desc<[...U], R> +>this : Desc<[...T, ...U], R> +>args : T +} + +declare const a: Desc<[string, number, boolean], object>; +>a : Desc<[string, number, boolean], object> + +const b = a.bind("", 1); // Desc<[boolean], object> +>b : Desc<[boolean], object> +>a.bind("", 1) : Desc<[boolean], object> +>a.bind : (this: Desc<[...T, ...U], R>, ...args: T) => Desc<[...U], R> +>a : Desc<[string, number, boolean], object> +>bind : (this: Desc<[...T, ...U], R>, ...args: T) => Desc<[...U], R> +>"" : "" +>1 : 1 + diff --git a/tests/cases/conformance/types/tuple/variadicTuples1.ts b/tests/cases/conformance/types/tuple/variadicTuples1.ts index 07732a0a5a726..e6562f20ccc4c 100644 --- a/tests/cases/conformance/types/tuple/variadicTuples1.ts +++ b/tests/cases/conformance/types/tuple/variadicTuples1.ts @@ -353,3 +353,13 @@ function f23(args: [...U, number]) { let v2 = f22(["foo", "bar"]); // [string, string] let v3 = f22(["foo", 42]); // [string] } + +// Repro from #39327 + +interface Desc { + readonly f: (...args: A) => T; + bind(this: Desc<[...T, ...U], R>, ...args: T): Desc<[...U], R>; +} + +declare const a: Desc<[string, number, boolean], object>; +const b = a.bind("", 1); // Desc<[boolean], object> From 21a26ca08a9bce10845e7f6c700557a61ce69412 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Sun, 28 Jun 2020 11:36:59 +0300 Subject: [PATCH 15/47] feat(25259): add better error to report for equals instead of the colon in object literals --- src/compiler/checker.ts | 7 ++-- src/compiler/diagnosticMessages.json | 6 +++- .../codefixes/fixPropertyAssignment.ts | 28 +++++++++++++++ src/services/tsconfig.json | 1 + ...pertyAssignmentsInDestructuring.errors.txt | 9 ++--- ...ndPropertyAssignmentsInDestructuring.types | 4 +-- ...yAssignmentsInDestructuring_ES6.errors.txt | 9 ++--- ...opertyAssignmentsInDestructuring_ES6.types | 4 +-- .../fourslash/codeFixPropertyAssignment1.ts | 14 ++++++++ .../fourslash/codeFixPropertyAssignment2.ts | 14 ++++++++ .../fourslash/codeFixPropertyAssignment3.ts | 18 ++++++++++ .../codeFixPropertyAssignment_fixAll.ts | 34 +++++++++++++++++++ 12 files changed, 129 insertions(+), 19 deletions(-) create mode 100644 src/services/codefixes/fixPropertyAssignment.ts create mode 100644 tests/cases/fourslash/codeFixPropertyAssignment1.ts create mode 100644 tests/cases/fourslash/codeFixPropertyAssignment2.ts create mode 100644 tests/cases/fourslash/codeFixPropertyAssignment3.ts create mode 100644 tests/cases/fourslash/codeFixPropertyAssignment_fixAll.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa0091f99523a..6a667916b38d2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23889,7 +23889,10 @@ namespace ts { memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment || isObjectLiteralMethod(memberDecl)) { let type = memberDecl.kind === SyntaxKind.PropertyAssignment ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring + // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. + // we don't want to say "could not find 'a'". + memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -38218,7 +38221,7 @@ namespace ts { if (prop.kind === SyntaxKind.ShorthandPropertyAssignment && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error - return grammarErrorOnNode(prop.equalsToken!, Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); + return grammarErrorOnNode(prop.equalsToken!, Diagnostics.Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuring_assignment); } if (name.kind === SyntaxKind.PrivateIdentifier) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b32e8d020290b..dc21a3581324a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -880,7 +880,7 @@ "category": "Error", "code": 1308 }, - "'=' can only be used in an object literal property inside a destructuring assignment.": { + "Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.": { "category": "Error", "code": 1312 }, @@ -5819,6 +5819,10 @@ "category": "Message", "code": 95137 }, + "Switch each misused '{0}' to '{1}'": { + "category": "Message", + "code": 95138 + }, "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": { "category": "Error", diff --git a/src/services/codefixes/fixPropertyAssignment.ts b/src/services/codefixes/fixPropertyAssignment.ts new file mode 100644 index 0000000000000..ee46d90858b83 --- /dev/null +++ b/src/services/codefixes/fixPropertyAssignment.ts @@ -0,0 +1,28 @@ +/* @internal */ +namespace ts.codefix { + const fixId = "fixPropertyAssignment"; + const errorCodes = [ + Diagnostics.Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuring_assignment.code + ]; + + registerCodeFix({ + errorCodes, + fixIds: [fixId], + getCodeActions(context) { + const { sourceFile, span } = context; + const property = getProperty(sourceFile, span.start); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, property)); + return [createCodeFixAction(fixId, changes, [Diagnostics.Change_0_to_1, "=", ":"], fixId, [Diagnostics.Switch_each_misused_0_to_1, "=", ":"])]; + }, + getAllCodeActions: context => + codeFixAll(context, errorCodes, (changes, diag) => doChange(changes, diag.file, getProperty(diag.file, diag.start))) + }); + + function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, node: ShorthandPropertyAssignment): void { + changes.replaceNode(sourceFile, node, factory.createPropertyAssignment(node.name, node.objectAssignmentInitializer as Expression)); + } + + function getProperty(sourceFile: SourceFile, pos: number): ShorthandPropertyAssignment { + return cast(getTokenAtPosition(sourceFile, pos).parent, isShorthandPropertyAssignment); + } +} diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 9567185c7a9ac..e1aab52f187f1 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -76,6 +76,7 @@ "codefixes/fixEnableExperimentalDecorators.ts", "codefixes/fixEnableJsxFlag.ts", "codefixes/fixModuleAndTargetOptions.ts", + "codefixes/fixPropertyAssignment.ts", "codefixes/fixExtendsInterfaceBecomesImplements.ts", "codefixes/fixForgottenThisPropertyAccess.ts", "codefixes/fixInvalidJsxCharacters.ts", diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt index cb22c03a20b60..ba8af08a9cbf3 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt @@ -11,11 +11,10 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(85,19): erro Types of property 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,12): error TS18004: No value exists in scope for the shorthand property 's'. Either declare one or provide an initializer. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: '=' can only be used in an object literal property inside a destructuring assignment. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment. -==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts (13 errors) ==== +==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts (12 errors) ==== (function() { var s0; for ({ s0 = 5 } of [{ s0: 1 }]) { @@ -153,10 +152,8 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,14): err (function() { let a = { s = 5 }; - ~ -!!! error TS18004: No value exists in scope for the shorthand property 's'. Either declare one or provide an initializer. ~ -!!! error TS1312: '=' can only be used in an object literal property inside a destructuring assignment. +!!! error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment. }); function foo({a = 4, b = { x: 5 }}) { diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types index b160cd31b1290..9e44644904c41 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types @@ -417,8 +417,8 @@ >function() { let a = { s = 5 };} : () => void let a = { s = 5 }; ->a : { s: any; } ->{ s = 5 } : { s: any; } +>a : { s: number; } +>{ s = 5 } : { s: number; } >s : any >5 : 5 diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt index fb368df29c380..d6b0da61711cb 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt @@ -11,11 +11,10 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,19): Types of property 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,12): error TS18004: No value exists in scope for the shorthand property 's'. Either declare one or provide an initializer. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: '=' can only be used in an object literal property inside a destructuring assignment. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment. -==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts (13 errors) ==== +==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts (12 errors) ==== (function() { var s0; for ({ s0 = 5 } of [{ s0: 1 }]) { @@ -153,10 +152,8 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): (function() { let a = { s = 5 }; - ~ -!!! error TS18004: No value exists in scope for the shorthand property 's'. Either declare one or provide an initializer. ~ -!!! error TS1312: '=' can only be used in an object literal property inside a destructuring assignment. +!!! error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment. }); function foo({a = 4, b = { x: 5 }}) { diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types index 1cdc84e83ba71..68ff6a0a26a7f 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types @@ -417,8 +417,8 @@ >function() { let a = { s = 5 };} : () => void let a = { s = 5 }; ->a : { s: any; } ->{ s = 5 } : { s: any; } +>a : { s: number; } +>{ s = 5 } : { s: number; } >s : any >5 : 5 diff --git a/tests/cases/fourslash/codeFixPropertyAssignment1.ts b/tests/cases/fourslash/codeFixPropertyAssignment1.ts new file mode 100644 index 0000000000000..3745a91f7540a --- /dev/null +++ b/tests/cases/fourslash/codeFixPropertyAssignment1.ts @@ -0,0 +1,14 @@ +/// + +////const a = { +//// x/**/= 1 +////} + +verify.codeFix({ + description: [ts.Diagnostics.Change_0_to_1.message, "=", ":"], + index: 0, + newFileContent: +`const a = { + x: 1 +}`, +}); diff --git a/tests/cases/fourslash/codeFixPropertyAssignment2.ts b/tests/cases/fourslash/codeFixPropertyAssignment2.ts new file mode 100644 index 0000000000000..233e612a9a054 --- /dev/null +++ b/tests/cases/fourslash/codeFixPropertyAssignment2.ts @@ -0,0 +1,14 @@ +/// + +////const a = { +//// x /**/= 1 +////} + +verify.codeFix({ + description: [ts.Diagnostics.Change_0_to_1.message, "=", ":"], + index: 0, + newFileContent: +`const a = { + x: 1 +}`, +}); diff --git a/tests/cases/fourslash/codeFixPropertyAssignment3.ts b/tests/cases/fourslash/codeFixPropertyAssignment3.ts new file mode 100644 index 0000000000000..8346230588e22 --- /dev/null +++ b/tests/cases/fourslash/codeFixPropertyAssignment3.ts @@ -0,0 +1,18 @@ +/// + +////const a = { +//// x: 1, +//// y /**/= 1, +//// z: 1 +////} + +verify.codeFix({ + description: [ts.Diagnostics.Change_0_to_1.message, "=", ":"], + index: 0, + newFileContent: +`const a = { + x: 1, + y: 1, + z: 1 +}`, +}); diff --git a/tests/cases/fourslash/codeFixPropertyAssignment_fixAll.ts b/tests/cases/fourslash/codeFixPropertyAssignment_fixAll.ts new file mode 100644 index 0000000000000..5cf54db26b1be --- /dev/null +++ b/tests/cases/fourslash/codeFixPropertyAssignment_fixAll.ts @@ -0,0 +1,34 @@ +/// + +////const a = { +//// x: 1, +//// y = 1, +//// z: 1 +////} +////const b = { +//// x = 1, +//// y: 1 +////} +////const c = { +//// x: 1, +//// y = 1 +////} + +verify.codeFixAll({ + fixAllDescription: "Switch each misused '=' to ':'", + fixId: "fixPropertyAssignment", + newFileContent: +`const a = { + x: 1, + y: 1, + z: 1 +} +const b = { + x: 1, + y: 1 +} +const c = { + x: 1, + y: 1 +}` +}); From ef40ed1ee6fa5d6546e8c24ecd8748569e89edf8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 26 May 2020 22:49:10 +0000 Subject: [PATCH 16/47] Exempt bare 'boolean's from the check. --- src/compiler/checker.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 949af06d12167..c8ae32d35a00c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17833,6 +17833,13 @@ namespace ts { } function typeCouldHaveTopLevelSingletonTypes(type: Type): boolean { + // Okay, yes, 'boolean' is a union of 'true | false', but that's not useful + // in error reporting scenarios. If you need to use this function but that detail matters, + // feel free to add a flag. + if (type.flags & TypeFlags.Boolean) { + return false; + } + if (type.flags & TypeFlags.UnionOrIntersection) { return !!forEach((type as IntersectionType).types, typeCouldHaveTopLevelSingletonTypes); } From 915d4fc06068a0be7bb9db70b23699e0c347e58c Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 26 May 2020 22:50:13 +0000 Subject: [PATCH 17/47] Accepted baselines. --- .../conditionalExpression1.errors.txt | 8 +++--- tests/baselines/reference/for-of46.errors.txt | 4 +-- .../generatorExplicitReturnType.errors.txt | 4 +-- .../reference/jsdocInTypeScript.errors.txt | 4 +-- .../reference/jsdocIndexSignature.errors.txt | 4 +-- .../reference/jsdocPrivateName1.errors.txt | 4 +-- .../matchReturnTypeInAllBranches.errors.txt | 4 +-- .../reference/parser15.4.4.14-9-2.errors.txt | 16 +++++------ ...eadonlyTupleAndArrayElaboration.errors.txt | 12 ++++---- ...estParameterWithBindingPattern3.errors.txt | 4 +-- ...tringsWithIncompatibleTypedTags.errors.txt | 28 +++++++++---------- ...ngsWithIncompatibleTypedTagsES6.errors.txt | 28 +++++++++---------- .../typeGuardFunctionErrors.errors.txt | 4 +-- .../reference/variadicTuples1.errors.txt | 4 +-- 14 files changed, 64 insertions(+), 64 deletions(-) diff --git a/tests/baselines/reference/conditionalExpression1.errors.txt b/tests/baselines/reference/conditionalExpression1.errors.txt index 2b34212952382..c49cdf0bb1ea1 100644 --- a/tests/baselines/reference/conditionalExpression1.errors.txt +++ b/tests/baselines/reference/conditionalExpression1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2322: Type '1 | ""' is not assignable to type 'boolean'. - Type '1' is not assignable to type 'boolean'. +tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2322: Type 'string | number' is not assignable to type 'boolean'. + Type 'number' is not assignable to type 'boolean'. ==== tests/cases/compiler/conditionalExpression1.ts (1 errors) ==== var x: boolean = (true ? 1 : ""); // should be an error ~ -!!! error TS2322: Type '1 | ""' is not assignable to type 'boolean'. -!!! error TS2322: Type '1' is not assignable to type 'boolean'. \ No newline at end of file +!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of46.errors.txt b/tests/baselines/reference/for-of46.errors.txt index ad9304026a6d7..13685b122ca7e 100644 --- a/tests/baselines/reference/for-of46.errors.txt +++ b/tests/baselines/reference/for-of46.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/for-ofStatements/for-of46.ts(3,7): error TS2322: Type 'boolean' is not assignable to type 'string'. -tests/cases/conformance/es6/for-ofStatements/for-of46.ts(3,18): error TS2322: Type '""' is not assignable to type 'boolean'. +tests/cases/conformance/es6/for-ofStatements/for-of46.ts(3,18): error TS2322: Type 'string' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/for-ofStatements/for-of46.ts (2 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of46.ts(3,18): error TS2322: Ty ~ !!! error TS2322: Type 'boolean' is not assignable to type 'string'. ~ -!!! error TS2322: Type '""' is not assignable to type 'boolean'. +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. k; v; } \ No newline at end of file diff --git a/tests/baselines/reference/generatorExplicitReturnType.errors.txt b/tests/baselines/reference/generatorExplicitReturnType.errors.txt index 558ccf56bfd7d..00726482a0c56 100644 --- a/tests/baselines/reference/generatorExplicitReturnType.errors.txt +++ b/tests/baselines/reference/generatorExplicitReturnType.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/generators/generatorExplicitReturnType.ts(2,5): error TS2322: Type 'undefined' is not assignable to type 'number'. tests/cases/conformance/generators/generatorExplicitReturnType.ts(3,11): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/generators/generatorExplicitReturnType.ts(4,11): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/generators/generatorExplicitReturnType.ts(5,5): error TS2322: Type '10' is not assignable to type 'boolean'. +tests/cases/conformance/generators/generatorExplicitReturnType.ts(5,5): error TS2322: Type 'number' is not assignable to type 'boolean'. tests/cases/conformance/generators/generatorExplicitReturnType.ts(16,11): error TS2322: Type 'symbol' is not assignable to type 'number'. @@ -18,7 +18,7 @@ tests/cases/conformance/generators/generatorExplicitReturnType.ts(16,11): error !!! error TS2322: Type 'string' is not assignable to type 'number'. return 10; // error ~~~~~~~~~~ -!!! error TS2322: Type '10' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. } function* g2(): Generator { diff --git a/tests/baselines/reference/jsdocInTypeScript.errors.txt b/tests/baselines/reference/jsdocInTypeScript.errors.txt index 38f3f136b9e34..1b15d2d0502ff 100644 --- a/tests/baselines/reference/jsdocInTypeScript.errors.txt +++ b/tests/baselines/reference/jsdocInTypeScript.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/jsdocInTypeScript.ts(16,23): error TS2304: Cannot find name 'MyType'. tests/cases/compiler/jsdocInTypeScript.ts(23,33): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. -tests/cases/compiler/jsdocInTypeScript.ts(25,3): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/compiler/jsdocInTypeScript.ts(25,3): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. tests/cases/compiler/jsdocInTypeScript.ts(25,15): error TS2339: Property 'length' does not exist on type 'number'. tests/cases/compiler/jsdocInTypeScript.ts(30,3): error TS2339: Property 'x' does not exist on type '{}'. tests/cases/compiler/jsdocInTypeScript.ts(42,12): error TS2503: Cannot find namespace 'N'. @@ -37,7 +37,7 @@ tests/cases/compiler/jsdocInTypeScript.ts(42,12): error TS2503: Cannot find name // Should fail, because it takes a boolean and returns a number f(1); f(true).length; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. ~~~~~~ !!! error TS2339: Property 'length' does not exist on type 'number'. diff --git a/tests/baselines/reference/jsdocIndexSignature.errors.txt b/tests/baselines/reference/jsdocIndexSignature.errors.txt index de336795b3e64..c47bd5a31dd4f 100644 --- a/tests/baselines/reference/jsdocIndexSignature.errors.txt +++ b/tests/baselines/reference/jsdocIndexSignature.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsdoc/indices.js(9,5): error TS2322: Type '1' is not assignable to type 'boolean'. +tests/cases/conformance/jsdoc/indices.js(9,5): error TS2322: Type 'number' is not assignable to type 'boolean'. ==== tests/cases/conformance/jsdoc/indices.js (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/jsdoc/indices.js(9,5): error TS2322: Type '1' is not ass function f(o) { o.foo = 1; // error ~~~~~ -!!! error TS2322: Type '1' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. o.bar = false; // ok } \ No newline at end of file diff --git a/tests/baselines/reference/jsdocPrivateName1.errors.txt b/tests/baselines/reference/jsdocPrivateName1.errors.txt index 503b1fdb3d6f4..8e9d2c6c164c7 100644 --- a/tests/baselines/reference/jsdocPrivateName1.errors.txt +++ b/tests/baselines/reference/jsdocPrivateName1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsdoc/jsdocPrivateName1.js(3,5): error TS2322: Type '3' is not assignable to type 'boolean'. +tests/cases/conformance/jsdoc/jsdocPrivateName1.js(3,5): error TS2322: Type 'number' is not assignable to type 'boolean'. ==== tests/cases/conformance/jsdoc/jsdocPrivateName1.js (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/conformance/jsdoc/jsdocPrivateName1.js(3,5): error TS2322: Type '3' /** @type {boolean} some number value */ #foo = 3 // Error because not assignable to boolean ~~~~ -!!! error TS2322: Type '3' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. } \ No newline at end of file diff --git a/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt b/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt index 6cf1bbc5fa3d6..3f7382919401f 100644 --- a/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt +++ b/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,13): error TS2322: Type '12345' is not assignable to type 'boolean'. +tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,13): error TS2322: Type 'number' is not assignable to type 'boolean'. ==== tests/cases/compiler/matchReturnTypeInAllBranches.ts (1 errors) ==== @@ -33,7 +33,7 @@ tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,13): error TS2322: Type { return 12345; ~~~~~~~~~~~~~ -!!! error TS2322: Type '12345' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. } } } diff --git a/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt b/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt index db526dd3e1522..ef37fd3e96450 100644 --- a/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt +++ b/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(16,42): error TS2345: Argument of type '"0"' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(16,42): error TS2345: Argument of type 'string' is not assignable to parameter of type 'boolean'. tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(17,17): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(18,17): error TS2345: Argument of type '0' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(19,17): error TS2345: Argument of type '0' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(20,17): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(18,17): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(19,17): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(20,17): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error TS2304: Cannot find name 'runTestCase'. @@ -24,19 +24,19 @@ tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error T var _float = -(4/3); var a = new Array(false,undefined,null,"0",obj,-1.3333333333333, "str",-0,true,+0, one, 1,0, false, _float, -(4/3)); ~~~ -!!! error TS2345: Argument of type '"0"' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'boolean'. if (a.indexOf(-(4/3)) === 14 && // a[14]=_float===-(4/3) ~~~~~~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. a.indexOf(0) === 7 && // a[7] = +0, 0===+0 ~ -!!! error TS2345: Argument of type '0' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. a.indexOf(-0) === 7 && // a[7] = +0, -0===+0 ~~ -!!! error TS2345: Argument of type '0' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. a.indexOf(1) === 10 ) // a[10] =one=== 1 ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. { return true; } diff --git a/tests/baselines/reference/readonlyTupleAndArrayElaboration.errors.txt b/tests/baselines/reference/readonlyTupleAndArrayElaboration.errors.txt index 833b39cf7e032..05cff73f9dcac 100644 --- a/tests/baselines/reference/readonlyTupleAndArrayElaboration.errors.txt +++ b/tests/baselines/reference/readonlyTupleAndArrayElaboration.errors.txt @@ -25,12 +25,12 @@ tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(45,7): error TS2322: Ty tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(48,7): error TS2322: Type 'number[]' is not assignable to type 'boolean[]'. Type 'number' is not assignable to type 'boolean'. tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(51,7): error TS2322: Type 'readonly [1]' is not assignable to type 'readonly boolean[]'. - Type '1' is not assignable to type 'boolean'. + Type 'number' is not assignable to type 'boolean'. tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(54,7): error TS4104: The type 'readonly [1]' is 'readonly' and cannot be assigned to the mutable type 'number[]'. tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(57,7): error TS2322: Type '[1]' is not assignable to type 'readonly boolean[]'. - Type '1' is not assignable to type 'boolean'. + Type 'number' is not assignable to type 'boolean'. tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(60,7): error TS2322: Type '[1]' is not assignable to type 'boolean[]'. - Type '1' is not assignable to type 'boolean'. + Type 'number' is not assignable to type 'boolean'. tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(63,7): error TS2322: Type 'readonly number[]' is not assignable to type 'readonly [1]'. Target requires 1 element(s) but source may have fewer. tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(66,7): error TS4104: The type 'readonly number[]' is 'readonly' and cannot be assigned to the mutable type '[1]'. @@ -134,7 +134,7 @@ tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(72,7): error TS2322: Ty const ta2: readonly boolean[] = ta1; ~~~ !!! error TS2322: Type 'readonly [1]' is not assignable to type 'readonly boolean[]'. -!!! error TS2322: Type '1' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. const ta3: readonly [1] = [1]; const ta4: number[] = ta3; @@ -145,13 +145,13 @@ tests/cases/compiler/readonlyTupleAndArrayElaboration.ts(72,7): error TS2322: Ty const ta6: readonly boolean[] = ta5; ~~~ !!! error TS2322: Type '[1]' is not assignable to type 'readonly boolean[]'. -!!! error TS2322: Type '1' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. const ta7: [1] = [1]; const ta8: boolean[] = ta7; ~~~ !!! error TS2322: Type '[1]' is not assignable to type 'boolean[]'. -!!! error TS2322: Type '1' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. const at1: readonly number[] = [1]; const at2: readonly [1] = at1; diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt b/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt index 0cf51f2c6453d..3a93a2e7d7ee4 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt +++ b/tests/baselines/reference/restParameterWithBindingPattern3.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/restParameterWithBindingPattern3.ts(1,23): error TS2322: Ty tests/cases/compiler/restParameterWithBindingPattern3.ts(3,23): error TS1186: A rest element cannot have an initializer. tests/cases/compiler/restParameterWithBindingPattern3.ts(5,30): error TS2493: Tuple type '[boolean, string, number]' of length '3' has no element at index '3'. tests/cases/compiler/restParameterWithBindingPattern3.ts(7,23): error TS2493: Tuple type '[boolean, string, number]' of length '3' has no element at index '3'. -tests/cases/compiler/restParameterWithBindingPattern3.ts(9,19): error TS2322: Type '1' is not assignable to type 'boolean'. +tests/cases/compiler/restParameterWithBindingPattern3.ts(9,19): error TS2322: Type 'number' is not assignable to type 'boolean'. tests/cases/compiler/restParameterWithBindingPattern3.ts(9,29): error TS2322: Type 'boolean' is not assignable to type 'string'. tests/cases/compiler/restParameterWithBindingPattern3.ts(9,48): error TS2566: A rest element cannot have a property name. @@ -29,7 +29,7 @@ tests/cases/compiler/restParameterWithBindingPattern3.ts(9,48): error TS2566: A function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) { } ~ -!!! error TS2322: Type '1' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. ~ !!! error TS2322: Type 'boolean' is not assignable to type 'string'. ~~~~ diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt index 215e5998a399f..8a7a083effe87 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,25): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,46): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,57): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,46): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,57): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (7 errors) ==== @@ -23,33 +23,33 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped f `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`.member f `abc${1}def${2}ghi`.member; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`["member"]; f `abc${1}def${2}ghi`["member"]; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`[0].member `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f.thisIsNotATag(`abc`); diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.errors.txt index 00d0f276dc9e0..81cfb13aea81b 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(14,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(18,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(22,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(24,25): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(26,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(26,46): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(28,57): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(24,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(26,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(26,46): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(28,57): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts (7 errors) ==== @@ -23,33 +23,33 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped f `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`.member f `abc${1}def${2}ghi`.member; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`["member"]; f `abc${1}def${2}ghi`["member"]; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`[0].member `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`; ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f.thisIsNotATag(`abc`); diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 59b105eede5e9..443c556fe558b 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(1,7): error TS2300: Duplicate identifier 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(14,5): error TS2322: Type '""' is not assignable to type 'boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(14,5): error TS2322: Type 'string' is not assignable to type 'boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,55): error TS2749: 'x' refers to a value, but is being used as a type here. Did you mean 'typeof x'? tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,57): error TS1144: '{' or ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,60): error TS1005: ';' expected. @@ -86,7 +86,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 function hasANonBooleanReturnStatement(x): x is A { return ''; ~~~~~~~~~~ -!!! error TS2322: Type '""' is not assignable to type 'boolean'. +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. } function hasTypeGuardTypeInsideTypeGuardType(x): x is x is A { diff --git a/tests/baselines/reference/variadicTuples1.errors.txt b/tests/baselines/reference/variadicTuples1.errors.txt index 8468cabd7119b..a50b0671fdeeb 100644 --- a/tests/baselines/reference/variadicTuples1.errors.txt +++ b/tests/baselines/reference/variadicTuples1.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(6,48): error TS1256: A rest element must be last in a tuple type. tests/cases/conformance/types/tuple/variadicTuples1.ts(52,5): error TS2555: Expected at least 3 arguments, but got 2. -tests/cases/conformance/types/tuple/variadicTuples1.ts(53,17): error TS2345: Argument of type '45' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/types/tuple/variadicTuples1.ts(53,17): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. tests/cases/conformance/types/tuple/variadicTuples1.ts(131,9): error TS2344: Type 'V' does not satisfy the constraint 'unknown[]'. The type 'readonly unknown[]' is 'readonly' and cannot be assigned to the mutable type 'unknown[]'. tests/cases/conformance/types/tuple/variadicTuples1.ts(149,5): error TS2322: Type '[string, ...unknown[]]' is not assignable to type '[string, ...T]'. @@ -104,7 +104,7 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(342,19): error TS2322: Ty !!! related TS6210 tests/cases/conformance/types/tuple/variadicTuples1.ts:45:45: An argument for 'c' was not provided. foo1(...t1, 45); // Error ~~ -!!! error TS2345: Argument of type '45' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. } declare function foo3(x: number, ...args: [...T, number]): T; From 40c3ffec91bd849e65915f9c7af8092f1201767a Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 28 May 2020 18:52:45 +0000 Subject: [PATCH 18/47] Add assertion. --- src/compiler/checker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c8ae32d35a00c..5ab03e855b139 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16130,6 +16130,7 @@ namespace ts { if (isLiteralType(source) && !typeCouldHaveTopLevelSingletonTypes(target)) { generalizedSource = getBaseTypeOfLiteralType(source); + Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } From 8b6a88700e392379e7d30c280485f1bdd37c8204 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Tue, 30 Jun 2020 21:44:47 +0300 Subject: [PATCH 19/47] fix(32297): add quick-fix action to delete parameter destructuring elements (#38764) --- src/compiler/diagnosticMessages.json | 12 ++- src/services/codefixes/fixUnusedIdentifier.ts | 76 ++++++++++++------- .../codeFixUnusedIdentifier_all_delete.ts | 2 +- .../codeFixUnusedIdentifier_all_delete_js.ts | 2 +- ...edIdentifier_all_delete_paramInFunction.ts | 2 +- .../codeFixUnusedIdentifier_deleteWrite.ts | 2 +- ...xUnusedIdentifier_destructure_allUnused.ts | 2 +- ...sedIdentifier_destructure_allUnused_all.ts | 4 +- ...sedIdentifier_destructure_allUnused_for.ts | 2 +- ...Identifier_destructure_allUnused_nested.ts | 2 +- ...usedIdentifier_destructure_partlyUnused.ts | 2 +- ...UnusedIdentifier_destructuring_elements.ts | 17 +++++ .../codeFixUnusedIdentifier_parameter_all.ts | 8 +- 13 files changed, 86 insertions(+), 47 deletions(-) create mode 100644 tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index dc21a3581324a..2ad1bfb8eea50 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -5155,10 +5155,6 @@ "category": "Message", "code": 90008 }, - "Remove destructuring": { - "category": "Message", - "code": 90009 - }, "Remove variable statement": { "category": "Message", "code": 90010 @@ -5275,6 +5271,14 @@ "category": "Message", "code": 90038 }, + "Remove unused destructuring declaration": { + "category": "Message", + "code": 90039 + }, + "Remove unused declarations for: '{0}'": { + "category": "Message", + "code": 90041 + }, "Declare a private field named '{0}'.": { "category": "Message", "code": 90053 diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index 4aa099cb379f5..9467b6a9b0a57 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -34,18 +34,33 @@ namespace ts.codefix { const changes = textChanges.ChangeTracker.with(context, t => t.delete(sourceFile, importDecl)); return [createDeleteFix(changes, [Diagnostics.Remove_import_from_0, showModuleSpecifier(importDecl)])]; } - const delDestructure = textChanges.ChangeTracker.with(context, t => - tryDeleteFullDestructure(token, t, sourceFile, checker, sourceFiles, /*isFixAll*/ false)); - if (delDestructure.length) { - return [createDeleteFix(delDestructure, Diagnostics.Remove_destructuring)]; + + if (isObjectBindingPattern(token.parent)) { + if (isParameter(token.parent.parent)) { + const elements = token.parent.elements; + const diagnostic: [DiagnosticMessage, string] = [ + elements.length > 1 ? Diagnostics.Remove_unused_declarations_for_Colon_0 : Diagnostics.Remove_unused_declaration_for_Colon_0, + map(elements, e => e.getText(sourceFile)).join(", ") + ]; + return [ + createDeleteFix(textChanges.ChangeTracker.with(context, t => + deleteDestructuringElements(t, sourceFile, token.parent)), diagnostic) + ]; + } + return [ + createDeleteFix(textChanges.ChangeTracker.with(context, t => + t.delete(sourceFile, token.parent.parent)), Diagnostics.Remove_unused_destructuring_declaration) + ]; } - const delVar = textChanges.ChangeTracker.with(context, t => tryDeleteFullVariableStatement(sourceFile, token, t)); - if (delVar.length) { - return [createDeleteFix(delVar, Diagnostics.Remove_variable_statement)]; + + if (canDeleteEntireVariableStatement(sourceFile, token)) { + return [ + createDeleteFix(textChanges.ChangeTracker.with(context, t => + deleteEntireVariableStatement(t, sourceFile, token.parent)), Diagnostics.Remove_variable_statement) + ]; } const result: CodeFixAction[] = []; - if (token.kind === SyntaxKind.InferKeyword) { const changes = textChanges.ChangeTracker.with(context, t => changeInferToUnknown(t, sourceFile, token)); const name = cast(token.parent, isInferTypeNode).typeParameter.name.text; @@ -79,7 +94,9 @@ namespace ts.codefix { tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === SyntaxKind.InferKeyword) break; // Can't delete + if (token.kind === SyntaxKind.InferKeyword) { + break; // Can't delete + } const importDecl = tryGetFullImport(token); if (importDecl) { changes.delete(sourceFile, importDecl); @@ -90,8 +107,18 @@ namespace ts.codefix { else if (token.kind === SyntaxKind.LessThanToken) { deleteTypeParameters(changes, sourceFile, token); } - else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && - !tryDeleteFullVariableStatement(sourceFile, token, changes)) { + else if (isObjectBindingPattern(token.parent)) { + if (isParameter(token.parent.parent)) { + deleteDestructuringElements(changes, sourceFile, token.parent); + } + else { + changes.delete(sourceFile, token.parent.parent); + } + } + else if (canDeleteEntireVariableStatement(sourceFile, token)) { + deleteEntireVariableStatement(changes, sourceFile, token.parent); + } + else { tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, /*isFixAll*/ true); } break; @@ -125,25 +152,16 @@ namespace ts.codefix { return token.kind === SyntaxKind.ImportKeyword ? tryCast(token.parent, isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(token: Node, changes: textChanges.ChangeTracker, sourceFile: SourceFile, checker: TypeChecker, sourceFiles: readonly SourceFile[], isFixAll: boolean): boolean { - if (token.kind !== SyntaxKind.OpenBraceToken || !isObjectBindingPattern(token.parent)) return false; - const decl = token.parent.parent; - if (decl.kind === SyntaxKind.Parameter) { - tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); - } - else { - changes.delete(sourceFile, decl); - } - return true; + function canDeleteEntireVariableStatement(sourceFile: SourceFile, token: Node): boolean { + return isVariableDeclarationList(token.parent) && first(token.parent.getChildren(sourceFile)) === token; } - function tryDeleteFullVariableStatement(sourceFile: SourceFile, token: Node, changes: textChanges.ChangeTracker): boolean { - const declarationList = tryCast(token.parent, isVariableDeclarationList); - if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === SyntaxKind.VariableStatement ? declarationList.parent : declarationList); - return true; - } - return false; + function deleteEntireVariableStatement(changes: textChanges.ChangeTracker, sourceFile: SourceFile, node: VariableDeclarationList) { + changes.delete(sourceFile, node.parent.kind === SyntaxKind.VariableStatement ? node.parent : node); + } + + function deleteDestructuringElements(changes: textChanges.ChangeTracker, sourceFile: SourceFile, node: ObjectBindingPattern) { + forEach(node.elements, n => changes.delete(sourceFile, n)); } function tryPrefixDeclaration(changes: textChanges.ChangeTracker, errorCode: number, sourceFile: SourceFile, token: Node): void { @@ -205,7 +223,7 @@ namespace ts.codefix { } } - function tryDeleteParameter(changes: textChanges.ChangeTracker, sourceFile: SourceFile, p: ParameterDeclaration, checker: TypeChecker, sourceFiles: readonly SourceFile[], isFixAll: boolean): void { + function tryDeleteParameter(changes: textChanges.ChangeTracker, sourceFile: SourceFile, p: ParameterDeclaration, checker: TypeChecker, sourceFiles: readonly SourceFile[], isFixAll = false): void { if (mayDeleteParameter(p, checker, isFixAll)) { if (p.modifiers && p.modifiers.length > 0 && (!isIdentifier(p.name) || FindAllReferences.Core.isSymbolReferencedInFile(p.name, checker, sourceFile))) { diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete.ts index b169ffb884800..92585714eec94 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete.ts @@ -50,7 +50,7 @@ verify.codeFixAll({ fixId: "unusedIdentifier_delete", - fixAllDescription: "Delete all unused declarations", + fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message, newFileContent: `import { used1 } from "foo"; import { used2 } from "foo"; diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_js.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_js.ts index a6251ffb19dca..7920810cacf50 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_js.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_js.ts @@ -38,7 +38,7 @@ verify.codeFixAll({ fixId: "unusedIdentifier_delete", - fixAllDescription: "Delete all unused declarations", + fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message, newFileContent: `/** Parameter doc comment */ function f() {} diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_paramInFunction.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_paramInFunction.ts index 80b190700bffa..4a5fdc78bca00 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_paramInFunction.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_all_delete_paramInFunction.ts @@ -5,6 +5,6 @@ verify.codeFixAll({ fixId: "unusedIdentifier_delete", - fixAllDescription: "Delete all unused declarations", + fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message, newFileContent: "export {};\n", }); diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_deleteWrite.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_deleteWrite.ts index 61ff1211c7c50..945f79bc0103c 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_deleteWrite.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_deleteWrite.ts @@ -14,7 +14,7 @@ verify.codeFixAll({ fixId: "unusedIdentifier_delete", - fixAllDescription: "Delete all unused declarations", + fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message, newFileContent: ` export class C { diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused.ts index 4f3f9a3e61ebb..71430d0a7bcff 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused.ts @@ -7,7 +7,7 @@ ////const { x, y } = o; verify.codeFix({ - description: "Remove destructuring", + description: ts.Diagnostics.Remove_unused_destructuring_declaration.message, newFileContent: `export {}; `, diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_all.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_all.ts index c9d4f62f2db36..5a16f374f34d1 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_all.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_all.ts @@ -12,11 +12,11 @@ verify.codeFixAll({ fixId: "unusedIdentifier_delete", - fixAllDescription: "Delete all unused declarations", + fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message, newFileContent: `const { a } = o; a; -export function f({ a }) { +export function f({ a }, { }) { a; }`, }); diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_for.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_for.ts index 27103357d3dd9..fab0d1795cbdc 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_for.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_for.ts @@ -6,7 +6,7 @@ ////for (const { x } of o) {} verify.codeFix({ - description: "Remove destructuring", + description: ts.Diagnostics.Remove_unused_destructuring_declaration.message, newFileContent: `for (const {} of o) {}`, }); diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_nested.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_nested.ts index 73fca1139289f..b830f5a90b569 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_nested.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_allUnused_nested.ts @@ -7,7 +7,7 @@ ////const { x: { a, b } } = o; verify.codeFix({ - description: "Remove destructuring", + description: ts.Diagnostics.Remove_unused_destructuring_declaration.message, newFileContent: `export {}; const { } = o;`, diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_partlyUnused.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_partlyUnused.ts index e07837060852b..e885054f35997 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_partlyUnused.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_destructure_partlyUnused.ts @@ -38,7 +38,7 @@ verify.codeFixAll({ fixId: "unusedIdentifier_delete", - fixAllDescription: "Delete all unused declarations", + fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message, newFileContent: `{ const { x } = o; diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements.ts new file mode 100644 index 0000000000000..060354a0422e5 --- /dev/null +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_destructuring_elements.ts @@ -0,0 +1,17 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true + +////export function f({ x, y }, a) { +//// a; +////} + +verify.codeFix({ + description: [ts.Diagnostics.Remove_unused_declarations_for_Colon_0.message, "x, y"], + index: 0, + newFileContent: +`export function f({ }, a) { + a; +}`, +}); diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_all.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_all.ts index a55e867634a76..16c9e6b481547 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_all.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_parameter_all.ts @@ -4,7 +4,7 @@ // @noUnusedParameters: true ////function f(a, b, { x, y }) { b; } -////f(0, 1, 2); +////f(0, 1, { x: 1, y: 1 }); //// ////class C { //// m(a, b, c) { b; } @@ -23,10 +23,10 @@ verify.codeFixAll({ fixId: "unusedIdentifier_delete", - fixAllDescription: "Delete all unused declarations", + fixAllDescription: ts.Diagnostics.Delete_all_unused_declarations.message, newFileContent: -`function f(b) { b; } -f(1); +`function f(b, { }) { b; } +f(1, { x: 1, y: 1 }); class C { m(b) { b; } From ff1f449b995145077e9d5d2a063106dfd051d7ae Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 30 Jun 2020 13:37:59 -0700 Subject: [PATCH 20/47] Fix type of computed name following spread (#39319) --- src/compiler/checker.ts | 12 ++++++++---- ...ithIndexDoesNotAddUndefinedToLocalIndex.js | 19 +++++++++++++++++++ ...dexDoesNotAddUndefinedToLocalIndex.symbols | 11 +++++++++++ ...IndexDoesNotAddUndefinedToLocalIndex.types | 16 ++++++++++++++++ ...ithIndexDoesNotAddUndefinedToLocalIndex.ts | 3 +++ 5 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.js create mode 100644 tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.symbols create mode 100644 tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.types create mode 100644 tests/cases/compiler/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7ad551e918d79..e22ab8affea01 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23836,10 +23836,15 @@ namespace ts { return links.resolvedType; } + function isSymbolWithNumericName(symbol: Symbol) { + const firstDecl = symbol.declarations?.[0]; + return isNumericLiteralName(symbol.escapedName) || (firstDecl && isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name)); + } + function getObjectLiteralIndexInfo(node: ObjectLiteralExpression, offset: number, properties: Symbol[], kind: IndexKind): IndexInfo { const propTypes: Type[] = []; for (let i = offset; i < properties.length; i++) { - if (kind === IndexKind.String || isNumericName(node.properties[i].name!)) { + if (kind === IndexKind.String || isSymbolWithNumericName(properties[i])) { propTypes.push(getTypeOfSymbol(properties[i])); } } @@ -23892,8 +23897,7 @@ namespace ts { } let offset = 0; - for (let i = 0; i < node.properties.length; i++) { - const memberDecl = node.properties[i]; + for (const memberDecl of node.properties) { let member = getSymbolOfNode(memberDecl); const computedNameType = memberDecl.name && memberDecl.name.kind === SyntaxKind.ComputedPropertyName && !isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; @@ -23980,7 +23984,7 @@ namespace ts { checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); } spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); - offset = i + 1; + offset = propertiesArray.length; continue; } else { diff --git a/tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.js b/tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.js new file mode 100644 index 0000000000000..570580f17e87a --- /dev/null +++ b/tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.js @@ -0,0 +1,19 @@ +//// [spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts] +declare const m: { [k: string]: string }; +const x: { [k: string]: string } = { ...m, ["a" + "b"]: "" }; + +//// [spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.js] +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var _a; +var x = __assign(__assign({}, m), (_a = {}, _a["a" + "b"] = "", _a)); diff --git a/tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.symbols b/tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.symbols new file mode 100644 index 0000000000000..d41f4c8fe0933 --- /dev/null +++ b/tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts === +declare const m: { [k: string]: string }; +>m : Symbol(m, Decl(spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts, 0, 13)) +>k : Symbol(k, Decl(spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts, 0, 20)) + +const x: { [k: string]: string } = { ...m, ["a" + "b"]: "" }; +>x : Symbol(x, Decl(spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts, 1, 5)) +>k : Symbol(k, Decl(spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts, 1, 12)) +>m : Symbol(m, Decl(spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts, 0, 13)) +>["a" + "b"] : Symbol(["a" + "b"], Decl(spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts, 1, 42)) + diff --git a/tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.types b/tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.types new file mode 100644 index 0000000000000..9a76d8dfdaf52 --- /dev/null +++ b/tests/baselines/reference/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts === +declare const m: { [k: string]: string }; +>m : { [k: string]: string; } +>k : string + +const x: { [k: string]: string } = { ...m, ["a" + "b"]: "" }; +>x : { [k: string]: string; } +>k : string +>{ ...m, ["a" + "b"]: "" } : { [x: string]: string; } +>m : { [k: string]: string; } +>["a" + "b"] : string +>"a" + "b" : string +>"a" : "a" +>"b" : "b" +>"" : "" + diff --git a/tests/cases/compiler/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts b/tests/cases/compiler/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts new file mode 100644 index 0000000000000..48cf12239caf7 --- /dev/null +++ b/tests/cases/compiler/spreadObjectWithIndexDoesNotAddUndefinedToLocalIndex.ts @@ -0,0 +1,3 @@ +// @strict: true +declare const m: { [k: string]: string }; +const x: { [k: string]: string } = { ...m, ["a" + "b"]: "" }; \ No newline at end of file From e2c5a90cc3bcbc0ea78e13bf0f5b889a2aed8248 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 30 Jun 2020 14:25:27 -0700 Subject: [PATCH 21/47] Disable signature help on unresolved bare identifiers; add more declaration info on other unresolved calls (#39352) * Disable signature help on unresolved bare identifiers; add more declaration info on unresolvedproperty access * Remove stray ts-ignore --- src/services/signatureHelp.ts | 17 +++++++++++++---- .../signatureHelpJSMissingIdentifier.ts | 9 +++++++++ .../signatureHelpJSMissingPropertyAccess.ts | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/signatureHelpJSMissingIdentifier.ts create mode 100644 tests/cases/fourslash/signatureHelpJSMissingPropertyAccess.ts diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 54447417a2a49..954cd1da9e1bf 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -120,14 +120,22 @@ namespace ts.SignatureHelp { if (argumentInfo.invocation.kind === InvocationKind.Contextual) return undefined; // See if we can find some symbol with the call expression name that has call signatures. const expression = getExpressionFromInvocation(argumentInfo.invocation); - const name = isIdentifier(expression) ? expression.text : isPropertyAccessExpression(expression) ? expression.name.text : undefined; + const name = isPropertyAccessExpression(expression) ? expression.name.text : undefined; const typeChecker = program.getTypeChecker(); return name === undefined ? undefined : firstDefined(program.getSourceFiles(), sourceFile => firstDefined(sourceFile.getNamedDeclarations().get(name), declaration => { const type = declaration.symbol && typeChecker.getTypeOfSymbolAtLocation(declaration.symbol, declaration); const callSignatures = type && type.getCallSignatures(); if (callSignatures && callSignatures.length) { - return typeChecker.runWithCancellationToken(cancellationToken, typeChecker => createSignatureHelpItems(callSignatures, callSignatures[0], argumentInfo, sourceFile, typeChecker)); + return typeChecker.runWithCancellationToken( + cancellationToken, + typeChecker => createSignatureHelpItems( + callSignatures, + callSignatures[0], + argumentInfo, + sourceFile, + typeChecker, + /*useFullPrefix*/ true)); } })); } @@ -496,10 +504,11 @@ namespace ts.SignatureHelp { { isTypeParameterList, argumentCount, argumentsSpan: applicableSpan, invocation, argumentIndex }: ArgumentListInfo, sourceFile: SourceFile, typeChecker: TypeChecker, + useFullPrefix?: boolean, ): SignatureHelpItems { const enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation); - const callTargetSymbol = invocation.kind === InvocationKind.Contextual ? invocation.symbol : typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)); - const callTargetDisplayParts = callTargetSymbol ? symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined) : emptyArray; + const callTargetSymbol = invocation.kind === InvocationKind.Contextual ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && resolvedSignature.declaration?.symbol); + const callTargetDisplayParts = callTargetSymbol ? symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : emptyArray; const items = map(candidates, candidateSignature => getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile)); if (argumentIndex !== 0) { diff --git a/tests/cases/fourslash/signatureHelpJSMissingIdentifier.ts b/tests/cases/fourslash/signatureHelpJSMissingIdentifier.ts new file mode 100644 index 0000000000000..73b22459d6303 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpJSMissingIdentifier.ts @@ -0,0 +1,9 @@ +/// + +// @allowJs: true +// @checkJs: true + +// @Filename: test.js +////log(/**/) + +verify.noSignatureHelp(""); diff --git a/tests/cases/fourslash/signatureHelpJSMissingPropertyAccess.ts b/tests/cases/fourslash/signatureHelpJSMissingPropertyAccess.ts new file mode 100644 index 0000000000000..1c1cf427528b0 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpJSMissingPropertyAccess.ts @@ -0,0 +1,19 @@ +/// + +// @allowJs: true +// @checkJs: true + +// @Filename: test.js +////foo.filter(/**/) + +goTo.marker(""); +verify.signatureHelp({ + text: "ReadonlyArray.filter(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[]", + overloadsCount: 2, + docComment: "Returns the elements of an array that meet the condition specified in a callback function.", + parameterDocComment: "A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.", + tags: [ + { name: "param", text: "predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array." }, + { name: "param", text: "thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value." } + ] +}); From 0f9d4c78d4e6b34d90585bc36f7a31d61ad5facb Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 30 Jun 2020 15:16:45 -0700 Subject: [PATCH 22/47] JSDoc uses same newlines as normal scanner (#39351) * JSDoc uses same newlines as normal scanner Previously, scanJsDocToken treated each newline character separately, so the sequence \r\n would be treated as two lines. This is unexpected, and not the way the normal scanner does it. This change makes the jsdoc scanner behave the same as the normal scanner. * fix lint in test --- src/compiler/scanner.ts | 6 +++++- src/testRunner/unittests/publicApi.ts | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index ab2a37032ced2..376e524f9c2d5 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -2352,8 +2352,12 @@ namespace ts { return token = SyntaxKind.WhitespaceTrivia; case CharacterCodes.at: return token = SyntaxKind.AtToken; - case CharacterCodes.lineFeed: case CharacterCodes.carriageReturn: + if (text.charCodeAt(pos) === CharacterCodes.lineFeed) { + pos++; + } + // falls through + case CharacterCodes.lineFeed: tokenFlags |= TokenFlags.PrecedingLineBreak; return token = SyntaxKind.NewLineTrivia; case CharacterCodes.asterisk: diff --git a/src/testRunner/unittests/publicApi.ts b/src/testRunner/unittests/publicApi.ts index 80df40e6d9b4e..7104662d033ef 100644 --- a/src/testRunner/unittests/publicApi.ts +++ b/src/testRunner/unittests/publicApi.ts @@ -53,6 +53,24 @@ describe("unittests:: Public APIs:: createPrivateIdentifier", () => { }); }); +describe("unittests:: Public APIs:: JSDoc newlines", () => { + it("are preserved verbatim", () => { + const testFilePath = "/file.ts"; + const testFileText = ` +/** +* @example +* Some\n * text\r\n * with newlines. +*/ +function test() {}`; + + const testSourceFile = ts.createSourceFile(testFilePath, testFileText, ts.ScriptTarget.Latest, /*setParentNodes*/ true); + const funcDec = testSourceFile.statements.find(ts.isFunctionDeclaration)!; + const tags = ts.getJSDocTags(funcDec); + assert.isDefined(tags[0].comment); + assert.equal(tags[0].comment, "Some\n text\r\n with newlines."); + }); +}); + describe("unittests:: Public APIs:: isPropertyName", () => { it("checks if a PrivateIdentifier is a valid property name", () => { const prop = ts.factory.createPrivateIdentifier("#foo"); From df5981319fc9686dec63305142f7a549e2e6b888 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 30 Jun 2020 15:53:13 -0700 Subject: [PATCH 23/47] Fix crash on completion in jsdoc namepath (#39347) contextToken may be undefined, so the isAssertionExpression call in filterGlobalCompletion needs to check for undefined. --- src/services/completions.ts | 6 +----- tests/cases/fourslash/completionJSDocNamePath.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 tests/cases/fourslash/completionJSDocNamePath.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 989aff628bdf8..88cee321e1023 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1464,7 +1464,7 @@ namespace ts.Completions { function filterGlobalCompletion(symbols: Symbol[]): void { const isTypeOnly = isTypeOnlyCompletion(); if (isTypeOnly) { - keywordFilters = isTypeAssertion() + keywordFilters = contextToken && isAssertionExpression(contextToken.parent) ? KeywordCompletionFilters.TypeAssertionKeywords : KeywordCompletionFilters.TypeKeywords; } @@ -1494,10 +1494,6 @@ namespace ts.Completions { }); } - function isTypeAssertion(): boolean { - return isAssertionExpression(contextToken.parent); - } - function isTypeOnlyCompletion(): boolean { return insideJsDocTagTypeExpression || !isContextTokenValueLocation(contextToken) && diff --git a/tests/cases/fourslash/completionJSDocNamePath.ts b/tests/cases/fourslash/completionJSDocNamePath.ts new file mode 100644 index 0000000000000..e15f70eaa472d --- /dev/null +++ b/tests/cases/fourslash/completionJSDocNamePath.ts @@ -0,0 +1,15 @@ +// @noLib: true + +/// + +// fix crash from #38407 + +//// /** +//// * @returns {modu/*1*/le:ControlFlow} +//// */ +//// export function cargo() { +//// } + +goTo.marker('1'); +verify.completions({ marker: "1", excludes: ["module", "ControlFlow"] }); + From 479650fbcab956c5bbe1449a29ac29a3928ddeb6 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Wed, 1 Jul 2020 11:18:15 -0400 Subject: [PATCH 24/47] Use MS repo for making monaco builds (#39316) --- scripts/post-vsts-artifact-comment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/post-vsts-artifact-comment.js b/scripts/post-vsts-artifact-comment.js index 076d5a753067d..125b047f51901 100644 --- a/scripts/post-vsts-artifact-comment.js +++ b/scripts/post-vsts-artifact-comment.js @@ -47,8 +47,8 @@ and then running \`npm install\`. }); // Temporarily disable until we get access controls set up right - // Send a ping to https://github.com/orta/make-monaco-builds#pull-request-builds - await gh.request("POST /repos/orta/make-monaco-builds/dispatches", { event_type: process.env.SOURCE_ISSUE, headers: { Accept: "application/vnd.github.everest-preview+json" }}); + // Send a ping to https://github.com/microsoft/typescript-make-monaco-builds#pull-request-builds + await gh.request("POST /repos/microsoft/typescript-make-monaco-builds/dispatches", { event_type: process.env.SOURCE_ISSUE, headers: { Accept: "application/vnd.github.everest-preview+json" }}); } main().catch(async e => { From 222d47e878a85a707262a9b255f39679609295bd Mon Sep 17 00:00:00 2001 From: csigs Date: Wed, 1 Jul 2020 16:10:50 +0000 Subject: [PATCH 25/47] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 44 ++++++++++-------- .../diagnosticMessages.generated.json.lcl | 46 +++++++++++-------- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 16ffe961adfa6..dacf250f2236d 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4077,6 +4077,12 @@ + + + + + + @@ -8883,15 +8889,6 @@ - - - - - - - - - @@ -8955,6 +8952,18 @@ + + + + + + + + + + + + @@ -10014,6 +10023,12 @@ + + + + + + @@ -10045,7 +10060,7 @@ - + @@ -12900,15 +12915,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index f4703259dd00f..391613d3caa3f 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -2581,7 +2581,7 @@ - + @@ -2590,7 +2590,7 @@ - + @@ -4068,6 +4068,12 @@ + + + + + + @@ -8874,15 +8880,6 @@ - - - - - - - - - @@ -8946,6 +8943,18 @@ + + + + + + + + + + + + @@ -10005,6 +10014,12 @@ + + + + + + @@ -12891,15 +12906,6 @@ - - - - - - - - - From 0e3f25d079a024404614af48409d9e621ecfc5bd Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 1 Jul 2020 13:55:35 -0700 Subject: [PATCH 26/47] Copy typesMap.json in produceLKG.ts (#39329) * Copy typesMap.json in produceLKG.ts It doesn't change very often and there's a hardcoded backup, but this seems like a booby trap. * Remove unused import --- scripts/produceLKG.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/produceLKG.ts b/scripts/produceLKG.ts index 762290bcfa6a0..7439abe9fcedf 100644 --- a/scripts/produceLKG.ts +++ b/scripts/produceLKG.ts @@ -3,7 +3,6 @@ import childProcess = require("child_process"); import fs = require("fs-extra"); import path = require("path"); -import removeInternal = require("remove-internal"); import glob = require("glob"); const root = path.join(__dirname, ".."); @@ -15,6 +14,7 @@ async function produceLKG() { console.log(`Building LKG from ${source} to ${dest}`); await copyLibFiles(); await copyLocalizedDiagnostics(); + await copyTypesMap(); await buildProtocol(); await copyScriptOutputs(); await copyDeclarationOutputs(); @@ -40,6 +40,10 @@ async function copyLocalizedDiagnostics() { } } +async function copyTypesMap() { + await copyFromBuiltLocal("typesMap.json"); // Cannot accommodate copyright header +} + async function buildProtocol() { const protocolScript = path.join(__dirname, "buildProtocol.js"); if (!fs.existsSync(protocolScript)) { From 7b942b4fa875f2877a90d201cf146e6196b0c07b Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 1 Jul 2020 17:00:26 -0700 Subject: [PATCH 27/47] Revert the type change to ts.Map (#39366) --- src/compiler/binder.ts | 6 +- src/compiler/builder.ts | 16 ++--- src/compiler/builderState.ts | 24 +++---- src/compiler/checker.ts | 68 +++++++++---------- src/compiler/commandLineParser.ts | 46 ++++++------- src/compiler/core.ts | 50 +++++++------- src/compiler/corePublic.ts | 20 +++++- src/compiler/factory/emitHelpers.ts | 2 +- src/compiler/moduleNameResolver.ts | 22 +++--- src/compiler/parser.ts | 4 +- src/compiler/performance.ts | 6 +- src/compiler/program.ts | 18 ++--- src/compiler/resolutionCache.ts | 20 +++--- src/compiler/scanner.ts | 2 +- src/compiler/sourcemap.ts | 2 +- src/compiler/sys.ts | 2 +- src/compiler/transformers/declarations.ts | 10 +-- src/compiler/transformers/es2015.ts | 8 +-- src/compiler/transformers/generators.ts | 2 +- .../transformers/module/esnextAnd2015.ts | 2 +- src/compiler/transformers/utilities.ts | 4 +- src/compiler/tsbuildPublic.ts | 36 +++++----- src/compiler/types.ts | 58 ++++++++-------- src/compiler/utilities.ts | 36 +++++----- src/compiler/watchPublic.ts | 4 +- src/compiler/watchUtilities.ts | 6 +- src/executeCommandLine/executeCommandLine.ts | 2 +- src/harness/client.ts | 2 +- src/harness/fourslashImpl.ts | 12 ++-- src/harness/fourslashInterfaceImpl.ts | 2 +- src/harness/harnessIO.ts | 10 +-- src/harness/harnessLanguageService.ts | 2 +- src/harness/loggedIO.ts | 2 +- src/harness/virtualFileSystemWithWatch.ts | 44 ++++++------ src/jsTyping/jsTyping.ts | 6 +- src/server/editorServices.ts | 32 ++++----- src/server/project.ts | 38 +++++------ src/server/typingsCache.ts | 4 +- src/server/utilities.ts | 2 +- .../codefixes/convertToAsyncFunction.ts | 8 +-- src/services/codefixes/convertToEs6Module.ts | 4 +- src/services/codefixes/importFixes.ts | 2 +- src/services/documentRegistry.ts | 4 +- src/services/findAllReferences.ts | 2 +- src/services/importTracker.ts | 4 +- src/services/navigationBar.ts | 4 +- src/services/patternMatcher.ts | 8 +-- src/services/refactorProvider.ts | 2 +- src/services/refactors/extractSymbol.ts | 16 ++--- src/services/services.ts | 14 ++-- src/services/shims.ts | 4 +- src/services/types.ts | 12 ++-- src/services/utilities.ts | 4 +- src/testRunner/parallel/worker.ts | 4 +- .../unittests/config/commandLineParsing.ts | 2 +- src/testRunner/unittests/createMapShim.ts | 8 +-- src/testRunner/unittests/createSetShim.ts | 6 +- src/testRunner/unittests/moduleResolution.ts | 4 +- src/testRunner/unittests/programApi.ts | 2 +- .../unittests/reuseProgramStructure.ts | 8 +-- .../unittests/services/extract/helpers.ts | 2 +- .../unittests/tsbuild/watchEnvironment.ts | 2 +- .../tsserver/cachingFileSystemInformation.ts | 2 +- src/testRunner/unittests/tsserver/helpers.ts | 4 +- src/testRunner/unittests/tsserver/symLinks.ts | 2 +- .../unittests/tsserver/typingsInstaller.ts | 2 +- src/tsserver/server.ts | 2 +- src/typingsInstaller/nodeTypingsInstaller.ts | 4 +- src/typingsInstallerCore/typingsInstaller.ts | 6 +- .../reference/api/tsserverlibrary.d.ts | 38 +++++++---- tests/baselines/reference/api/typescript.d.ts | 30 +++++--- 71 files changed, 443 insertions(+), 405 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index ca3399375a28a..a8ff97aab2e01 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -15,7 +15,7 @@ namespace ts { referenced: boolean; } - export function getModuleInstanceState(node: ModuleDeclaration, visited?: Map): ModuleInstanceState { + export function getModuleInstanceState(node: ModuleDeclaration, visited?: ESMap): ModuleInstanceState { if (node.body && !node.body.parent) { // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already setParent(node.body, node); @@ -35,7 +35,7 @@ namespace ts { return result; } - function getModuleInstanceStateWorker(node: Node, visited: Map): ModuleInstanceState { + function getModuleInstanceStateWorker(node: Node, visited: ESMap): ModuleInstanceState { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations @@ -107,7 +107,7 @@ namespace ts { return ModuleInstanceState.Instantiated; } - function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: Map) { + function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: ESMap) { const name = specifier.propertyName || specifier.name; let p: Node | undefined = specifier.parent; while (p) { diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index ea92c99c5172f..7765a75331281 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -24,7 +24,7 @@ namespace ts { /** * Cache of bind and check diagnostics for files with their Path being the key */ - semanticDiagnosticsPerFile?: ReadonlyMap | undefined; + semanticDiagnosticsPerFile?: ReadonlyESMap | undefined; /** * The map has key by source file's path that has been changed */ @@ -41,7 +41,7 @@ namespace ts { * Map of file signatures, with key being file path, calculated while getting current changed file's affected files * These will be committed whenever the iteration through affected files of current changed file is complete */ - currentAffectedFilesSignatures?: ReadonlyMap | undefined; + currentAffectedFilesSignatures?: ReadonlyESMap | undefined; /** * Newly computed visible to outside referencedSet */ @@ -65,7 +65,7 @@ namespace ts { /** * Files pending to be emitted kind. */ - affectedFilesPendingEmitKind?: ReadonlyMap | undefined; + affectedFilesPendingEmitKind?: ReadonlyESMap | undefined; /** * Current index to retrieve pending affected file */ @@ -89,7 +89,7 @@ namespace ts { /** * Cache of bind and check diagnostics for files with their Path being the key */ - semanticDiagnosticsPerFile: Map | undefined; + semanticDiagnosticsPerFile: ESMap | undefined; /** * The map has key by source file's path that has been changed */ @@ -110,7 +110,7 @@ namespace ts { * Map of file signatures, with key being file path, calculated while getting current changed file's affected files * These will be committed whenever the iteration through affected files of current changed file is complete */ - currentAffectedFilesSignatures: Map | undefined; + currentAffectedFilesSignatures: ESMap | undefined; /** * Newly computed visible to outside referencedSet */ @@ -142,7 +142,7 @@ namespace ts { /** * Files pending to be emitted kind. */ - affectedFilesPendingEmitKind: Map | undefined; + affectedFilesPendingEmitKind: ESMap | undefined; /** * Current index to retrieve pending affected file */ @@ -154,7 +154,7 @@ namespace ts { /** * Already seen emitted files */ - seenEmittedFiles: Map | undefined; + seenEmittedFiles: ESMap | undefined; /** * true if program has been emitted */ @@ -1140,7 +1140,7 @@ namespace ts { } } - function getMapOfReferencedSet(mapLike: MapLike | undefined, toPath: (path: string) => Path): ReadonlyMap | undefined { + function getMapOfReferencedSet(mapLike: MapLike | undefined, toPath: (path: string) => Path): ReadonlyESMap | undefined { if (!mapLike) return undefined; const map = new Map(); // Copies keys/values from template. Note that for..in will not throw if diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index 311f92ceabe12..1ad8c0aad1739 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -15,36 +15,36 @@ namespace ts { /** * Information of the file eg. its version, signature etc */ - fileInfos: ReadonlyMap; + fileInfos: ReadonlyESMap; /** * Contains the map of ReferencedSet=Referenced files of the file if module emit is enabled * Otherwise undefined * Thus non undefined value indicates, module emit */ - readonly referencedMap?: ReadonlyMap | undefined; + readonly referencedMap?: ReadonlyESMap | undefined; /** * Contains the map of exported modules ReferencedSet=exported module files from the file if module emit is enabled * Otherwise undefined */ - readonly exportedModulesMap?: ReadonlyMap | undefined; + readonly exportedModulesMap?: ReadonlyESMap | undefined; } export interface BuilderState { /** * Information of the file eg. its version, signature etc */ - fileInfos: Map; + fileInfos: ESMap; /** * Contains the map of ReferencedSet=Referenced files of the file if module emit is enabled * Otherwise undefined * Thus non undefined value indicates, module emit */ - readonly referencedMap: ReadonlyMap | undefined; + readonly referencedMap: ReadonlyESMap | undefined; /** * Contains the map of exported modules ReferencedSet=exported module files from the file if module emit is enabled * Otherwise undefined */ - readonly exportedModulesMap: Map | undefined; + readonly exportedModulesMap: ESMap | undefined; /** * Map of files that have already called update signature. * That means hence forth these files are assumed to have @@ -83,7 +83,7 @@ namespace ts { * Exported modules to from declaration emit being computed. * This can contain false in the affected file path to specify that there are no exported module(types from other modules) for this file */ - export type ComputingExportedModulesMap = Map; + export type ComputingExportedModulesMap = ESMap; /** * Get the referencedFile from the imported module symbol @@ -192,7 +192,7 @@ namespace ts { /** * Returns true if oldState is reusable, that is the emitKind = module/non module has not changed */ - export function canReuseOldState(newReferencedMap: ReadonlyMap | undefined, oldState: Readonly | undefined) { + export function canReuseOldState(newReferencedMap: ReadonlyESMap | undefined, oldState: Readonly | undefined) { return oldState && !oldState.referencedMap === !newReferencedMap; } @@ -258,7 +258,7 @@ namespace ts { /** * Gets the files affected by the path from the program */ - export function getFilesAffectedBy(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, cacheToUpdateSignature?: Map, exportedModulesMapCache?: ComputingExportedModulesMap): readonly SourceFile[] { + export function getFilesAffectedBy(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, cacheToUpdateSignature?: ESMap, exportedModulesMapCache?: ComputingExportedModulesMap): readonly SourceFile[] { // Since the operation could be cancelled, the signatures are always stored in the cache // They will be committed once it is safe to use them // eg when calling this api from tsserver, if there is no cancellation of the operation @@ -285,7 +285,7 @@ namespace ts { * Updates the signatures from the cache into state's fileinfo signatures * This should be called whenever it is safe to commit the state of the builder */ - export function updateSignaturesFromCache(state: BuilderState, signatureCache: Map) { + export function updateSignaturesFromCache(state: BuilderState, signatureCache: ESMap) { signatureCache.forEach((signature, path) => updateSignatureOfFile(state, signature, path)); } @@ -297,7 +297,7 @@ namespace ts { /** * Returns if the shape of the signature has changed since last emit */ - export function updateShapeSignature(state: Readonly, programOfThisState: Program, sourceFile: SourceFile, cacheToUpdateSignature: Map, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, exportedModulesMapCache?: ComputingExportedModulesMap) { + export function updateShapeSignature(state: Readonly, programOfThisState: Program, sourceFile: SourceFile, cacheToUpdateSignature: ESMap, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, exportedModulesMapCache?: ComputingExportedModulesMap) { Debug.assert(!!sourceFile); Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state"); @@ -518,7 +518,7 @@ namespace ts { /** * When program emits modular code, gets the files affected by the sourceFile whose shape has changed */ - function getFilesAffectedByUpdatedShapeWhenModuleEmit(state: BuilderState, programOfThisState: Program, sourceFileWithUpdatedShape: SourceFile, cacheToUpdateSignature: Map, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash | undefined, exportedModulesMapCache: ComputingExportedModulesMap | undefined) { + function getFilesAffectedByUpdatedShapeWhenModuleEmit(state: BuilderState, programOfThisState: Program, sourceFileWithUpdatedShape: SourceFile, cacheToUpdateSignature: ESMap, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash | undefined, exportedModulesMapCache: ComputingExportedModulesMap | undefined) { if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e22ab8affea01..cc2ed2e3d421e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -134,7 +134,7 @@ namespace ts { EmptyObjectFacts = All, } - const typeofEQFacts: ReadonlyMap = createMapFromTemplate({ + const typeofEQFacts: ReadonlyESMap = createMapFromTemplate({ string: TypeFacts.TypeofEQString, number: TypeFacts.TypeofEQNumber, bigint: TypeFacts.TypeofEQBigInt, @@ -145,7 +145,7 @@ namespace ts { function: TypeFacts.TypeofEQFunction }); - const typeofNEFacts: ReadonlyMap = createMapFromTemplate({ + const typeofNEFacts: ReadonlyESMap = createMapFromTemplate({ string: TypeFacts.TypeofNEString, number: TypeFacts.TypeofNENumber, bigint: TypeFacts.TypeofNEBigInt, @@ -826,10 +826,10 @@ namespace ts { readonly firstFile: SourceFile; readonly secondFile: SourceFile; /** Key is symbol name. */ - readonly conflictingSymbols: Map; + readonly conflictingSymbols: ESMap; } /** Key is "/path/to/a.ts|/path/to/b.ts". */ - let amalgamatedDuplicates: Map | undefined; + let amalgamatedDuplicates: ESMap | undefined; const reverseMappedCache = createMap(); let inInferTypeForHomomorphicMappedType = false; let ambientModulesCache: Symbol[] | undefined; @@ -839,7 +839,7 @@ namespace ts { * This is only used if there is no exact match. */ let patternAmbientModules: PatternAmbientModule[]; - let patternAmbientModuleAugmentations: Map | undefined; + let patternAmbientModuleAugmentations: ESMap | undefined; let globalObjectType: ObjectType; let globalFunctionType: ObjectType; @@ -907,7 +907,7 @@ namespace ts { const mergedSymbols: Symbol[] = []; const symbolLinks: SymbolLinks[] = []; const nodeLinks: NodeLinks[] = []; - const flowLoopCaches: Map[] = []; + const flowLoopCaches: ESMap[] = []; const flowLoopNodes: FlowNode[] = []; const flowLoopKeys: string[] = []; const flowLoopTypes: Type[][] = []; @@ -923,7 +923,7 @@ namespace ts { const diagnostics = createDiagnosticCollection(); const suggestionDiagnostics = createDiagnosticCollection(); - const typeofTypesByName: ReadonlyMap = createMapFromTemplate({ + const typeofTypesByName: ReadonlyESMap = createMapFromTemplate({ string: stringType, number: numberType, bigint: bigintType, @@ -3753,7 +3753,7 @@ namespace ts { return rightMeaning === SymbolFlags.Value ? SymbolFlags.Value : SymbolFlags.Namespace; } - function getAccessibleSymbolChain(symbol: Symbol | undefined, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean, visitedSymbolTablesMap: Map = createMap()): Symbol[] | undefined { + function getAccessibleSymbolChain(symbol: Symbol | undefined, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean, visitedSymbolTablesMap: ESMap = createMap()): Symbol[] | undefined { if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { return undefined; } @@ -5878,7 +5878,7 @@ namespace ts { const enclosingDeclaration = context.enclosingDeclaration!; let results: Statement[] = []; const visitedSymbols = new Set(); - let deferredPrivates: Map | undefined; + let deferredPrivates: ESMap | undefined; const oldcontext = context; context = { ...oldcontext, @@ -7186,15 +7186,15 @@ namespace ts { // State encounteredError: boolean; visitedTypes: Set | undefined; - symbolDepth: Map | undefined; + symbolDepth: ESMap | undefined; inferTypeParameters: TypeParameter[] | undefined; approximateLength: number; truncating?: boolean; typeParameterSymbolList?: Set; - typeParameterNames?: Map; + typeParameterNames?: ESMap; typeParameterNamesByText?: Set; usedSymbolNames?: Set; - remappedSymbolNames?: Map; + remappedSymbolNames?: ESMap; } function isDefaultBindingContext(location: Node) { @@ -10829,7 +10829,7 @@ namespace ts { function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined { let singleProp: Symbol | undefined; - let propSet: Map | undefined; + let propSet: ESMap | undefined; let indexTypes: Type[] | undefined; const isUnion = containingType.flags & TypeFlags.Union; // Flags we want to propagate to the result if they exist in all source symbols @@ -12890,7 +12890,7 @@ namespace ts { return links.resolvedType; } - function addTypeToIntersection(typeSet: Map, includes: TypeFlags, type: Type) { + function addTypeToIntersection(typeSet: ESMap, includes: TypeFlags, type: Type) { const flags = type.flags; if (flags & TypeFlags.Intersection) { return addTypesToIntersection(typeSet, includes, (type).types); @@ -12920,7 +12920,7 @@ namespace ts { // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. - function addTypesToIntersection(typeSet: Map, includes: TypeFlags, types: readonly Type[]) { + function addTypesToIntersection(typeSet: ESMap, includes: TypeFlags, types: readonly Type[]) { for (const type of types) { includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } @@ -13037,7 +13037,7 @@ namespace ts { // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution // for intersections of types with signatures can be deterministic. function getIntersectionType(types: readonly Type[], aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]): Type { - const typeMembershipMap: Map = createMap(); + const typeMembershipMap: ESMap = createMap(); const includes = addTypesToIntersection(typeMembershipMap, 0, types); const typeSet: Type[] = arrayFrom(typeMembershipMap.values()); // An intersection type is considered empty if it contains @@ -15077,7 +15077,7 @@ namespace ts { function checkTypeRelatedToAndOptionallyElaborate( source: Type, target: Type, - relation: Map, + relation: ESMap, errorNode: Node | undefined, expr: Expression | undefined, headMessage: DiagnosticMessage | undefined, @@ -15099,7 +15099,7 @@ namespace ts { node: Expression | undefined, source: Type, target: Type, - relation: Map, + relation: ESMap, headMessage: DiagnosticMessage | undefined, containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined @@ -15136,7 +15136,7 @@ namespace ts { node: Expression, source: Type, target: Type, - relation: Map, + relation: ESMap, headMessage: DiagnosticMessage | undefined, containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined @@ -15165,7 +15165,7 @@ namespace ts { node: ArrowFunction, source: Type, target: Type, - relation: Map, + relation: ESMap, containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined ): boolean { @@ -15252,7 +15252,7 @@ namespace ts { iterator: ElaborationIterator, source: Type, target: Type, - relation: Map, + relation: ESMap, containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined ) { @@ -15366,7 +15366,7 @@ namespace ts { node: JsxAttributes, source: Type, target: Type, - relation: Map, + relation: ESMap, containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined ) { @@ -15467,7 +15467,7 @@ namespace ts { node: ArrayLiteralExpression, source: Type, target: Type, - relation: Map, + relation: ESMap, containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined ) { @@ -15520,7 +15520,7 @@ namespace ts { node: ObjectLiteralExpression, source: Type, target: Type, - relation: Map, + relation: ESMap, containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined ) { @@ -15811,7 +15811,7 @@ namespace ts { return true; } - function isSimpleTypeRelatedTo(source: Type, target: Type, relation: Map, errorReporter?: ErrorReporter) { + function isSimpleTypeRelatedTo(source: Type, target: Type, relation: ESMap, errorReporter?: ErrorReporter) { const s = source.flags; const t = target.flags; if (t & TypeFlags.AnyOrUnknown || s & TypeFlags.Never || source === wildcardType) return true; @@ -15848,7 +15848,7 @@ namespace ts { return false; } - function isTypeRelatedTo(source: Type, target: Type, relation: Map) { + function isTypeRelatedTo(source: Type, target: Type, relation: ESMap) { if (isFreshLiteralType(source)) { source = (source).regularType; } @@ -15911,7 +15911,7 @@ namespace ts { function checkTypeRelatedTo( source: Type, target: Type, - relation: Map, + relation: ESMap, errorNode: Node | undefined, headMessage?: DiagnosticMessage, containingMessageChain?: () => DiagnosticMessageChain | undefined, @@ -18041,7 +18041,7 @@ namespace ts { * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters. * For other cases, the types ids are used. */ - function getRelationKey(source: Type, target: Type, intersectionState: IntersectionState, relation: Map) { + function getRelationKey(source: Type, target: Type, intersectionState: IntersectionState, relation: ESMap) { if (relation === identityRelation && source.id > target.id) { const temp = source; source = target; @@ -19225,7 +19225,7 @@ namespace ts { function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0, contravariant = false) { let symbolOrTypeStack: (Symbol | Type)[]; - let visited: Map; + let visited: ESMap; let bivariant = false; let propagationType: Type; let inferencePriority = InferencePriority.MaxValue; @@ -25919,7 +25919,7 @@ namespace ts { function checkApplicableSignatureForJsxOpeningLikeElement( node: JsxOpeningLikeElement, signature: Signature, - relation: Map, + relation: ESMap, checkMode: CheckMode, reportErrors: boolean, containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, @@ -26019,7 +26019,7 @@ namespace ts { node: CallLikeExpression, args: readonly Expression[], signature: Signature, - relation: Map, + relation: ESMap, checkMode: CheckMode, reportErrors: boolean, containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined, @@ -26543,7 +26543,7 @@ namespace ts { return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); - function chooseOverload(candidates: Signature[], relation: Map, signatureHelpTrailingComma = false) { + function chooseOverload(candidates: Signature[], relation: ESMap, signatureHelpTrailingComma = false) { candidatesForArgumentError = undefined; candidateForArgumentArityError = undefined; candidateForTypeArgumentError = undefined; @@ -32283,7 +32283,7 @@ namespace ts { return !(getMergedSymbol(typeParameter.symbol).isReferenced! & SymbolFlags.TypeParameter) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); } - function addToGroup(map: Map, key: K, value: V, getKey: (key: K) => number | string): void { + function addToGroup(map: ESMap, key: K, value: V, getKey: (key: K) => number | string): void { const keyString = String(getKey(key)); const group = map.get(keyString); if (group) { @@ -37174,7 +37174,7 @@ namespace ts { // this variable and functions that use it are deliberately moved here from the outer scope // to avoid scope pollution const resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives(); - let fileToDirective: Map; + let fileToDirective: ESMap; if (resolvedTypeReferenceDirectives) { // populate reverse mapping: file path -> type reference directive that was resolved to this file fileToDirective = createMap(); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index b2884340dfce0..a8bd8c1dcd279 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1090,8 +1090,8 @@ namespace ts { /* @internal */ export interface OptionsNameMap { - optionsNameMap: Map; - shortOptionNames: Map; + optionsNameMap: ESMap; + shortOptionNames: ESMap; } /*@internal*/ @@ -1469,7 +1469,7 @@ namespace ts { configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, - extendedConfigCache?: Map, + extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[], ): ParsedCommandLine | undefined { @@ -1562,15 +1562,15 @@ namespace ts { optionTypeMismatchDiagnostic: Diagnostics.Watch_option_0_requires_a_value_of_type_1 }; - let commandLineCompilerOptionsMapCache: Map; + let commandLineCompilerOptionsMapCache: ESMap; function getCommandLineCompilerOptionsMap() { return commandLineCompilerOptionsMapCache || (commandLineCompilerOptionsMapCache = commandLineOptionsToMap(optionDeclarations)); } - let commandLineWatchOptionsMapCache: Map; + let commandLineWatchOptionsMapCache: ESMap; function getCommandLineWatchOptionsMap() { return commandLineWatchOptionsMapCache || (commandLineWatchOptionsMapCache = commandLineOptionsToMap(optionsForWatch)); } - let commandLineTypeAcquisitionMapCache: Map; + let commandLineTypeAcquisitionMapCache: ESMap; function getCommandLineTypeAcquisitionMap() { return commandLineTypeAcquisitionMapCache || (commandLineTypeAcquisitionMapCache = commandLineOptionsToMap(typeAcquisitionDeclarations)); } @@ -1703,13 +1703,13 @@ namespace ts { return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions); - function isRootOptionMap(knownOptions: Map | undefined) { + function isRootOptionMap(knownOptions: ESMap | undefined) { return knownRootOptions && (knownRootOptions as TsConfigOnlyOption).elementOptions === knownOptions; } function convertObjectLiteralExpressionToJson( node: ObjectLiteralExpression, - knownOptions: Map | undefined, + knownOptions: ESMap | undefined, extraKeyDiagnostics: DidYouMeanOptionsDiagnostics | undefined, parentOption: string | undefined ): any { @@ -1964,7 +1964,7 @@ namespace ts { return config; } - function optionMapToObject(optionMap: Map): object { + function optionMapToObject(optionMap: ESMap): object { return { ...arrayFrom(optionMap.entries()).reduce((prev, cur) => ({ ...prev, [cur[0]]: cur[1] }), {}), }; @@ -1994,7 +1994,7 @@ namespace ts { return _ => true; } - function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): Map | undefined { + function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): ESMap | undefined { if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean" || optionDefinition.type === "object") { // this is of a type CommandLineOptionOfPrimitiveType return undefined; @@ -2007,7 +2007,7 @@ namespace ts { } } - function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: Map): string | undefined { + function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: ESMap): string | undefined { // There is a typeMap associated with this command-line option so use it to map value back to its name return forEachEntry(customTypeMap, (mapValue, key) => { if (mapValue === value) { @@ -2019,7 +2019,7 @@ namespace ts { function serializeCompilerOptions( options: CompilerOptions, pathOptions?: { configFilePath: string, useCaseSensitiveFileNames: boolean } - ): Map { + ): ESMap { return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions); } @@ -2031,7 +2031,7 @@ namespace ts { options: OptionsBase, { optionsNameMap }: OptionsNameMap, pathOptions?: { configFilePath: string, useCaseSensitiveFileNames: boolean } - ): Map { + ): ESMap { const result = createMap(); const getCanonicalFileName = pathOptions && createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames); @@ -2220,7 +2220,7 @@ namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map, existingWatchOptions?: WatchOptions): ParsedCommandLine { + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map, existingWatchOptions?: WatchOptions): ParsedCommandLine { return parseJsonConfigFileContentWorker(json, /*sourceFile*/ undefined, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); } @@ -2231,7 +2231,7 @@ namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map, existingWatchOptions?: WatchOptions): ParsedCommandLine { + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map, existingWatchOptions?: WatchOptions): ParsedCommandLine { return parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); } @@ -2271,7 +2271,7 @@ namespace ts { configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: readonly FileExtensionInfo[] = [], - extendedConfigCache?: Map + extendedConfigCache?: ESMap ): ParsedCommandLine { Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined)); const errors: Diagnostic[] = []; @@ -2456,7 +2456,7 @@ namespace ts { configFileName: string | undefined, resolutionStack: string[], errors: Push, - extendedConfigCache?: Map + extendedConfigCache?: ESMap ): ParsedTsconfig { basePath = normalizeSlashes(basePath); const resolvedPath = getNormalizedAbsolutePath(configFileName || "", basePath); @@ -2645,7 +2645,7 @@ namespace ts { basePath: string, resolutionStack: string[], errors: Push, - extendedConfigCache?: Map + extendedConfigCache?: ESMap ): ParsedTsconfig | undefined { const path = host.useCaseSensitiveFileNames ? extendedConfigPath : toFileNameLowerCase(extendedConfigPath); let value: ExtendedConfigCacheEntry | undefined; @@ -2750,11 +2750,11 @@ namespace ts { return convertOptionsFromJson(getCommandLineWatchOptionsMap(), jsonOptions, basePath, /*defaultOptions*/ undefined, watchOptionsDidYouMeanDiagnostics, errors); } - function convertOptionsFromJson(optionsNameMap: Map, jsonOptions: any, basePath: string, + function convertOptionsFromJson(optionsNameMap: ESMap, jsonOptions: any, basePath: string, defaultOptions: undefined, diagnostics: DidYouMeanOptionsDiagnostics, errors: Push): WatchOptions | undefined; - function convertOptionsFromJson(optionsNameMap: Map, jsonOptions: any, basePath: string, + function convertOptionsFromJson(optionsNameMap: ESMap, jsonOptions: any, basePath: string, defaultOptions: CompilerOptions | TypeAcquisition, diagnostics: DidYouMeanOptionsDiagnostics, errors: Push): CompilerOptions | TypeAcquisition; - function convertOptionsFromJson(optionsNameMap: Map, jsonOptions: any, basePath: string, + function convertOptionsFromJson(optionsNameMap: ESMap, jsonOptions: any, basePath: string, defaultOptions: CompilerOptions | TypeAcquisition | WatchOptions | undefined, diagnostics: DidYouMeanOptionsDiagnostics, errors: Push) { if (!jsonOptions) { @@ -3174,7 +3174,7 @@ namespace ts { * @param extensionPriority The priority of the extension. * @param context The expansion context. */ - function hasFileWithHigherPriorityExtension(file: string, literalFiles: Map, wildcardFiles: Map, extensions: readonly string[], keyMapper: (value: string) => string) { + function hasFileWithHigherPriorityExtension(file: string, literalFiles: ESMap, wildcardFiles: ESMap, extensions: readonly string[], keyMapper: (value: string) => string) { const extensionPriority = getExtensionPriority(file, extensions); const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority, extensions); for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) { @@ -3196,7 +3196,7 @@ namespace ts { * @param extensionPriority The priority of the extension. * @param context The expansion context. */ - function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: Map, extensions: readonly string[], keyMapper: (value: string) => string) { + function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: ESMap, extensions: readonly string[], keyMapper: (value: string) => string) { const extensionPriority = getExtensionPriority(file, extensions); const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority, extensions); for (let i = nextExtensionPriority; i < extensions.length; i++) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 573a45b9f3b1d..b79f09154a602 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1,7 +1,7 @@ /* @internal */ namespace ts { - type GetIteratorCallback = | ReadonlyMap | undefined>(iterable: I) => Iterator< - I extends ReadonlyMap ? [K, V] : + type GetIteratorCallback = | ReadonlyESMap | undefined>(iterable: I) => Iterator< + I extends ReadonlyESMap ? [K, V] : I extends ReadonlySet ? T : I extends readonly (infer T)[] ? T : I extends undefined ? undefined : @@ -20,17 +20,17 @@ namespace ts { export const Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim"); export const Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim"); - export function getIterator | ReadonlyMap | undefined>(iterable: I): Iterator< - I extends ReadonlyMap ? [K, V] : + export function getIterator | ReadonlyESMap | undefined>(iterable: I): Iterator< + I extends ReadonlyESMap ? [K, V] : I extends ReadonlySet ? T : I extends readonly (infer T)[] ? T : I extends undefined ? undefined : never>; - export function getIterator(iterable: ReadonlyMap): Iterator<[K, V]>; - export function getIterator(iterable: ReadonlyMap | undefined): Iterator<[K, V]> | undefined; + export function getIterator(iterable: ReadonlyESMap): Iterator<[K, V]>; + export function getIterator(iterable: ReadonlyESMap | undefined): Iterator<[K, V]> | undefined; export function getIterator(iterable: readonly T[] | ReadonlySet): Iterator; export function getIterator(iterable: readonly T[] | ReadonlySet | undefined): Iterator | undefined; - export function getIterator(iterable: readonly any[] | ReadonlySet | ReadonlyMap | undefined): Iterator | undefined { + export function getIterator(iterable: readonly any[] | ReadonlySet | ReadonlyESMap | undefined): Iterator | undefined { if (iterable) { if (isArray(iterable)) return arrayIterator(iterable); if (iterable instanceof Map) return iterable.entries(); @@ -42,15 +42,15 @@ namespace ts { export const emptyArray: never[] = [] as never[]; /** Create a new map. */ - export function createMap(): Map; - export function createMap(): Map; - export function createMap(): Map { + export function createMap(): ESMap; + export function createMap(): ESMap; + export function createMap(): ESMap { return new Map(); } /** Create a new map from a template object is provided, the map will copy entries from it. */ - export function createMapFromTemplate(template: MapLike): Map { - const map: Map = new Map(); + export function createMapFromTemplate(template: MapLike): ESMap { + const map: ESMap = new Map(); // Copies keys/values from template. Note that for..in will not throw if // template is undefined, and instead will just exit the loop. @@ -160,7 +160,7 @@ namespace ts { }; } - export function zipToMap(keys: readonly K[], values: readonly V[]): Map { + export function zipToMap(keys: readonly K[], values: readonly V[]): ESMap { Debug.assert(keys.length === values.length); const map = new Map(); for (let i = 0; i < keys.length; ++i) { @@ -554,9 +554,9 @@ namespace ts { }; } - export function mapDefinedEntries(map: ReadonlyMap, f: (key: K1, value: V1) => readonly [K2, V2] | undefined): Map; - export function mapDefinedEntries(map: ReadonlyMap | undefined, f: (key: K1, value: V1) => readonly [K2 | undefined, V2 | undefined] | undefined): Map | undefined; - export function mapDefinedEntries(map: ReadonlyMap | undefined, f: (key: K1, value: V1) => readonly [K2 | undefined, V2 | undefined] | undefined): Map | undefined { + export function mapDefinedEntries(map: ReadonlyESMap, f: (key: K1, value: V1) => readonly [K2, V2] | undefined): ESMap; + export function mapDefinedEntries(map: ReadonlyESMap | undefined, f: (key: K1, value: V1) => readonly [K2 | undefined, V2 | undefined] | undefined): ESMap | undefined; + export function mapDefinedEntries(map: ReadonlyESMap | undefined, f: (key: K1, value: V1) => readonly [K2 | undefined, V2 | undefined] | undefined): ESMap | undefined { if (!map) { return undefined; } @@ -660,9 +660,9 @@ namespace ts { return result; } - export function mapEntries(map: ReadonlyMap, f: (key: K1, value: V1) => readonly [K2, V2]): Map; - export function mapEntries(map: ReadonlyMap | undefined, f: (key: K1, value: V1) => readonly [K2, V2]): Map | undefined; - export function mapEntries(map: ReadonlyMap | undefined, f: (key: K1, value: V1) => readonly [K2, V2]): Map | undefined { + export function mapEntries(map: ReadonlyESMap, f: (key: K1, value: V1) => readonly [K2, V2]): ESMap; + export function mapEntries(map: ReadonlyESMap | undefined, f: (key: K1, value: V1) => readonly [K2, V2]): ESMap | undefined; + export function mapEntries(map: ReadonlyESMap | undefined, f: (key: K1, value: V1) => readonly [K2, V2]): ESMap | undefined { if (!map) { return undefined; } @@ -1342,11 +1342,11 @@ namespace ts { * the same key with the given 'makeKey' function, then the element with the higher * index in the array will be the one associated with the produced key. */ - export function arrayToMap(array: readonly V[], makeKey: (value: V) => K | undefined): Map; - export function arrayToMap(array: readonly V1[], makeKey: (value: V1) => K | undefined, makeValue: (value: V1) => V2): Map; - export function arrayToMap(array: readonly T[], makeKey: (value: T) => string | undefined): Map; - export function arrayToMap(array: readonly T[], makeKey: (value: T) => string | undefined, makeValue: (value: T) => U): Map; - export function arrayToMap(array: readonly V1[], makeKey: (value: V1) => K | undefined, makeValue: (value: V1) => V1 | V2 = identity): Map { + export function arrayToMap(array: readonly V[], makeKey: (value: V) => K | undefined): ESMap; + export function arrayToMap(array: readonly V1[], makeKey: (value: V1) => K | undefined, makeValue: (value: V1) => V2): ESMap; + export function arrayToMap(array: readonly T[], makeKey: (value: T) => string | undefined): ESMap; + export function arrayToMap(array: readonly T[], makeKey: (value: T) => string | undefined, makeValue: (value: T) => U): ESMap; + export function arrayToMap(array: readonly V1[], makeKey: (value: V1) => K | undefined, makeValue: (value: V1) => V1 | V2 = identity): ESMap { const result = new Map(); for (const value of array) { const key = makeKey(value); @@ -1425,7 +1425,7 @@ namespace ts { return fn ? fn.bind(obj) : undefined; } - export interface MultiMap extends Map { + export interface MultiMap extends ESMap { /** * Adds the value to an array of values associated with the key, and returns the array. * Creates the array if it does not already exist. diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index f580dc5b92451..13ef334670914 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -36,22 +36,36 @@ namespace ts { } /** ES6 Map interface, only read methods included. */ - export interface ReadonlyMap extends ReadonlyCollection { + export interface ReadonlyESMap extends ReadonlyCollection { get(key: K): V | undefined; values(): Iterator; entries(): Iterator<[K, V]>; forEach(action: (value: V, key: K) => void): void; } + /** + * ES6 Map interface, only read methods included. + * @deprecated Use `ts.ReadonlyESMap` instead. + */ + export interface ReadonlyMap extends ReadonlyESMap { + } + /** ES6 Map interface. */ - export interface Map extends ReadonlyMap, Collection { + export interface ESMap extends ReadonlyESMap, Collection { set(key: K, value: V): this; } + /** + * ES6 Map interface. + * @deprecated Use `ts.ESMap` instead. + */ + export interface Map extends ESMap { + } + /* @internal */ export interface MapConstructor { // eslint-disable-next-line @typescript-eslint/prefer-function-type - new (iterable?: readonly (readonly [K, V])[] | ReadonlyMap): Map; + new (iterable?: readonly (readonly [K, V])[] | ReadonlyESMap): ESMap; } /** ES6 Set interface, only read methods included. */ diff --git a/src/compiler/factory/emitHelpers.ts b/src/compiler/factory/emitHelpers.ts index e59c06f151647..6060311957eb2 100644 --- a/src/compiler/factory/emitHelpers.ts +++ b/src/compiler/factory/emitHelpers.ts @@ -841,7 +841,7 @@ namespace ts { };` }; - let allUnscopedEmitHelpers: ReadonlyMap | undefined; + let allUnscopedEmitHelpers: ReadonlyESMap | undefined; export function getAllUnscopedEmitHelpers() { return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = arrayToMap([ diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 50d7e9a4d0f53..5109bb56c8697 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -442,8 +442,8 @@ namespace ts { * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ export interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { - getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; - /*@internal*/ directoryToModuleNameMap: CacheWithRedirects>; + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + /*@internal*/ directoryToModuleNameMap: CacheWithRedirects>; } /** @@ -472,18 +472,18 @@ namespace ts { /*@internal*/ export interface CacheWithRedirects { - ownMap: Map; - redirectsMap: Map>; - getOrCreateMapOfCacheRedirects(redirectedReference: ResolvedProjectReference | undefined): Map; + ownMap: ESMap; + redirectsMap: ESMap>; + getOrCreateMapOfCacheRedirects(redirectedReference: ResolvedProjectReference | undefined): ESMap; clear(): void; setOwnOptions(newOptions: CompilerOptions): void; - setOwnMap(newOwnMap: Map): void; + setOwnMap(newOwnMap: ESMap): void; } /*@internal*/ export function createCacheWithRedirects(options?: CompilerOptions): CacheWithRedirects { - let ownMap: Map = createMap(); - const redirectsMap = new Map>(); + let ownMap: ESMap = createMap(); + const redirectsMap = new Map>(); return { ownMap, redirectsMap, @@ -497,7 +497,7 @@ namespace ts { options = newOptions; } - function setOwnMap(newOwnMap: Map) { + function setOwnMap(newOwnMap: ESMap) { ownMap = newOwnMap; } @@ -523,7 +523,7 @@ namespace ts { /*@internal*/ export function createModuleResolutionCacheWithMaps( - directoryToModuleNameMap: CacheWithRedirects>, + directoryToModuleNameMap: CacheWithRedirects>, moduleNameToDirectoryMap: CacheWithRedirects, currentDirectory: string, getCanonicalFileName: GetCanonicalFileName): ModuleResolutionCache { @@ -532,7 +532,7 @@ namespace ts { function getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference) { const path = toPath(directoryName, currentDirectory, getCanonicalFileName); - return getOrCreateCache>(directoryToModuleNameMap, redirectedReference, path, createMap); + return getOrCreateCache>(directoryToModuleNameMap, redirectedReference, path, createMap); } function getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 2e8729b29c220..5961e4ddbb095 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -722,8 +722,8 @@ namespace ts { let currentToken: SyntaxKind; let nodeCount: number; - let identifiers: Map; - let privateIdentifiers: Map; + let identifiers: ESMap; + let privateIdentifiers: ESMap; let identifierCount: number; let parsingContext: ParsingContext; diff --git a/src/compiler/performance.ts b/src/compiler/performance.ts index 3da794c638b16..86526ce8f3830 100644 --- a/src/compiler/performance.ts +++ b/src/compiler/performance.ts @@ -8,9 +8,9 @@ namespace ts.performance { let enabled = false; let profilerStart = 0; - let counts: Map; - let marks: Map; - let measures: Map; + let counts: ESMap; + let marks: ESMap; + let measures: ESMap; export interface Timer { enter(): void; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 8cee3aae854d7..006ef6475834a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -126,7 +126,7 @@ namespace ts { } } - let outputFingerprints: Map; + let outputFingerprints: ESMap; function writeFileWorker(fileName: string, data: string, writeByteOrderMark: boolean) { if (!isWatchSet(options) || !system.createHash || !system.getModifiedTime) { system.writeFile(fileName, data, writeByteOrderMark); @@ -533,7 +533,7 @@ namespace ts { export const inferredTypesContainingFile = "__inferred type names__.ts"; interface DiagnosticCache { - perFile?: Map; + perFile?: ESMap; allDiagnostics?: readonly T[]; } @@ -702,7 +702,7 @@ namespace ts { let processingDefaultLibFiles: SourceFile[] | undefined; let processingOtherFiles: SourceFile[] | undefined; let files: SourceFile[]; - let symlinks: ReadonlyMap | undefined; + let symlinks: ReadonlyESMap | undefined; let commonSourceDirectory: string; let diagnosticsProducingTypeChecker: TypeChecker; let noDiagnosticsTypeChecker: TypeChecker; @@ -803,9 +803,9 @@ namespace ts { // A parallel array to projectReferences storing the results of reading in the referenced tsconfig files let resolvedProjectReferences: readonly (ResolvedProjectReference | undefined)[] | undefined; - let projectReferenceRedirects: Map | undefined; - let mapFromFileToProjectReferenceRedirects: Map | undefined; - let mapFromToProjectReferenceRedirectSource: Map | undefined; + let projectReferenceRedirects: ESMap | undefined; + let mapFromFileToProjectReferenceRedirects: ESMap | undefined; + let mapFromToProjectReferenceRedirectSource: ESMap | undefined; const useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect?.() && !options.disableSourceOfProjectReferenceRedirect; @@ -3452,7 +3452,7 @@ namespace ts { return comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === Comparison.EqualTo; } - function getProbableSymlinks(): ReadonlyMap { + function getProbableSymlinks(): ReadonlyESMap { if (host.getSymlinks) { return host.getSymlinks(); } @@ -3479,8 +3479,8 @@ namespace ts { function updateHostForUseSourceOfProjectReferenceRedirect(host: HostForUseSourceOfProjectReferenceRedirect) { let setOfDeclarationDirectories: Set | undefined; - let symlinkedDirectories: Map | undefined; - let symlinkedFiles: Map | undefined; + let symlinkedDirectories: ESMap | undefined; + let symlinkedFiles: ESMap | undefined; const originalFileExists = host.compilerHost.fileExists; const originalDirectoryExists = host.compilerHost.directoryExists; diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index dc79fe0fabff9..6ad1f9a29c7aa 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -13,7 +13,7 @@ namespace ts { invalidateResolutionOfFile(filePath: Path): void; removeResolutionsOfFile(filePath: Path): void; removeResolutionsFromProjectReferenceRedirects(filePath: Path): void; - setFilesWithInvalidatedNonRelativeUnresolvedImports(filesWithUnresolvedImports: Map): void; + setFilesWithInvalidatedNonRelativeUnresolvedImports(filesWithUnresolvedImports: ESMap): void; createHasInvalidatedResolution(forceAllFilesAsInvalidated?: boolean): HasInvalidatedResolution; hasChangedAutomaticTypeDirectiveNames(): boolean; @@ -144,7 +144,7 @@ namespace ts { export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootDirForResolution: string | undefined, logChangesWhenResolvingModule: boolean): ResolutionCache { let filesWithChangedSetOfUnresolvedImports: Path[] | undefined; let filesWithInvalidatedResolutions: Set | undefined; - let filesWithInvalidatedNonRelativeUnresolvedImports: ReadonlyMap | undefined; + let filesWithInvalidatedNonRelativeUnresolvedImports: ReadonlyESMap | undefined; const nonRelativeExternalModuleResolutions = createMultiMap(); const resolutionsWithFailedLookups: ResolutionWithFailedLookupLocations[] = []; @@ -161,8 +161,8 @@ namespace ts { // The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file. // The key in the map is source file's path. // The values are Map of resolutions with key being name lookedup. - const resolvedModuleNames = new Map>(); - const perDirectoryResolvedModuleNames: CacheWithRedirects> = createCacheWithRedirects(); + const resolvedModuleNames = new Map>(); + const perDirectoryResolvedModuleNames: CacheWithRedirects> = createCacheWithRedirects(); const nonRelativeModuleNameCache: CacheWithRedirects = createCacheWithRedirects(); const moduleResolutionCache = createModuleResolutionCacheWithMaps( perDirectoryResolvedModuleNames, @@ -171,8 +171,8 @@ namespace ts { resolutionHost.getCanonicalFileName ); - const resolvedTypeReferenceDirectives = new Map>(); - const perDirectoryResolvedTypeReferenceDirectives: CacheWithRedirects> = createCacheWithRedirects(); + const resolvedTypeReferenceDirectives = new Map>(); + const perDirectoryResolvedTypeReferenceDirectives: CacheWithRedirects> = createCacheWithRedirects(); /** * These are the extensions that failed lookup files will have by default, @@ -334,8 +334,8 @@ namespace ts { names: readonly string[]; containingFile: string; redirectedReference: ResolvedProjectReference | undefined; - cache: Map>; - perDirectoryCacheWithRedirects: CacheWithRedirects>; + cache: ESMap>; + perDirectoryCacheWithRedirects: CacheWithRedirects>; loader: (name: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference) => T; getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName; shouldRetryResolution: (t: T) => boolean; @@ -684,7 +684,7 @@ namespace ts { } function removeResolutionsOfFileFromCache( - cache: Map>, + cache: ESMap>, filePath: Path, getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName, ) { @@ -741,7 +741,7 @@ namespace ts { } } - function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap: ReadonlyMap) { + function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap: ReadonlyESMap) { Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined); filesWithInvalidatedNonRelativeUnresolvedImports = filesMap; } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 376e524f9c2d5..b58ae9aee773c 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -330,7 +330,7 @@ namespace ts { lookupInUnicodeMap(code, unicodeES3IdentifierPart); } - function makeReverseMap(source: Map): string[] { + function makeReverseMap(source: ESMap): string[] { const result: string[] = []; source.forEach((value, name) => { result[value] = name; diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 3e70d335566bb..c698acf2f25c7 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -16,7 +16,7 @@ namespace ts { let sourcesContent: (string | null)[] | undefined; const names: string[] = []; - let nameToNameIndexMap: Map | undefined; + let nameToNameIndexMap: ESMap | undefined; let mappings = ""; // Last recorded and encoded mappings diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index fcbaddb966ed2..1662a7ef31096 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -538,7 +538,7 @@ namespace ts { }; } - type InvokeMap = Map; + type InvokeMap = ESMap; function invokeCallbacks(dirPath: Path, fileName: string): void; function invokeCallbacks(dirPath: Path, invokeMap: InvokeMap, fileNames: string[] | undefined): void; function invokeCallbacks(dirPath: Path, fileNameOrInvokeMap: string | InvokeMap, fileNames?: string[]) { diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 8d05347bc6f31..5e154661fa35c 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -60,7 +60,7 @@ namespace ts { let enclosingDeclaration: Node; let necessaryTypeReferences: Set | undefined; let lateMarkedStatements: LateVisibilityPaintedStatement[] | undefined; - let lateStatementReplacementMap: Map>; + let lateStatementReplacementMap: ESMap>; let suppressNewDiagnosticContexts: boolean; let exportedModulesFromDeclarationEmit: Symbol[] | undefined; @@ -81,8 +81,8 @@ namespace ts { let errorNameNode: DeclarationName | undefined; let currentSourceFile: SourceFile; - let refs: Map; - let libs: Map; + let refs: ESMap; + let libs: ESMap; let emittedImports: readonly AnyImportSyntax[] | undefined; // must be declared in container so it can be `undefined` while transformer's first pass const resolver = context.getEmitResolver(); const options = context.getCompilerOptions(); @@ -402,7 +402,7 @@ namespace ts { } } - function collectReferences(sourceFile: SourceFile | UnparsedSource, ret: Map) { + function collectReferences(sourceFile: SourceFile | UnparsedSource, ret: ESMap) { if (noResolve || (!isUnparsedSource(sourceFile) && isSourceFileJS(sourceFile))) return ret; forEach(sourceFile.referencedFiles, f => { const elem = host.getSourceFileFromReference(sourceFile, f); @@ -413,7 +413,7 @@ namespace ts { return ret; } - function collectLibs(sourceFile: SourceFile | UnparsedSource, ret: Map) { + function collectLibs(sourceFile: SourceFile | UnparsedSource, ret: ESMap) { forEach(sourceFile.libReferenceDirectives, ref => { const lib = host.getLibFileFromReference(ref); if (lib) { diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index f9d94f3ee5976..4c20c28ffcc86 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -72,15 +72,15 @@ namespace ts { * set of labels that occurred inside the converted loop * used to determine if labeled jump can be emitted as is or it should be dispatched to calling code */ - labels?: Map; + labels?: ESMap; /* * collection of labeled jumps that transfer control outside the converted loop. * maps store association 'label -> labelMarker' where * - label - value of label as it appear in code * - label marker - return value that should be interpreted by calling code as 'jump to + + + + + + @@ -8874,15 +8880,6 @@ - - - - - - - - - @@ -8946,6 +8943,18 @@ + + + + + + + + + + + + @@ -10005,6 +10014,12 @@ + + + + + + @@ -12891,15 +12906,6 @@ - - - - - - - - - From 652a1c5950d00ede5848e2c1de6191db0553f98e Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 2 Jul 2020 11:39:27 -0700 Subject: [PATCH 30/47] Emit fallback for decorator metadata for type only imports (#39337) --- src/compiler/checker.ts | 16 ++--- .../decoratorMetadataWithTypeOnlyImport.js | 60 +++++++++++++++++++ ...ecoratorMetadataWithTypeOnlyImport.symbols | 30 ++++++++++ .../decoratorMetadataWithTypeOnlyImport.types | 29 +++++++++ .../decoratorMetadataWithTypeOnlyImport.ts | 21 +++++++ 5 files changed, 149 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.js create mode 100644 tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.symbols create mode 100644 tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.types create mode 100644 tests/cases/conformance/decorators/decoratorMetadataWithTypeOnlyImport.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cc2ed2e3d421e..a5c26b6154197 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -36989,29 +36989,31 @@ namespace ts { } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. - const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + const isTypeOnly = valueSymbol?.declarations?.every(isTypeOnlyImportOrExportDeclaration) || false; + const resolvedSymbol = valueSymbol && valueSymbol.flags & SymbolFlags.Alias ? resolveAlias(valueSymbol) : valueSymbol; // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. const typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); - if (valueSymbol && valueSymbol === typeSymbol) { + if (resolvedSymbol && resolvedSymbol === typeSymbol) { const globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); - if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { + if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) { return TypeReferenceSerializationKind.Promise; } - const constructorType = getTypeOfSymbol(valueSymbol); + const constructorType = getTypeOfSymbol(resolvedSymbol); if (constructorType && isConstructorType(constructorType)) { - return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + return isTypeOnly ? TypeReferenceSerializationKind.TypeWithCallSignature : TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; } } // We might not be able to resolve type symbol so use unknown type in that case (eg error case) if (!typeSymbol) { - return TypeReferenceSerializationKind.Unknown; + return isTypeOnly ? TypeReferenceSerializationKind.ObjectType : TypeReferenceSerializationKind.Unknown; } const type = getDeclaredTypeOfSymbol(typeSymbol); if (type === errorType) { - return TypeReferenceSerializationKind.Unknown; + return isTypeOnly ? TypeReferenceSerializationKind.ObjectType : TypeReferenceSerializationKind.Unknown; } else if (type.flags & TypeFlags.AnyOrUnknown) { return TypeReferenceSerializationKind.ObjectType; diff --git a/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.js b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.js new file mode 100644 index 0000000000000..0596ecfa12be6 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.js @@ -0,0 +1,60 @@ +//// [tests/cases/conformance/decorators/decoratorMetadataWithTypeOnlyImport.ts] //// + +//// [service.ts] +export class Service { +} +//// [component.ts] +import type { Service } from "./service"; + +declare var decorator: any; + +@decorator +class MyComponent { + constructor(public Service: Service) { + } + + @decorator + method(x: this) { + } +} + +//// [service.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Service = void 0; +var Service = /** @class */ (function () { + function Service() { + } + return Service; +}()); +exports.Service = Service; +//// [component.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var MyComponent = /** @class */ (function () { + function MyComponent(Service) { + this.Service = Service; + } + MyComponent.prototype.method = function (x) { + }; + __decorate([ + decorator, + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object]), + __metadata("design:returntype", void 0) + ], MyComponent.prototype, "method", null); + MyComponent = __decorate([ + decorator, + __metadata("design:paramtypes", [Function]) + ], MyComponent); + return MyComponent; +}()); diff --git a/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.symbols b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.symbols new file mode 100644 index 0000000000000..a36cba8c590e1 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/decorators/service.ts === +export class Service { +>Service : Symbol(Service, Decl(service.ts, 0, 0)) +} +=== tests/cases/conformance/decorators/component.ts === +import type { Service } from "./service"; +>Service : Symbol(Service, Decl(component.ts, 0, 13)) + +declare var decorator: any; +>decorator : Symbol(decorator, Decl(component.ts, 2, 11)) + +@decorator +>decorator : Symbol(decorator, Decl(component.ts, 2, 11)) + +class MyComponent { +>MyComponent : Symbol(MyComponent, Decl(component.ts, 2, 27)) + + constructor(public Service: Service) { +>Service : Symbol(MyComponent.Service, Decl(component.ts, 6, 16)) +>Service : Symbol(Service, Decl(component.ts, 0, 13)) + } + + @decorator +>decorator : Symbol(decorator, Decl(component.ts, 2, 11)) + + method(x: this) { +>method : Symbol(MyComponent.method, Decl(component.ts, 7, 5)) +>x : Symbol(x, Decl(component.ts, 10, 11)) + } +} diff --git a/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.types b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.types new file mode 100644 index 0000000000000..125380a21a9a0 --- /dev/null +++ b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/decorators/service.ts === +export class Service { +>Service : Service +} +=== tests/cases/conformance/decorators/component.ts === +import type { Service } from "./service"; +>Service : Service + +declare var decorator: any; +>decorator : any + +@decorator +>decorator : any + +class MyComponent { +>MyComponent : MyComponent + + constructor(public Service: Service) { +>Service : Service + } + + @decorator +>decorator : any + + method(x: this) { +>method : (x: this) => void +>x : this + } +} diff --git a/tests/cases/conformance/decorators/decoratorMetadataWithTypeOnlyImport.ts b/tests/cases/conformance/decorators/decoratorMetadataWithTypeOnlyImport.ts new file mode 100644 index 0000000000000..e0f26d0518c44 --- /dev/null +++ b/tests/cases/conformance/decorators/decoratorMetadataWithTypeOnlyImport.ts @@ -0,0 +1,21 @@ +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @target: es5 +// @module: commonjs +// @filename: service.ts +export class Service { +} +// @filename: component.ts +import type { Service } from "./service"; + +declare var decorator: any; + +@decorator +class MyComponent { + constructor(public Service: Service) { + } + + @decorator + method(x: this) { + } +} \ No newline at end of file From 93ccc176588e7f5ede6ff220a680f33b11269e12 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 2 Jul 2020 14:09:59 -0700 Subject: [PATCH 31/47] Node-based @deprecated checks (#39323) * Node-based @deprecated checks Switch the checker to syntactic checks for `@deprecated` on declarations. This requires a bit more checking of declarations in the checker at times, but it 1. Gets rid of work, and a symbol flag, in the binder. 2. Skips work in the checker unless there is a `@deprecated` tag. 3. Makes it fairly simple to only issue errors on particular signatures of overloaded functions. * remove in-progress comment * remove unused isTypeDeclaration * :heart: lint * support jsx and tagged template functions * Support decorators too --- src/compiler/binder.ts | 4 - src/compiler/checker.ts | 35 +- src/compiler/types.ts | 3 +- .../reference/api/tsserverlibrary.d.ts | 1 - tests/baselines/reference/api/typescript.d.ts | 1 - .../fourslash/jsdocDeprecated_suggestion1.ts | 313 +++++++++++++----- .../fourslash/jsdocDeprecated_suggestion2.ts | 131 ++++++++ .../fourslash/jsdocDeprecated_suggestion3.ts | 124 +++++++ 8 files changed, 504 insertions(+), 108 deletions(-) create mode 100644 tests/cases/fourslash/jsdocDeprecated_suggestion2.ts create mode 100644 tests/cases/fourslash/jsdocDeprecated_suggestion3.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index a8ff97aab2e01..ff617602d430c 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -537,10 +537,6 @@ namespace ts { symbol.parent = parent; } - if (node.flags & NodeFlags.Deprecated) { - symbol.flags |= SymbolFlags.Deprecated; - } - return symbol; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a5c26b6154197..7c8a38f62125e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13284,13 +13284,19 @@ namespace ts { undefined; } + function isUncalledFunctionReference(node: Node, symbol: Symbol) { + return !(symbol.flags & (SymbolFlags.Function | SymbolFlags.Method)) + || !isCallLikeExpression(findAncestor(node, n => !isAccessExpression(n)) || node.parent) + && every(symbol.declarations, d => !isFunctionLike(d) || !!(d.flags & NodeFlags.Deprecated)); + } + function getPropertyTypeForIndexType(originalObjectType: Type, objectType: Type, indexType: Type, fullIndexType: Type, suppressNoImplicitAnyError: boolean, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, accessFlags: AccessFlags) { const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined; const propName = accessNode && isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { const prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessNode && prop.flags & SymbolFlags.Deprecated) { + if (accessNode && prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) { const deprecatedNode = accessExpression?.argumentExpression ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); errorOrSuggestion(/* isError */ false, deprecatedNode, Diagnostics._0_is_deprecated, propName as string); } @@ -22055,9 +22061,8 @@ namespace ts { const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); let declaration: Declaration | undefined = localOrExportSymbol.valueDeclaration; - const target = (symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol); - if (target.flags & SymbolFlags.Deprecated) { - errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string); + if (declaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, localOrExportSymbol)) { + errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);; } if (localOrExportSymbol.flags & SymbolFlags.Class) { // Due to the emit for class decorators, any reference to the class from inside of the class body @@ -24604,6 +24609,7 @@ namespace ts { if (isNodeOpeningLikeElement) { const jsxOpeningLikeNode = node as JsxOpeningLikeElement; const sig = getResolvedSignature(jsxOpeningLikeNode); + checkDeprecatedSignature(sig, node); checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode); } } @@ -25032,7 +25038,7 @@ namespace ts { propType = indexInfo.type; } else { - if (prop.flags & SymbolFlags.Deprecated) { + if (prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) { errorOrSuggestion(/* isError */ false, right, Diagnostics._0_is_deprecated, right.escapedText as string); } @@ -27424,6 +27430,8 @@ namespace ts { return nonInferrableType; } + checkDeprecatedSignature(signature, node); + if (node.expression.kind === SyntaxKind.SuperKeyword) { return voidType; } @@ -27483,6 +27491,12 @@ namespace ts { return returnType; } + function checkDeprecatedSignature(signature: Signature, node: Node) { + if (signature.declaration && signature.declaration.flags & NodeFlags.Deprecated) { + errorOrSuggestion(/*isError*/ false, node, Diagnostics._0_is_deprecated, signatureToString(signature)); + } + } + function isSymbolOrSymbolForCall(node: Node) { if (!isCallExpression(node)) return false; let left = node.expression; @@ -27591,7 +27605,9 @@ namespace ts { if (languageVersion < ScriptTarget.ES2015) { checkExternalEmitHelpers(node, ExternalEmitHelpers.MakeTemplateObject); } - return getReturnTypeOfSignature(getResolvedSignature(node)); + const signature = getResolvedSignature(node); + checkDeprecatedSignature(signature, node); + return getReturnTypeOfSignature(signature); } function checkAssertion(node: AssertionExpression) { @@ -30867,7 +30883,7 @@ namespace ts { } const symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - if (symbol.flags & SymbolFlags.Deprecated) { + if (every(symbol.declarations, d => !isTypeDeclaration(d) || !!(d.flags & NodeFlags.Deprecated))) { const diagLocation = isTypeReferenceNode(node) && isQualifiedName(node.typeName) ? node.typeName.right : node; errorOrSuggestion(/* isError */ false, diagLocation, Diagnostics._0_is_deprecated, symbol.escapedName as string); } @@ -31719,6 +31735,7 @@ namespace ts { /** Check a decorator */ function checkDecorator(node: Decorator): void { const signature = getResolvedSignature(node); + checkDeprecatedSignature(signature, node); const returnType = getReturnTypeOfSignature(signature); if (returnType.flags & TypeFlags.Any) { return; @@ -35212,7 +35229,9 @@ namespace ts { } } - if (isImportSpecifier(node) && target.flags & SymbolFlags.Deprecated) { + if (isImportSpecifier(node) && + (target.valueDeclaration && target.valueDeclaration.flags & NodeFlags.Deprecated + || every(target.declarations, d => !!(d.flags & NodeFlags.Deprecated)))) { errorOrSuggestion(/* isError */ false, node.name, Diagnostics._0_is_deprecated, symbol.escapedName as string); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 518114d08b8db..2472b302545cc 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4512,10 +4512,9 @@ namespace ts { Transient = 1 << 25, // Transient symbol (created during type check) Assignment = 1 << 26, // Assignment treated as declaration (eg `this.prop = 1`) ModuleExports = 1 << 27, // Symbol for CommonJS `module` of `module.exports` - Deprecated = 1 << 28, // Symbol has Deprecated declaration tag (eg `@deprecated`) /* @internal */ All = FunctionScopedVariable | BlockScopedVariable | Property | EnumMember | Function | Class | Interface | ConstEnum | RegularEnum | ValueModule | NamespaceModule | TypeLiteral - | ObjectLiteral | Method | Constructor | GetAccessor | SetAccessor | Signature | TypeParameter | TypeAlias | ExportValue | Alias | Prototype | ExportStar | Optional | Transient | Deprecated, + | ObjectLiteral | Method | Constructor | GetAccessor | SetAccessor | Signature | TypeParameter | TypeAlias | ExportValue | Alias | Prototype | ExportStar | Optional | Transient, Enum = RegularEnum | ConstEnum, Variable = FunctionScopedVariable | BlockScopedVariable, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index dd44ee78b0123..360aa0650053d 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2343,7 +2343,6 @@ declare namespace ts { Transient = 33554432, Assignment = 67108864, ModuleExports = 134217728, - Deprecated = 268435456, Enum = 384, Variable = 3, Value = 111551, diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 2ec3b7371aa9b..d30b0b8f7ac84 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2343,7 +2343,6 @@ declare namespace ts { Transient = 33554432, Assignment = 67108864, ModuleExports = 134217728, - Deprecated = 268435456, Enum = 384, Variable = 3, Value = 111551, diff --git a/tests/cases/fourslash/jsdocDeprecated_suggestion1.ts b/tests/cases/fourslash/jsdocDeprecated_suggestion1.ts index a8e13edbe04de..5725870f0fbb5 100644 --- a/tests/cases/fourslash/jsdocDeprecated_suggestion1.ts +++ b/tests/cases/fourslash/jsdocDeprecated_suggestion1.ts @@ -1,19 +1,22 @@ +/// +// @experimentalDecorators: true + // @Filename: a.ts //// export namespace foo { //// /** @deprecated */ //// export function faff () { } -//// [|faff|]() +//// [|faff()|] //// } -//// const [|a|] = foo.[|faff|]() +//// const [|a|] = [|foo.faff()|] //// foo[[|"faff"|]] //// const { [|faff|] } = foo -//// faff() +//// [|faff()|] //// /** @deprecated */ //// export function bar () { -//// foo?.[|faff|]() +//// [|foo?.faff()|] //// } -//// foo?.[[|"faff"|]]?.() -//// [|bar|](); +//// [|foo?.["faff"]?.()|] +//// [|bar()|]; //// /** @deprecated */ //// export interface Foo { //// /** @deprecated */ @@ -22,13 +25,52 @@ //// /** @deprecated */ //// export type QW = [|Foo|][[|"zzz"|]] //// export type WQ = [|QW|] +//// class C { +//// /** @deprecated */ +//// constructor() { +//// } +//// /** @deprecated */ +//// m() { } +//// } +//// /** @deprecated */ +//// class D { +//// constructor() { +//// } +//// } +//// var c = [|new C()|] +//// [|c.m()|] +//// c.[|m|] +//// new [|D|]() +//// C +//// [|D|] +// @Filename: j.tsx +//// type Props = { someProp?: any } +//// declare var props: Props +//// /** @deprecated */ +//// function Compi(_props: Props) { +//// return
+//// } +//// [|Compi|]; +//// [||]; +//// [||]
; +//// /** @deprecated */ +//// function ttf(_x: unknown) { +//// } +//// [|ttf``|] +//// [|ttf|] +//// /** @deprecated */ +//// function dec(_c: unknown) { } +//// [|dec|] +//// [|@dec|] +//// class K { } // @Filename: b.ts +//// // imports and aliases //// import * as f from './a'; //// import { [|bar|], [|QW|] } from './a'; -//// f.[|bar|](); -//// f.foo.[|faff|](); -//// [|bar|](); +//// [|f.bar()|]; +//// [|f.foo.faff()|]; +//// [|bar()|]; //// type Z = [|QW|]; //// type A = f.[|Foo|]; //// type B = f.[|QW|]; @@ -40,127 +82,214 @@ const ranges = test.ranges(); verify.getSuggestionDiagnostics([ { - message: "'faff' is deprecated", - code: 6385, - range: ranges[0], - reportsDeprecated: true, + "code": 6385, + "message": "'(): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[0] }, { - message: "'a' is declared but its value is never read.", - code: 6133, - range: ranges[1], - reportsUnnecessary: true + "code": 6133, + "message": "'a' is declared but its value is never read.", + "reportsUnnecessary": true, + "range": ranges[1] }, { - message: "'faff' is deprecated", - code: 6385, - range: ranges[2], - reportsDeprecated: true, + "code": 6385, + "message": "'(): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[2] }, { - message: "'faff' is deprecated", - code: 6385, - range: ranges[3], - reportsDeprecated: true, + "code": 6385, + "message": "'faff' is deprecated", + "reportsDeprecated": true, + "range": ranges[3] }, { - message: "'faff' is deprecated", - code: 6385, - range: ranges[4], - reportsDeprecated: true, + "code": 6385, + "message": "'faff' is deprecated", + "reportsDeprecated": true, + "range": ranges[4] }, { - message: "'faff' is deprecated", - code: 6385, - range: ranges[5], - reportsDeprecated: true, + "code": 6385, + "message": "'(): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[5] }, { - message: "'faff' is deprecated", - code: 6385, - range: ranges[6], - reportsDeprecated: true, + "code": 6385, + "message": "'(): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[6] }, { - message: "'bar' is deprecated", - code: 6385, - range: ranges[7], - reportsDeprecated: true, + "code": 6385, + "message": "'(): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[7] }, { - message: "'Foo' is deprecated", - code: 6385, - range: ranges[8], - reportsDeprecated: true, + "code": 6385, + "message": "'(): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[8] }, { - message: "'zzz' is deprecated", - code: 6385, - range: ranges[9], - reportsDeprecated: true, + "code": 6385, + "message": "'Foo' is deprecated", + "reportsDeprecated": true, + "range": ranges[9] }, { - message: "'QW' is deprecated", - code: 6385, - range: ranges[10], - reportsDeprecated: true, - } -]) + "code": 6385, + "message": "'zzz' is deprecated", + "reportsDeprecated": true, + "range": ranges[10] + }, + { + "code": 6385, + "message": "'QW' is deprecated", + "reportsDeprecated": true, + "range": ranges[11] + }, + { + "code": 6385, + "message": "'(): C' is deprecated", + "reportsDeprecated": true, + "range": ranges[12] + }, + { + "code": 6385, + "message": "'(): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[13] + }, + { + "code": 6385, + "message": "'m' is deprecated", + "reportsDeprecated": true, + "range": ranges[14] + }, + { + "code": 6385, + "message": "'D' is deprecated", + "reportsDeprecated": true, + "range": ranges[15] + }, + { + "code": 6385, + "message": "'D' is deprecated", + "reportsDeprecated": true, + "range": ranges[16] + }, +]); +goTo.file('j.tsx') +verify.getSuggestionDiagnostics([ + { + "code": 6385, + "message": "'Compi' is deprecated", + "reportsDeprecated": true, + "range": ranges[17] + }, + { + "code": 6385, + "message": "'(_props: Props): any' is deprecated", + "reportsDeprecated": true, + "range": ranges[18] + }, + { + "code": 6385, + "message": "'(_props: Props): any' is deprecated", + "reportsDeprecated": true, + "range": ranges[19] + }, + { + "code": 6385, + "message": "'Compi' is deprecated", + "reportsDeprecated": true, + "range": ranges[20] + }, + { + "code": 6385, + "message": "'(_x: unknown): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[21] + }, + { + "code": 6385, + "message": "'ttf' is deprecated", + "reportsDeprecated": true, + "range": ranges[22] + }, + { + "code": 6385, + "message": "'dec' is deprecated", + "reportsDeprecated": true, + "range": ranges[23] + }, + { + "code": 6385, + "message": "'(_c: unknown): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[24] + }, +]); goTo.file('b.ts') verify.getSuggestionDiagnostics([ { - message: "'bar' is deprecated", - code: 6385, - range: ranges[11], - reportsDeprecated: true, + "code": 6385, + "message": "'bar' is deprecated", + "reportsDeprecated": true, + "range": ranges[25] }, { - message: "'QW' is deprecated", - code: 6385, - range: ranges[12], - reportsDeprecated: true, + "code": 6385, + "message": "'QW' is deprecated", + "reportsDeprecated": true, + "range": ranges[26] }, { - message: "'bar' is deprecated", - code: 6385, - range: ranges[13], - reportsDeprecated: true, + "code": 6385, + "message": "'(): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[27] }, { - message: "'faff' is deprecated", - code: 6385, - range: ranges[14], - reportsDeprecated: true, + "code": 6385, + "message": "'(): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[28] }, { - message: "'bar' is deprecated", - code: 6385, - range: ranges[15], - reportsDeprecated: true, + "code": 6385, + "message": "'(): void' is deprecated", + "reportsDeprecated": true, + "range": ranges[29] }, { - message: "'QW' is deprecated", - code: 6385, - range: ranges[16], - reportsDeprecated: true, + "code": 6385, + "message": "'QW' is deprecated", + "reportsDeprecated": true, + "range": ranges[30] }, { - message: "'Foo' is deprecated", - code: 6385, - range: ranges[17], - reportsDeprecated: true, + "code": 6385, + "message": "'Foo' is deprecated", + "reportsDeprecated": true, + "range": ranges[31] }, { - message: "'QW' is deprecated", - code: 6385, - range: ranges[18], - reportsDeprecated: true, + "code": 6385, + "message": "'QW' is deprecated", + "reportsDeprecated": true, + "range": ranges[32] }, { - message: "'O' is declared but never used.", - code: 6196, - range: ranges[19], - reportsUnnecessary: true + "code": 6196, + "message": "'O' is declared but never used.", + "reportsUnnecessary": true, + "range": ranges[33] } -]) \ No newline at end of file +]) diff --git a/tests/cases/fourslash/jsdocDeprecated_suggestion2.ts b/tests/cases/fourslash/jsdocDeprecated_suggestion2.ts new file mode 100644 index 0000000000000..5f1560f08c238 --- /dev/null +++ b/tests/cases/fourslash/jsdocDeprecated_suggestion2.ts @@ -0,0 +1,131 @@ +/// + +//// // overloads +//// declare function foo(a: string): number; +//// /** @deprecated */ +//// declare function foo(): undefined; +//// declare function foo (a?: string): number | undefined; +//// [|foo()|]; +//// foo(''); +//// foo; + +//// /** @deprecated */ +//// declare function bar(): number; +//// [|bar()|]; +//// [|bar|]; + +//// /** @deprecated */ +//// declare function baz(): number; +//// /** @deprecated */ +//// declare function baz(): number | undefined; +//// [|baz()|]; +//// [|baz|]; + +//// interface Foo { +//// /** @deprecated */ +//// (): void +//// (a: number): void +//// } +//// declare const f: Foo; +//// [|f()|]; +//// f(1); + +//// interface T { +//// createElement(): void +//// /** @deprecated */ +//// createElement(tag: 'xmp'): void; +//// } +//// declare const t: T; +//// t.createElement(); +//// [|t.createElement('xmp')|]; + +//// declare class C { +//// /** @deprecated */ +//// constructor (); +//// constructor(v: string) +//// } +//// C; +//// const c = [|new C()|]; + +//// interface Ca { +//// /** @deprecated */ +//// (): void +//// new (): void +//// } +//// interface Cb { +//// (): void +//// /** @deprecated */ +//// new (): string +//// } +//// declare const ca: Ca; +//// declare const cb: Cb; +//// ca; +//// cb; +//// [|ca()|]; +//// cb(); +//// new ca(); +//// [|new cb()|]; + +const ranges = test.ranges(); +verify.getSuggestionDiagnostics([ + { + message: "'(): undefined' is deprecated", + code: 6385, + range: ranges[0], + reportsDeprecated: true, + }, + { + message: "'(): number' is deprecated", + code: 6385, + range: ranges[1], + reportsDeprecated: true, + }, + { + message: "'bar' is deprecated", + code: 6385, + range: ranges[2], + reportsDeprecated: true, + }, + { + message: "'(): number' is deprecated", + code: 6385, + range: ranges[3], + reportsDeprecated: true, + }, + { + message: "'baz' is deprecated", + code: 6385, + range: ranges[4], + reportsDeprecated: true, + }, + { + message: "'(): void' is deprecated", + code: 6385, + range: ranges[5], + reportsDeprecated: true, + }, + { + message: `'(tag: "xmp"): void' is deprecated`, + code: 6385, + range: ranges[6], + reportsDeprecated: true, + }, + { + message: `'(): C' is deprecated`, + code: 6385, + range: ranges[7], + reportsDeprecated: true, + }, + { + message: `'(): void' is deprecated`, + code: 6385, + range: ranges[8], + reportsDeprecated: true, + }, + { + message: `'(): string' is deprecated`, + code: 6385, + range: ranges[9], + reportsDeprecated: true, + }, +]) diff --git a/tests/cases/fourslash/jsdocDeprecated_suggestion3.ts b/tests/cases/fourslash/jsdocDeprecated_suggestion3.ts new file mode 100644 index 0000000000000..829060345fe22 --- /dev/null +++ b/tests/cases/fourslash/jsdocDeprecated_suggestion3.ts @@ -0,0 +1,124 @@ +/// + +//// // merges +//// /** @deprecated */ +//// interface a { a: number } +//// declare function a(): void +//// declare const ta: [|a|] +//// a; +//// a(); + +//// interface b { a: number; } +//// /** @deprecated */ +//// declare function b(): void +//// declare const tb: b; +//// [|b|] +//// [|b()|]; + +//// interface c { } +//// /** @deprecated */ +//// declare function c(): void +//// declare function c(a: number): void +//// declare const tc: c; +//// c; +//// [|c()|]; +//// c(1); + +//// /** @deprecated */ +//// interface d { } +//// declare function d(): void +//// declare function d(a: number): void +//// declare const td: [|d|]; +//// d; +//// d(); +//// d(1); + +//// /** @deprecated */ +//// declare function e(): void +//// /** @deprecated */ +//// declare function e(a: number): void +//// [|e|]; +//// [|e()|]; +//// [|e(1)|]; + +//// /** @deprecated */ +//// interface f { a: number } +//// declare const tf: [|f|] + +//// /** @deprecated */ +//// type g = number +//// declare const tg: [|g|] + +//// /** @deprecated */ +//// class H { } +//// declare const th: [|H|] + +const ranges = test.ranges(); +verify.getSuggestionDiagnostics([ + { + message: "'a' is deprecated", + code: 6385, + range: ranges[0], + reportsDeprecated: true, + }, + { + message: "'b' is deprecated", + code: 6385, + range: ranges[1], + reportsDeprecated: true, + }, + { + message: "'(): void' is deprecated", + code: 6385, + range: ranges[2], + reportsDeprecated: true, + }, + { + message: "'(): void' is deprecated", + code: 6385, + range: ranges[3], + reportsDeprecated: true, + }, + { + message: "'d' is deprecated", + code: 6385, + range: ranges[4], + reportsDeprecated: true, + }, + { + message: "'e' is deprecated", + code: 6385, + range: ranges[5], + reportsDeprecated: true, + }, + { + message: "'(): void' is deprecated", + code: 6385, + range: ranges[6], + reportsDeprecated: true, + }, + { + message: "'(a: number): void' is deprecated", + code: 6385, + range: ranges[7], + reportsDeprecated: true, + }, + { + message: "'f' is deprecated", + code: 6385, + range: ranges[8], + reportsDeprecated: true, + }, + { + message: "'g' is deprecated", + code: 6385, + range: ranges[9], + reportsDeprecated: true, + }, + { + message: "'H' is deprecated", + code: 6385, + range: ranges[10], + reportsDeprecated: true, + }, +]) From 2d09da6df5d033f9ff8ad7b365a11ea968f00985 Mon Sep 17 00:00:00 2001 From: Michael Hensler Date: Thu, 2 Jul 2020 15:19:37 -0600 Subject: [PATCH 32/47] allow consecutive newlines in jsdoc tag comments (#38036) --- src/compiler/parser.ts | 8 ++--- src/testRunner/unittests/jsDocParsing.ts | 6 ++++ ...sCorrectly.consecutive newline tokens.json | 31 +++++++++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.consecutive newline tokens.json diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 5961e4ddbb095..c5cbb950f69d7 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -7440,11 +7440,9 @@ namespace ts { loop: while (true) { switch (tok) { case SyntaxKind.NewLineTrivia: - if (state >= JSDocState.SawAsterisk) { - state = JSDocState.BeginningOfLine; - // don't use pushComment here because we want to keep the margin unchanged - comments.push(scanner.getTokenText()); - } + state = JSDocState.BeginningOfLine; + // don't use pushComment here because we want to keep the margin unchanged + comments.push(scanner.getTokenText()); indent = 0; break; case SyntaxKind.AtToken: diff --git a/src/testRunner/unittests/jsDocParsing.ts b/src/testRunner/unittests/jsDocParsing.ts index 0af076df7622b..ace9f0af99654 100644 --- a/src/testRunner/unittests/jsDocParsing.ts +++ b/src/testRunner/unittests/jsDocParsing.ts @@ -320,6 +320,12 @@ namespace ts { `/** * @author John Doe * @author John Doe unexpected comment + */`); + + parsesCorrectly("consecutive newline tokens", + `/** + * @example + * Some\n\n * text\r\n * with newlines. */`); }); }); diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.consecutive newline tokens.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.consecutive newline tokens.json new file mode 100644 index 0000000000000..26875d7eba7c7 --- /dev/null +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.consecutive newline tokens.json @@ -0,0 +1,31 @@ +{ + "kind": "JSDocComment", + "pos": 0, + "end": 55, + "flags": "JSDoc", + "modifierFlagsCache": 0, + "transformFlags": 0, + "tags": { + "0": { + "kind": "JSDocTag", + "pos": 7, + "end": 19, + "modifierFlagsCache": 0, + "transformFlags": 0, + "tagName": { + "kind": "Identifier", + "pos": 8, + "end": 15, + "modifierFlagsCache": 0, + "transformFlags": 0, + "escapedText": "example" + }, + "comment": "Some\n\ntext\r\nwith newlines." + }, + "length": 1, + "pos": 7, + "end": 19, + "hasTrailingComma": false, + "transformFlags": 0 + } +} \ No newline at end of file From 7c71a7f03452102fb5a1c6c098139f8e1aad5323 Mon Sep 17 00:00:00 2001 From: csigs Date: Fri, 3 Jul 2020 10:10:39 +0000 Subject: [PATCH 33/47] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 12 +++++ .../diagnosticMessages.generated.json.lcl | 54 ++++++++++++------- 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index dacf250f2236d..af468581cb18c 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4080,6 +4080,9 @@ + + + @@ -8955,12 +8958,18 @@ + + + + + + @@ -10026,6 +10035,9 @@ + + + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index fcf6a377c7e75..f10b2f623f61c 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4061,6 +4061,15 @@
+ + + + + + + + + @@ -8864,15 +8873,6 @@ - - - - - - - - - @@ -8936,6 +8936,24 @@ + + + + + + + + + + + + + + + + + + @@ -9995,6 +10013,15 @@ + + + + + + + + + @@ -12881,15 +12908,6 @@ - - - - - - - - - From bf6c69ba71ab8946dac04628f24f68fc52aca7f7 Mon Sep 17 00:00:00 2001 From: csigs Date: Fri, 3 Jul 2020 16:10:37 +0000 Subject: [PATCH 34/47] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 3 ++ .../diagnosticMessages.generated.json.lcl | 54 ++++++++++++------- .../diagnosticMessages.generated.json.lcl | 54 ++++++++++++------- .../diagnosticMessages.generated.json.lcl | 12 +++++ .../diagnosticMessages.generated.json.lcl | 54 ++++++++++++------- 5 files changed, 123 insertions(+), 54 deletions(-) diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index ce6998aba3dc7..667068395a22e 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -8952,6 +8952,9 @@ + + + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 43d80efe4d033..a1e4a83bef8a3 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4080,6 +4080,15 @@ + + + + + + + + + @@ -8886,15 +8895,6 @@ - - - - - - - - - @@ -8958,6 +8958,24 @@ + + + + + + + + + + + + + + + + + + @@ -10017,6 +10035,15 @@ + + + + + + + + + @@ -12903,15 +12930,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 83247fd5a6f4d..48d64afd60eed 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4080,6 +4080,15 @@ + + + + + + + + + @@ -8886,15 +8895,6 @@ - - - - - - - - - @@ -8958,6 +8958,24 @@ + + + + + + + + + + + + + + + + + + @@ -10017,6 +10035,15 @@ + + + + + + + + + @@ -12903,15 +12930,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 391613d3caa3f..0753386ed00c2 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4071,6 +4071,9 @@ + + + @@ -8946,12 +8949,18 @@ + + + + + + @@ -10017,6 +10026,9 @@ + + + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 78907975e4991..c3eb08758fb2d 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4058,6 +4058,15 @@ + + + + + + + + + @@ -8861,15 +8870,6 @@ - - - - - - - - - @@ -8933,6 +8933,24 @@ + + + + + + + + + + + + + + + + + + @@ -9992,6 +10010,15 @@ + + + + + + + + + @@ -12878,15 +12905,6 @@ - - - - - - - - - From 2fe2f88047e6c1465744cf869b53810ee8d0edfc Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 3 Jul 2020 09:51:01 -0700 Subject: [PATCH 35/47] Fix control flow analysis for nested try-catch-finally statements (#39399) * Fix control flow analysis for nested try-catch-finally statements * Add tests --- src/compiler/binder.ts | 5 + .../tryCatchFinallyControlFlow.errors.txt | 70 +++++++ .../reference/tryCatchFinallyControlFlow.js | 138 +++++++++++++ .../tryCatchFinallyControlFlow.symbols | 136 +++++++++++++ .../tryCatchFinallyControlFlow.types | 188 ++++++++++++++++++ .../compiler/tryCatchFinallyControlFlow.ts | 70 +++++++ 6 files changed, 607 insertions(+) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index ff617602d430c..b9126ca464ce3 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1241,6 +1241,11 @@ namespace ts { if (currentReturnTarget && returnLabel.antecedents) { addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow)); } + // If we have an outer exception target (i.e. a containing try-finally or try-catch-finally), add a + // control flow that goes back through the finally blok and back through each possible exception source. + if (currentExceptionTarget && exceptionLabel.antecedents) { + addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedents, currentFlow)); + } // If the end of the finally block is reachable, but the end of the try and catch blocks are not, // convert the current flow to unreachable. For example, 'try { return 1; } finally { ... }' should // result in an unreachable current control flow. diff --git a/tests/baselines/reference/tryCatchFinallyControlFlow.errors.txt b/tests/baselines/reference/tryCatchFinallyControlFlow.errors.txt index b9be03058276f..a6972d05d8ec5 100644 --- a/tests/baselines/reference/tryCatchFinallyControlFlow.errors.txt +++ b/tests/baselines/reference/tryCatchFinallyControlFlow.errors.txt @@ -275,4 +275,74 @@ tests/cases/compiler/tryCatchFinallyControlFlow.ts(255,9): error TS7027: Unreach })(); x; // Reachable } + + // Repro from #39043 + + type State = { tag: "one" } | { tag: "two" } | { tag: "three" }; + + function notallowed(arg: number) { + let state: State = { tag: "one" }; + try { + state = { tag: "two" }; + try { + state = { tag: "three" }; + } + finally { } + } + catch (err) { + state.tag; + if (state.tag !== "one" && state.tag !== "two") { + console.log(state.tag); + } + } + } + + function f20() { + let x: 0 | 1 | 2 | 3 | 4 | 5 | 6 = 0; + try { + x = 1; + try { + x = 2; + try { + x = 3; + } + finally { + if (!!true) x = 4; + } + x; // 3 | 4 + } + finally { + if (!!true) x = 5; + } + x; // 3 | 4 | 5 + } + finally { + if (!!true) x = 6; + } + x; // 3 | 4 | 5 | 6 + } + + function f21() { + let x: 0 | 1 | 2 | 3 | 4 | 5 = 0; + try { + x = 1; + try { + x = 2; + try { + x = 3; + } + finally { + if (!!true) x = 4; + } + x; // 3 | 4 + } + finally { + if (!!true) x = 5; + } + x; // 3 | 4 | 5 + } + catch (e) { + x; // 0 | 1 | 2 | 3 | 4 | 5 + } + } \ No newline at end of file diff --git a/tests/baselines/reference/tryCatchFinallyControlFlow.js b/tests/baselines/reference/tryCatchFinallyControlFlow.js index 2ccecd0cf20f7..32eed6689ba5c 100644 --- a/tests/baselines/reference/tryCatchFinallyControlFlow.js +++ b/tests/baselines/reference/tryCatchFinallyControlFlow.js @@ -257,6 +257,76 @@ function t1() { })(); x; // Reachable } + +// Repro from #39043 + +type State = { tag: "one" } | { tag: "two" } | { tag: "three" }; + +function notallowed(arg: number) { + let state: State = { tag: "one" }; + try { + state = { tag: "two" }; + try { + state = { tag: "three" }; + } + finally { } + } + catch (err) { + state.tag; + if (state.tag !== "one" && state.tag !== "two") { + console.log(state.tag); + } + } +} + +function f20() { + let x: 0 | 1 | 2 | 3 | 4 | 5 | 6 = 0; + try { + x = 1; + try { + x = 2; + try { + x = 3; + } + finally { + if (!!true) x = 4; + } + x; // 3 | 4 + } + finally { + if (!!true) x = 5; + } + x; // 3 | 4 | 5 + } + finally { + if (!!true) x = 6; + } + x; // 3 | 4 | 5 | 6 +} + +function f21() { + let x: 0 | 1 | 2 | 3 | 4 | 5 = 0; + try { + x = 1; + try { + x = 2; + try { + x = 3; + } + finally { + if (!!true) x = 4; + } + x; // 3 | 4 + } + finally { + if (!!true) x = 5; + } + x; // 3 | 4 | 5 + } + catch (e) { + x; // 0 | 1 | 2 | 3 | 4 | 5 + } +} //// [tryCatchFinallyControlFlow.js] @@ -503,3 +573,71 @@ function t1() { })(); x; // Reachable } +function notallowed(arg) { + var state = { tag: "one" }; + try { + state = { tag: "two" }; + try { + state = { tag: "three" }; + } + finally { } + } + catch (err) { + state.tag; + if (state.tag !== "one" && state.tag !== "two") { + console.log(state.tag); + } + } +} +function f20() { + var x = 0; + try { + x = 1; + try { + x = 2; + try { + x = 3; + } + finally { + if (!!true) + x = 4; + } + x; // 3 | 4 + } + finally { + if (!!true) + x = 5; + } + x; // 3 | 4 | 5 + } + finally { + if (!!true) + x = 6; + } + x; // 3 | 4 | 5 | 6 +} +function f21() { + var x = 0; + try { + x = 1; + try { + x = 2; + try { + x = 3; + } + finally { + if (!!true) + x = 4; + } + x; // 3 | 4 + } + finally { + if (!!true) + x = 5; + } + x; // 3 | 4 | 5 + } + catch (e) { + x; // 0 | 1 | 2 | 3 | 4 | 5 + } +} diff --git a/tests/baselines/reference/tryCatchFinallyControlFlow.symbols b/tests/baselines/reference/tryCatchFinallyControlFlow.symbols index 30e6ea3da352b..94a4c006ec45d 100644 --- a/tests/baselines/reference/tryCatchFinallyControlFlow.symbols +++ b/tests/baselines/reference/tryCatchFinallyControlFlow.symbols @@ -445,3 +445,139 @@ function t1() { >x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 247, 9)) } +// Repro from #39043 + +type State = { tag: "one" } | { tag: "two" } | { tag: "three" }; +>State : Symbol(State, Decl(tryCatchFinallyControlFlow.ts, 257, 1)) +>tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 261, 14)) +>tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 261, 31)) +>tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 261, 48)) + +function notallowed(arg: number) { +>notallowed : Symbol(notallowed, Decl(tryCatchFinallyControlFlow.ts, 261, 64)) +>arg : Symbol(arg, Decl(tryCatchFinallyControlFlow.ts, 263, 20)) + + let state: State = { tag: "one" }; +>state : Symbol(state, Decl(tryCatchFinallyControlFlow.ts, 264, 7)) +>State : Symbol(State, Decl(tryCatchFinallyControlFlow.ts, 257, 1)) +>tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 264, 24)) + + try { + state = { tag: "two" }; +>state : Symbol(state, Decl(tryCatchFinallyControlFlow.ts, 264, 7)) +>tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 266, 17)) + + try { + state = { tag: "three" }; +>state : Symbol(state, Decl(tryCatchFinallyControlFlow.ts, 264, 7)) +>tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 268, 21)) + } + finally { } + } + catch (err) { +>err : Symbol(err, Decl(tryCatchFinallyControlFlow.ts, 272, 11)) + + state.tag; +>state.tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 261, 14), Decl(tryCatchFinallyControlFlow.ts, 261, 31), Decl(tryCatchFinallyControlFlow.ts, 261, 48)) +>state : Symbol(state, Decl(tryCatchFinallyControlFlow.ts, 264, 7)) +>tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 261, 14), Decl(tryCatchFinallyControlFlow.ts, 261, 31), Decl(tryCatchFinallyControlFlow.ts, 261, 48)) + + if (state.tag !== "one" && state.tag !== "two") { +>state.tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 261, 14), Decl(tryCatchFinallyControlFlow.ts, 261, 31), Decl(tryCatchFinallyControlFlow.ts, 261, 48)) +>state : Symbol(state, Decl(tryCatchFinallyControlFlow.ts, 264, 7)) +>tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 261, 14), Decl(tryCatchFinallyControlFlow.ts, 261, 31), Decl(tryCatchFinallyControlFlow.ts, 261, 48)) +>state.tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 261, 31), Decl(tryCatchFinallyControlFlow.ts, 261, 48)) +>state : Symbol(state, Decl(tryCatchFinallyControlFlow.ts, 264, 7)) +>tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 261, 31), Decl(tryCatchFinallyControlFlow.ts, 261, 48)) + + console.log(state.tag); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>state.tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 261, 48)) +>state : Symbol(state, Decl(tryCatchFinallyControlFlow.ts, 264, 7)) +>tag : Symbol(tag, Decl(tryCatchFinallyControlFlow.ts, 261, 48)) + } + } +} + +function f20() { +>f20 : Symbol(f20, Decl(tryCatchFinallyControlFlow.ts, 278, 1)) + + let x: 0 | 1 | 2 | 3 | 4 | 5 | 6 = 0; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 281, 7)) + + try { + x = 1; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 281, 7)) + + try { + x = 2; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 281, 7)) + + try { + x = 3; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 281, 7)) + } + finally { + if (!!true) x = 4; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 281, 7)) + } + x; // 3 | 4 +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 281, 7)) + } + finally { + if (!!true) x = 5; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 281, 7)) + } + x; // 3 | 4 | 5 +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 281, 7)) + } + finally { + if (!!true) x = 6; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 281, 7)) + } + x; // 3 | 4 | 5 | 6 +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 281, 7)) +} + +function f21() { +>f21 : Symbol(f21, Decl(tryCatchFinallyControlFlow.ts, 303, 1)) + + let x: 0 | 1 | 2 | 3 | 4 | 5 = 0; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 306, 7)) + + try { + x = 1; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 306, 7)) + + try { + x = 2; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 306, 7)) + + try { + x = 3; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 306, 7)) + } + finally { + if (!!true) x = 4; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 306, 7)) + } + x; // 3 | 4 +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 306, 7)) + } + finally { + if (!!true) x = 5; +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 306, 7)) + } + x; // 3 | 4 | 5 +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 306, 7)) + } + catch (e) { +>e : Symbol(e, Decl(tryCatchFinallyControlFlow.ts, 324, 11)) + + x; // 0 | 1 | 2 | 3 | 4 | 5 +>x : Symbol(x, Decl(tryCatchFinallyControlFlow.ts, 306, 7)) + } +} + diff --git a/tests/baselines/reference/tryCatchFinallyControlFlow.types b/tests/baselines/reference/tryCatchFinallyControlFlow.types index 70c11b87dca59..1674907b3a266 100644 --- a/tests/baselines/reference/tryCatchFinallyControlFlow.types +++ b/tests/baselines/reference/tryCatchFinallyControlFlow.types @@ -589,3 +589,191 @@ function t1() { >x : "x" | null } +// Repro from #39043 + +type State = { tag: "one" } | { tag: "two" } | { tag: "three" }; +>State : State +>tag : "one" +>tag : "two" +>tag : "three" + +function notallowed(arg: number) { +>notallowed : (arg: number) => void +>arg : number + + let state: State = { tag: "one" }; +>state : State +>{ tag: "one" } : { tag: "one"; } +>tag : "one" +>"one" : "one" + + try { + state = { tag: "two" }; +>state = { tag: "two" } : { tag: "two"; } +>state : State +>{ tag: "two" } : { tag: "two"; } +>tag : "two" +>"two" : "two" + + try { + state = { tag: "three" }; +>state = { tag: "three" } : { tag: "three"; } +>state : State +>{ tag: "three" } : { tag: "three"; } +>tag : "three" +>"three" : "three" + } + finally { } + } + catch (err) { +>err : any + + state.tag; +>state.tag : "one" | "two" | "three" +>state : State +>tag : "one" | "two" | "three" + + if (state.tag !== "one" && state.tag !== "two") { +>state.tag !== "one" && state.tag !== "two" : boolean +>state.tag !== "one" : boolean +>state.tag : "one" | "two" | "three" +>state : State +>tag : "one" | "two" | "three" +>"one" : "one" +>state.tag !== "two" : boolean +>state.tag : "two" | "three" +>state : { tag: "two"; } | { tag: "three"; } +>tag : "two" | "three" +>"two" : "two" + + console.log(state.tag); +>console.log(state.tag) : void +>console.log : (...data: any[]) => void +>console : Console +>log : (...data: any[]) => void +>state.tag : "three" +>state : { tag: "three"; } +>tag : "three" + } + } +} + +function f20() { +>f20 : () => void + + let x: 0 | 1 | 2 | 3 | 4 | 5 | 6 = 0; +>x : 0 | 1 | 2 | 3 | 4 | 5 | 6 +>0 : 0 + + try { + x = 1; +>x = 1 : 1 +>x : 0 | 1 | 2 | 3 | 4 | 5 | 6 +>1 : 1 + + try { + x = 2; +>x = 2 : 2 +>x : 0 | 1 | 2 | 3 | 4 | 5 | 6 +>2 : 2 + + try { + x = 3; +>x = 3 : 3 +>x : 0 | 1 | 2 | 3 | 4 | 5 | 6 +>3 : 3 + } + finally { + if (!!true) x = 4; +>!!true : true +>!true : false +>true : true +>x = 4 : 4 +>x : 0 | 1 | 2 | 3 | 4 | 5 | 6 +>4 : 4 + } + x; // 3 | 4 +>x : 3 | 4 + } + finally { + if (!!true) x = 5; +>!!true : true +>!true : false +>true : true +>x = 5 : 5 +>x : 0 | 1 | 2 | 3 | 4 | 5 | 6 +>5 : 5 + } + x; // 3 | 4 | 5 +>x : 3 | 4 | 5 + } + finally { + if (!!true) x = 6; +>!!true : true +>!true : false +>true : true +>x = 6 : 6 +>x : 0 | 1 | 2 | 3 | 4 | 5 | 6 +>6 : 6 + } + x; // 3 | 4 | 5 | 6 +>x : 3 | 4 | 5 | 6 +} + +function f21() { +>f21 : () => void + + let x: 0 | 1 | 2 | 3 | 4 | 5 = 0; +>x : 0 | 1 | 2 | 3 | 4 | 5 +>0 : 0 + + try { + x = 1; +>x = 1 : 1 +>x : 0 | 1 | 2 | 3 | 4 | 5 +>1 : 1 + + try { + x = 2; +>x = 2 : 2 +>x : 0 | 1 | 2 | 3 | 4 | 5 +>2 : 2 + + try { + x = 3; +>x = 3 : 3 +>x : 0 | 1 | 2 | 3 | 4 | 5 +>3 : 3 + } + finally { + if (!!true) x = 4; +>!!true : true +>!true : false +>true : true +>x = 4 : 4 +>x : 0 | 1 | 2 | 3 | 4 | 5 +>4 : 4 + } + x; // 3 | 4 +>x : 3 | 4 + } + finally { + if (!!true) x = 5; +>!!true : true +>!true : false +>true : true +>x = 5 : 5 +>x : 0 | 1 | 2 | 3 | 4 | 5 +>5 : 5 + } + x; // 3 | 4 | 5 +>x : 3 | 4 | 5 + } + catch (e) { +>e : any + + x; // 0 | 1 | 2 | 3 | 4 | 5 +>x : 0 | 1 | 2 | 3 | 4 | 5 + } +} + diff --git a/tests/cases/compiler/tryCatchFinallyControlFlow.ts b/tests/cases/compiler/tryCatchFinallyControlFlow.ts index 83909b5ddb035..c2f19bbe5bbc9 100644 --- a/tests/cases/compiler/tryCatchFinallyControlFlow.ts +++ b/tests/cases/compiler/tryCatchFinallyControlFlow.ts @@ -259,3 +259,73 @@ function t1() { })(); x; // Reachable } + +// Repro from #39043 + +type State = { tag: "one" } | { tag: "two" } | { tag: "three" }; + +function notallowed(arg: number) { + let state: State = { tag: "one" }; + try { + state = { tag: "two" }; + try { + state = { tag: "three" }; + } + finally { } + } + catch (err) { + state.tag; + if (state.tag !== "one" && state.tag !== "two") { + console.log(state.tag); + } + } +} + +function f20() { + let x: 0 | 1 | 2 | 3 | 4 | 5 | 6 = 0; + try { + x = 1; + try { + x = 2; + try { + x = 3; + } + finally { + if (!!true) x = 4; + } + x; // 3 | 4 + } + finally { + if (!!true) x = 5; + } + x; // 3 | 4 | 5 + } + finally { + if (!!true) x = 6; + } + x; // 3 | 4 | 5 | 6 +} + +function f21() { + let x: 0 | 1 | 2 | 3 | 4 | 5 = 0; + try { + x = 1; + try { + x = 2; + try { + x = 3; + } + finally { + if (!!true) x = 4; + } + x; // 3 | 4 + } + finally { + if (!!true) x = 5; + } + x; // 3 | 4 | 5 + } + catch (e) { + x; // 0 | 1 | 2 | 3 | 4 | 5 + } +} From db785545f25b91e81d3e1fb4bc11123111e8a1bd Mon Sep 17 00:00:00 2001 From: csigs Date: Fri, 3 Jul 2020 22:11:08 +0000 Subject: [PATCH 36/47] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 54 ++++++++++++------- .../diagnosticMessages.generated.json.lcl | 9 ++++ .../diagnosticMessages.generated.json.lcl | 54 ++++++++++++------- .../diagnosticMessages.generated.json.lcl | 54 ++++++++++++------- .../diagnosticMessages.generated.json.lcl | 54 ++++++++++++------- .../diagnosticMessages.generated.json.lcl | 54 ++++++++++++------- 6 files changed, 189 insertions(+), 90 deletions(-) diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 8f6ec604a5fea..2cd4c28a19aff 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4068,6 +4068,15 @@ + + + + + + + + + @@ -8874,15 +8883,6 @@ - - - - - - - - - @@ -8946,6 +8946,24 @@ + + + + + + + + + + + + + + + + + + @@ -10005,6 +10023,15 @@ + + + + + + + + + @@ -12891,15 +12918,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index 667068395a22e..de3b5b3d8cf5a 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4071,6 +4071,9 @@ + + + @@ -8946,6 +8949,9 @@ + + + @@ -10020,6 +10026,9 @@ + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 90fdb4515093d..be93c7d709892 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4065,6 +4065,15 @@ + + + + + + + + + @@ -8868,15 +8877,6 @@ - - - - - - - - - @@ -8940,6 +8940,24 @@ + + + + + + + + + + + + + + + + + + @@ -9999,6 +10017,15 @@ + + + + + + + + + @@ -12885,15 +12912,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index c0b79b74435a9..8ab32789f0d08 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4068,6 +4068,15 @@ + + + + + + + + + @@ -8874,15 +8883,6 @@ - - - - - - - - - @@ -8946,6 +8946,24 @@ + + + + + + + + + + + + + + + + + + @@ -10005,6 +10023,15 @@ + + + + + + + + + @@ -12891,15 +12918,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index 5350c5fa7d2c5..5ae3fdb64eeee 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4067,6 +4067,15 @@ + + + + + + + + + @@ -8873,15 +8882,6 @@ - - - - - - - - - @@ -8945,6 +8945,24 @@ + + + + + + + + + + + + + + + + + + @@ -10004,6 +10022,15 @@ + + + + + + + + + @@ -12890,15 +12917,6 @@ - - - - - - - - - diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index c2d226a465b9c..3ee93af1607a1 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4061,6 +4061,15 @@ + + + + + + + + + @@ -8867,15 +8876,6 @@ - - - - - - - - - @@ -8939,6 +8939,24 @@ + + + + + + + + + + + + + + + + + + @@ -9998,6 +10016,15 @@ + + + + + + + + + @@ -12884,15 +12911,6 @@ - - - - - - - - - From 7eeecee3b348f14cbf36fb0fdcabf915c22c4c06 Mon Sep 17 00:00:00 2001 From: csigs Date: Sat, 4 Jul 2020 04:10:46 +0000 Subject: [PATCH 37/47] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 54 ++++++++++++------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index 4ca0d886b0593..3d7f1f2e903b8 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -4068,6 +4068,15 @@ + + + + + + + + + @@ -8874,15 +8883,6 @@ - - - - - - - - - @@ -8946,6 +8946,24 @@ + + + + + + + + + + + + + + + + + + @@ -10005,6 +10023,15 @@ + + + + + + + + + @@ -12891,15 +12918,6 @@ - - - - - - - - - From 9f8585913b2465d460f1bbec4d054a4b43a37a9f Mon Sep 17 00:00:00 2001 From: Alexander T Date: Sat, 4 Jul 2020 09:05:47 +0300 Subject: [PATCH 38/47] feat(25259): change diagnostic message --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- src/services/codefixes/fixPropertyAssignment.ts | 2 +- .../shorthandPropertyAssignmentsInDestructuring.errors.txt | 4 ++-- ...shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7c8a38f62125e..fa4ab977a9dc8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -38259,7 +38259,7 @@ namespace ts { if (prop.kind === SyntaxKind.ShorthandPropertyAssignment && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error - return grammarErrorOnNode(prop.equalsToken!, Diagnostics.Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuring_assignment); + return grammarErrorOnNode(prop.equalsToken!, Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } if (name.kind === SyntaxKind.PrivateIdentifier) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 2ad1bfb8eea50..cc5ed962ab91a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -880,7 +880,7 @@ "category": "Error", "code": 1308 }, - "Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.": { + "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.": { "category": "Error", "code": 1312 }, diff --git a/src/services/codefixes/fixPropertyAssignment.ts b/src/services/codefixes/fixPropertyAssignment.ts index ee46d90858b83..309280f6afe4b 100644 --- a/src/services/codefixes/fixPropertyAssignment.ts +++ b/src/services/codefixes/fixPropertyAssignment.ts @@ -2,7 +2,7 @@ namespace ts.codefix { const fixId = "fixPropertyAssignment"; const errorCodes = [ - Diagnostics.Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuring_assignment.code + Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern.code ]; registerCodeFix({ diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt index ba8af08a9cbf3..f3b510eee3b4e 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt @@ -11,7 +11,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(85,19): erro Types of property 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. ==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts (12 errors) ==== @@ -153,7 +153,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(111,14): err (function() { let a = { s = 5 }; ~ -!!! error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment. +!!! error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. }); function foo({a = 4, b = { x: 5 }}) { diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt index d6b0da61711cb..5a8d0931770d6 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt @@ -11,7 +11,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,19): Types of property 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. ==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts (12 errors) ==== @@ -153,7 +153,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): (function() { let a = { s = 5 }; ~ -!!! error TS1312: Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment. +!!! error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. }); function foo({a = 4, b = { x: 5 }}) { From f29e03eea5548115158bfc406af08f01b3e10101 Mon Sep 17 00:00:00 2001 From: ShuiRuTian <158983297@qq.com> Date: Mon, 6 Jul 2020 20:49:50 +0800 Subject: [PATCH 39/47] autocomplete works for const assertion. (#39412) * fix 39384 * add test --- src/compiler/checker.ts | 9 ++++++++- .../fourslash/memberListInFunctionCall2.ts | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/memberListInFunctionCall2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7c8a38f62125e..c7ca36381a5e5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23425,7 +23425,7 @@ namespace ts { return getContextualTypeForArgument(parent, node); case SyntaxKind.TypeAssertionExpression: case SyntaxKind.AsExpression: - return isConstTypeReference((parent).type) ? undefined : getTypeFromTypeNode((parent).type); + return isConstTypeReference((parent).type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode((parent).type); case SyntaxKind.BinaryExpression: return getContextualTypeForBinaryOperand(node, contextFlags); case SyntaxKind.PropertyAssignment: @@ -23458,6 +23458,13 @@ namespace ts { return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; + + function tryFindWhenConstTypeReference(node: Expression) { + if(isCallLikeExpression(node.parent)){ + return getContextualTypeForArgument(node.parent, node); + } + return undefined; + } } function getInferenceContext(node: Node) { diff --git a/tests/cases/fourslash/memberListInFunctionCall2.ts b/tests/cases/fourslash/memberListInFunctionCall2.ts new file mode 100644 index 0000000000000..5eb117b58f9cd --- /dev/null +++ b/tests/cases/fourslash/memberListInFunctionCall2.ts @@ -0,0 +1,17 @@ +/// + +////type T = { +//// a: 1; +//// b: 2; +////} +////function F(x: T) { +////} +////F({/*1*/} as const) + +verify.completions({ + marker: "1", + exact: [ + { name: "a", text: "(property) a: 1" }, + { name: "b", text: "(property) b: 2" }, + ], +}); From 222e18770da80b3b8a49bdc9b276d4fcba6160a5 Mon Sep 17 00:00:00 2001 From: csigs Date: Mon, 6 Jul 2020 16:10:37 +0000 Subject: [PATCH 40/47] LEGO: check in for master to temporary branch. --- .../diagnosticMessages/diagnosticMessages.generated.json.lcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 2cd4c28a19aff..800795d4a959f 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -2581,7 +2581,7 @@ - + @@ -2590,7 +2590,7 @@ - + From d462fb2fb953fcbffffb3813453b282dd1437728 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Mon, 6 Jul 2020 12:24:33 -0400 Subject: [PATCH 41/47] Split the GH actions CI into multiple stages (#39210) * Split the GH actions CI into multiple stages * Add the -- for npm * Improve the CI reports * Use stylish formatting on CI * Break TSC instead * Try add the problem register for TSC only on node 12 * Fix GH Actions syntax maybe --- .github/tsc.json | 18 ++++++++++++++++++ .github/workflows/ci.yml | 19 +++++++++++++------ Gulpfile.js | 11 +++++++++-- 3 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 .github/tsc.json diff --git a/.github/tsc.json b/.github/tsc.json new file mode 100644 index 0000000000000..158f7e83d3a1b --- /dev/null +++ b/.github/tsc.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "owner": "tsc", + "pattern": [ + { + "regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),(\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "code": 5, + "message": 6 + } + ] + } + ] +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 251303b0c952b..2a08d7bd3d183 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,12 +30,19 @@ jobs: run: | npm uninstall typescript --no-save npm uninstall tslint --no-save - - name: npm install and test - run: | - npm install - npm update - npm test - + - run: npm install + - run: npm update + + # Re: https://github.com/actions/setup-node/pull/125 + - name: Register Problem Matcher for TSC + run: echo "##[add-matcher].github/tsc.json" + + - name: Tests + run: npm test -- --no-lint + + - name: Linter + run: npm run lint:ci + - name: Validate the browser can import TypeScript run: gulp test-browser-integration \ No newline at end of file diff --git a/Gulpfile.js b/Gulpfile.js index 095ea5025c4d0..41f193261e990 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -354,7 +354,6 @@ const eslint = (folder) => async () => { "node_modules/eslint/bin/eslint", "--cache", "--cache-location", `${folder}/.eslintcache`, - "--format", "autolinkable-stylish", "--rulesdir", "scripts/eslint/built/rules", "--ext", ".ts", ]; @@ -363,11 +362,19 @@ const eslint = (folder) => async () => { args.push("--fix"); } + // Use stylish format on CI, so that it can be picked up by GH Action's rule matchers + if (cmdLineOptions.ci) { + args.push("--format", "stylish"); + } + else { + args.push("--format", "autolinkable-stylish"); + } + args.push(folder); log(`Linting: ${args.join(" ")}`); return exec(process.execPath, args); -} +}; const lintScripts = eslint("scripts"); lintScripts.displayName = "lint-scripts"; From 3593c286920261fa24abdb2d80c014cf7d9ac9b5 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Mon, 6 Jul 2020 12:27:52 -0400 Subject: [PATCH 42/47] Adds a script for hooking up dev builds of TS to the playground (#38859) --- scripts/createPlaygroundBuild.js | 322 +++++++++++++++++++++++++++++++ 1 file changed, 322 insertions(+) create mode 100644 scripts/createPlaygroundBuild.js diff --git a/scripts/createPlaygroundBuild.js b/scripts/createPlaygroundBuild.js new file mode 100644 index 0000000000000..8fbee8ce8a676 --- /dev/null +++ b/scripts/createPlaygroundBuild.js @@ -0,0 +1,322 @@ +// @ts-check + +// This script does two things: +// +// - Listens to changes to the built version of TypeScript (via a filewatcher on `built/local/typescriptServices.js`) +// these trigger creating monaco-typescript compatible builds of TypeScript at `internal/lib/typescriptServices.js§ +// +// - Creates a HTTP server which the playground uses. The webserver almost exclusively re-directs requests to +// the latest stable version of monaco-typescript, but specifically overrides requests for the TypeScript js +// file to the version created in the above step. +// + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +const path = require('path'); +const fs = require('fs'); +const child_process = require('child_process'); +const http = require('http'); +const url = require('url'); + +function updateTSDist() { + // This code is a direct port of a script from monaco-typescript + // https://github.com/microsoft/monaco-typescript/blob/master/scripts/importTypescript.js + // Currently based on 778ace1 on Apr 25 2020 + + const generatedNote = `// + // **NOTE**: Do not edit directly! This file is generated using \`npm run import-typescript\` + // + `; + + const TYPESCRIPT_LIB_SOURCE = path.join(__dirname, '../built/local'); + const TYPESCRIPT_LIB_DESTINATION = path.join(__dirname, '../internal/lib'); + + (function () { + try { + fs.statSync(TYPESCRIPT_LIB_DESTINATION); + } catch (err) { + fs.mkdirSync(TYPESCRIPT_LIB_DESTINATION); + } + importLibs(); + + const npmLsOutput = JSON.parse(child_process.execSync("npm ls typescript --depth=0 --json=true").toString()); + const typeScriptDependencyVersion = npmLsOutput.dependencies.typescript.version; + + fs.writeFileSync( + path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServicesMetadata.ts'), + `${generatedNote} + export const typescriptVersion = "${typeScriptDependencyVersion}";\n` + ); + + var tsServices = fs.readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescriptServices.js')).toString(); + + // Ensure we never run into the node system... + // (this also removes require calls that trick webpack into shimming those modules...) + tsServices = ( + tsServices.replace(/\n ts\.sys =([^]*)\n \}\)\(\);/m, `\n // MONACOCHANGE\n ts.sys = undefined;\n // END MONACOCHANGE`) + ); + + // Eliminate more require() calls... + tsServices = tsServices.replace(/^( +)etwModule = require\(.*$/m, '$1// MONACOCHANGE\n$1etwModule = undefined;\n$1// END MONACOCHANGE'); + tsServices = tsServices.replace(/^( +)var result = ts\.sys\.require\(.*$/m, '$1// MONACOCHANGE\n$1var result = undefined;\n$1// END MONACOCHANGE'); + + // Flag any new require calls (outside comments) so they can be corrected preemptively. + // To avoid missing cases (or using an even more complex regex), temporarily remove comments + // about require() and then check for lines actually calling require(). + // \/[*/] matches the start of a comment (single or multi-line). + // ^\s+\*[^/] matches (presumably) a later line of a multi-line comment. + const tsServicesNoCommentedRequire = tsServices.replace(/(\/[*/]|^\s+\*[^/]).*\brequire\(.*/gm, ''); + const linesWithRequire = tsServicesNoCommentedRequire.match(/^.*?\brequire\(.*$/gm) + + // Allow error messages to include references to require() in their strings + const runtimeRequires = linesWithRequire && linesWithRequire.filter(l => !l.includes(": diag(")) + + if (runtimeRequires && runtimeRequires.length) { + console.error('Found new require() calls on the following lines. These should be removed to avoid breaking webpack builds.\n'); + console.error(linesWithRequire.join('\n')); + process.exit(1); + } + + // Make sure process.args don't get called in the browser, this + // should only happen in TS 2.6.2 + const beforeProcess = `ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(process.argv));` + const afterProcess = `// MONACOCHANGE\n ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify([]));\n// END MONACOCHANGE` + tsServices = tsServices.replace(beforeProcess, afterProcess); + + var tsServices_amd = generatedNote + tsServices + + ` + // MONACOCHANGE + // Defining the entire module name because r.js has an issue and cannot bundle this file + // correctly with an anonymous define call + define("vs/language/typescript/lib/typescriptServices", [], function() { return ts; }); + // END MONACOCHANGE + `; + fs.writeFileSync(path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices-amd.js'), tsServices_amd); + + var tsServices_esm = generatedNote + tsServices + + ` + // MONACOCHANGE + export var createClassifier = ts.createClassifier; + export var createLanguageService = ts.createLanguageService; + export var displayPartsToString = ts.displayPartsToString; + export var EndOfLineState = ts.EndOfLineState; + export var flattenDiagnosticMessageText = ts.flattenDiagnosticMessageText; + export var IndentStyle = ts.IndentStyle; + export var ScriptKind = ts.ScriptKind; + export var ScriptTarget = ts.ScriptTarget; + export var TokenClass = ts.TokenClass; + // END MONACOCHANGE + `; + fs.writeFileSync(path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices.js'), tsServices_esm); + + var dtsServices = fs.readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescriptServices.d.ts')).toString(); + dtsServices += + ` + // MONACOCHANGE + export = ts; + // END MONACOCHANGE + `; + fs.writeFileSync(path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices.d.ts'), generatedNote + dtsServices); + + })(); + + function importLibs() { + function getFileName(name) { + return (name === '' ? 'lib.d.ts' : `lib.${name}.d.ts`); + } + function getVariableName(name) { + return (name === '' ? 'lib_dts' : `lib_${name.replace(/\./g, '_')}_dts`); + } + function readLibFile(name) { + var srcPath = path.join(TYPESCRIPT_LIB_SOURCE, getFileName(name)); + return fs.readFileSync(srcPath).toString(); + } + + var queue = []; + var in_queue = {}; + + var enqueue = function (name) { + if (in_queue[name]) { + return; + } + in_queue[name] = true; + queue.push(name); + }; + + enqueue(''); + enqueue('es2015'); + + var result = []; + while (queue.length > 0) { + var name = queue.shift(); + var contents = readLibFile(name); + var lines = contents.split(/\r\n|\r|\n/); + + var output = ''; + var writeOutput = function (text) { + if (output.length === 0) { + output = text; + } else { + output += ` + ${text}`; + } + }; + var outputLines = []; + var flushOutputLines = function () { + writeOutput(`"${escapeText(outputLines.join('\n'))}"`); + outputLines = []; + }; + var deps = []; + for (let i = 0; i < lines.length; i++) { + let m = lines[i].match(/\/\/\/\s* 0) { + for (let i = result.length - 1; i >= 0; i--) { + if (result[i].deps.length === 0) { + // emit this node + strResult += `\nexport const ${result[i].name}: string = ${result[i].output};\n`; + + // mark dep as resolved + for (let j = 0; j < result.length; j++) { + for (let k = 0; k < result[j].deps.length; k++) { + if (result[j].deps[k] === result[i].name) { + result[j].deps.splice(k, 1); + break; + } + } + } + + // remove from result + result.splice(i, 1); + break; + } + } + } + + strResult += ` + /** This is the DTS which is used when the target is ES6 or below */ + export const lib_es5_bundled_dts = lib_dts; + + /** This is the DTS which is used by default in monaco-typescript, and when the target is 2015 or above */ + export const lib_es2015_bundled_dts = lib_es2015_dts + "" + lib_dom_dts + "" + lib_webworker_importscripts_dts + "" + lib_scripthost_dts + ""; + ` + + var dstPath = path.join(TYPESCRIPT_LIB_DESTINATION, 'lib.ts'); + fs.writeFileSync(dstPath, strResult); + } + + /** + * Escape text such that it can be used in a javascript string enclosed by double quotes (") + */ + function escapeText(text) { + // See http://www.javascriptkit.com/jsref/escapesequence.shtml + var _backspace = '\b'.charCodeAt(0); + var _formFeed = '\f'.charCodeAt(0); + var _newLine = '\n'.charCodeAt(0); + var _nullChar = 0; + var _carriageReturn = '\r'.charCodeAt(0); + var _tab = '\t'.charCodeAt(0); + var _verticalTab = '\v'.charCodeAt(0); + var _backslash = '\\'.charCodeAt(0); + var _doubleQuote = '"'.charCodeAt(0); + + var startPos = 0, chrCode, replaceWith = null, resultPieces = []; + + for (var i = 0, len = text.length; i < len; i++) { + chrCode = text.charCodeAt(i); + switch (chrCode) { + case _backspace: + replaceWith = '\\b'; + break; + case _formFeed: + replaceWith = '\\f'; + break; + case _newLine: + replaceWith = '\\n'; + break; + case _nullChar: + replaceWith = '\\0'; + break; + case _carriageReturn: + replaceWith = '\\r'; + break; + case _tab: + replaceWith = '\\t'; + break; + case _verticalTab: + replaceWith = '\\v'; + break; + case _backslash: + replaceWith = '\\\\'; + break; + case _doubleQuote: + replaceWith = '\\"'; + break; + } + if (replaceWith !== null) { + resultPieces.push(text.substring(startPos, i)); + resultPieces.push(replaceWith); + startPos = i + 1; + replaceWith = null; + } + } + resultPieces.push(text.substring(startPos, len)); + return resultPieces.join(''); + } + + /// End of import +} + +const services = path.join(__dirname, '../built/local/typescriptServices.js'); +fs.watchFile(services, () =>{ + console.log("Updating the monaco build") + updateTSDist() +}) + +http.createServer(function (req, res) { + const incoming = url.parse(req.url) + if (incoming.path.endsWith("typescriptServices.js")) { + // Use the built version + res.writeHead(200, {"Content-Type": "text/javascript"}); + const amdPath = path.join(__dirname, '../internal/lib/typescriptServices-amd.js'); + res.write(fs.readFileSync(amdPath)) + } else { + // Redirect to the TS CDN + res.writeHead(302, { + 'Location': `https://typescript.azureedge.net/cdn/3.9.2/monaco/${incoming.path}` + }); + } + + res.end(); +}).listen(5615); + +console.log("Starting servers\n") +console.log(" - [✓] file watcher: " + services) +console.log(" - [✓] http server: http://localhost:5615") + +console.log("\n\nGet started: http://www.staging-typescript.org/play?ts=dev") From 17d8b02796efb478823a99705d69ecc86b36d0ec Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Mon, 6 Jul 2020 16:02:56 -0400 Subject: [PATCH 43/47] Retain the original eslint arg order (#39450) --- Gulpfile.js | 10 ++-------- package.json | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Gulpfile.js b/Gulpfile.js index 41f193261e990..7bd32515ba5fe 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -350,10 +350,12 @@ const lintFoldEnd = async () => { if (fold.isTravis()) console.log(fold.end("lin /** @type { (folder: string) => { (): Promise; displayName?: string } } */ const eslint = (folder) => async () => { + const formatter = cmdLineOptions.ci ? "stylish" : "autolinkable-stylish"; const args = [ "node_modules/eslint/bin/eslint", "--cache", "--cache-location", `${folder}/.eslintcache`, + "--format", formatter, "--rulesdir", "scripts/eslint/built/rules", "--ext", ".ts", ]; @@ -362,14 +364,6 @@ const eslint = (folder) => async () => { args.push("--fix"); } - // Use stylish format on CI, so that it can be picked up by GH Action's rule matchers - if (cmdLineOptions.ci) { - args.push("--format", "stylish"); - } - else { - args.push("--format", "autolinkable-stylish"); - } - args.push(folder); log(`Linting: ${args.join(" ")}`); diff --git a/package.json b/package.json index 6947d7ec11f92..7f9e66add40e7 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@types/through2": "latest", "@types/travis-fold": "latest", "@types/xml2js": "^0.4.0", - "@typescript-eslint/eslint-plugin": "^3.4.1-alpha.1", + "@typescript-eslint/eslint-plugin": "^3.6.1-alpha.1", "@typescript-eslint/experimental-utils": "^3.4.1-alpha.1", "@typescript-eslint/parser": "^3.4.1-alpha.1", "async": "latest", From 0d84f210b786685696585cf86ce77425577c8050 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 6 Jul 2020 14:00:12 -0700 Subject: [PATCH 44/47] In JS, assignment to `void 0` isn't a declaration (#39452) Previously, property assignments with `void 0` initialisers were treated like any other values. But this causes us to choke when checking our own commonjs emit. This is something that happens by mistake a fair amount, so this PR goes back to treating these assignments as normal assignments. This should allow us to check our own emit in loose cases without harming other code bases, since `void 0` is rarely written by hand. Note that other errors still happen: noImplicitAny forbids accessing undeclared properties on object literals, and strictNullChecks forbids assigning `undefined` to properties with a different type. However, this change is enough to unblock compilation with `strictNullChecks: false`. --- src/compiler/utilities.ts | 6 +- .../reference/assignmentToVoidZero1.js | 17 ++++ .../reference/assignmentToVoidZero1.symbols | 20 +++++ .../reference/assignmentToVoidZero1.types | 28 ++++++ .../assignmentToVoidZero2.errors.txt | 36 ++++++++ .../reference/assignmentToVoidZero2.js | 46 ++++++++++ .../reference/assignmentToVoidZero2.symbols | 53 ++++++++++++ .../reference/assignmentToVoidZero2.types | 86 +++++++++++++++++++ .../salsa/assignmentToVoidZero1.ts | 11 +++ .../salsa/assignmentToVoidZero2.ts | 24 ++++++ 10 files changed, 326 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/assignmentToVoidZero1.js create mode 100644 tests/baselines/reference/assignmentToVoidZero1.symbols create mode 100644 tests/baselines/reference/assignmentToVoidZero1.types create mode 100644 tests/baselines/reference/assignmentToVoidZero2.errors.txt create mode 100644 tests/baselines/reference/assignmentToVoidZero2.js create mode 100644 tests/baselines/reference/assignmentToVoidZero2.symbols create mode 100644 tests/baselines/reference/assignmentToVoidZero2.types create mode 100644 tests/cases/conformance/salsa/assignmentToVoidZero1.ts create mode 100644 tests/cases/conformance/salsa/assignmentToVoidZero2.ts diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 74ebe61b454ef..732630d7d9f5a 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2220,7 +2220,7 @@ namespace ts { } return AssignmentDeclarationKind.ObjectDefinePropertyValue; } - if (expr.operatorToken.kind !== SyntaxKind.EqualsToken || !isAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== SyntaxKind.EqualsToken || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { return AssignmentDeclarationKind.None; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { @@ -2230,6 +2230,10 @@ namespace ts { return getAssignmentDeclarationPropertyAccessKind(expr.left); } + function isVoidZero(node: Node) { + return isVoidExpression(node) && isNumericLiteral(node.expression) && node.expression.text === "0"; + } + /** * Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions * throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand) diff --git a/tests/baselines/reference/assignmentToVoidZero1.js b/tests/baselines/reference/assignmentToVoidZero1.js new file mode 100644 index 0000000000000..542c1fdcf1818 --- /dev/null +++ b/tests/baselines/reference/assignmentToVoidZero1.js @@ -0,0 +1,17 @@ +//// [assignmentToVoidZero1.js] +// #38552 +exports.y = exports.x = void 0; +exports.x = 1; +exports.y = 2; + + +//// [assignmentToVoidZero1.js] +// #38552 +exports.y = exports.x = void 0; +exports.x = 1; +exports.y = 2; + + +//// [assignmentToVoidZero1.d.ts] +export var x: number; +export var y: number; diff --git a/tests/baselines/reference/assignmentToVoidZero1.symbols b/tests/baselines/reference/assignmentToVoidZero1.symbols new file mode 100644 index 0000000000000..814c82b35e21c --- /dev/null +++ b/tests/baselines/reference/assignmentToVoidZero1.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/salsa/assignmentToVoidZero1.js === +// #38552 +exports.y = exports.x = void 0; +>exports.y : Symbol(y, Decl(assignmentToVoidZero1.js, 2, 14)) +>exports : Symbol("tests/cases/conformance/salsa/assignmentToVoidZero1", Decl(assignmentToVoidZero1.js, 0, 0)) +>y : Symbol(y, Decl(assignmentToVoidZero1.js, 2, 14)) +>exports.x : Symbol(x, Decl(assignmentToVoidZero1.js, 1, 31)) +>exports : Symbol("tests/cases/conformance/salsa/assignmentToVoidZero1", Decl(assignmentToVoidZero1.js, 0, 0)) +>x : Symbol(x, Decl(assignmentToVoidZero1.js, 1, 31)) + +exports.x = 1; +>exports.x : Symbol(x, Decl(assignmentToVoidZero1.js, 1, 31)) +>exports : Symbol(x, Decl(assignmentToVoidZero1.js, 1, 31)) +>x : Symbol(x, Decl(assignmentToVoidZero1.js, 1, 31)) + +exports.y = 2; +>exports.y : Symbol(y, Decl(assignmentToVoidZero1.js, 2, 14)) +>exports : Symbol(y, Decl(assignmentToVoidZero1.js, 2, 14)) +>y : Symbol(y, Decl(assignmentToVoidZero1.js, 2, 14)) + diff --git a/tests/baselines/reference/assignmentToVoidZero1.types b/tests/baselines/reference/assignmentToVoidZero1.types new file mode 100644 index 0000000000000..810cdff57aa0c --- /dev/null +++ b/tests/baselines/reference/assignmentToVoidZero1.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/salsa/assignmentToVoidZero1.js === +// #38552 +exports.y = exports.x = void 0; +>exports.y = exports.x = void 0 : undefined +>exports.y : number +>exports : typeof import("tests/cases/conformance/salsa/assignmentToVoidZero1") +>y : number +>exports.x = void 0 : undefined +>exports.x : number +>exports : typeof import("tests/cases/conformance/salsa/assignmentToVoidZero1") +>x : number +>void 0 : undefined +>0 : 0 + +exports.x = 1; +>exports.x = 1 : 1 +>exports.x : number +>exports : typeof import("tests/cases/conformance/salsa/assignmentToVoidZero1") +>x : number +>1 : 1 + +exports.y = 2; +>exports.y = 2 : 2 +>exports.y : number +>exports : typeof import("tests/cases/conformance/salsa/assignmentToVoidZero1") +>y : number +>2 : 2 + diff --git a/tests/baselines/reference/assignmentToVoidZero2.errors.txt b/tests/baselines/reference/assignmentToVoidZero2.errors.txt new file mode 100644 index 0000000000000..b9da759c092cc --- /dev/null +++ b/tests/baselines/reference/assignmentToVoidZero2.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/salsa/assignmentToVoidZero2.js(2,9): error TS2339: Property 'k' does not exist on type 'typeof import("tests/cases/conformance/salsa/assignmentToVoidZero2")'. +tests/cases/conformance/salsa/assignmentToVoidZero2.js(5,3): error TS2339: Property 'y' does not exist on type 'typeof o'. +tests/cases/conformance/salsa/assignmentToVoidZero2.js(6,9): error TS2339: Property 'y' does not exist on type 'typeof o'. +tests/cases/conformance/salsa/assignmentToVoidZero2.js(13,9): error TS2339: Property 'q' does not exist on type 'C'. +tests/cases/conformance/salsa/importer.js(1,13): error TS2305: Module '"./assignmentToVoidZero2"' has no exported member 'k'. + + +==== tests/cases/conformance/salsa/assignmentToVoidZero2.js (4 errors) ==== + exports.j = 1; + exports.k = void 0; + ~ +!!! error TS2339: Property 'k' does not exist on type 'typeof import("tests/cases/conformance/salsa/assignmentToVoidZero2")'. + var o = {} + o.x = 1 + o.y = void 0 + ~ +!!! error TS2339: Property 'y' does not exist on type 'typeof o'. + o.x + o.y + ~ +!!! error TS2339: Property 'y' does not exist on type 'typeof o'. + + function C() { + this.p = 1 + this.q = void 0 + } + var c = new C() + c.p + c.q + ~ +!!! error TS2339: Property 'q' does not exist on type 'C'. + +==== tests/cases/conformance/salsa/importer.js (1 errors) ==== + import { j, k } from './assignmentToVoidZero2' + ~ +!!! error TS2305: Module '"./assignmentToVoidZero2"' has no exported member 'k'. + j + k + \ No newline at end of file diff --git a/tests/baselines/reference/assignmentToVoidZero2.js b/tests/baselines/reference/assignmentToVoidZero2.js new file mode 100644 index 0000000000000..c8b658474d2b8 --- /dev/null +++ b/tests/baselines/reference/assignmentToVoidZero2.js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/salsa/assignmentToVoidZero2.ts] //// + +//// [assignmentToVoidZero2.js] +exports.j = 1; +exports.k = void 0; +var o = {} +o.x = 1 +o.y = void 0 +o.x + o.y + +function C() { + this.p = 1 + this.q = void 0 +} +var c = new C() +c.p + c.q + +//// [importer.js] +import { j, k } from './assignmentToVoidZero2' +j + k + + +//// [assignmentToVoidZero2.js] +exports.j = 1; +exports.k = void 0; +var o = {}; +o.x = 1; +o.y = void 0; +o.x + o.y; +function C() { + this.p = 1; + this.q = void 0; +} +var c = new C(); +c.p + c.q; +//// [importer.js] +"use strict"; +exports.__esModule = true; +var assignmentToVoidZero2_1 = require("./assignmentToVoidZero2"); +assignmentToVoidZero2_1.j + assignmentToVoidZero2_1.k; + + +//// [assignmentToVoidZero2.d.ts] +export var j: number; +//// [importer.d.ts] +export {}; diff --git a/tests/baselines/reference/assignmentToVoidZero2.symbols b/tests/baselines/reference/assignmentToVoidZero2.symbols new file mode 100644 index 0000000000000..b5a93872fa8e3 --- /dev/null +++ b/tests/baselines/reference/assignmentToVoidZero2.symbols @@ -0,0 +1,53 @@ +=== tests/cases/conformance/salsa/assignmentToVoidZero2.js === +exports.j = 1; +>exports.j : Symbol(j, Decl(assignmentToVoidZero2.js, 0, 0)) +>exports : Symbol(j, Decl(assignmentToVoidZero2.js, 0, 0)) +>j : Symbol(j, Decl(assignmentToVoidZero2.js, 0, 0)) + +exports.k = void 0; +>exports : Symbol("tests/cases/conformance/salsa/assignmentToVoidZero2", Decl(assignmentToVoidZero2.js, 0, 0)) + +var o = {} +>o : Symbol(o, Decl(assignmentToVoidZero2.js, 2, 3), Decl(assignmentToVoidZero2.js, 2, 10)) + +o.x = 1 +>o.x : Symbol(o.x, Decl(assignmentToVoidZero2.js, 2, 10)) +>o : Symbol(o, Decl(assignmentToVoidZero2.js, 2, 3), Decl(assignmentToVoidZero2.js, 2, 10)) +>x : Symbol(o.x, Decl(assignmentToVoidZero2.js, 2, 10)) + +o.y = void 0 +>o : Symbol(o, Decl(assignmentToVoidZero2.js, 2, 3), Decl(assignmentToVoidZero2.js, 2, 10)) + +o.x + o.y +>o.x : Symbol(o.x, Decl(assignmentToVoidZero2.js, 2, 10)) +>o : Symbol(o, Decl(assignmentToVoidZero2.js, 2, 3), Decl(assignmentToVoidZero2.js, 2, 10)) +>x : Symbol(o.x, Decl(assignmentToVoidZero2.js, 2, 10)) +>o : Symbol(o, Decl(assignmentToVoidZero2.js, 2, 3), Decl(assignmentToVoidZero2.js, 2, 10)) + +function C() { +>C : Symbol(C, Decl(assignmentToVoidZero2.js, 5, 9)) + + this.p = 1 +>p : Symbol(C.p, Decl(assignmentToVoidZero2.js, 7, 14)) + + this.q = void 0 +} +var c = new C() +>c : Symbol(c, Decl(assignmentToVoidZero2.js, 11, 3)) +>C : Symbol(C, Decl(assignmentToVoidZero2.js, 5, 9)) + +c.p + c.q +>c.p : Symbol(C.p, Decl(assignmentToVoidZero2.js, 7, 14)) +>c : Symbol(c, Decl(assignmentToVoidZero2.js, 11, 3)) +>p : Symbol(C.p, Decl(assignmentToVoidZero2.js, 7, 14)) +>c : Symbol(c, Decl(assignmentToVoidZero2.js, 11, 3)) + +=== tests/cases/conformance/salsa/importer.js === +import { j, k } from './assignmentToVoidZero2' +>j : Symbol(j, Decl(importer.js, 0, 8)) +>k : Symbol(k, Decl(importer.js, 0, 11)) + +j + k +>j : Symbol(j, Decl(importer.js, 0, 8)) +>k : Symbol(k, Decl(importer.js, 0, 11)) + diff --git a/tests/baselines/reference/assignmentToVoidZero2.types b/tests/baselines/reference/assignmentToVoidZero2.types new file mode 100644 index 0000000000000..0b24811f9579d --- /dev/null +++ b/tests/baselines/reference/assignmentToVoidZero2.types @@ -0,0 +1,86 @@ +=== tests/cases/conformance/salsa/assignmentToVoidZero2.js === +exports.j = 1; +>exports.j = 1 : 1 +>exports.j : number +>exports : typeof import("tests/cases/conformance/salsa/assignmentToVoidZero2") +>j : number +>1 : 1 + +exports.k = void 0; +>exports.k = void 0 : undefined +>exports.k : any +>exports : typeof import("tests/cases/conformance/salsa/assignmentToVoidZero2") +>k : any +>void 0 : undefined +>0 : 0 + +var o = {} +>o : typeof o +>{} : {} + +o.x = 1 +>o.x = 1 : 1 +>o.x : number +>o : typeof o +>x : number +>1 : 1 + +o.y = void 0 +>o.y = void 0 : undefined +>o.y : any +>o : typeof o +>y : any +>void 0 : undefined +>0 : 0 + +o.x + o.y +>o.x + o.y : any +>o.x : number +>o : typeof o +>x : number +>o.y : any +>o : typeof o +>y : any + +function C() { +>C : typeof C + + this.p = 1 +>this.p = 1 : 1 +>this.p : any +>this : any +>p : any +>1 : 1 + + this.q = void 0 +>this.q = void 0 : undefined +>this.q : any +>this : any +>q : any +>void 0 : undefined +>0 : 0 +} +var c = new C() +>c : C +>new C() : C +>C : typeof C + +c.p + c.q +>c.p + c.q : any +>c.p : number +>c : C +>p : number +>c.q : any +>c : C +>q : any + +=== tests/cases/conformance/salsa/importer.js === +import { j, k } from './assignmentToVoidZero2' +>j : number +>k : any + +j + k +>j + k : any +>j : number +>k : any + diff --git a/tests/cases/conformance/salsa/assignmentToVoidZero1.ts b/tests/cases/conformance/salsa/assignmentToVoidZero1.ts new file mode 100644 index 0000000000000..b4911c98d2bfc --- /dev/null +++ b/tests/cases/conformance/salsa/assignmentToVoidZero1.ts @@ -0,0 +1,11 @@ +// @filename: assignmentToVoidZero1.js +// @declaration: true +// @module: commonjs +// @outdir: auss +// @checkJs: true +// @allowJs: true + +// #38552 +exports.y = exports.x = void 0; +exports.x = 1; +exports.y = 2; diff --git a/tests/cases/conformance/salsa/assignmentToVoidZero2.ts b/tests/cases/conformance/salsa/assignmentToVoidZero2.ts new file mode 100644 index 0000000000000..6820076ee5f3b --- /dev/null +++ b/tests/cases/conformance/salsa/assignmentToVoidZero2.ts @@ -0,0 +1,24 @@ +// @filename: assignmentToVoidZero2.js +// @declaration: true +// @module: commonjs +// @outdir: auss +// @checkJs: true +// @allowJs: true +// @noImplicitAny: true +exports.j = 1; +exports.k = void 0; +var o = {} +o.x = 1 +o.y = void 0 +o.x + o.y + +function C() { + this.p = 1 + this.q = void 0 +} +var c = new C() +c.p + c.q + +// @filename: importer.js +import { j, k } from './assignmentToVoidZero2' +j + k From 453365284cbd9ec763ca72f65969c353d2875a92 Mon Sep 17 00:00:00 2001 From: Wenlu Wang Date: Tue, 7 Jul 2020 06:01:05 +0800 Subject: [PATCH 45/47] Avoid check for union keys (#39314) --- src/compiler/checker.ts | 6 +-- .../fourslash/jsdocDeprecated_suggestion4.ts | 50 +++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 tests/cases/fourslash/jsdocDeprecated_suggestion4.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cf0a2c0089535..58b4c2ac47f08 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13290,13 +13290,13 @@ namespace ts { && every(symbol.declarations, d => !isFunctionLike(d) || !!(d.flags & NodeFlags.Deprecated)); } - function getPropertyTypeForIndexType(originalObjectType: Type, objectType: Type, indexType: Type, fullIndexType: Type, suppressNoImplicitAnyError: boolean, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, accessFlags: AccessFlags) { + function getPropertyTypeForIndexType(originalObjectType: Type, objectType: Type, indexType: Type, fullIndexType: Type, suppressNoImplicitAnyError: boolean, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, accessFlags: AccessFlags, reportDeprecated?: boolean) { const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined; const propName = accessNode && isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { const prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessNode && prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) { + if (reportDeprecated && accessNode && prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) { const deprecatedNode = accessExpression?.argumentExpression ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); errorOrSuggestion(/* isError */ false, deprecatedNode, Diagnostics._0_is_deprecated, propName as string); } @@ -13666,7 +13666,7 @@ namespace ts { } return accessFlags & AccessFlags.Writing ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, UnionReduction.Literal, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | AccessFlags.CacheSymbol); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | AccessFlags.CacheSymbol, /* reportDeprecated */ true); } function getTypeFromIndexedAccessTypeNode(node: IndexedAccessTypeNode) { diff --git a/tests/cases/fourslash/jsdocDeprecated_suggestion4.ts b/tests/cases/fourslash/jsdocDeprecated_suggestion4.ts new file mode 100644 index 0000000000000..9bcdf0de5e2b7 --- /dev/null +++ b/tests/cases/fourslash/jsdocDeprecated_suggestion4.ts @@ -0,0 +1,50 @@ +/// + +//// interface Foo { +//// /** @deprecated */ +//// f: number +//// b: number +//// /** @deprecated */ +//// baz: number +//// } + +//// declare const f: Foo +//// f.[|f|]; +//// f.b; +//// f.[|baz|]; + +//// const kf = 'f' +//// const kb = 'b' +//// declare const k: 'f' | 'b' | 'baz' +//// declare const kfb: 'f' | 'b' +//// declare const kfz: 'f' | 'baz' +//// declare const keys: keyof Foo +//// f[[|kf|]] +//// f[kb] +//// f[k] +//// f[kfb] +//// f[kfz] +//// f[keys] + + +const ranges = test.ranges(); +verify.getSuggestionDiagnostics([ + { + message: "'f' is deprecated", + code: 6385, + range: ranges[0], + reportsDeprecated: true, + }, + { + message: "'baz' is deprecated", + code: 6385, + range: ranges[1], + reportsDeprecated: true, + }, + { + message: "'f' is deprecated", + code: 6385, + range: ranges[2], + reportsDeprecated: true, + } +]) From 2a92a6ea91294beb6aad674bb326aff8c05836ae Mon Sep 17 00:00:00 2001 From: Alexander T Date: Tue, 7 Jul 2020 03:00:35 +0300 Subject: [PATCH 46/47] fix(39332): handle quotes preference in interface method signatures (#39348) --- ...sDoesntImplementInheritedAbstractMember.ts | 2 +- .../fixClassIncorrectlyImplementsInterface.ts | 2 +- src/services/codefixes/helpers.ts | 44 ++++++++++--------- ...FixClassImplementInterface1_optionQuote.ts | 21 --------- ...deFixClassImplementInterfaceAutoImports.ts | 2 +- ...sImplementInterfaceAutoImports_typeOnly.ts | 2 +- ...eFixClassImplementInterface_optionQuote.ts | 20 --------- ...ImplementInterface_quotePreferenceAuto1.ts | 32 ++++++++++++++ ...ImplementInterface_quotePreferenceAuto2.ts | 32 ++++++++++++++ ...mplementInterface_quotePreferenceDouble.ts | 34 ++++++++++++++ ...mplementInterface_quotePreferenceSingle.ts | 34 ++++++++++++++ tests/cases/fourslash/fourslash.ts | 2 +- 12 files changed, 161 insertions(+), 66 deletions(-) delete mode 100644 tests/cases/fourslash/codeFixClassImplementInterface1_optionQuote.ts delete mode 100644 tests/cases/fourslash/codeFixClassImplementInterface_optionQuote.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto1.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto2.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceDouble.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceSingle.ts diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts index eac02f0d7135a..7fe143139454e 100644 --- a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -42,7 +42,7 @@ namespace ts.codefix { const abstractAndNonPrivateExtendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType).filter(symbolPointsToNonPrivateAndAbstractMember); const importAdder = createImportAdder(sourceFile, context.program, preferences, context.host); - createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, context, preferences, importAdder, member => changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member)); + createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, sourceFile, context, preferences, importAdder, member => changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member)); importAdder.writeFixes(changeTracker); } diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 954a64ef53dcd..fb00d2477dcd4 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -64,7 +64,7 @@ namespace ts.codefix { } const importAdder = createImportAdder(sourceFile, context.program, preferences, context.host); - createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, context, preferences, importAdder, member => insertInterfaceMemberNode(sourceFile, classDeclaration, member)); + createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, member => insertInterfaceMemberNode(sourceFile, classDeclaration, member)); importAdder.writeFixes(changeTracker); function createMissingIndexSignatureDeclaration(type: InterfaceType, kind: IndexKind): void { diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 405a5db924bd6..f1b557da71874 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -7,11 +7,11 @@ namespace ts.codefix { * @param importAdder If provided, type annotations will use identifier type references instead of ImportTypeNodes, and the missing imports will be added to the importAdder. * @returns Empty string iff there are no member insertions. */ - export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: readonly Symbol[], context: TypeConstructionContext, preferences: UserPreferences, importAdder: ImportAdder | undefined, addClassElement: (node: ClassElement) => void): void { + export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: readonly Symbol[], sourceFile: SourceFile, context: TypeConstructionContext, preferences: UserPreferences, importAdder: ImportAdder | undefined, addClassElement: (node: ClassElement) => void): void { const classMembers = classDeclaration.symbol.members!; for (const symbol of possiblyMissingSymbols) { if (!classMembers.has(symbol.escapedName)) { - addNewNodeForMemberSymbol(symbol, classDeclaration, context, preferences, importAdder, addClassElement); + addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement); } } } @@ -31,7 +31,7 @@ namespace ts.codefix { /** * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. */ - function addNewNodeForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, context: TypeConstructionContext, preferences: UserPreferences, importAdder: ImportAdder | undefined, addClassElement: (node: Node) => void): void { + function addNewNodeForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, sourceFile: SourceFile, context: TypeConstructionContext, preferences: UserPreferences, importAdder: ImportAdder | undefined, addClassElement: (node: Node) => void): void { const declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return undefined; @@ -45,11 +45,12 @@ namespace ts.codefix { const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); const optional = !!(symbol.flags & SymbolFlags.Optional); const ambient = !!(enclosingDeclaration.flags & NodeFlags.Ambient); + const quotePreference = getQuotePreference(sourceFile, preferences); switch (declaration.kind) { case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: - const flags = preferences.quotePreference === "single" ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : undefined; + const flags = quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : undefined; let typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { const importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget); @@ -88,7 +89,7 @@ namespace ts.codefix { name, emptyArray, typeNode, - ambient ? undefined : createStubbedMethodBody(preferences))); + ambient ? undefined : createStubbedMethodBody(quotePreference))); } else { Debug.assertNode(accessor, isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); @@ -99,7 +100,7 @@ namespace ts.codefix { modifiers, name, createDummyParameters(1, [parameterName], [typeNode], 1, /*inJs*/ false), - ambient ? undefined : createStubbedMethodBody(preferences))); + ambient ? undefined : createStubbedMethodBody(quotePreference))); } } break; @@ -121,36 +122,37 @@ namespace ts.codefix { if (declarations.length === 1) { Debug.assert(signatures.length === 1, "One declaration implies one signature"); const signature = signatures[0]; - outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); + outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(quotePreference)); break; } for (const signature of signatures) { // Need to ensure nodes are fresh each time so they can have different positions. - outputMethod(signature, getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), getSynthesizedDeepClone(name, /*includeTrivia*/ false)); + outputMethod(quotePreference, signature, getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), getSynthesizedDeepClone(name, /*includeTrivia*/ false)); } if (!ambient) { if (declarations.length > signatures.length) { const signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration)!; - outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); + outputMethod(quotePreference, signature, modifiers, name, createStubbedMethodBody(quotePreference)); } else { Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + addClassElement(createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference)); } } break; } - function outputMethod(signature: Signature, modifiers: NodeArray | undefined, name: PropertyName, body?: Block): void { - const method = signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body, importAdder); + function outputMethod(quotePreference: QuotePreference, signature: Signature, modifiers: NodeArray | undefined, name: PropertyName, body?: Block): void { + const method = signatureToMethodDeclaration(context, quotePreference, signature, enclosingDeclaration, modifiers, name, optional, body, importAdder); if (method) addClassElement(method); } } function signatureToMethodDeclaration( context: TypeConstructionContext, + quotePreference: QuotePreference, signature: Signature, enclosingDeclaration: ClassLikeDeclaration, modifiers: NodeArray | undefined, @@ -162,7 +164,8 @@ namespace ts.codefix { const program = context.program; const checker = program.getTypeChecker(); const scriptTarget = getEmitScriptTarget(program.getCompilerOptions()); - const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, NodeBuilderFlags.NoTruncation | NodeBuilderFlags.SuppressAnyReturnType, getNoopSymbolTrackerWithResolver(context)); + const flags = NodeBuilderFlags.NoTruncation | NodeBuilderFlags.SuppressAnyReturnType | (quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : 0); + const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -266,6 +269,7 @@ namespace ts.codefix { isIdentifier(arg) ? arg.text : isPropertyAccessExpression(arg) && isIdentifier(arg.name) ? arg.name.text : undefined); const contextualType = checker.getContextualType(call); const returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); + const quotePreference = getQuotePreference(context.sourceFile, context.preferences); return factory.createMethodDeclaration( /*decorators*/ undefined, /*modifiers*/ modifierFlags ? factory.createNodeArray(factory.createModifiersFromModifierFlags(modifierFlags)) : undefined, @@ -276,7 +280,7 @@ namespace ts.codefix { factory.createTypeParameterDeclaration(CharacterCodes.T + typeArguments!.length - 1 <= CharacterCodes.Z ? String.fromCharCode(CharacterCodes.T + i) : `T${i}`)), /*parameters*/ createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, inJs), /*type*/ returnType, - body ? createStubbedMethodBody(context.preferences) : undefined); + body ? createStubbedMethodBody(quotePreference) : undefined); } export function typeToAutoImportableTypeNode(checker: TypeChecker, importAdder: ImportAdder, type: Type, contextNode: Node, scriptTarget: ScriptTarget, flags?: NodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined { @@ -312,7 +316,7 @@ namespace ts.codefix { name: PropertyName, optional: boolean, modifiers: readonly Modifier[] | undefined, - preferences: UserPreferences, + quotePreference: QuotePreference, ): MethodDeclaration { /** This is *a* signature with the maximal number of arguments, * such that if there is a "maximal" signature without rest arguments, @@ -355,7 +359,7 @@ namespace ts.codefix { /*typeParameters*/ undefined, parameters, /*returnType*/ undefined, - preferences); + quotePreference); } function createStubbedMethod( @@ -365,7 +369,7 @@ namespace ts.codefix { typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], returnType: TypeNode | undefined, - preferences: UserPreferences + quotePreference: QuotePreference ): MethodDeclaration { return factory.createMethodDeclaration( /*decorators*/ undefined, @@ -376,17 +380,17 @@ namespace ts.codefix { typeParameters, parameters, returnType, - createStubbedMethodBody(preferences)); + createStubbedMethodBody(quotePreference)); } - function createStubbedMethodBody(preferences: UserPreferences): Block { + function createStubbedMethodBody(quotePreference: QuotePreference): Block { return factory.createBlock( [factory.createThrowStatement( factory.createNewExpression( factory.createIdentifier("Error"), /*typeArguments*/ undefined, // TODO Handle auto quote preference. - [factory.createStringLiteral("Method not implemented.", /*isSingleQuote*/ preferences.quotePreference === "single")]))], + [factory.createStringLiteral("Method not implemented.", /*isSingleQuote*/ quotePreference === QuotePreference.Single)]))], /*multiline*/ true); } diff --git a/tests/cases/fourslash/codeFixClassImplementInterface1_optionQuote.ts b/tests/cases/fourslash/codeFixClassImplementInterface1_optionQuote.ts deleted file mode 100644 index 855d5acb76920..0000000000000 --- a/tests/cases/fourslash/codeFixClassImplementInterface1_optionQuote.ts +++ /dev/null @@ -1,21 +0,0 @@ -/// - -////interface IFoo { -//// a: 'string'; -//// c: { d: 'string'; }; -////} -////class Foo implements IFoo {} - -verify.codeFix({ - description: [ts.Diagnostics.Implement_interface_0.message, "IFoo"], - newFileContent: -`interface IFoo { - a: 'string'; - c: { d: 'string'; }; -} -class Foo implements IFoo { - a: 'string'; - c: { d: 'string'; }; -}`, - preferences: { quotePreference: "single" } -}); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports.ts index 3a08ffa5e5a2a..473e7273ae228 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports.ts @@ -34,7 +34,7 @@ import { B, C, D } from './types2'; export class C implements Base { a: A; b(p1: C): D { - throw new Error("Method not implemented."); + throw new Error('Method not implemented.'); } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports_typeOnly.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports_typeOnly.ts index 9f261a72c2aed..55103d11486e1 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports_typeOnly.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceAutoImports_typeOnly.ts @@ -36,7 +36,7 @@ import type { B, C, D } from './types2'; export class C implements Base { a: A; b(p1: C): D { - throw new Error("Method not implemented."); + throw new Error('Method not implemented.'); } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterface_optionQuote.ts b/tests/cases/fourslash/codeFixClassImplementInterface_optionQuote.ts deleted file mode 100644 index 7fa6d8d9a9c97..0000000000000 --- a/tests/cases/fourslash/codeFixClassImplementInterface_optionQuote.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -////interface I { -//// m(): void; -////} -////class C implements I {} - -verify.codeFix({ - description: "Implement interface 'I'", - newFileContent: -`interface I { - m(): void; -} -class C implements I { - m(): void { - throw new Error('Method not implemented.'); - } -}`, - preferences: { quotePreference: "single" } -}); diff --git a/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto1.ts b/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto1.ts new file mode 100644 index 0000000000000..9c0e5e111fb63 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto1.ts @@ -0,0 +1,32 @@ +/// + +// @filename: a.ts +////export interface I { +//// a(): void; +//// b(x: "x", y: "a" | "b"): "b"; +//// +//// c: "c"; +//// d: { e: "e"; }; +////} +// @filename: b.ts +////import { I } from "./a"; +////class Foo implements I {} + +goTo.file("b.ts") +verify.codeFix({ + description: [ts.Diagnostics.Implement_interface_0.message, "I"], + index: 0, + newFileContent: +`import { I } from "./a"; +class Foo implements I { + a(): void { + throw new Error("Method not implemented."); + } + b(x: "x", y: "a" | "b"): "b" { + throw new Error("Method not implemented."); + } + c: "c"; + d: { e: "e"; }; +}`, + preferences: { quotePreference: "auto" } +}); diff --git a/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto2.ts b/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto2.ts new file mode 100644 index 0000000000000..d38832e91c092 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceAuto2.ts @@ -0,0 +1,32 @@ +/// + +// @filename: a.ts +////export interface I { +//// a(): void; +//// b(x: 'x', y: 'a' | 'b'): 'b'; +//// +//// c: 'c'; +//// d: { e: 'e'; }; +////} +// @filename: b.ts +////import { I } from './a'; +////class Foo implements I {} + +goTo.file("b.ts") +verify.codeFix({ + description: [ts.Diagnostics.Implement_interface_0.message, "I"], + index: 0, + newFileContent: +`import { I } from './a'; +class Foo implements I { + a(): void { + throw new Error('Method not implemented.'); + } + b(x: 'x', y: 'a' | 'b'): 'b' { + throw new Error('Method not implemented.'); + } + c: 'c'; + d: { e: 'e'; }; +}`, + preferences: { quotePreference: "auto" } +}); diff --git a/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceDouble.ts b/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceDouble.ts new file mode 100644 index 0000000000000..2e048875b8b05 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceDouble.ts @@ -0,0 +1,34 @@ +/// + +////interface I { +//// a(): void; +//// b(x: "x", y: "a" | "b"): "b"; +//// +//// c: "c"; +//// d: { e: "e"; }; +////} +////class Foo implements I {} + +verify.codeFix({ + description: [ts.Diagnostics.Implement_interface_0.message, "I"], + index: 0, + newFileContent: +`interface I { + a(): void; + b(x: "x", y: "a" | "b"): "b"; + + c: "c"; + d: { e: "e"; }; +} +class Foo implements I { + a(): void { + throw new Error("Method not implemented."); + } + b(x: "x", y: "a" | "b"): "b" { + throw new Error("Method not implemented."); + } + c: "c"; + d: { e: "e"; }; +}`, + preferences: { quotePreference: "double" } +}); diff --git a/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceSingle.ts b/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceSingle.ts new file mode 100644 index 0000000000000..0367ec6daa11b --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterface_quotePreferenceSingle.ts @@ -0,0 +1,34 @@ +/// + +////interface I { +//// a(): void; +//// b(x: 'x', y: 'a' | 'b'): 'b'; +//// +//// c: 'c'; +//// d: { e: 'e'; }; +////} +////class Foo implements I {} + +verify.codeFix({ + description: [ts.Diagnostics.Implement_interface_0.message, "I"], + index: 0, + newFileContent: +`interface I { + a(): void; + b(x: 'x', y: 'a' | 'b'): 'b'; + + c: 'c'; + d: { e: 'e'; }; +} +class Foo implements I { + a(): void { + throw new Error('Method not implemented.'); + } + b(x: 'x', y: 'a' | 'b'): 'b' { + throw new Error('Method not implemented.'); + } + c: 'c'; + d: { e: 'e'; }; +}`, + preferences: { quotePreference: "single" } +}); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index a1f91482309c6..a2be4e57a2e0a 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -592,7 +592,7 @@ declare namespace FourSlashInterface { filesToSearch?: ReadonlyArray; } interface UserPreferences { - readonly quotePreference?: "double" | "single"; + readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; readonly includeInsertTextCompletions?: boolean; readonly includeAutomaticOptionalChainCompletions?: boolean; From 4f72ae2638c5ad21e3889a346bd5842badf44fcc Mon Sep 17 00:00:00 2001 From: csigs Date: Tue, 7 Jul 2020 04:10:42 +0000 Subject: [PATCH 47/47] LEGO: check in for master to temporary branch. --- .../diagnosticMessages/diagnosticMessages.generated.json.lcl | 4 ++-- .../diagnosticMessages/diagnosticMessages.generated.json.lcl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 48d64afd60eed..c9deb6438412f 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -2593,7 +2593,7 @@ - + @@ -2602,7 +2602,7 @@ - + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index f10b2f623f61c..3478f60826188 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -2574,7 +2574,7 @@ - + @@ -2583,7 +2583,7 @@ - +