From 7acca501b6d7ab1ec29c784546ff83741d579613 Mon Sep 17 00:00:00 2001 From: gb714us Date: Fri, 7 Jun 2019 03:48:19 -0700 Subject: [PATCH 01/43] create outlining span for JsxFragment --- src/services/outliningElementsCollector.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 650a107f4a5e7..6e3a5dc6ecd79 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -198,6 +198,8 @@ namespace ts.OutliningElementsCollector { return spanForObjectOrArrayLiteral(n, SyntaxKind.OpenBracketToken); case SyntaxKind.JsxElement: return spanForJSXElement(n); + case SyntaxKind.JsxFragment: + return spanForJSXFragment(n); case SyntaxKind.JsxSelfClosingElement: case SyntaxKind.JsxOpeningElement: return spanForJSXAttributes((n).attributes); @@ -210,6 +212,12 @@ namespace ts.OutliningElementsCollector { return createOutliningSpan(textSpan, OutliningSpanKind.Code, textSpan, /*autoCollapse*/ false, bannerText); } + function spanForJSXFragment(node: JsxFragment): OutliningSpan | undefined { + const textSpan = createTextSpanFromBounds(node.openingFragment.getStart(sourceFile), node.closingFragment.getEnd()); + const bannerText = "<>..."; + return createOutliningSpan(textSpan, OutliningSpanKind.Code, textSpan, /*autoCollapse*/ false, bannerText); + } + function spanForJSXAttributes(node: JsxAttributes): OutliningSpan | undefined { if (node.properties.length === 0) { return undefined; From 29f995829b6037273effd2838eae97ade82e31ee Mon Sep 17 00:00:00 2001 From: gb714us Date: Sat, 8 Jun 2019 15:23:50 -0700 Subject: [PATCH 02/43] Added test cases for JSXFragment span --- tests/cases/fourslash/getJSXOutliningSpans.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/cases/fourslash/getJSXOutliningSpans.tsx b/tests/cases/fourslash/getJSXOutliningSpans.tsx index fa4f541b1939b..f00eac19d5cd0 100644 --- a/tests/cases/fourslash/getJSXOutliningSpans.tsx +++ b/tests/cases/fourslash/getJSXOutliningSpans.tsx @@ -25,9 +25,12 @@ //// md: 5 //// }|]}|] //// /> +//// [|<> +//// text +//// |] //// |] //// ); //// }|] ////}|] -verify.outliningSpansInCurrentFile(test.ranges(), "code"); +verify.outliningSpansInCurrentFile(test.ranges(), "code"); \ No newline at end of file From 6e9d098d4134f865c9e352e46182ec6a2417dd41 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Wed, 3 Jul 2019 17:59:35 -0400 Subject: [PATCH 03/43] Adds support for completions after ASI inserted expressions Signed-off-by: Andrew Branch --- src/services/completions.ts | 18 +++++++++++++--- src/services/types.ts | 2 +- ...ompletionEntryAfterASIExpressionInClass.ts | 21 +++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/completionEntryAfterASIExpressionInClass.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 6d1d48b22b828..ce8fec3f04fd6 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1538,7 +1538,7 @@ namespace ts.Completions { * Relevant symbols are stored in the captured 'symbols' variable. */ function tryGetClassLikeCompletionSymbols(): GlobalsSearch { - const decl = tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location); + const decl = tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position); if (!decl) return GlobalsSearch.Continue; // We're looking up possible property names from parent type. @@ -2155,7 +2155,7 @@ namespace ts.Completions { * Returns the immediate owning class declaration of a context token, * on the condition that one exists and that the context implies completion should be given. */ - function tryGetObjectTypeDeclarationCompletionContainer(sourceFile: SourceFile, contextToken: Node | undefined, location: Node): ObjectTypeDeclaration | undefined { + function tryGetObjectTypeDeclarationCompletionContainer(sourceFile: SourceFile, contextToken: Node | undefined, location: Node, position: number): ObjectTypeDeclaration | undefined { // class c { method() { } | method2() { } } switch (location.kind) { case SyntaxKind.SyntaxList: @@ -2165,9 +2165,15 @@ namespace ts.Completions { if (cls && !findChildOfKind(cls, SyntaxKind.CloseBraceToken, sourceFile)) { return cls; } + break; + case SyntaxKind.Identifier: // class c extends React.Component { a: () => 1\n compon| } + if (isFromObjectTypeDeclaration(location)) { + return findAncestor(location, isObjectTypeDeclaration); + } } if (!contextToken) return undefined; + switch (contextToken.kind) { case SyntaxKind.SemicolonToken: // class c {getValue(): number; | } case SyntaxKind.CloseBraceToken: // class c { method() { } | } @@ -2179,7 +2185,13 @@ namespace ts.Completions { case SyntaxKind.CommaToken: // class c {getValue(): number, | } return tryCast(contextToken.parent, isObjectTypeDeclaration); default: - if (!isFromObjectTypeDeclaration(contextToken)) return undefined; + if (!isFromObjectTypeDeclaration(contextToken)) { + // class c extends React.Component { a: () => 1\n| } + if (getLineAndCharacterOfPosition(sourceFile, contextToken.getEnd()).line !== getLineAndCharacterOfPosition(sourceFile, position).line && isObjectTypeDeclaration(location)) { + return location; + } + return undefined; + } const isValidKeyword = isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; return (isValidKeyword(contextToken.kind) || contextToken.kind === SyntaxKind.AsteriskToken || isIdentifier(contextToken) && isValidKeyword(stringToToken(contextToken.text)!)) // TODO: GH#18217 ? contextToken.parent.parent as ObjectTypeDeclaration : undefined; diff --git a/src/services/types.ts b/src/services/types.ts index b97125734f7c5..099263063a851 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -892,7 +892,7 @@ namespace ts { } export interface CompletionInfo { - /** Not true for all glboal completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ + /** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ isGlobalCompletion: boolean; isMemberCompletion: boolean; diff --git a/tests/cases/fourslash/completionEntryAfterASIExpressionInClass.ts b/tests/cases/fourslash/completionEntryAfterASIExpressionInClass.ts new file mode 100644 index 0000000000000..61271140ad0af --- /dev/null +++ b/tests/cases/fourslash/completionEntryAfterASIExpressionInClass.ts @@ -0,0 +1,21 @@ +/// + +//// class Parent { +//// protected shouldWork() { +//// console.log(); +//// } +//// } +//// +//// class Child extends Parent { +//// // this assumes ASI, but on next line wants to +//// x = () => 1 +//// shoul/*insideid*/ +//// } +//// +//// class ChildTwo extends Parent { +//// // this assumes ASI, but on next line wants to +//// x = () => 1 +//// /*root*/ //nothing +//// } + +verify.completions({ marker: ["insideid", "root"], includes: "shouldWork", isNewIdentifierLocation: true }); From e55f97ec282d720f9bf58792ece0acc048202f93 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Mon, 8 Jul 2019 14:43:06 -0400 Subject: [PATCH 04/43] Updates the baselines for the typo fixes --- tests/baselines/reference/api/tsserverlibrary.d.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 944092e13d0b8..7853a4855ef5f 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -5398,7 +5398,7 @@ declare namespace ts { argumentCount: number; } interface CompletionInfo { - /** Not true for all glboal completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ + /** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ isGlobalCompletion: boolean; isMemberCompletion: boolean; /** diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index be8eea8062b2e..142ed88a11145 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -5398,7 +5398,7 @@ declare namespace ts { argumentCount: number; } interface CompletionInfo { - /** Not true for all glboal completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ + /** Not true for all global completions. This will be true if the enclosing scope matches a few syntax kinds. See `isSnippetScope`. */ isGlobalCompletion: boolean; isMemberCompletion: boolean; /** From dfc97db32325ed86ff86e51f6091714aa21dda65 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Thu, 11 Jul 2019 14:26:03 -0400 Subject: [PATCH 05/43] Don't add extra indentation for objects inside function parameters --- src/services/formatting/smartIndenter.ts | 3 ++- ...dentionsOfObjectsInAListAfterFormatting.ts | 2 +- .../formatMultipleFunctionArguments.ts | 26 +++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/formatMultipleFunctionArguments.ts diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 0c9e7b186f79a..62f4c3c556c0a 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -482,7 +482,6 @@ namespace ts.formatting { case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.Block: case SyntaxKind.ModuleBlock: - case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.TypeLiteral: case SyntaxKind.MappedType: case SyntaxKind.TupleType: @@ -524,6 +523,8 @@ namespace ts.formatting { return rangeIsOnOneLine(sourceFile, child!); } return true; + case SyntaxKind.CallExpression: + return childKind !== SyntaxKind.ObjectLiteralExpression case SyntaxKind.DoStatement: case SyntaxKind.WhileStatement: case SyntaxKind.ForInStatement: diff --git a/tests/cases/fourslash/consistenceOnIndentionsOfObjectsInAListAfterFormatting.ts b/tests/cases/fourslash/consistenceOnIndentionsOfObjectsInAListAfterFormatting.ts index 14ada2060267c..bbcdaec9cad6b 100644 --- a/tests/cases/fourslash/consistenceOnIndentionsOfObjectsInAListAfterFormatting.ts +++ b/tests/cases/fourslash/consistenceOnIndentionsOfObjectsInAListAfterFormatting.ts @@ -8,4 +8,4 @@ format.document(); goTo.marker("1"); verify.currentLineContentIs("}, {"); goTo.marker("2"); -verify.currentLineContentIs(" });"); \ No newline at end of file +verify.currentLineContentIs("});"); diff --git a/tests/cases/fourslash/formatMultipleFunctionArguments.ts b/tests/cases/fourslash/formatMultipleFunctionArguments.ts new file mode 100644 index 0000000000000..1e3909305a611 --- /dev/null +++ b/tests/cases/fourslash/formatMultipleFunctionArguments.ts @@ -0,0 +1,26 @@ +/// + +//// +//// someRandomFunction({ +//// prop1: 1, +//// prop2: 2 +//// }, { +//// prop3: 3, +//// prop4: 4 +//// }, { +//// prop5: 5, +//// prop6: 6 +//// }); + +format.document(); +verify.currentFileContentIs(` +someRandomFunction({ + prop1: 1, + prop2: 2 +}, { + prop3: 3, + prop4: 4 +}, { + prop5: 5, + prop6: 6 +});`); From 0e273c3e07666d201bb434a6c822a2efbaec5a77 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 11 Jul 2019 10:45:19 -1000 Subject: [PATCH 06/43] Fix type parameter inference cache invalidation --- src/compiler/checker.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5d5d99f62c61a..b840417db3b19 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15229,8 +15229,8 @@ namespace ts { const inference = inferences[i]; if (t === inference.typeParameter) { if (fix && !inference.isFixed) { + clearCachedInferences(inferences); inference.isFixed = true; - inference.inferredType = undefined; } return getInferredType(context, i); } @@ -15238,6 +15238,14 @@ namespace ts { return t; } + function clearCachedInferences(inferences: InferenceInfo[]) { + for (const inference of inferences) { + if (!inference.isFixed) { + inference.inferredType = undefined; + } + } + } + function createInferenceInfo(typeParameter: TypeParameter): InferenceInfo { return { typeParameter, @@ -15517,17 +15525,17 @@ namespace ts { if (contravariant && !bivariant) { if (!contains(inference.contraCandidates, candidate)) { inference.contraCandidates = append(inference.contraCandidates, candidate); - inference.inferredType = undefined; + clearCachedInferences(inferences); } } else if (!contains(inference.candidates, candidate)) { inference.candidates = append(inference.candidates, candidate); - inference.inferredType = undefined; + clearCachedInferences(inferences); } } if (!(priority & InferencePriority.ReturnType) && target.flags & TypeFlags.TypeParameter && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; - inference.inferredType = undefined; + clearCachedInferences(inferences); } } return; From c53246fa35bb0e8f931042240e0fe28d5c34f31a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 11 Jul 2019 10:47:27 -1000 Subject: [PATCH 07/43] Add regression test --- .../typeInferenceCacheInvalidation.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/cases/compiler/typeInferenceCacheInvalidation.ts diff --git a/tests/cases/compiler/typeInferenceCacheInvalidation.ts b/tests/cases/compiler/typeInferenceCacheInvalidation.ts new file mode 100644 index 0000000000000..d037f139ec5fd --- /dev/null +++ b/tests/cases/compiler/typeInferenceCacheInvalidation.ts @@ -0,0 +1,23 @@ +// @strict: true + +// Repro from #32230 + +type Callback = (foo: TFoo, bar: TBar) => any + +declare function example>( + foo: TFoo, + callback: TCallback, + bar: TBar, +): TCallback + +example(42, (foo, bar) => ({ + t: () => { + let s: string = bar; + } +}), '42'); + +example(42, (foo, bar) => ({ + t() { + let s: string = bar; + } +}), '42'); From 4b9ca33e1d532b33da2331420b5353bb9a5ae576 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 11 Jul 2019 10:47:34 -1000 Subject: [PATCH 08/43] Accept new baselines --- .../typeInferenceCacheInvalidation.js | 37 +++++++++++ .../typeInferenceCacheInvalidation.symbols | 64 +++++++++++++++++++ .../typeInferenceCacheInvalidation.types | 63 ++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 tests/baselines/reference/typeInferenceCacheInvalidation.js create mode 100644 tests/baselines/reference/typeInferenceCacheInvalidation.symbols create mode 100644 tests/baselines/reference/typeInferenceCacheInvalidation.types diff --git a/tests/baselines/reference/typeInferenceCacheInvalidation.js b/tests/baselines/reference/typeInferenceCacheInvalidation.js new file mode 100644 index 0000000000000..bda29ad8b70b9 --- /dev/null +++ b/tests/baselines/reference/typeInferenceCacheInvalidation.js @@ -0,0 +1,37 @@ +//// [typeInferenceCacheInvalidation.ts] +// Repro from #32230 + +type Callback = (foo: TFoo, bar: TBar) => any + +declare function example>( + foo: TFoo, + callback: TCallback, + bar: TBar, +): TCallback + +example(42, (foo, bar) => ({ + t: () => { + let s: string = bar; + } +}), '42'); + +example(42, (foo, bar) => ({ + t() { + let s: string = bar; + } +}), '42'); + + +//// [typeInferenceCacheInvalidation.js] +"use strict"; +// Repro from #32230 +example(42, function (foo, bar) { return ({ + t: function () { + var s = bar; + } +}); }, '42'); +example(42, function (foo, bar) { return ({ + t: function () { + var s = bar; + } +}); }, '42'); diff --git a/tests/baselines/reference/typeInferenceCacheInvalidation.symbols b/tests/baselines/reference/typeInferenceCacheInvalidation.symbols new file mode 100644 index 0000000000000..e9e1949dc9132 --- /dev/null +++ b/tests/baselines/reference/typeInferenceCacheInvalidation.symbols @@ -0,0 +1,64 @@ +=== tests/cases/compiler/typeInferenceCacheInvalidation.ts === +// Repro from #32230 + +type Callback = (foo: TFoo, bar: TBar) => any +>Callback : Symbol(Callback, Decl(typeInferenceCacheInvalidation.ts, 0, 0)) +>TFoo : Symbol(TFoo, Decl(typeInferenceCacheInvalidation.ts, 2, 14)) +>TBar : Symbol(TBar, Decl(typeInferenceCacheInvalidation.ts, 2, 19)) +>foo : Symbol(foo, Decl(typeInferenceCacheInvalidation.ts, 2, 29)) +>TFoo : Symbol(TFoo, Decl(typeInferenceCacheInvalidation.ts, 2, 14)) +>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 2, 39)) +>TBar : Symbol(TBar, Decl(typeInferenceCacheInvalidation.ts, 2, 19)) + +declare function example>( +>example : Symbol(example, Decl(typeInferenceCacheInvalidation.ts, 2, 57)) +>TFoo : Symbol(TFoo, Decl(typeInferenceCacheInvalidation.ts, 4, 25)) +>TBar : Symbol(TBar, Decl(typeInferenceCacheInvalidation.ts, 4, 30)) +>TCallback : Symbol(TCallback, Decl(typeInferenceCacheInvalidation.ts, 4, 36)) +>Callback : Symbol(Callback, Decl(typeInferenceCacheInvalidation.ts, 0, 0)) +>TFoo : Symbol(TFoo, Decl(typeInferenceCacheInvalidation.ts, 4, 25)) +>TBar : Symbol(TBar, Decl(typeInferenceCacheInvalidation.ts, 4, 30)) + + foo: TFoo, +>foo : Symbol(foo, Decl(typeInferenceCacheInvalidation.ts, 4, 77)) +>TFoo : Symbol(TFoo, Decl(typeInferenceCacheInvalidation.ts, 4, 25)) + + callback: TCallback, +>callback : Symbol(callback, Decl(typeInferenceCacheInvalidation.ts, 5, 14)) +>TCallback : Symbol(TCallback, Decl(typeInferenceCacheInvalidation.ts, 4, 36)) + + bar: TBar, +>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 6, 24)) +>TBar : Symbol(TBar, Decl(typeInferenceCacheInvalidation.ts, 4, 30)) + +): TCallback +>TCallback : Symbol(TCallback, Decl(typeInferenceCacheInvalidation.ts, 4, 36)) + +example(42, (foo, bar) => ({ +>example : Symbol(example, Decl(typeInferenceCacheInvalidation.ts, 2, 57)) +>foo : Symbol(foo, Decl(typeInferenceCacheInvalidation.ts, 10, 13)) +>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 10, 17)) + + t: () => { +>t : Symbol(t, Decl(typeInferenceCacheInvalidation.ts, 10, 28)) + + let s: string = bar; +>s : Symbol(s, Decl(typeInferenceCacheInvalidation.ts, 12, 11)) +>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 10, 17)) + } +}), '42'); + +example(42, (foo, bar) => ({ +>example : Symbol(example, Decl(typeInferenceCacheInvalidation.ts, 2, 57)) +>foo : Symbol(foo, Decl(typeInferenceCacheInvalidation.ts, 16, 13)) +>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 16, 17)) + + t() { +>t : Symbol(t, Decl(typeInferenceCacheInvalidation.ts, 16, 28)) + + let s: string = bar; +>s : Symbol(s, Decl(typeInferenceCacheInvalidation.ts, 18, 11)) +>bar : Symbol(bar, Decl(typeInferenceCacheInvalidation.ts, 16, 17)) + } +}), '42'); + diff --git a/tests/baselines/reference/typeInferenceCacheInvalidation.types b/tests/baselines/reference/typeInferenceCacheInvalidation.types new file mode 100644 index 0000000000000..35911fafb392b --- /dev/null +++ b/tests/baselines/reference/typeInferenceCacheInvalidation.types @@ -0,0 +1,63 @@ +=== tests/cases/compiler/typeInferenceCacheInvalidation.ts === +// Repro from #32230 + +type Callback = (foo: TFoo, bar: TBar) => any +>Callback : Callback +>foo : TFoo +>bar : TBar + +declare function example>( +>example : >(foo: TFoo, callback: TCallback, bar: TBar) => TCallback + + foo: TFoo, +>foo : TFoo + + callback: TCallback, +>callback : TCallback + + bar: TBar, +>bar : TBar + +): TCallback + +example(42, (foo, bar) => ({ +>example(42, (foo, bar) => ({ t: () => { let s: string = bar; }}), '42') : (foo: number, bar: string) => { t: () => void; } +>example : >(foo: TFoo, callback: TCallback, bar: TBar) => TCallback +>42 : 42 +>(foo, bar) => ({ t: () => { let s: string = bar; }}) : (foo: number, bar: string) => { t: () => void; } +>foo : number +>bar : string +>({ t: () => { let s: string = bar; }}) : { t: () => void; } +>{ t: () => { let s: string = bar; }} : { t: () => void; } + + t: () => { +>t : () => void +>() => { let s: string = bar; } : () => void + + let s: string = bar; +>s : string +>bar : string + } +}), '42'); +>'42' : "42" + +example(42, (foo, bar) => ({ +>example(42, (foo, bar) => ({ t() { let s: string = bar; }}), '42') : (foo: number, bar: string) => { t(): void; } +>example : >(foo: TFoo, callback: TCallback, bar: TBar) => TCallback +>42 : 42 +>(foo, bar) => ({ t() { let s: string = bar; }}) : (foo: number, bar: string) => { t(): void; } +>foo : number +>bar : string +>({ t() { let s: string = bar; }}) : { t(): void; } +>{ t() { let s: string = bar; }} : { t(): void; } + + t() { +>t : () => void + + let s: string = bar; +>s : string +>bar : string + } +}), '42'); +>'42' : "42" + From 84f4acdb89e3d2cd202c7e43933d661cfa8da29d Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 11 Jul 2019 20:34:41 -0400 Subject: [PATCH 09/43] Add kind to JsxAttributes. --- src/compiler/types.ts | 1 + tests/baselines/reference/api/tsserverlibrary.d.ts | 1 + tests/baselines/reference/api/typescript.d.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a88580f9b1240..439dfb5f98ec9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1882,6 +1882,7 @@ namespace ts { } export interface JsxAttributes extends ObjectLiteralExpressionBase { + kind: SyntaxKind.JsxAttributes; parent: JsxOpeningLikeElement; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index b4a089f63b9e7..fb39db1d3e065 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1155,6 +1155,7 @@ declare namespace ts { expression: JsxTagNameExpression; } interface JsxAttributes extends ObjectLiteralExpressionBase { + kind: SyntaxKind.JsxAttributes; parent: JsxOpeningLikeElement; } interface JsxOpeningElement extends Expression { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 46f1c31e6e353..c9d6a220e6fc3 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1155,6 +1155,7 @@ declare namespace ts { expression: JsxTagNameExpression; } interface JsxAttributes extends ObjectLiteralExpressionBase { + kind: SyntaxKind.JsxAttributes; parent: JsxOpeningLikeElement; } interface JsxOpeningElement extends Expression { From 1d93b76b3f0fecc726b5f64defbe8cb54400b959 Mon Sep 17 00:00:00 2001 From: Dmitrijs Minajevs Date: Fri, 12 Jul 2019 14:04:19 +0300 Subject: [PATCH 10/43] Added "readonly" to Type Keywords --- src/harness/fourslash.ts | 6 +++--- src/services/utilities.ts | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index ffc0759e92ebf..c8c1643b0e01f 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -865,7 +865,7 @@ namespace FourSlash { ts.zipWith(actual, expected, (completion, expectedCompletion, index) => { const name = typeof expectedCompletion === "string" ? expectedCompletion : expectedCompletion.name; if (completion.name !== name) { - this.raiseError(`${marker ? JSON.stringify(marker) : "" } Expected completion at index ${index} to be ${name}, got ${completion.name}`); + this.raiseError(`${marker ? JSON.stringify(marker) : ""} Expected completion at index ${index} to be ${name}, got ${completion.name}`); } this.verifyCompletionEntry(completion, expectedCompletion); }); @@ -3742,7 +3742,7 @@ namespace FourSlashInterface { } export class Plugins { - constructor (private state: FourSlash.TestState) { + constructor(private state: FourSlash.TestState) { } public configurePlugin(pluginName: string, configuration: any): void { @@ -4565,7 +4565,7 @@ namespace FourSlashInterface { export const keywords: ReadonlyArray = keywordsWithUndefined.filter(k => k.name !== "undefined"); export const typeKeywords: ReadonlyArray = - ["false", "null", "true", "void", "any", "boolean", "keyof", "never", "number", "object", "string", "symbol", "undefined", "unique", "unknown", "bigint"].map(keywordEntry); + ["false", "null", "true", "void", "any", "boolean", "keyof", "never", "readonly", "number", "object", "string", "symbol", "undefined", "unique", "unknown", "bigint"].map(keywordEntry); const globalTypeDecls: ReadonlyArray = [ interfaceEntry("Symbol"), diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 44125fea6d05c..7a273b64ad1be 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1224,6 +1224,7 @@ namespace ts { SyntaxKind.NullKeyword, SyntaxKind.NumberKeyword, SyntaxKind.ObjectKeyword, + SyntaxKind.ReadonlyKeyword, SyntaxKind.StringKeyword, SyntaxKind.SymbolKeyword, SyntaxKind.TrueKeyword, @@ -1751,8 +1752,8 @@ namespace ts { function getSynthesizedDeepCloneWorker(node: T, renameMap?: Map, checker?: TypeChecker, callback?: (originalNode: Node, clone: Node) => any): T { const visited = (renameMap || checker || callback) ? - visitEachChild(node, wrapper, nullTransformationContext) : - visitEachChild(node, getSynthesizedDeepClone, nullTransformationContext); + visitEachChild(node, wrapper, nullTransformationContext) : + visitEachChild(node, getSynthesizedDeepClone, nullTransformationContext); if (visited === node) { // This only happens for leaf nodes - internal nodes always see their children change. From 74805c2e2392707af8aa606f8f7a52dfc28bdabb Mon Sep 17 00:00:00 2001 From: Dmitrijs Minajevs Date: Fri, 12 Jul 2019 14:11:23 +0300 Subject: [PATCH 11/43] Fixed failing test due to changed details --- .../fourslash/documentHighlightsInvalidModifierLocations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/fourslash/documentHighlightsInvalidModifierLocations.ts b/tests/cases/fourslash/documentHighlightsInvalidModifierLocations.ts index f008e63246461..baa203901fd26 100644 --- a/tests/cases/fourslash/documentHighlightsInvalidModifierLocations.ts +++ b/tests/cases/fourslash/documentHighlightsInvalidModifierLocations.ts @@ -6,5 +6,5 @@ ////function f([|readonly|] p) {} for (const r of test.ranges()) { - verify.documentHighlightsOf(r, [r]); + verify.documentHighlightsOf(r, test.ranges()); } From b2c555a57dfc2f2ad3c029d97ebc6f0932a2614e Mon Sep 17 00:00:00 2001 From: Dmitrijs Minajevs Date: Fri, 12 Jul 2019 15:25:00 +0300 Subject: [PATCH 12/43] Added new keword compeltion filter for assertions --- src/services/completions.ts | 27 +++++++++++++------ .../cases/fourslash/completionListAsConst.ts | 11 ++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 tests/cases/fourslash/completionListAsConst.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 6d1d48b22b828..f95526121a3b6 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -38,6 +38,7 @@ namespace ts.Completions { InterfaceElementKeywords, // Keywords inside interface body ConstructorParameterKeywords, // Keywords at constructor parameter FunctionLikeBodyKeywords, // Keywords at function like body + TypeAssertionKeywords, TypeKeywords, Last = TypeKeywords } @@ -441,7 +442,7 @@ namespace ts.Completions { (symbol.escapedName === InternalSymbolName.ExportEquals)) // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase. ? firstDefined(symbol.declarations, d => isExportAssignment(d) && isIdentifier(d.expression) ? d.expression.text : undefined) - || codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) + || codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) : symbol.name; } @@ -632,9 +633,9 @@ namespace ts.Completions { // At `,`, treat this as the next argument after the comma. ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === SyntaxKind.CommaToken ? 1 : 0)) : isEqualityOperatorKind(previousToken.kind) && isBinaryExpression(parent) && isEqualityOperatorKind(parent.operatorToken.kind) - // completion at `x ===/**/` should be for the right side - ? checker.getTypeAtLocation(parent.left) - : checker.getContextualType(previousToken as Expression); + // completion at `x ===/**/` should be for the right side + ? checker.getTypeAtLocation(parent.left) + : checker.getContextualType(previousToken as Expression); } } @@ -1181,7 +1182,11 @@ namespace ts.Completions { function filterGlobalCompletion(symbols: Symbol[]): void { const isTypeOnly = isTypeOnlyCompletion(); const allowTypes = isTypeOnly || !isContextTokenValueLocation(contextToken) && isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker); - if (isTypeOnly) keywordFilters = KeywordCompletionFilters.TypeKeywords; + if (isTypeOnly) { + keywordFilters = isInsideTypeAssertion() + ? KeywordCompletionFilters.TypeAssertionKeywords + : KeywordCompletionFilters.TypeKeywords; + } filterMutate(symbols, symbol => { if (!isSourceFile(location)) { @@ -1211,6 +1216,10 @@ namespace ts.Completions { }); } + function isInsideTypeAssertion(): boolean { + return isAsExpression(contextToken.parent); + } + function isTypeOnlyCompletion(): boolean { return insideJsDocTagTypeExpression || !isContextTokenValueLocation(contextToken) && (isPartOfTypeNode(location) || isContextTokenTypeLocation(contextToken)); } @@ -1434,7 +1443,7 @@ namespace ts.Completions { // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). return (isRegularExpressionLiteral(contextToken) || isStringTextContainingNode(contextToken)) && ( rangeContainsPositionExclusive(createTextRangeFromSpan(createTextSpanFromNode(contextToken)), position) || - position === contextToken.end && (!!contextToken.isUnterminated || isRegularExpressionLiteral(contextToken))); + position === contextToken.end && (!!contextToken.isUnterminated || isRegularExpressionLiteral(contextToken))); } /** @@ -1944,8 +1953,8 @@ namespace ts.Completions { return baseSymbols.filter(propertySymbol => !existingMemberNames.has(propertySymbol.escapedName) && - !!propertySymbol.declarations && - !(getDeclarationModifierFlagsFromSymbol(propertySymbol) & ModifierFlags.Private)); + !!propertySymbol.declarations && + !(getDeclarationModifierFlagsFromSymbol(propertySymbol) & ModifierFlags.Private)); } /** @@ -2057,6 +2066,8 @@ namespace ts.Completions { return isParameterPropertyModifier(kind); case KeywordCompletionFilters.FunctionLikeBodyKeywords: return isFunctionLikeBodyKeyword(kind); + case KeywordCompletionFilters.TypeAssertionKeywords: + return isTypeKeyword(kind) || kind === SyntaxKind.ConstKeyword; case KeywordCompletionFilters.TypeKeywords: return isTypeKeyword(kind); default: diff --git a/tests/cases/fourslash/completionListAsConst.ts b/tests/cases/fourslash/completionListAsConst.ts new file mode 100644 index 0000000000000..3a8b706cea26c --- /dev/null +++ b/tests/cases/fourslash/completionListAsConst.ts @@ -0,0 +1,11 @@ +/// + +////const a = { +//// b: 42 as con/*0*/ +////}; +//// +////1 as con/*1*/ +//// +////const b = 42 as /*2*/ + +verify.completions({ marker: test.markers(), includes: [{ name: "const", sortText: completion.SortText.GlobalsOrKeywords }] }); From 59d5585814afee67d162228c9b5f702ab1caf8ab Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Fri, 12 Jul 2019 15:21:57 -0400 Subject: [PATCH 13/43] Don't indent properties if an object literal follows directly from another object on the same line --- src/services/formatting/formatting.ts | 3 +++ src/services/formatting/smartIndenter.ts | 23 +++++++++++++++++-- .../formatMultipleFunctionArguments.ts | 20 +++++++++++++++- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 01c09a4989ce7..e4b6459a31e36 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -490,6 +490,9 @@ namespace ts.formatting { else if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { return { indentation: parentDynamicIndentation.getIndentation(), delta }; } + else if (SmartIndenter.childStartsInlineWithPreviousObject(parent, node, startLine, sourceFile)) { + return { indentation: parentDynamicIndentation.getIndentation(), delta }; + } else { return { indentation: parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(node), delta }; } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 62f4c3c556c0a..766228c1f093c 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -322,6 +322,26 @@ namespace ts.formatting { return false; } + export function childStartsInlineWithPreviousObject(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean { + if (parent.kind === SyntaxKind.CallExpression) { + const parentCallExpression = parent; + const currentNode = find(parentCallExpression.arguments, arg => arg.pos === child.pos); + if (!currentNode) return false; // Shouldn't happen + + const currentIndex = parentCallExpression.arguments.indexOf(currentNode); + if (currentIndex === 0) return false; // Can't look at previous node if first + + const previousNode = parentCallExpression.arguments[currentIndex - 1]; + const lineOfPreviousNode = getLineAndCharacterOfPosition(sourceFile, previousNode.getEnd()).line; + + if (childStartLine === lineOfPreviousNode) { + return true; + } + } + + return false; + } + export function getContainingList(node: Node, sourceFile: SourceFile): NodeArray | undefined { return node.parent && getListByRange(node.getStart(sourceFile), node.getEnd(), node.parent, sourceFile); } @@ -482,6 +502,7 @@ namespace ts.formatting { case SyntaxKind.ArrayLiteralExpression: case SyntaxKind.Block: case SyntaxKind.ModuleBlock: + case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.TypeLiteral: case SyntaxKind.MappedType: case SyntaxKind.TupleType: @@ -523,8 +544,6 @@ namespace ts.formatting { return rangeIsOnOneLine(sourceFile, child!); } return true; - case SyntaxKind.CallExpression: - return childKind !== SyntaxKind.ObjectLiteralExpression case SyntaxKind.DoStatement: case SyntaxKind.WhileStatement: case SyntaxKind.ForInStatement: diff --git a/tests/cases/fourslash/formatMultipleFunctionArguments.ts b/tests/cases/fourslash/formatMultipleFunctionArguments.ts index 1e3909305a611..32e6d0eea8971 100644 --- a/tests/cases/fourslash/formatMultipleFunctionArguments.ts +++ b/tests/cases/fourslash/formatMultipleFunctionArguments.ts @@ -11,6 +11,15 @@ //// prop5: 5, //// prop6: 6 //// }); +//// +//// someRandomFunction( +//// { prop7: 1, prop8: 2 }, +//// { prop9: 3, prop10: 4 }, +//// { +//// prop11: 5, +//// prop2: 6 +//// } +//// ); format.document(); verify.currentFileContentIs(` @@ -23,4 +32,13 @@ someRandomFunction({ }, { prop5: 5, prop6: 6 -});`); +}); + +someRandomFunction( + { prop7: 1, prop8: 2 }, + { prop9: 3, prop10: 4 }, + { + prop11: 5, + prop2: 6 + } +);`); From ba79b5ffacec89ee79219eb6de5e35b90a0bf537 Mon Sep 17 00:00:00 2001 From: Titian Cernicova-Dragomir Date: Fri, 12 Jul 2019 23:14:42 +0300 Subject: [PATCH 14/43] Fixed auto completion after a < token to return types not values. --- src/services/completions.ts | 3 +++ .../cases/fourslash/completionsAfterLessThanToken.ts | 12 ++++++++++++ .../completionsIsPossiblyTypeArgumentPosition.ts | 9 ++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 tests/cases/fourslash/completionsAfterLessThanToken.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index cf707c642ed36..29ce51bd47ac7 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1239,6 +1239,9 @@ namespace ts.Completions { case SyntaxKind.AsKeyword: return parentKind === SyntaxKind.AsExpression; + case SyntaxKind.LessThanToken: + return parentKind === SyntaxKind.TypeReference; + case SyntaxKind.ExtendsKeyword: return parentKind === SyntaxKind.TypeParameter; } diff --git a/tests/cases/fourslash/completionsAfterLessThanToken.ts b/tests/cases/fourslash/completionsAfterLessThanToken.ts new file mode 100644 index 0000000000000..c236f85e1fe62 --- /dev/null +++ b/tests/cases/fourslash/completionsAfterLessThanToken.ts @@ -0,0 +1,12 @@ +/// + +//// function f() { +//// const k: Record Date: Fri, 12 Jul 2019 14:01:57 -0700 Subject: [PATCH 15/43] Parse quoted constructors as constructors, not methods (#31949) * Parse quoted constructors as constructors, not methods * Update baselines * Fix disambiguation between quoted constructor and property named constructor * Clean up parsing a bit * Support escapes in constructor name * Update baselines --- src/compiler/checker.ts | 3 - src/compiler/diagnosticMessages.json | 4 -- src/compiler/parser.ts | 34 ++++++++--- src/compiler/utilities.ts | 17 ++++++ src/services/utilities.ts | 17 ------ .../reference/quotedConstructors.errors.txt | 30 --------- .../baselines/reference/quotedConstructors.js | 38 +++++++++--- .../reference/quotedConstructors.symbols | 61 ++++++++++++++----- .../reference/quotedConstructors.types | 58 +++++++++++++++--- .../quotedConstructors.ts | 22 +++++-- 10 files changed, 186 insertions(+), 98 deletions(-) delete mode 100644 tests/baselines/reference/quotedConstructors.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3dd9f9ef6f045..610c1c38de0a5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -33017,9 +33017,6 @@ namespace ts { return grammarErrorAtPos(node, node.end - 1, ";".length, Diagnostics._0_expected, "{"); } } - else if (isClassLike(node.parent) && isStringLiteral(node.name) && node.name.text === "constructor" && (!compilerOptions.target || compilerOptions.target < ScriptTarget.ES5)) { - return grammarErrorOnNode(node.name, Diagnostics.Quoted_constructors_have_previously_been_interpreted_as_methods_which_is_incorrect_In_TypeScript_3_6_they_will_be_correctly_parsed_as_constructors_In_the_meantime_consider_using_constructor_to_write_a_constructor_or_constructor_to_write_a_method); - } if (checkGrammarForGenerator(node)) { return true; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 7a6b798e2aee3..4528d504d0d12 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -5113,10 +5113,6 @@ "category": "Error", "code": 18004 }, - "Quoted constructors have previously been interpreted as methods, which is incorrect. In TypeScript 3.6, they will be correctly parsed as constructors. In the meantime, consider using 'constructor()' to write a constructor, or '[\"constructor\"]()' to write a method.": { - "category": "Error", - "code": 18005 - }, "Classes may not have a field named 'constructor'.": { "category": "Error", "code": 18006 diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f115d66951af4..254be93000b03 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5656,12 +5656,27 @@ namespace ts { return finishNode(node); } - function parseConstructorDeclaration(node: ConstructorDeclaration): ConstructorDeclaration { - node.kind = SyntaxKind.Constructor; - parseExpected(SyntaxKind.ConstructorKeyword); - fillSignature(SyntaxKind.ColonToken, SignatureFlags.None, node); - node.body = parseFunctionBlockOrSemicolon(SignatureFlags.None, Diagnostics.or_expected); - return finishNode(node); + function parseConstructorName() { + if (token() === SyntaxKind.ConstructorKeyword) { + return parseExpected(SyntaxKind.ConstructorKeyword); + } + if (token() === SyntaxKind.StringLiteral && lookAhead(nextToken) === SyntaxKind.OpenParenToken) { + return tryParse(() => { + const literalNode = parseLiteralNode(); + return literalNode.text === "constructor" ? literalNode : undefined; + }); + } + } + + function tryParseConstructorDeclaration(node: ConstructorDeclaration): ConstructorDeclaration | undefined { + return tryParse(() => { + if (parseConstructorName()) { + node.kind = SyntaxKind.Constructor; + fillSignature(SyntaxKind.ColonToken, SignatureFlags.None, node); + node.body = parseFunctionBlockOrSemicolon(SignatureFlags.None, Diagnostics.or_expected); + return finishNode(node); + } + }); } function parseMethodDeclaration(node: MethodDeclaration, asteriskToken: AsteriskToken, diagnosticMessage?: DiagnosticMessage): MethodDeclaration { @@ -5867,8 +5882,11 @@ namespace ts { return parseAccessorDeclaration(node, SyntaxKind.SetAccessor); } - if (token() === SyntaxKind.ConstructorKeyword) { - return parseConstructorDeclaration(node); + if (token() === SyntaxKind.ConstructorKeyword || token() === SyntaxKind.StringLiteral) { + const constructorDeclaration = tryParseConstructorDeclaration(node); + if (constructorDeclaration) { + return constructorDeclaration; + } } if (isIndexSignature()) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0d3bad879deca..fb5c69c637563 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3150,6 +3150,23 @@ namespace ts { return s.replace(escapedCharsRegExp, getReplacement); } + /** + * Strip off existed single quotes or double quotes from a given string + * + * @return non-quoted string + */ + export function stripQuotes(name: string) { + const length = name.length; + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + return name.substring(1, length - 1); + } + return name; + } + + export function startsWithQuote(name: string): boolean { + return isSingleOrDoubleQuote(name.charCodeAt(0)); + } + function getReplacement(c: string, offset: number, input: string) { if (c.charCodeAt(0) === CharacterCodes.nullCharacter) { const lookAhead = input.charCodeAt(offset + c.length); diff --git a/src/services/utilities.ts b/src/services/utilities.ts index cbadfbc9b53a8..6b224df4d4dd0 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1636,23 +1636,6 @@ namespace ts { return !!location.parent && isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location; } - /** - * Strip off existed single quotes or double quotes from a given string - * - * @return non-quoted string - */ - export function stripQuotes(name: string) { - const length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { - return name.substring(1, length - 1); - } - return name; - } - - export function startsWithQuote(name: string): boolean { - return isSingleOrDoubleQuote(name.charCodeAt(0)); - } - export function scriptKindIs(fileName: string, host: LanguageServiceHost, ...scriptKinds: ScriptKind[]): boolean { const scriptKind = getScriptKind(fileName, host); return some(scriptKinds, k => k === scriptKind); diff --git a/tests/baselines/reference/quotedConstructors.errors.txt b/tests/baselines/reference/quotedConstructors.errors.txt deleted file mode 100644 index 9e70452ff4062..0000000000000 --- a/tests/baselines/reference/quotedConstructors.errors.txt +++ /dev/null @@ -1,30 +0,0 @@ -tests/cases/conformance/classes/constructorDeclarations/quotedConstructors.ts(2,5): error TS18005: Quoted constructors have previously been interpreted as methods, which is incorrect. In TypeScript 3.6, they will be correctly parsed as constructors. In the meantime, consider using 'constructor()' to write a constructor, or '["constructor"]()' to write a method. -tests/cases/conformance/classes/constructorDeclarations/quotedConstructors.ts(6,5): error TS18005: Quoted constructors have previously been interpreted as methods, which is incorrect. In TypeScript 3.6, they will be correctly parsed as constructors. In the meantime, consider using 'constructor()' to write a constructor, or '["constructor"]()' to write a method. -tests/cases/conformance/classes/constructorDeclarations/quotedConstructors.ts(14,5): error TS18005: Quoted constructors have previously been interpreted as methods, which is incorrect. In TypeScript 3.6, they will be correctly parsed as constructors. In the meantime, consider using 'constructor()' to write a constructor, or '["constructor"]()' to write a method. - - -==== tests/cases/conformance/classes/constructorDeclarations/quotedConstructors.ts (3 errors) ==== - class C { - "constructor"() {} // Error in 3.5 - ~~~~~~~~~~~~~ -!!! error TS18005: Quoted constructors have previously been interpreted as methods, which is incorrect. In TypeScript 3.6, they will be correctly parsed as constructors. In the meantime, consider using 'constructor()' to write a constructor, or '["constructor"]()' to write a method. - } - - class D { - 'constructor'() {} // Error in 3.5 - ~~~~~~~~~~~~~ -!!! error TS18005: Quoted constructors have previously been interpreted as methods, which is incorrect. In TypeScript 3.6, they will be correctly parsed as constructors. In the meantime, consider using 'constructor()' to write a constructor, or '["constructor"]()' to write a method. - } - - class E { - ['constructor']() {} - } - - new class { - "constructor"() {} // Error in 3.5 - ~~~~~~~~~~~~~ -!!! error TS18005: Quoted constructors have previously been interpreted as methods, which is incorrect. In TypeScript 3.6, they will be correctly parsed as constructors. In the meantime, consider using 'constructor()' to write a constructor, or '["constructor"]()' to write a method. - }; - - var o = { "constructor"() {} }; - \ No newline at end of file diff --git a/tests/baselines/reference/quotedConstructors.js b/tests/baselines/reference/quotedConstructors.js index c9a662e6af526..36b57718f0a49 100644 --- a/tests/baselines/reference/quotedConstructors.js +++ b/tests/baselines/reference/quotedConstructors.js @@ -1,46 +1,68 @@ //// [quotedConstructors.ts] class C { - "constructor"() {} // Error in 3.5 + "constructor"() { + console.log(this); + } } class D { - 'constructor'() {} // Error in 3.5 + 'constructor'() { + console.log(this); + } } class E { - ['constructor']() {} + ['constructor']() { + console.log(this); + } } new class { - "constructor"() {} // Error in 3.5 + "constructor"() { + console.log(this); + } }; var o = { "constructor"() {} }; + +class F { + "\x63onstructor"() { + console.log(this); + } +} //// [quotedConstructors.js] var C = /** @class */ (function () { function C() { + console.log(this); } - C.prototype["constructor"] = function () { }; // Error in 3.5 return C; }()); var D = /** @class */ (function () { function D() { + console.log(this); } - D.prototype['constructor'] = function () { }; // Error in 3.5 return D; }()); var E = /** @class */ (function () { function E() { } - E.prototype['constructor'] = function () { }; + E.prototype['constructor'] = function () { + console.log(this); + }; return E; }()); new /** @class */ (function () { function class_1() { + console.log(this); } - class_1.prototype["constructor"] = function () { }; // Error in 3.5 return class_1; }()); var o = { "constructor": function () { } }; +var F = /** @class */ (function () { + function F() { + console.log(this); + } + return F; +}()); diff --git a/tests/baselines/reference/quotedConstructors.symbols b/tests/baselines/reference/quotedConstructors.symbols index be68e48484754..a4476a25ae5e8 100644 --- a/tests/baselines/reference/quotedConstructors.symbols +++ b/tests/baselines/reference/quotedConstructors.symbols @@ -2,32 +2,65 @@ class C { >C : Symbol(C, Decl(quotedConstructors.ts, 0, 0)) - "constructor"() {} // Error in 3.5 ->"constructor" : Symbol(C["constructor"], Decl(quotedConstructors.ts, 0, 9)) + "constructor"() { + console.log(this); +>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, --, --)) +>this : Symbol(C, Decl(quotedConstructors.ts, 0, 0)) + } } class D { ->D : Symbol(D, Decl(quotedConstructors.ts, 2, 1)) +>D : Symbol(D, Decl(quotedConstructors.ts, 4, 1)) - 'constructor'() {} // Error in 3.5 ->'constructor' : Symbol(D['constructor'], Decl(quotedConstructors.ts, 4, 9)) + 'constructor'() { + console.log(this); +>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, --, --)) +>this : Symbol(D, Decl(quotedConstructors.ts, 4, 1)) + } } class E { ->E : Symbol(E, Decl(quotedConstructors.ts, 6, 1)) +>E : Symbol(E, Decl(quotedConstructors.ts, 10, 1)) - ['constructor']() {} ->['constructor'] : Symbol(E['constructor'], Decl(quotedConstructors.ts, 8, 9)) ->'constructor' : Symbol(E['constructor'], Decl(quotedConstructors.ts, 8, 9)) + ['constructor']() { +>['constructor'] : Symbol(E['constructor'], Decl(quotedConstructors.ts, 12, 9)) +>'constructor' : Symbol(E['constructor'], Decl(quotedConstructors.ts, 12, 9)) + + console.log(this); +>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, --, --)) +>this : Symbol(E, Decl(quotedConstructors.ts, 10, 1)) + } } new class { - "constructor"() {} // Error in 3.5 ->"constructor" : Symbol((Anonymous class)["constructor"], Decl(quotedConstructors.ts, 12, 11)) - + "constructor"() { + console.log(this); +>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, --, --)) +>this : Symbol((Anonymous class), Decl(quotedConstructors.ts, 18, 3)) + } }; var o = { "constructor"() {} }; ->o : Symbol(o, Decl(quotedConstructors.ts, 16, 3)) ->"constructor" : Symbol("constructor", Decl(quotedConstructors.ts, 16, 9)) +>o : Symbol(o, Decl(quotedConstructors.ts, 24, 3)) +>"constructor" : Symbol("constructor", Decl(quotedConstructors.ts, 24, 9)) + +class F { +>F : Symbol(F, Decl(quotedConstructors.ts, 24, 31)) + + "\x63onstructor"() { + console.log(this); +>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, --, --)) +>this : Symbol(F, Decl(quotedConstructors.ts, 24, 31)) + } +} diff --git a/tests/baselines/reference/quotedConstructors.types b/tests/baselines/reference/quotedConstructors.types index 907a2152a80ac..65be89ff815a9 100644 --- a/tests/baselines/reference/quotedConstructors.types +++ b/tests/baselines/reference/quotedConstructors.types @@ -2,32 +2,57 @@ class C { >C : C - "constructor"() {} // Error in 3.5 ->"constructor" : () => void + "constructor"() { + console.log(this); +>console.log(this) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>this : this + } } class D { >D : D - 'constructor'() {} // Error in 3.5 ->'constructor' : () => void + 'constructor'() { + console.log(this); +>console.log(this) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>this : this + } } class E { >E : E - ['constructor']() {} + ['constructor']() { >['constructor'] : () => void >'constructor' : "constructor" + + console.log(this); +>console.log(this) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>this : this + } } new class { ->new class { "constructor"() {} // Error in 3.5} : (Anonymous class) ->class { "constructor"() {} // Error in 3.5} : typeof (Anonymous class) - - "constructor"() {} // Error in 3.5 ->"constructor" : () => void +>new class { "constructor"() { console.log(this); }} : (Anonymous class) +>class { "constructor"() { console.log(this); }} : typeof (Anonymous class) + "constructor"() { + console.log(this); +>console.log(this) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>this : this + } }; var o = { "constructor"() {} }; @@ -35,3 +60,16 @@ var o = { "constructor"() {} }; >{ "constructor"() {} } : { "constructor"(): void; } >"constructor" : () => void +class F { +>F : F + + "\x63onstructor"() { + console.log(this); +>console.log(this) : void +>console.log : (message?: any, ...optionalParams: any[]) => void +>console : Console +>log : (message?: any, ...optionalParams: any[]) => void +>this : this + } +} + diff --git a/tests/cases/conformance/classes/constructorDeclarations/quotedConstructors.ts b/tests/cases/conformance/classes/constructorDeclarations/quotedConstructors.ts index 3ab45c72810cd..c03ce26cc2f6e 100644 --- a/tests/cases/conformance/classes/constructorDeclarations/quotedConstructors.ts +++ b/tests/cases/conformance/classes/constructorDeclarations/quotedConstructors.ts @@ -1,17 +1,31 @@ class C { - "constructor"() {} // Error in 3.5 + "constructor"() { + console.log(this); + } } class D { - 'constructor'() {} // Error in 3.5 + 'constructor'() { + console.log(this); + } } class E { - ['constructor']() {} + ['constructor']() { + console.log(this); + } } new class { - "constructor"() {} // Error in 3.5 + "constructor"() { + console.log(this); + } }; var o = { "constructor"() {} }; + +class F { + "\x63onstructor"() { + console.log(this); + } +} From 1d78218053332e0a7de3cadcea53a64f3b0beff1 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Mon, 15 Jul 2019 10:48:10 -0400 Subject: [PATCH 16/43] Handle feedback from #32359 --- src/services/formatting/formatting.ts | 2 +- src/services/formatting/smartIndenter.ts | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index e4b6459a31e36..ed6b71efb7523 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -490,7 +490,7 @@ namespace ts.formatting { else if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { return { indentation: parentDynamicIndentation.getIndentation(), delta }; } - else if (SmartIndenter.childStartsInlineWithPreviousObject(parent, node, startLine, sourceFile)) { + else if (SmartIndenter.argumentStartsOnSameLineAsPreviousArgument(parent, node, startLine, sourceFile)) { return { indentation: parentDynamicIndentation.getIndentation(), delta }; } else { diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 766228c1f093c..7a8bfb5f5d509 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -322,16 +322,15 @@ namespace ts.formatting { return false; } - export function childStartsInlineWithPreviousObject(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean { - if (parent.kind === SyntaxKind.CallExpression) { - const parentCallExpression = parent; - const currentNode = find(parentCallExpression.arguments, arg => arg.pos === child.pos); - if (!currentNode) return false; // Shouldn't happen + export function argumentStartsOnSameLineAsPreviousArgument(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean { + if (isCallOrNewExpression(parent)) { + if (!parent.arguments) return false; - const currentIndex = parentCallExpression.arguments.indexOf(currentNode); + const currentNode = Debug.assertDefined(find(parent.arguments, arg => arg.pos === child.pos)); + const currentIndex = parent.arguments.indexOf(currentNode); if (currentIndex === 0) return false; // Can't look at previous node if first - const previousNode = parentCallExpression.arguments[currentIndex - 1]; + const previousNode = parent.arguments[currentIndex - 1]; const lineOfPreviousNode = getLineAndCharacterOfPosition(sourceFile, previousNode.getEnd()).line; if (childStartLine === lineOfPreviousNode) { From 79201c909d1889f0436c5ddefc74c39f99ed1262 Mon Sep 17 00:00:00 2001 From: csigs Date: Mon, 15 Jul 2019 16:10:11 +0000 Subject: [PATCH 17/43] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 20276 ++++++++-------- 1 file changed, 10138 insertions(+), 10138 deletions(-) diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1a28819584407..56bd64e882e8e 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1,10139 +1,10139 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - or -. For example '{0}' or '{1}'.]]> - - 或 <语言>-<区域> 形式。例如“{0}”或“{1}”。]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - type.]]> - - 类型。]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ()' instead.]]> - - ()"。]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + or -. For example '{0}' or '{1}'.]]> + + 或 <语言>-<区域> 形式。例如“{0}”或“{1}”。]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + type.]]> + + 类型。]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ()' instead.]]> + + ()"。]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 1397dc93873feb2005b5a9a09062d7fd36978765 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Mon, 15 Jul 2019 10:17:29 -0700 Subject: [PATCH 18/43] Update user baselines (#32403) --- .../baselines/reference/docker/azure-sdk.log | 14 +-- .../reference/docker/office-ui-fabric.log | 38 +++++-- .../user/chrome-devtools-frontend.log | 106 ------------------ tests/baselines/reference/user/uglify-js.log | 2 +- 4 files changed, 38 insertions(+), 122 deletions(-) diff --git a/tests/baselines/reference/docker/azure-sdk.log b/tests/baselines/reference/docker/azure-sdk.log index 5991387679e43..a1e33524e6e1c 100644 --- a/tests/baselines/reference/docker/azure-sdk.log +++ b/tests/baselines/reference/docker/azure-sdk.log @@ -1,7 +1,7 @@ Exit Code: 1 Standard output: -Rush Multi-Project Build Tool 5.7.3 - https://rushjs.io +Rush Multi-Project Build Tool 5.10.1 - https://rushjs.io Starting "rush rebuild" Executing a maximum of 1 simultaneous processes... [@azure/cosmos] started @@ -13,7 +13,7 @@ npm ERR! npm ERR! Failed at the @azure/cosmos@X.X.X compile script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-11T13_39_53_628Z-debug.log +npm ERR! /root/.npm/_logs/2019-07-15T13_35_10_789Z-debug.log [@azure/service-bus] started [@azure/storage-blob] started XX of XX: [@azure/storage-blob] completed successfully in ? seconds @@ -38,7 +38,7 @@ npm ERR! npm ERR! Failed at the @azure/core-http@X.X.X-preview.1 build:tsc script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-11T13_41_08_804Z-debug.log +npm ERR! /root/.npm/_logs/2019-07-15T13_36_24_862Z-debug.log ERROR: "build:tsc" exited with 2. npm ERR! code ELIFECYCLE npm ERR! errno 1 @@ -48,7 +48,7 @@ npm ERR! npm ERR! Failed at the @azure/core-http@X.X.X-preview.1 build:lib script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-11T13_41_08_852Z-debug.log +npm ERR! /root/.npm/_logs/2019-07-15T13_36_24_938Z-debug.log ERROR: "build:lib" exited with 1. [@azure/core-paging] started XX of XX: [@azure/core-paging] completed successfully in ? seconds @@ -90,7 +90,7 @@ npm ERR! npm ERR! Failed at the @azure/core-http@X.X.X-preview.1 build:tsc script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-11T13_41_08_804Z-debug.log +npm ERR! /root/.npm/_logs/2019-07-15T13_36_24_862Z-debug.log ERROR: "build:tsc" exited with 2. npm ERR! code ELIFECYCLE npm ERR! errno 1 @@ -100,7 +100,7 @@ npm ERR! npm ERR! Failed at the @azure/core-http@X.X.X-preview.1 build:lib script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-11T13_41_08_852Z-debug.log +npm ERR! /root/.npm/_logs/2019-07-15T13_36_24_938Z-debug.log ERROR: "build:lib" exited with 1. @azure/cosmos ( ? seconds) npm ERR! code ELIFECYCLE @@ -111,7 +111,7 @@ npm ERR! npm ERR! Failed at the @azure/cosmos@X.X.X compile script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-11T13_39_53_628Z-debug.log +npm ERR! /root/.npm/_logs/2019-07-15T13_35_10_789Z-debug.log @azure/service-bus ( ? seconds) >>> @azure/service-bus tsc -p . && rollup -c 2>&1 && npm run extract-api diff --git a/tests/baselines/reference/docker/office-ui-fabric.log b/tests/baselines/reference/docker/office-ui-fabric.log index 70e9ab2cc7b1c..c3a55fc3f6b9e 100644 --- a/tests/baselines/reference/docker/office-ui-fabric.log +++ b/tests/baselines/reference/docker/office-ui-fabric.log @@ -10,12 +10,24 @@ XX of XX: [@uifabric/prettier-rules] completed successfully in ? seconds XX of XX: [@uifabric/tslint-rules] completed successfully in ? seconds [@uifabric/codepen-loader] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. + PASS src/__tests__/codepenTransform.test.ts + codepen transform + ✓ handles examples with function components (225ms) + ✓ handles examples with class components (38ms) + ✓ handles examples importing exampleData (115ms) + ✓ handles examples importing TestImages (45ms) + ✓ handles examples importing PeopleExampleData (288ms) +Test Suites: 1 passed, 1 total +Tests: 5 passed, 5 total +Snapshots: 4 passed, 4 total +Time: ?s +Ran all test suites. [@uifabric/build] started XX of XX: [@uifabric/build] completed successfully in ? seconds [@uifabric/migration] started XX of XX: [@uifabric/migration] completed successfully in ? seconds [@uifabric/set-version] started -ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. +XX of XX: [@uifabric/set-version] completed successfully in ? seconds [@uifabric/merge-styles] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. [@uifabric/jest-serializer-merge-styles] started @@ -204,7 +216,7 @@ ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed [XX:XX:XX XM] x Error detected while running 'jest' [XX:XX:XX XM] x ------------------------------------ [XX:XX:XX XM] x Error: Command failed: /usr/local/bin/node /office-ui-fabric-react/common/temp/node_modules/jest/bin/jest.js --config /office-ui-fabric-react/packages/foundation/jest.config.js --passWithNoTests --colors - at ChildProcess. (/office-ui-fabric-react/common/temp/node_modules/.registry.npmjs.org/just-scripts-utils/0.8.1/node_modules/just-scripts-utils/lib/exec.js:70:31) + at ChildProcess. (/office-ui-fabric-react/common/temp/node_modules/.registry.npmjs.org/just-scripts-utils/0.8.2/node_modules/just-scripts-utils/lib/exec.js:70:31) at ChildProcess.emit (events.js:203:13) at ChildProcess.EventEmitter.emit (domain.js:494:23) at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) @@ -216,27 +228,38 @@ ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed XX of XX: [@uifabric/icons] completed successfully in ? seconds [@uifabric/webpack-utils] started XX of XX: [@uifabric/webpack-utils] completed successfully in ? seconds -SUCCESS (8) +SUCCESS (9) ================================ @uifabric/build (? seconds) @uifabric/file-type-icons (? seconds) @uifabric/icons (? seconds) @uifabric/migration (? seconds) @uifabric/prettier-rules (? seconds) +@uifabric/set-version (? seconds) @uifabric/test-utilities (? seconds) @uifabric/tslint-rules (? seconds) @uifabric/webpack-utils (? seconds) ================================ -SUCCESS WITH WARNINGS (6) +SUCCESS WITH WARNINGS (5) ================================ @uifabric/codepen-loader (? seconds) ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. + PASS src/__tests__/codepenTransform.test.ts + codepen transform + ✓ handles examples with function components (225ms) + ✓ handles examples with class components (38ms) + ✓ handles examples importing exampleData (115ms) + ✓ handles examples importing TestImages (45ms) + ✓ handles examples importing PeopleExampleData (288ms) +Test Suites: 1 passed, 1 total +Tests: 5 passed, 5 total +Snapshots: 4 passed, 4 total +Time: ?s +Ran all test suites. @uifabric/jest-serializer-merge-styles (? seconds) ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. @uifabric/merge-styles (? seconds) ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. -@uifabric/set-version (? seconds) -ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. @uifabric/styling (? seconds) ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. @uifabric/utilities (? seconds) @@ -296,7 +319,7 @@ ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed [XX:XX:XX XM] x Error detected while running 'jest' [XX:XX:XX XM] x ------------------------------------ [XX:XX:XX XM] x Error: Command failed: /usr/local/bin/node /office-ui-fabric-react/common/temp/node_modules/jest/bin/jest.js --config /office-ui-fabric-react/packages/foundation/jest.config.js --passWithNoTests --colors - at ChildProcess. (/office-ui-fabric-react/common/temp/node_modules/.registry.npmjs.org/just-scripts-utils/0.8.1/node_modules/just-scripts-utils/lib/exec.js:70:31) + at ChildProcess. (/office-ui-fabric-react/common/temp/node_modules/.registry.npmjs.org/just-scripts-utils/0.8.2/node_modules/just-scripts-utils/lib/exec.js:70:31) at ChildProcess.emit (events.js:203:13) at ChildProcess.EventEmitter.emit (domain.js:494:23) at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) @@ -313,7 +336,6 @@ rush rebuild - Errors! ( ? seconds) Standard error: Your version of Node.js (X.X.X) has not been tested with this release of Rush. The Rush team will not accept issue reports for it. Please consider upgrading Rush or downgrading Node.js. XX of XX: [@uifabric/codepen-loader] completed with warnings in ? seconds -XX of XX: [@uifabric/set-version] completed with warnings in ? seconds XX of XX: [@uifabric/merge-styles] completed with warnings in ? seconds XX of XX: [@uifabric/jest-serializer-merge-styles] completed with warnings in ? seconds XX of XX: [@uifabric/utilities] completed with warnings in ? seconds diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 87a3cd23c38b6..3f4fa8d5b95f1 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -3178,8 +3178,6 @@ node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBindin node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(51,31): error TS2339: Property 'remove' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(65,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(76,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(85,5): error TS2322: Type 'StackTraceTopFrameLocation' is not assignable to type '{ update(): void; uiLocation(): UILocation; dispose(): void; isBlackboxed(): boolean; }'. - Property '_updateScheduled' does not exist on type '{ update(): void; uiLocation(): UILocation; dispose(): void; isBlackboxed(): boolean; }'. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(90,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(195,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(207,34): error TS2339: Property 'valuesArray' does not exist on type 'Set'. @@ -3287,12 +3285,6 @@ node_modules/chrome-devtools-frontend/front_end/bindings_test_runner/IsolatedFil node_modules/chrome-devtools-frontend/front_end/bindings_test_runner/IsolatedFilesystemTestRunner.js(275,8): error TS2551: Property '_entry' does not exist on type 'typeof TestFileSystem'. Did you mean 'Entry'? node_modules/chrome-devtools-frontend/front_end/bindings_test_runner/IsolatedFilesystemTestRunner.js(276,8): error TS2339: Property '_modificationTimesDelta' does not exist on type 'typeof TestFileSystem'. node_modules/chrome-devtools-frontend/front_end/bindings_test_runner/OverridesTestRunner.js(7,13): error TS1064: The return type of an async function or method must be the global Promise type. -node_modules/chrome-devtools-frontend/front_end/bindings_test_runner/PersistenceTestRunner.js(45,46): error TS2345: Argument of type '(bindingCreated: (arg0: PersistenceBinding) => any, bindingRemoved: (arg0: PersistenceBinding) => any) => DefaultMapping' is not assignable to parameter of type '(arg0: (arg0: PersistenceBinding) => any, arg1: (arg0: PersistenceBinding) => any) => { dispose: () => void; }'. - Type 'DefaultMapping' is not assignable to type '{ dispose: () => void; }'. - Property '_workspace' does not exist on type '{ dispose: () => void; }'. -node_modules/chrome-devtools-frontend/front_end/bindings_test_runner/PersistenceTestRunner.js(54,46): error TS2345: Argument of type '(bindingCreated: (arg0: PersistenceBinding) => any, bindingRemoved: (arg0: PersistenceBinding) => any) => TestMapping' is not assignable to parameter of type '(arg0: (arg0: PersistenceBinding) => any, arg1: (arg0: PersistenceBinding) => any) => { dispose: () => void; }'. - Type 'TestMapping' is not assignable to type '{ dispose: () => void; }'. - Property '_onBindingAdded' does not exist on type '{ dispose: () => void; }'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(7,51): error TS2694: Namespace 'Changes.ChangesView' has no exported member 'Row'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(9,56): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. node_modules/chrome-devtools-frontend/front_end/changes/ChangesHighlighter.js(10,75): error TS2694: Namespace 'Changes.ChangesHighlighter' has no exported member 'DiffState'. @@ -4029,8 +4021,6 @@ node_modules/chrome-devtools-frontend/front_end/console/ConsoleView.js(232,15): node_modules/chrome-devtools-frontend/front_end/console/ConsoleView.js(232,51): error TS2339: Property 'ConsoleView' does not exist on type '{ new (): Console; prototype: Console; }'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleView.js(233,20): error TS2339: Property 'ConsoleView' does not exist on type '{ new (): Console; prototype: Console; }'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleView.js(241,76): error TS2339: Property 'ConsoleFilter' does not exist on type '{ new (): Console; prototype: Console; }'. -node_modules/chrome-devtools-frontend/front_end/console/ConsoleView.js(287,5): error TS2322: Type 'ConsoleViewMessage' is not assignable to type '{ willHide(): void; wasShown(): void; element(): Element; }'. - Property '_message' does not exist on type '{ willHide(): void; wasShown(): void; element(): Element; }'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleView.js(312,24): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleView.js(411,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleView.js(419,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. @@ -4460,8 +4450,6 @@ node_modules/chrome-devtools-frontend/front_end/coverage/CoverageListView.js(285 node_modules/chrome-devtools-frontend/front_end/coverage/CoverageListView.js(286,45): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageListView.js(290,33): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(34,42): error TS2694: Namespace 'Protocol' has no exported member 'Profiler'. -node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(103,46): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. - Property '_cssModel' does not exist on type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(131,31): error TS2694: Namespace 'Protocol' has no exported member 'Profiler'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(170,31): error TS2694: Namespace 'Protocol' has no exported member 'CSS'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(175,64): error TS2694: Namespace 'Coverage' has no exported member 'RangeUseCount'. @@ -5850,8 +5838,6 @@ node_modules/chrome-devtools-frontend/front_end/emulation/AdvancedApp.js(124,22) node_modules/chrome-devtools-frontend/front_end/emulation/AdvancedApp.js(142,44): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/emulation/AdvancedApp.js(169,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/emulation/AdvancedApp.js(174,57): error TS2339: Property 'window' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/emulation/AdvancedApp.js(199,5): error TS2322: Type 'AdvancedApp' is not assignable to type '{ presentUI(document: Document): void; }'. - Property '_rootSplitWidget' does not exist on type '{ presentUI(document: Document): void; }'. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeModel.js(9,1): error TS8022: JSDoc '@extends' is not attached to a class. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeModel.js(56,42): error TS2694: Namespace 'Emulation.EmulatedDevice' has no exported member 'Mode'. node_modules/chrome-devtools-frontend/front_end/emulation/DeviceModeModel.js(65,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. @@ -6584,36 +6570,15 @@ node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapsho node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1974,10): error TS2339: Property 'countDelta' does not exist on type 'Diff'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(1975,10): error TS2339: Property 'sizeDelta' does not exist on type 'Diff'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2021,80): error TS2339: Property 'edges' does not exist on type 'void'. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2021,89): error TS2345: Argument of type 'HeapSnapshotEdgeIndexProvider' is not assignable to parameter of type '{ itemForIndex(newIndex: number): { itemIndex(): number; serialize(): any; }; }'. - Types of property 'itemForIndex' are incompatible. - Type '(index: number) => HeapSnapshotEdge' is not assignable to type '(newIndex: number) => { itemIndex(): number; serialize(): any; }'. - Type 'HeapSnapshotEdge' is not assignable to type '{ itemIndex(): number; serialize(): any; }'. - Property '_snapshot' does not exist on type '{ itemIndex(): number; serialize(): any; }'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2032,80): error TS2339: Property 'edges' does not exist on type 'void'. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2032,89): error TS2345: Argument of type 'HeapSnapshotEdgeIndexProvider' is not assignable to parameter of type '{ itemForIndex(newIndex: number): { itemIndex(): number; serialize(): any; }; }'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2057,80): error TS2339: Property 'retainers' does not exist on type 'void'. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2057,93): error TS2345: Argument of type 'HeapSnapshotRetainerEdgeIndexProvider' is not assignable to parameter of type '{ itemForIndex(newIndex: number): { itemIndex(): number; serialize(): any; }; }'. - Types of property 'itemForIndex' are incompatible. - Type '(index: number) => HeapSnapshotRetainerEdge' is not assignable to type '(newIndex: number) => { itemIndex(): number; serialize(): any; }'. - Type 'HeapSnapshotRetainerEdge' is not assignable to type '{ itemIndex(): number; serialize(): any; }'. - Property '_snapshot' does not exist on type '{ itemIndex(): number; serialize(): any; }'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2126,33): error TS2339: Property 'AggregatedInfo' does not exist on type 'typeof HeapSnapshot'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2205,12): error TS2339: Property 'sort' does not exist on type 'HeapSnapshotItemProvider'. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2244,13): error TS2345: Argument of type 'HeapSnapshotEdgeIterator' is not assignable to parameter of type '{ hasNext(): boolean; item(): { itemIndex(): number; serialize(): any; }; next(): void; }'. - Types of property 'item' are incompatible. - Type '() => HeapSnapshotEdge' is not assignable to type '() => { itemIndex(): number; serialize(): any; }'. - Type 'HeapSnapshotEdge' is not assignable to type '{ itemIndex(): number; serialize(): any; }'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2283,13): error TS2339: Property 'nodeIndex' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2287,13): error TS2339: Property 'nodeIndex' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2322,28): error TS2339: Property 'sortRange' does not exist on type 'number[]'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2324,28): error TS2339: Property 'sortRange' does not exist on type 'number[]'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2326,28): error TS2339: Property 'sortRange' does not exist on type 'number[]'. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2340,68): error TS2345: Argument of type 'HeapSnapshotNodeIndexProvider' is not assignable to parameter of type '{ itemForIndex(newIndex: number): { itemIndex(): number; serialize(): any; }; }'. - Types of property 'itemForIndex' are incompatible. - Type '(index: number) => HeapSnapshotNode' is not assignable to type '(newIndex: number) => { itemIndex(): number; serialize(): any; }'. - Type 'HeapSnapshotNode' is not assignable to type '{ itemIndex(): number; serialize(): any; }'. - Property '_snapshot' does not exist on type '{ itemIndex(): number; serialize(): any; }'. -node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2341,15): error TS2345: Argument of type 'HeapSnapshotNodeIndexProvider' is not assignable to parameter of type '{ itemForIndex(newIndex: number): { itemIndex(): number; serialize(): any; }; }'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2353,12): error TS2339: Property 'nodeIndex' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2354,16): error TS2339: Property 'id' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/heap_snapshot_worker/HeapSnapshot.js(2397,13): error TS2339: Property 'nodeIndex' does not exist on type 'void'. @@ -7332,8 +7297,6 @@ node_modules/chrome-devtools-frontend/front_end/network/NetworkItemView.js(62,40 node_modules/chrome-devtools-frontend/front_end/network/NetworkItemView.js(65,37): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogView.js(86,48): error TS2694: Namespace 'Network.NetworkLogView' has no exported member 'Filter'. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogView.js(88,40): error TS2694: Namespace 'Network.NetworkLogView' has no exported member 'Filter'. -node_modules/chrome-devtools-frontend/front_end/network/NetworkLogView.js(114,37): error TS2345: Argument of type 'NetworkFrameGrouper' is not assignable to parameter of type '{ groupNodeForRequest: (request: NetworkRequest) => NetworkGroupNode; reset: () => void; }'. - Property '_parentView' does not exist on type '{ groupNodeForRequest: (request: NetworkRequest) => NetworkGroupNode; reset: () => void; }'. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogView.js(124,33): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogView.js(144,44): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogView.js(147,57): error TS2555: Expected at least 2 arguments, but got 1. @@ -7671,8 +7634,6 @@ node_modules/chrome-devtools-frontend/front_end/network/ResourceWebSocketFrameVi node_modules/chrome-devtools-frontend/front_end/network/ResourceWebSocketFrameView.js(241,34): error TS2694: Namespace 'SDK.NetworkRequest' has no exported member 'WebSocketFrame'. node_modules/chrome-devtools-frontend/front_end/network/ResourceWebSocketFrameView.js(250,14): error TS2339: Property 'createTextChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/network/ResourceWebSocketFrameView.js(251,14): error TS2339: Property 'title' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/network/ResourceWebSocketFrameView.js(292,5): error TS2322: Type 'StaticContentProvider' is not assignable to type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. - Property '_contentURL' does not exist on type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/network_log/HAREntry.js(130,29): error TS2339: Property 'localizedFailDescription' does not exist on type 'NetworkRequest'. node_modules/chrome-devtools-frontend/front_end/network_log/HAREntry.js(150,36): error TS2694: Namespace 'NetworkLog.HAREntry' has no exported member 'Timing'. node_modules/chrome-devtools-frontend/front_end/network_log/HAREntry.js(319,21): error TS2339: Property 'Timing' does not exist on type 'typeof HAREntry'. @@ -8585,8 +8546,6 @@ node_modules/chrome-devtools-frontend/front_end/profiler/CPUProfileFlameChart.js node_modules/chrome-devtools-frontend/front_end/profiler/CPUProfileFlameChart.js(481,40): error TS2339: Property 'window' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/profiler/CPUProfileView.js(61,23): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/CPUProfileView.js(63,23): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/profiler/CPUProfileView.js(73,5): error TS2322: Type 'CPUFlameChartDataProvider' is not assignable to type '{ minimumBoundary(): number; totalTime(): number; formatValue(value: number, precision?: number): string; maxStackDepth(): number; timelineData(): TimelineData; prepareHighlightedEntryInfo(entryIndex: number): Element; ... 6 more ...; textColor(entryIndex: number): string; }'. - Property '_cpuProfile' does not exist on type '{ minimumBoundary(): number; totalTime(): number; formatValue(value: number, precision?: number): string; maxStackDepth(): number; timelineData(): TimelineData; prepareHighlightedEntryInfo(entryIndex: number): Element; ... 6 more ...; textColor(entryIndex: number): string; }'. node_modules/chrome-devtools-frontend/front_end/profiler/CPUProfileView.js(82,50): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/CPUProfileView.js(85,29): error TS2339: Property 'instance' does not exist on type 'typeof CPUProfileType'. node_modules/chrome-devtools-frontend/front_end/profiler/CPUProfileView.js(115,37): error TS2555: Expected at least 2 arguments, but got 1. @@ -8611,8 +8570,6 @@ node_modules/chrome-devtools-frontend/front_end/profiler/CPUProfileView.js(405,7 node_modules/chrome-devtools-frontend/front_end/profiler/CPUProfileView.js(407,31): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/HeapProfileView.js(31,23): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/HeapProfileView.js(33,23): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapProfileView.js(43,5): error TS2322: Type 'HeapFlameChartDataProvider' is not assignable to type '{ minimumBoundary(): number; totalTime(): number; formatValue(value: number, precision?: number): string; maxStackDepth(): number; timelineData(): TimelineData; prepareHighlightedEntryInfo(entryIndex: number): Element; ... 6 more ...; textColor(entryIndex: number): string; }'. - Property '_profile' does not exist on type '{ minimumBoundary(): number; totalTime(): number; formatValue(value: number, precision?: number): string; maxStackDepth(): number; timelineData(): TimelineData; prepareHighlightedEntryInfo(entryIndex: number): Element; ... 6 more ...; textColor(entryIndex: number): string; }'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapProfileView.js(52,59): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/HeapProfileView.js(54,38): error TS2339: Property 'instance' does not exist on type 'typeof SamplingHeapProfileType'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapProfileView.js(82,37): error TS2555: Expected at least 2 arguments, but got 1. @@ -8688,10 +8645,6 @@ node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.j node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(700,24): error TS2694: Namespace 'Protocol' has no exported member 'HeapProfiler'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(713,67): error TS2339: Property '_name' does not exist on type 'HeapSnapshotGridNode'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(717,30): error TS2339: Property 'populateNodeBySnapshotObjectId' does not exist on type 'HeapSnapshotGridNode'. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(776,11): error TS2345: Argument of type 'HeapSnapshotConstructorNode' is not assignable to parameter of type 'HeapSnapshotGridNode'. - Types of property 'createProvider' are incompatible. - Type '() => HeapSnapshotProviderProxy' is not assignable to type '() => { dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. - Type 'HeapSnapshotProviderProxy' is not assignable to type '{ dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(822,56): error TS2694: Namespace 'DataGrid.DataGrid' has no exported member 'ColumnDescriptor'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(823,36): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(824,40): error TS2555: Expected at least 2 arguments, but got 1. @@ -8700,10 +8653,6 @@ node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.j node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(828,23): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(834,41): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(835,39): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(887,40): error TS2345: Argument of type 'HeapSnapshotDiffNode' is not assignable to parameter of type 'HeapSnapshotGridNode'. - Types of property 'createProvider' are incompatible. - Type '() => HeapSnapshotDiffNodesProvider' is not assignable to type '() => { dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. - Type 'HeapSnapshotDiffNodesProvider' is not assignable to type '{ dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(902,56): error TS2694: Namespace 'DataGrid.DataGrid' has no exported member 'ColumnDescriptor'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(903,39): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotDataGrids.js(904,35): error TS2555: Expected at least 2 arguments, but got 1. @@ -8739,36 +8688,13 @@ node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.j node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(580,12): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(581,10): error TS2339: Property 'heapSnapshotNode' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(602,82): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(682,3): error TS2416: Property 'createProvider' in type 'HeapSnapshotObjectNode' is not assignable to the same property in base type 'HeapSnapshotGenericObjectNode'. - Type '() => HeapSnapshotProviderProxy' is not assignable to type '() => { dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(682,3): error TS2416: Property 'createProvider' in type 'HeapSnapshotObjectNode' is not assignable to the same property in base type 'HeapSnapshotGenericObjectNode'. - Type '() => HeapSnapshotProviderProxy' is not assignable to type '() => { dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. - Type 'HeapSnapshotProviderProxy' is not assignable to type '{ dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. - Property '_worker' does not exist on type '{ dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(804,15): error TS2577: Return type annotation circularly references itself. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(871,36): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(874,34): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(892,3): error TS2416: Property 'createProvider' in type 'HeapSnapshotInstanceNode' is not assignable to the same property in base type 'HeapSnapshotGenericObjectNode'. - Type '() => HeapSnapshotProviderProxy' is not assignable to type '() => { dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(892,3): error TS2416: Property 'createProvider' in type 'HeapSnapshotInstanceNode' is not assignable to the same property in base type 'HeapSnapshotGenericObjectNode'. - Type '() => HeapSnapshotProviderProxy' is not assignable to type '() => { dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. - Type 'HeapSnapshotProviderProxy' is not assignable to type '{ dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(966,23): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(968,29): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(969,30): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(980,3): error TS2416: Property 'createProvider' in type 'HeapSnapshotConstructorNode' is not assignable to the same property in base type 'HeapSnapshotGridNode'. - Type '() => HeapSnapshotProviderProxy' is not assignable to type '() => { dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(980,3): error TS2416: Property 'createProvider' in type 'HeapSnapshotConstructorNode' is not assignable to the same property in base type 'HeapSnapshotGridNode'. - Type '() => HeapSnapshotProviderProxy' is not assignable to type '() => { dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. - Type 'HeapSnapshotProviderProxy' is not assignable to type '{ dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(981,27): error TS2339: Property 'snapshot' does not exist on type 'HeapSnapshotSortableDataGrid'. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1001,5): error TS2322: Type '(HeapSnapshotGridNode | this)[]' is not assignable to type 'HeapSnapshotGridNode[]'. - Type 'HeapSnapshotGridNode | this' is not assignable to type 'HeapSnapshotGridNode'. - Type 'this' is not assignable to type 'HeapSnapshotGridNode'. - Type 'HeapSnapshotConstructorNode' is not assignable to type 'HeapSnapshotGridNode'. - Types of property 'createProvider' are incompatible. - Type '() => HeapSnapshotProviderProxy' is not assignable to type '() => { dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. - Type 'HeapSnapshotProviderProxy' is not assignable to type '{ dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1019,14): error TS2339: Property '_searchMatched' does not exist on type 'HeapSnapshotConstructorNode'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1029,81): error TS2339: Property 'snapshot' does not exist on type 'HeapSnapshotSortableDataGrid'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1140,22): error TS2339: Property 'pushAll' does not exist on type 'any[]'. @@ -8778,12 +8704,6 @@ node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.j node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1181,27): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1182,29): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1183,65): error TS2339: Property 'withThousandsSeparator' does not exist on type 'NumberConstructor'. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1191,3): error TS2416: Property 'createProvider' in type 'HeapSnapshotDiffNode' is not assignable to the same property in base type 'HeapSnapshotGridNode'. - Type '() => HeapSnapshotDiffNodesProvider' is not assignable to type '() => { dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. -node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1191,3): error TS2416: Property 'createProvider' in type 'HeapSnapshotDiffNode' is not assignable to the same property in base type 'HeapSnapshotGridNode'. - Type '() => HeapSnapshotDiffNodesProvider' is not assignable to type '() => { dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. - Type 'HeapSnapshotDiffNodesProvider' is not assignable to type '{ dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. - Property '_addedNodesProvider' does not exist on type '{ dispose(): void; nodePosition(snapshotObjectId: number): Promise; isEmpty(): Promise; serializeItemsRange(startPosition: number, endPosition: number): Promise<...>; sortAndRewind(comparator: ComparatorConfig): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1194,14): error TS2339: Property 'snapshot' does not exist on type 'HeapSnapshotSortableDataGrid'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1194,53): error TS2339: Property 'baseSnapshot' does not exist on type 'HeapSnapshotSortableDataGrid'. node_modules/chrome-devtools-frontend/front_end/profiler/HeapSnapshotGridNodes.js(1195,14): error TS2339: Property 'baseSnapshot' does not exist on type 'HeapSnapshotSortableDataGrid'. @@ -9497,8 +9417,6 @@ node_modules/chrome-devtools-frontend/front_end/screencast/ScreencastApp.js(16,6 Types of parameters 'screenCaptureModel' and 'model' are incompatible. Type 'T' is not assignable to type 'ScreenCaptureModel'. node_modules/chrome-devtools-frontend/front_end/screencast/ScreencastApp.js(85,35): error TS2345: Argument of type 'ScreencastView' is not assignable to parameter of type 'boolean'. -node_modules/chrome-devtools-frontend/front_end/screencast/ScreencastApp.js(121,5): error TS2322: Type 'ScreencastApp' is not assignable to type '{ presentUI(document: Document): void; }'. - Property '_enabledSetting' does not exist on type '{ presentUI(document: Document): void; }'. node_modules/chrome-devtools-frontend/front_end/screencast/ScreencastView.js(56,42): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/screencast/ScreencastView.js(152,24): error TS2694: Namespace 'Protocol' has no exported member 'Page'. node_modules/chrome-devtools-frontend/front_end/screencast/ScreencastView.js(193,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -9672,7 +9590,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/CSSStyleDeclaration.js(8,24) node_modules/chrome-devtools-frontend/front_end/sdk/CSSStyleDeclaration.js(41,47): error TS2694: Namespace 'Protocol' has no exported member 'CSS'. node_modules/chrome-devtools-frontend/front_end/sdk/CSSStyleDeclaration.js(50,24): error TS2694: Namespace 'Protocol' has no exported member 'CSS'. node_modules/chrome-devtools-frontend/front_end/sdk/CSSStyleSheetHeader.js(11,24): error TS2694: Namespace 'Protocol' has no exported member 'CSS'. -node_modules/chrome-devtools-frontend/front_end/sdk/CSSStyleSheetHeader.js(40,5): error TS2322: Type 'StaticContentProvider' is not assignable to type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/sdk/Connections.js(10,52): error TS2694: Namespace 'Protocol.InspectorBackend.Connection' has no exported member 'Params'. node_modules/chrome-devtools-frontend/front_end/sdk/Connections.js(34,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sdk/Connections.js(41,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -10410,7 +10327,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/ScreenCaptureModel.js(152,24 node_modules/chrome-devtools-frontend/front_end/sdk/ScreenCaptureModel.js(160,24): error TS2694: Namespace 'Protocol' has no exported member 'Page'. node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(39,24): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(143,52): error TS2339: Property 'debuggerAgent' does not exist on type 'Target'. -node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(159,5): error TS2322: Type 'StaticContentProvider' is not assignable to type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(174,43): error TS2339: Property 'debuggerAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(190,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/sdk/Script.js(190,50): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. @@ -10475,9 +10391,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(196,28): error node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(198,25): error TS2339: Property '_base64Map' does not exist on type 'typeof TextSourceMap'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(200,27): error TS2339: Property '_base64Map' does not exist on type 'typeof TextSourceMap'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(272,30): error TS2339: Property 'keysArray' does not exist on type 'Map'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(284,7): error TS2322: Type 'StaticContentProvider' is not assignable to type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(285,5): error TS2322: Type 'CompilerSourceMappingContentProvider' is not assignable to type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. - Property '_sourceURL' does not exist on type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(325,26): error TS2339: Property 'upperBound' does not exist on type 'SourceMapEntry[]'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(338,26): error TS2339: Property 'lowerBound' does not exist on type 'SourceMapEntry[]'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(339,25): error TS2339: Property 'upperBound' does not exist on type 'SourceMapEntry[]'. @@ -10502,9 +10415,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(141,49): 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(146,44): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(159,36): error TS2352: Conversion of type 'TextSourceMap' to type '{ compiledURL(): string; url(): string; sourceURLs(): string[]; sourceContentProvider(sourceURL: string, contentType: ResourceType): { contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise<...>; requestContent(): Promise<...>; searchInContent(query: string, caseSensitive: boolean, isRegex: boo...' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. -node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(159,36): error TS2352: Conversion of type 'TextSourceMap' to type '{ compiledURL(): string; url(): string; sourceURLs(): string[]; sourceContentProvider(sourceURL: string, contentType: ResourceType): { contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise<...>; requestContent(): Promise<...>; searchInContent(query: string, caseSensitive: boolean, isRegex: boo...' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - Property '_json' does not exist on type '{ compiledURL(): string; url(): string; sourceURLs(): string[]; sourceContentProvider(sourceURL: string, contentType: ResourceType): { contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise<...>; requestContent(): Promise<...>; searchInContent(query: string, caseSensitive: boolean, isRegex: boo...'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(163,12): error TS2339: Property 'catchException' does not exist on type 'Promise'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(173,60): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. 'string' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint '{}'. @@ -10563,12 +10473,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(329,32): er node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(351,42): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(352,12): error TS2339: Property 'runtimeAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(356,52): error TS2694: Namespace 'Protocol.InspectorBackend.Connection' has no exported member 'Params'. -node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(364,7): error TS2322: Type 'WebSocketConnection' is not assignable to type '{ sendMessage(message: string): void; disconnect(): Promise; }'. - Property '_socket' does not exist on type '{ sendMessage(message: string): void; disconnect(): Promise; }'. -node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(366,7): error TS2322: Type 'StubConnection' is not assignable to type '{ sendMessage(message: string): void; disconnect(): Promise; }'. - Property '_onMessage' does not exist on type '{ sendMessage(message: string): void; disconnect(): Promise; }'. -node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(368,7): error TS2322: Type 'MainConnection' is not assignable to type '{ sendMessage(message: string): void; disconnect(): Promise; }'. - Property '_onMessage' does not exist on type '{ sendMessage(message: string): void; disconnect(): Promise; }'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(381,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(401,38): error TS2339: Property 'targetAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(406,18): error TS2339: Property 'registerTargetDispatcher' does not exist on type 'Target'. @@ -10580,8 +10484,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(530,24): er node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(552,12): error TS2339: Property 'runtimeAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(581,24): error TS2694: Namespace 'Protocol' has no exported member 'TargetAgent'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(583,52): error TS2694: Namespace 'Protocol.InspectorBackend.Connection' has no exported member 'Params'. -node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(589,5): error TS2322: Type 'ChildConnection' is not assignable to type '{ sendMessage(message: string): void; disconnect(): Promise; }'. - Property '_agent' does not exist on type '{ sendMessage(message: string): void; disconnect(): Promise; }'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(598,24): error TS2694: Namespace 'Protocol' has no exported member 'TargetAgent'. node_modules/chrome-devtools-frontend/front_end/sdk/TargetManager.js(600,52): error TS2694: Namespace 'Protocol.InspectorBackend.Connection' has no exported member 'Params'. node_modules/chrome-devtools-frontend/front_end/sdk/TracingManager.js(13,42): error TS2694: Namespace 'SDK.TracingManager' has no exported member 'EventPayload'. @@ -10822,8 +10724,6 @@ node_modules/chrome-devtools-frontend/front_end/snippets/ScriptSnippetModel.js(5 Types of parameters 'debuggerModel' and 'model' are incompatible. Type 'T' is not assignable to type 'DebuggerModel'. node_modules/chrome-devtools-frontend/front_end/snippets/ScriptSnippetModel.js(70,35): error TS2339: Property 'remove' does not exist on type 'Map'. -node_modules/chrome-devtools-frontend/front_end/snippets/ScriptSnippetModel.js(113,5): error TS2322: Type 'SnippetsProject' is not assignable to type '{ workspace(): Workspace; id(): string; type(): string; isServiceProject(): boolean; displayName(): string; requestMetadata(uiSourceCode: UISourceCode): Promise; ... 17 more ...; uiSourceCodes(): UISourceCode[]; }'. - Property '_model' does not exist on type '{ workspace(): Workspace; id(): string; type(): string; isServiceProject(): boolean; displayName(): string; requestMetadata(uiSourceCode: UISourceCode): Promise; ... 17 more ...; uiSourceCodes(): UISourceCode[]; }'. node_modules/chrome-devtools-frontend/front_end/snippets/ScriptSnippetModel.js(146,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/snippets/ScriptSnippetModel.js(165,36): error TS2339: Property 'remove' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/snippets/ScriptSnippetModel.js(172,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. @@ -13496,14 +13396,8 @@ node_modules/chrome-devtools-frontend/front_end/ui/View.js(254,15): error TS2355 node_modules/chrome-devtools-frontend/front_end/ui/View.js(263,1): error TS8022: JSDoc '@extends' is not attached to a class. node_modules/chrome-devtools-frontend/front_end/ui/View.js(267,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/ui/View.js(282,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -node_modules/chrome-devtools-frontend/front_end/ui/View.js(299,41): error TS2345: Argument of type 'ProvidedView' is not assignable to parameter of type '{ viewId(): string; title(): string; isCloseable(): boolean; isTransient(): boolean; toolbarItems(): Promise; widget(): Promise; disposeView(): void; }'. - Property '_extension' does not exist on type '{ viewId(): string; title(): string; isCloseable(): boolean; isTransient(): boolean; toolbarItems(): Promise; widget(): Promise; disposeView(): void; }'. node_modules/chrome-devtools-frontend/front_end/ui/View.js(326,21): error TS2339: Property 'showView' does not exist on type '_Location'. node_modules/chrome-devtools-frontend/front_end/ui/View.js(371,23): error TS2339: Property 'showView' does not exist on type '_Location'. -node_modules/chrome-devtools-frontend/front_end/ui/View.js(401,5): error TS2322: Type '_TabbedLocation' is not assignable to type '{ tabbedPane(): TabbedPane; enableMoreTabsButton(): void; }'. - Property '_tabbedPane' does not exist on type '{ tabbedPane(): TabbedPane; enableMoreTabsButton(): void; }'. -node_modules/chrome-devtools-frontend/front_end/ui/View.js(411,5): error TS2322: Type '_StackLocation' is not assignable to type '{ appendApplicableItems(locationName: string): void; appendView(view: { viewId(): string; title(): string; isCloseable(): boolean; isTransient(): boolean; toolbarItems(): Promise; widget(): Promise<...>; disposeView(): void; }, insertBefore?: { ...; }): void; showView(view: { ...; }, insertBefore?: { ...'. - Property '_vbox' does not exist on type '{ appendApplicableItems(locationName: string): void; appendView(view: { viewId(): string; title(): string; isCloseable(): boolean; isTransient(): boolean; toolbarItems(): Promise; widget(): Promise<...>; disposeView(): void; }, insertBefore?: { ...; }): void; showView(view: { ...; }, insertBefore?: { ...'. node_modules/chrome-devtools-frontend/front_end/ui/View.js(440,18): error TS2339: Property 'tabIndex' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/View.js(454,38): error TS2339: Property 'hasFocus' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/View.js(461,44): error TS2769: No overload matches this call. diff --git a/tests/baselines/reference/user/uglify-js.log b/tests/baselines/reference/user/uglify-js.log index a01073ce3a23f..78c15c035b599 100644 --- a/tests/baselines/reference/user/uglify-js.log +++ b/tests/baselines/reference/user/uglify-js.log @@ -41,7 +41,7 @@ node_modules/uglify-js/lib/compress.js(3839,12): error TS2339: Property 'push' d node_modules/uglify-js/lib/compress.js(3914,38): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/compress.js(3935,24): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. node_modules/uglify-js/lib/compress.js(3945,28): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(4114,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'defs' must be of type 'Dictionary & { set: (key: any, val: any) => Dictionary & { set: ...; add: (key: any, val: any) => Dictionary & { set: ...; add: ...; get: (key: any) => any; del: (key: any) => Dictionary & { set: ...; ... 8 more ...; toObject: () => any; }; ... 5 more ...; toObject: () => any; }; ... 7 more ...; toObject: () => any;...', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(4114,21): error TS2403: Subsequent variable declarations must have the same type. Variable 'defs' must be of type 'Dictionary & { set: (key: any, val: any) => Dictionary & ...; add: (key: any, val: any) => Dictionary & ...; get: (key: any) => any; del: (key: any) => Dictionary & ...; has: (key: any) => boolean; ... 4 more ...; toObject: () => any; }', but here has type 'any'. node_modules/uglify-js/lib/compress.js(4166,17): error TS2447: The '|=' operator is not allowed for boolean types. Consider using '||' instead. node_modules/uglify-js/lib/compress.js(4229,45): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/compress.js(4340,33): error TS2554: Expected 0 arguments, but got 1. From 17762c480df52ab4ea49e0a832ba29fbaf57e92c Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 15 Jul 2019 13:41:17 -0700 Subject: [PATCH 19/43] Fall back to (Async)IterableIterator if (Async)Generator not found (#32303) --- src/compiler/checker.ts | 67 ++++++++++++------- .../reference/castOfYield.errors.txt | 4 +- .../generatorReturnTypeFallback.1.symbols | 7 ++ .../generatorReturnTypeFallback.1.types | 9 +++ .../generatorReturnTypeFallback.2.errors.txt | 10 +++ .../generatorReturnTypeFallback.2.symbols | 8 +++ .../generatorReturnTypeFallback.2.types | 10 +++ .../generatorReturnTypeFallback.3.errors.txt | 10 +++ .../generatorReturnTypeFallback.3.symbols | 9 +++ .../generatorReturnTypeFallback.3.types | 11 +++ .../generatorReturnTypeFallback.4.symbols | 9 +++ .../generatorReturnTypeFallback.4.types | 11 +++ .../generatorReturnTypeFallback.5.symbols | 8 +++ .../generatorReturnTypeFallback.5.types | 9 +++ ...romGeneratorMakesRequiredParams.errors.txt | 4 +- ...eStringWithEmbeddedYieldKeyword.errors.txt | 4 +- .../types.forAwait.es2018.3.errors.txt | 4 +- .../generatorReturnTypeFallback.1.ts | 9 +++ .../generatorReturnTypeFallback.2.ts | 10 +++ .../generatorReturnTypeFallback.3.ts | 10 +++ .../generatorReturnTypeFallback.4.ts | 10 +++ .../generatorReturnTypeFallback.5.ts | 9 +++ 22 files changed, 209 insertions(+), 33 deletions(-) create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.1.symbols create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.1.types create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.2.errors.txt create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.2.symbols create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.2.types create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.3.errors.txt create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.3.symbols create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.3.types create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.4.symbols create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.4.types create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.5.symbols create mode 100644 tests/baselines/reference/generatorReturnTypeFallback.5.types create mode 100644 tests/cases/conformance/generators/generatorReturnTypeFallback.1.ts create mode 100644 tests/cases/conformance/generators/generatorReturnTypeFallback.2.ts create mode 100644 tests/cases/conformance/generators/generatorReturnTypeFallback.3.ts create mode 100644 tests/cases/conformance/generators/generatorReturnTypeFallback.4.ts create mode 100644 tests/cases/conformance/generators/generatorReturnTypeFallback.5.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5b5ae6b4b24ce..c31732cc24ac9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -42,10 +42,10 @@ namespace ts { iterableCacheKey: "iterationTypesOfAsyncIterable" | "iterationTypesOfIterable"; iteratorCacheKey: "iterationTypesOfAsyncIterator" | "iterationTypesOfIterator"; iteratorSymbolName: "asyncIterator" | "iterator"; - getGlobalIteratorType: (reportErrors: boolean) => Type; - getGlobalIterableType: (reportErrors: boolean) => Type; - getGlobalIterableIteratorType: (reportErrors: boolean) => Type; - getGlobalGeneratorType: (reportErrors: boolean) => Type; + getGlobalIteratorType: (reportErrors: boolean) => GenericType; + getGlobalIterableType: (reportErrors: boolean) => GenericType; + getGlobalIterableIteratorType: (reportErrors: boolean) => GenericType; + getGlobalGeneratorType: (reportErrors: boolean) => GenericType; resolveIterationType: (type: Type, errorNode: Node | undefined) => Type | undefined; mustHaveANextMethodDiagnostic: DiagnosticMessage; mustBeAMethodDiagnostic: DiagnosticMessage; @@ -9531,24 +9531,10 @@ namespace ts { return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]); } - function createAsyncGeneratorType(yieldType: Type, returnType: Type, nextType: Type) { - const globalAsyncGeneratorType = getGlobalAsyncGeneratorType(/*reportErrors*/ true); - if (globalAsyncGeneratorType !== emptyGenericType) { - yieldType = getAwaitedType(yieldType) || unknownType; - returnType = getAwaitedType(returnType) || unknownType; - nextType = getAwaitedType(nextType) || unknownType; - } - return createTypeFromGenericGlobalType(globalAsyncGeneratorType, [yieldType, returnType, nextType]); - } - function createIterableType(iteratedType: Type): Type { return createTypeFromGenericGlobalType(getGlobalIterableType(/*reportErrors*/ true), [iteratedType]); } - function createGeneratorType(yieldType: Type, returnType: Type, nextType: Type) { - return createTypeFromGenericGlobalType(getGlobalGeneratorType(/*reportErrors*/ true), [yieldType, returnType, nextType]); - } - function createArrayType(elementType: Type, readonly?: boolean): ObjectType { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } @@ -23401,9 +23387,36 @@ namespace ts { } function createGeneratorReturnType(yieldType: Type, returnType: Type, nextType: Type, isAsyncGenerator: boolean) { - return isAsyncGenerator - ? createAsyncGeneratorType(yieldType, returnType, nextType) - : createGeneratorType(yieldType, returnType, nextType); + const resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; + const globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false); + yieldType = resolver.resolveIterationType(yieldType, /*errorNode*/ undefined) || unknownType; + returnType = resolver.resolveIterationType(returnType, /*errorNode*/ undefined) || unknownType; + nextType = resolver.resolveIterationType(nextType, /*errorNode*/ undefined) || unknownType; + if (globalGeneratorType === emptyGenericType) { + // Fall back to the global IterableIterator if returnType is assignable to the expected return iteration + // type of IterableIterator, and the expected next iteration type of IterableIterator is assignable to + // nextType. + const globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); + const iterationTypes = globalType !== emptyGenericType ? getIterationTypesOfGlobalIterableType(globalType, resolver) : undefined; + const iterableIteratorReturnType = iterationTypes ? iterationTypes.returnType : anyType; + const iterableIteratorNextType = iterationTypes ? iterationTypes.nextType : undefinedType; + if (isTypeAssignableTo(returnType, iterableIteratorReturnType) && + isTypeAssignableTo(iterableIteratorNextType, nextType)) { + if (globalType !== emptyGenericType) { + return createTypeFromGenericGlobalType(globalType, [yieldType]); + } + + // The global IterableIterator type doesn't exist, so report an error + resolver.getGlobalIterableIteratorType(/*reportErrors*/ true); + return emptyObjectType; + } + + // The global Generator type doesn't exist, so report an error + resolver.getGlobalGeneratorType(/*reportErrors*/ true); + return emptyObjectType; + } + + return createTypeFromGenericGlobalType(globalGeneratorType, [yieldType, returnType, nextType]); } function checkAndAggregateYieldOperandTypes(func: FunctionLikeDeclaration, checkMode: CheckMode | undefined) { @@ -28240,6 +28253,13 @@ namespace ts { return (type as IterableOrIteratorType)[resolver.iterableCacheKey]; } + function getIterationTypesOfGlobalIterableType(globalType: Type, resolver: IterationTypesResolver) { + const globalIterationTypes = + getIterationTypesOfIterableCached(globalType, resolver) || + getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined); + return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes; + } + /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like * type from from common heuristics. @@ -28265,10 +28285,7 @@ namespace ts { // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use // different definitions. - const globalIterationTypes = - getIterationTypesOfIterableCached(globalType, resolver) || - getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined); - const { returnType, nextType } = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes; + const { returnType, nextType } = getIterationTypesOfGlobalIterableType(globalType, resolver); return (type as IterableOrIteratorType)[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } diff --git a/tests/baselines/reference/castOfYield.errors.txt b/tests/baselines/reference/castOfYield.errors.txt index 90725000c909d..0d40a4dcd987d 100644 --- a/tests/baselines/reference/castOfYield.errors.txt +++ b/tests/baselines/reference/castOfYield.errors.txt @@ -1,8 +1,8 @@ -error TS2318: Cannot find global type 'Generator'. +error TS2318: Cannot find global type 'IterableIterator'. tests/cases/compiler/castOfYield.ts(4,14): error TS1109: Expression expected. -!!! error TS2318: Cannot find global type 'Generator'. +!!! error TS2318: Cannot find global type 'IterableIterator'. ==== tests/cases/compiler/castOfYield.ts (1 errors) ==== function* f() { (yield 0); diff --git a/tests/baselines/reference/generatorReturnTypeFallback.1.symbols b/tests/baselines/reference/generatorReturnTypeFallback.1.symbols new file mode 100644 index 0000000000000..9c2b38be4c380 --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.1.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/generators/generatorReturnTypeFallback.1.ts === +// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. +function* f() { +>f : Symbol(f, Decl(generatorReturnTypeFallback.1.ts, 0, 0)) + + yield 1; +} diff --git a/tests/baselines/reference/generatorReturnTypeFallback.1.types b/tests/baselines/reference/generatorReturnTypeFallback.1.types new file mode 100644 index 0000000000000..8603cb356cae5 --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.1.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/generators/generatorReturnTypeFallback.1.ts === +// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. +function* f() { +>f : () => IterableIterator + + yield 1; +>yield 1 : any +>1 : 1 +} diff --git a/tests/baselines/reference/generatorReturnTypeFallback.2.errors.txt b/tests/baselines/reference/generatorReturnTypeFallback.2.errors.txt new file mode 100644 index 0000000000000..9cf7569ef3fc1 --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.2.errors.txt @@ -0,0 +1,10 @@ +error TS2318: Cannot find global type 'IterableIterator'. + + +!!! error TS2318: Cannot find global type 'IterableIterator'. +==== tests/cases/conformance/generators/generatorReturnTypeFallback.2.ts (0 errors) ==== + // Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. + // Report an error if IterableIterator cannot be found. + function* f() { + yield 1; + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorReturnTypeFallback.2.symbols b/tests/baselines/reference/generatorReturnTypeFallback.2.symbols new file mode 100644 index 0000000000000..5cd344e538cac --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.2.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/generators/generatorReturnTypeFallback.2.ts === +// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. +// Report an error if IterableIterator cannot be found. +function* f() { +>f : Symbol(f, Decl(generatorReturnTypeFallback.2.ts, 0, 0)) + + yield 1; +} diff --git a/tests/baselines/reference/generatorReturnTypeFallback.2.types b/tests/baselines/reference/generatorReturnTypeFallback.2.types new file mode 100644 index 0000000000000..36730010f7661 --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.2.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/generators/generatorReturnTypeFallback.2.ts === +// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. +// Report an error if IterableIterator cannot be found. +function* f() { +>f : () => {} + + yield 1; +>yield 1 : any +>1 : 1 +} diff --git a/tests/baselines/reference/generatorReturnTypeFallback.3.errors.txt b/tests/baselines/reference/generatorReturnTypeFallback.3.errors.txt new file mode 100644 index 0000000000000..a365ba8c6cd79 --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.3.errors.txt @@ -0,0 +1,10 @@ +error TS2318: Cannot find global type 'Generator'. + + +!!! error TS2318: Cannot find global type 'Generator'. +==== tests/cases/conformance/generators/generatorReturnTypeFallback.3.ts (0 errors) ==== + // Do not allow generators to fallback to IterableIterator while in strictNullChecks mode if they need a type for the sent value. + // NOTE: In non-strictNullChecks mode, `undefined` (the default sent value) is assignable to everything. + function* f() { + const x: string = yield 1; + } \ No newline at end of file diff --git a/tests/baselines/reference/generatorReturnTypeFallback.3.symbols b/tests/baselines/reference/generatorReturnTypeFallback.3.symbols new file mode 100644 index 0000000000000..17252fab306ad --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.3.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/generators/generatorReturnTypeFallback.3.ts === +// Do not allow generators to fallback to IterableIterator while in strictNullChecks mode if they need a type for the sent value. +// NOTE: In non-strictNullChecks mode, `undefined` (the default sent value) is assignable to everything. +function* f() { +>f : Symbol(f, Decl(generatorReturnTypeFallback.3.ts, 0, 0)) + + const x: string = yield 1; +>x : Symbol(x, Decl(generatorReturnTypeFallback.3.ts, 3, 9)) +} diff --git a/tests/baselines/reference/generatorReturnTypeFallback.3.types b/tests/baselines/reference/generatorReturnTypeFallback.3.types new file mode 100644 index 0000000000000..634f3f2277d0a --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.3.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/generators/generatorReturnTypeFallback.3.ts === +// Do not allow generators to fallback to IterableIterator while in strictNullChecks mode if they need a type for the sent value. +// NOTE: In non-strictNullChecks mode, `undefined` (the default sent value) is assignable to everything. +function* f() { +>f : () => {} + + const x: string = yield 1; +>x : string +>yield 1 : any +>1 : 1 +} diff --git a/tests/baselines/reference/generatorReturnTypeFallback.4.symbols b/tests/baselines/reference/generatorReturnTypeFallback.4.symbols new file mode 100644 index 0000000000000..3be221fffcaa4 --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.4.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/generators/generatorReturnTypeFallback.4.ts === +// Allow generators to fallback to IterableIterator if they are not in strictNullChecks mode +// NOTE: In non-strictNullChecks mode, `undefined` (the default sent value) is assignable to everything. +function* f() { +>f : Symbol(f, Decl(generatorReturnTypeFallback.4.ts, 0, 0)) + + const x: string = yield 1; +>x : Symbol(x, Decl(generatorReturnTypeFallback.4.ts, 3, 9)) +} diff --git a/tests/baselines/reference/generatorReturnTypeFallback.4.types b/tests/baselines/reference/generatorReturnTypeFallback.4.types new file mode 100644 index 0000000000000..2879058f37faf --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.4.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/generators/generatorReturnTypeFallback.4.ts === +// Allow generators to fallback to IterableIterator if they are not in strictNullChecks mode +// NOTE: In non-strictNullChecks mode, `undefined` (the default sent value) is assignable to everything. +function* f() { +>f : () => IterableIterator + + const x: string = yield 1; +>x : string +>yield 1 : any +>1 : 1 +} diff --git a/tests/baselines/reference/generatorReturnTypeFallback.5.symbols b/tests/baselines/reference/generatorReturnTypeFallback.5.symbols new file mode 100644 index 0000000000000..411ce92a4421a --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.5.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/generators/generatorReturnTypeFallback.5.ts === +// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. +function* f(): IterableIterator { +>f : Symbol(f, Decl(generatorReturnTypeFallback.5.ts, 0, 0)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) + + yield 1; +} diff --git a/tests/baselines/reference/generatorReturnTypeFallback.5.types b/tests/baselines/reference/generatorReturnTypeFallback.5.types new file mode 100644 index 0000000000000..d0ed412746538 --- /dev/null +++ b/tests/baselines/reference/generatorReturnTypeFallback.5.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/generators/generatorReturnTypeFallback.5.ts === +// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. +function* f(): IterableIterator { +>f : () => IterableIterator + + yield 1; +>yield 1 : undefined +>1 : 1 +} diff --git a/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt index 1b1f93ffc3f5f..393e21edb6c53 100644 --- a/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt +++ b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt @@ -1,8 +1,8 @@ -error TS2318: Cannot find global type 'Generator'. +error TS2318: Cannot find global type 'IterableIterator'. tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts(6,1): error TS2554: Expected 2 arguments, but got 1. -!!! error TS2318: Cannot find global type 'Generator'. +!!! error TS2318: Cannot find global type 'IterableIterator'. ==== tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts (1 errors) ==== declare function call any>( fn: Fn, diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt index a96993063732a..ce0d781d8246c 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt @@ -1,8 +1,8 @@ -error TS2318: Cannot find global type 'Generator'. +error TS2318: Cannot find global type 'IterableIterator'. tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,15): error TS1005: '(' expected. -!!! error TS2318: Cannot find global type 'Generator'. +!!! error TS2318: Cannot find global type 'IterableIterator'. ==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts (1 errors) ==== function* gen { ~ diff --git a/tests/baselines/reference/types.forAwait.es2018.3.errors.txt b/tests/baselines/reference/types.forAwait.es2018.3.errors.txt index 1aca869fb0c68..296ac0d066bc1 100644 --- a/tests/baselines/reference/types.forAwait.es2018.3.errors.txt +++ b/tests/baselines/reference/types.forAwait.es2018.3.errors.txt @@ -1,11 +1,11 @@ -error TS2318: Cannot find global type 'AsyncGenerator'. +error TS2318: Cannot find global type 'AsyncIterableIterator'. tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts(3,27): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts(5,21): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts(10,27): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts(12,21): error TS2504: Type '{}' must have a '[Symbol.asyncIterator]()' method that returns an async iterator. -!!! error TS2318: Cannot find global type 'AsyncGenerator'. +!!! error TS2318: Cannot find global type 'AsyncIterableIterator'. ==== tests/cases/conformance/types/forAwait/types.forAwait.es2018.3.ts (4 errors) ==== async function f1() { let y: number; diff --git a/tests/cases/conformance/generators/generatorReturnTypeFallback.1.ts b/tests/cases/conformance/generators/generatorReturnTypeFallback.1.ts new file mode 100644 index 0000000000000..dbf249d7e275b --- /dev/null +++ b/tests/cases/conformance/generators/generatorReturnTypeFallback.1.ts @@ -0,0 +1,9 @@ +// @target: esnext +// @lib: es5,es2015.iterable +// @noemit: true +// @strict: true + +// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. +function* f() { + yield 1; +} \ No newline at end of file diff --git a/tests/cases/conformance/generators/generatorReturnTypeFallback.2.ts b/tests/cases/conformance/generators/generatorReturnTypeFallback.2.ts new file mode 100644 index 0000000000000..4579f05387a6c --- /dev/null +++ b/tests/cases/conformance/generators/generatorReturnTypeFallback.2.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @lib: es5 +// @noemit: true +// @strict: true + +// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. +// Report an error if IterableIterator cannot be found. +function* f() { + yield 1; +} \ No newline at end of file diff --git a/tests/cases/conformance/generators/generatorReturnTypeFallback.3.ts b/tests/cases/conformance/generators/generatorReturnTypeFallback.3.ts new file mode 100644 index 0000000000000..388d8bee7ee3b --- /dev/null +++ b/tests/cases/conformance/generators/generatorReturnTypeFallback.3.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @lib: es5,es2015.iterable +// @noemit: true +// @strict: true + +// Do not allow generators to fallback to IterableIterator while in strictNullChecks mode if they need a type for the sent value. +// NOTE: In non-strictNullChecks mode, `undefined` (the default sent value) is assignable to everything. +function* f() { + const x: string = yield 1; +} \ No newline at end of file diff --git a/tests/cases/conformance/generators/generatorReturnTypeFallback.4.ts b/tests/cases/conformance/generators/generatorReturnTypeFallback.4.ts new file mode 100644 index 0000000000000..3fc9d4f50c6f2 --- /dev/null +++ b/tests/cases/conformance/generators/generatorReturnTypeFallback.4.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @lib: es5,es2015.iterable +// @noemit: true +// @strict: false + +// Allow generators to fallback to IterableIterator if they are not in strictNullChecks mode +// NOTE: In non-strictNullChecks mode, `undefined` (the default sent value) is assignable to everything. +function* f() { + const x: string = yield 1; +} \ No newline at end of file diff --git a/tests/cases/conformance/generators/generatorReturnTypeFallback.5.ts b/tests/cases/conformance/generators/generatorReturnTypeFallback.5.ts new file mode 100644 index 0000000000000..b495d3ff7b692 --- /dev/null +++ b/tests/cases/conformance/generators/generatorReturnTypeFallback.5.ts @@ -0,0 +1,9 @@ +// @target: esnext +// @lib: es5,es2015.iterable +// @noemit: true +// @strict: true + +// Allow generators to fallback to IterableIterator if they do not need a type for the sent value while in strictNullChecks mode. +function* f(): IterableIterator { + yield 1; +} \ No newline at end of file From 7cdfbceb43e478663cd3263d230fbebf9acb78c1 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 15 Jul 2019 15:17:32 -0700 Subject: [PATCH 20/43] Improve accuracy of remove unnecessary await fix (#32384) --- src/compiler/factory.ts | 2 +- src/services/codefixes/removeUnnecessaryAwait.ts | 16 +++++++++++++--- .../fourslash/codeFixRemoveUnnecessaryAwait.ts | 9 +++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index f88950f531a37..1f0294423a5d9 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -4701,7 +4701,7 @@ namespace ts { } } - function getLeftmostExpression(node: Expression, stopAtCallExpressions: boolean) { + export function getLeftmostExpression(node: Expression, stopAtCallExpressions: boolean) { while (true) { switch (node.kind) { case SyntaxKind.PostfixUnaryExpression: diff --git a/src/services/codefixes/removeUnnecessaryAwait.ts b/src/services/codefixes/removeUnnecessaryAwait.ts index c235d028efbce..07028e2793762 100644 --- a/src/services/codefixes/removeUnnecessaryAwait.ts +++ b/src/services/codefixes/removeUnnecessaryAwait.ts @@ -26,8 +26,18 @@ namespace ts.codefix { return; } - const parenthesizedExpression = tryCast(awaitExpression.parent, isParenthesizedExpression); - const removeParens = parenthesizedExpression && (isIdentifier(awaitExpression.expression) || isCallExpression(awaitExpression.expression)); - changeTracker.replaceNode(sourceFile, removeParens ? parenthesizedExpression || awaitExpression : awaitExpression, awaitExpression.expression); + let expressionToReplace: Node = awaitExpression; + const hasSurroundingParens = isParenthesizedExpression(awaitExpression.parent); + if (hasSurroundingParens) { + const leftMostExpression = getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); + if (isIdentifier(leftMostExpression)) { + const precedingToken = findPrecedingToken(awaitExpression.parent.pos, sourceFile); + if (precedingToken && precedingToken.kind !== SyntaxKind.NewKeyword) { + expressionToReplace = awaitExpression.parent; + } + } + } + + changeTracker.replaceNode(sourceFile, expressionToReplace, awaitExpression.expression); } } diff --git a/tests/cases/fourslash/codeFixRemoveUnnecessaryAwait.ts b/tests/cases/fourslash/codeFixRemoveUnnecessaryAwait.ts index b8e1de4605e27..3e209cd59f208 100644 --- a/tests/cases/fourslash/codeFixRemoveUnnecessaryAwait.ts +++ b/tests/cases/fourslash/codeFixRemoveUnnecessaryAwait.ts @@ -1,5 +1,6 @@ /// ////declare class C { foo(): void } +////declare function getC(): { Class: C }; ////declare function foo(): string; ////async function f() { //// await ""; @@ -7,6 +8,8 @@ //// (await foo()).toLowerCase(); //// (await 0).toFixed(); //// (await new C).foo(); +//// (await function() { }()); +//// new (await getC()).Class(); ////} verify.codeFix({ @@ -14,6 +17,7 @@ verify.codeFix({ index: 0, newFileContent: `declare class C { foo(): void } +declare function getC(): { Class: C }; declare function foo(): string; async function f() { ""; @@ -21,6 +25,8 @@ async function f() { (await foo()).toLowerCase(); (await 0).toFixed(); (await new C).foo(); + (await function() { }()); + new (await getC()).Class(); }` }); @@ -29,6 +35,7 @@ verify.codeFixAll({ fixId: "removeUnnecessaryAwait", newFileContent: `declare class C { foo(): void } +declare function getC(): { Class: C }; declare function foo(): string; async function f() { ""; @@ -36,5 +43,7 @@ async function f() { foo().toLowerCase(); (0).toFixed(); (new C).foo(); + (function() { } ()); + new (getC()).Class(); }` }); From 9a37ef86676263a37f6068d02af96461aa00238a Mon Sep 17 00:00:00 2001 From: Dmitrijs Minajevs Date: Tue, 16 Jul 2019 10:04:14 +0300 Subject: [PATCH 21/43] typeAssertionKeywords tests --- src/harness/fourslash.ts | 3 +++ tests/cases/fourslash/completionListAsConst.ts | 11 ----------- .../fourslash/completionsTypeAssertionKeywords.ts | 13 +++++++++++++ tests/cases/fourslash/fourslash.ts | 1 + 4 files changed, 17 insertions(+), 11 deletions(-) delete mode 100644 tests/cases/fourslash/completionListAsConst.ts create mode 100644 tests/cases/fourslash/completionsTypeAssertionKeywords.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c8c1643b0e01f..28e2659418f61 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -4681,6 +4681,9 @@ namespace FourSlashInterface { ]; } + export const typeAssertionKeywords: ReadonlyArray = + globalTypesPlus([keywordEntry("const")]); + function getInJsKeywords(keywords: ReadonlyArray): ReadonlyArray { return keywords.filter(keyword => { switch (keyword.name) { diff --git a/tests/cases/fourslash/completionListAsConst.ts b/tests/cases/fourslash/completionListAsConst.ts deleted file mode 100644 index 3a8b706cea26c..0000000000000 --- a/tests/cases/fourslash/completionListAsConst.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -////const a = { -//// b: 42 as con/*0*/ -////}; -//// -////1 as con/*1*/ -//// -////const b = 42 as /*2*/ - -verify.completions({ marker: test.markers(), includes: [{ name: "const", sortText: completion.SortText.GlobalsOrKeywords }] }); diff --git a/tests/cases/fourslash/completionsTypeAssertionKeywords.ts b/tests/cases/fourslash/completionsTypeAssertionKeywords.ts new file mode 100644 index 0000000000000..100ab6e51e25e --- /dev/null +++ b/tests/cases/fourslash/completionsTypeAssertionKeywords.ts @@ -0,0 +1,13 @@ +/// + +////const a = { +//// b: 42 as /*0*/ +////}; +//// +////1 as /*1*/ +//// +////const b = 42 as /*2*/ +//// +////var c = 42 + +verify.completions({ marker: test.markers(), exact: completion.typeAssertionKeywords }); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 05799a156420a..47c835d9c88f1 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -696,6 +696,7 @@ declare namespace completion { export const typeKeywords: ReadonlyArray; export const globalTypes: ReadonlyArray; export function globalTypesPlus(plus: ReadonlyArray): ReadonlyArray; + export const typeAssertionKeywords: ReadonlyArray; export const classElementKeywords: ReadonlyArray; export const classElementInJsKeywords: ReadonlyArray; export const constructorParameterKeywords: ReadonlyArray; From 0075b0a6a55ac6f27a05bdbfbcce4614f40761d1 Mon Sep 17 00:00:00 2001 From: Dmitrijs Minajevs Date: Tue, 16 Jul 2019 10:06:16 +0300 Subject: [PATCH 22/43] Fix for angle-bracket type assertion --- src/services/completions.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index f95526121a3b6..cd70f0ddcdde7 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1183,7 +1183,7 @@ namespace ts.Completions { const isTypeOnly = isTypeOnlyCompletion(); const allowTypes = isTypeOnly || !isContextTokenValueLocation(contextToken) && isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker); if (isTypeOnly) { - keywordFilters = isInsideTypeAssertion() + keywordFilters = isTypeAssertion() ? KeywordCompletionFilters.TypeAssertionKeywords : KeywordCompletionFilters.TypeKeywords; } @@ -1216,8 +1216,8 @@ namespace ts.Completions { }); } - function isInsideTypeAssertion(): boolean { - return isAsExpression(contextToken.parent); + function isTypeAssertion(): boolean { + return isAssertionExpression(contextToken.parent); } function isTypeOnlyCompletion(): boolean { @@ -1249,6 +1249,9 @@ namespace ts.Completions { case SyntaxKind.ExtendsKeyword: return parentKind === SyntaxKind.TypeParameter; + + case SyntaxKind.LessThanToken: + return parentKind === SyntaxKind.TypeAssertionExpression; } } return false; From 84cdc63d1faf89885cd2b24de57e2c29d8901651 Mon Sep 17 00:00:00 2001 From: Dmitrijs Minajevs Date: Tue, 16 Jul 2019 11:00:45 +0300 Subject: [PATCH 23/43] Merge angle-bracket fix --- src/services/completions.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index dc23c0a9b12f4..d7b40d14587c3 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1249,13 +1249,11 @@ namespace ts.Completions { return parentKind === SyntaxKind.AsExpression; case SyntaxKind.LessThanToken: - return parentKind === SyntaxKind.TypeReference; + return parentKind === SyntaxKind.TypeReference || + parentKind === SyntaxKind.TypeAssertionExpression; case SyntaxKind.ExtendsKeyword: return parentKind === SyntaxKind.TypeParameter; - - case SyntaxKind.LessThanToken: - return parentKind === SyntaxKind.TypeAssertionExpression; } } return false; From d3f3c8e1135b321979f2e93b9cae3c79158cd7e8 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Tue, 16 Jul 2019 12:00:22 -0400 Subject: [PATCH 24/43] Make it easier to read multi-line exceptions --- src/harness/fourslash.ts | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 56cc2b65508b2..71a07c9e2481a 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -948,7 +948,7 @@ namespace FourSlash { const actual = checker.typeToString(type); if (actual !== expected) { - this.raiseError(`Expected: '${expected}', actual: '${actual}'`); + this.raiseError(displayExpectedAndActualString(expected, actual)); } } @@ -1024,9 +1024,7 @@ namespace FourSlash { private assertObjectsEqual(fullActual: T, fullExpected: T, msgPrefix = ""): void { const recur = (actual: U, expected: U, path: string) => { const fail = (msg: string) => { - this.raiseError(`${msgPrefix} At ${path}: ${msg} -Expected: ${stringify(fullExpected)} -Actual: ${stringify(fullActual)}`); + this.raiseError(`${msgPrefix} At ${path}: ${msg} ${displayExpectedAndActualString(stringify(fullExpected), stringify(fullActual))}`); }; if ((actual === undefined) !== (expected === undefined)) { @@ -1058,9 +1056,7 @@ Actual: ${stringify(fullActual)}`); if (fullActual === fullExpected) { return; } - this.raiseError(`${msgPrefix} -Expected: ${stringify(fullExpected)} -Actual: ${stringify(fullActual)}`); + this.raiseError(`${msgPrefix} ${displayExpectedAndActualString(stringify(fullExpected), stringify(fullActual))}`); } recur(fullActual, fullExpected, ""); @@ -2111,9 +2107,7 @@ Actual: ${stringify(fullActual)}`); public verifyCurrentLineContent(text: string) { const actual = this.getCurrentLineContent(); if (actual !== text) { - throw new Error("verifyCurrentLineContent\n" + - "\tExpected: \"" + text + "\"\n" + - "\t Actual: \"" + actual + "\""); + throw new Error("verifyCurrentLineContent\n" + displayExpectedAndActualString(text, actual, /* quoted */ true)); } } @@ -2139,25 +2133,19 @@ Actual: ${stringify(fullActual)}`); public verifyTextAtCaretIs(text: string) { const actual = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition, this.currentCaretPosition + text.length); if (actual !== text) { - throw new Error("verifyTextAtCaretIs\n" + - "\tExpected: \"" + text + "\"\n" + - "\t Actual: \"" + actual + "\""); + throw new Error("verifyTextAtCaretIs\n" + displayExpectedAndActualString(text, actual, /* quoted */ true)); } } public verifyCurrentNameOrDottedNameSpanText(text: string) { const span = this.languageService.getNameOrDottedNameSpan(this.activeFile.fileName, this.currentCaretPosition, this.currentCaretPosition); if (!span) { - return this.raiseError("verifyCurrentNameOrDottedNameSpanText\n" + - "\tExpected: \"" + text + "\"\n" + - "\t Actual: undefined"); + return this.raiseError("verifyCurrentNameOrDottedNameSpanText\n" + displayExpectedAndActualString("\"" + text + "\"", "undefined")); } const actual = this.getFileContent(this.activeFile.fileName).substring(span.start, ts.textSpanEnd(span)); if (actual !== text) { - this.raiseError("verifyCurrentNameOrDottedNameSpanText\n" + - "\tExpected: \"" + text + "\"\n" + - "\t Actual: \"" + actual + "\""); + this.raiseError("verifyCurrentNameOrDottedNameSpanText\n" + displayExpectedAndActualString(text, actual, /* quoted */ true)); } } @@ -3690,7 +3678,7 @@ ${code} expected = makeWhitespaceVisible(expected); actual = makeWhitespaceVisible(actual); } - return `Expected:\n${expected}\nActual:\n${actual}`; + return displayExpectedAndActualString(expected, actual); } function differOnlyByWhitespace(a: string, b: string) { @@ -3710,6 +3698,14 @@ ${code} } } } + + function displayExpectedAndActualString(expected: string, actual: string, quoted = false) { + const expectMsg = "\x1b[1mExpected\x1b[0m\x1b[31m"; + const actualMsg = "\x1b[1mActual\x1b[0m\x1b[31m"; + const expectedString = quoted ? "\"" + expected + "\"" : expected; + const actualString = quoted ? "\"" + actual + "\"" : actual; + return `\n${expectMsg}:\n${expectedString}\n\n${actualMsg}:\n${actualString}`; + } } namespace FourSlashInterface { From 1de76cd605c8abcf61ffadebe3e515f1b56eab1c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 16 Jul 2019 10:10:58 -0700 Subject: [PATCH 25/43] Control flow for element access expressions (#31478) * Control flow for element access expressions Draft version, just want to see how performance is * Add baselines * Fix cast lint * Cleanup to share code path * Fix errant diffs --- src/compiler/checker.ts | 13 ++-- .../reference/controlFlowElementAccess2.js | 25 ++++++++ .../controlFlowElementAccess2.symbols | 37 +++++++++++ .../reference/controlFlowElementAccess2.types | 63 +++++++++++++++++++ .../controlFlow/controlFlowElementAccess2.ts | 13 ++++ 5 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/controlFlowElementAccess2.js create mode 100644 tests/baselines/reference/controlFlowElementAccess2.symbols create mode 100644 tests/baselines/reference/controlFlowElementAccess2.types create mode 100644 tests/cases/conformance/controlFlow/controlFlowElementAccess2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c31732cc24ac9..06395d935b7df 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20573,10 +20573,15 @@ namespace ts { } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } + return getFlowTypeOfAccessExpression(node, prop, propType, right); + } + + function getFlowTypeOfAccessExpression(node: ElementAccessExpression | PropertyAccessExpression | QualifiedName, prop: Symbol | undefined, propType: Type, errorNode: Node) { // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== SyntaxKind.PropertyAccessExpression || + const assignmentKind = getAssignmentTargetKind(node); + if (node.kind !== SyntaxKind.ElementAccessExpression && node.kind !== SyntaxKind.PropertyAccessExpression || assignmentKind === AssignmentKind.Definite || prop && !(prop.flags & (SymbolFlags.Variable | SymbolFlags.Property | SymbolFlags.Accessor)) && !(prop.flags & SymbolFlags.Method && propType.flags & TypeFlags.Union)) { return propType; @@ -20586,7 +20591,7 @@ namespace ts { // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. let assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && left.kind === SyntaxKind.ThisKeyword) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === SyntaxKind.ThisKeyword) { const declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { const flowContainer = getControlFlowContainer(node); @@ -20603,7 +20608,7 @@ namespace ts { } const flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); if (assumeUninitialized && !(getFalsyFlags(propType) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) { - error(right, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop!)); // TODO: GH#18217 + error(errorNode, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop!)); // TODO: GH#18217 // Return the declared type to reduce follow-on errors return propType; } @@ -20960,7 +20965,7 @@ namespace ts { AccessFlags.Writing | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? AccessFlags.NoIndexSignatures : 0) : AccessFlags.None; const indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, node, accessFlags) || errorType; - return checkIndexedAccessIndexType(indexedAccessType, node); + return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); } function checkThatExpressionIsProperSymbolReference(expression: Expression, expressionType: Type, reportError: boolean): boolean { diff --git a/tests/baselines/reference/controlFlowElementAccess2.js b/tests/baselines/reference/controlFlowElementAccess2.js new file mode 100644 index 0000000000000..050fc15b8af1f --- /dev/null +++ b/tests/baselines/reference/controlFlowElementAccess2.js @@ -0,0 +1,25 @@ +//// [controlFlowElementAccess2.ts] +declare const config: { + [key: string]: boolean | { prop: string }; +}; + +if (typeof config['works'] !== 'boolean') { + config.works.prop = 'test'; // ok + config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } +} +if (typeof config.works !== 'boolean') { + config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } + config.works.prop = 'test'; // ok +} + + +//// [controlFlowElementAccess2.js] +"use strict"; +if (typeof config['works'] !== 'boolean') { + config.works.prop = 'test'; // ok + config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } +} +if (typeof config.works !== 'boolean') { + config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } + config.works.prop = 'test'; // ok +} diff --git a/tests/baselines/reference/controlFlowElementAccess2.symbols b/tests/baselines/reference/controlFlowElementAccess2.symbols new file mode 100644 index 0000000000000..5cdd890a75973 --- /dev/null +++ b/tests/baselines/reference/controlFlowElementAccess2.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/controlFlow/controlFlowElementAccess2.ts === +declare const config: { +>config : Symbol(config, Decl(controlFlowElementAccess2.ts, 0, 13)) + + [key: string]: boolean | { prop: string }; +>key : Symbol(key, Decl(controlFlowElementAccess2.ts, 1, 5)) +>prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) + +}; + +if (typeof config['works'] !== 'boolean') { +>config : Symbol(config, Decl(controlFlowElementAccess2.ts, 0, 13)) + + config.works.prop = 'test'; // ok +>config.works.prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) +>config : Symbol(config, Decl(controlFlowElementAccess2.ts, 0, 13)) +>prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) + + config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } +>config['works'].prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) +>config : Symbol(config, Decl(controlFlowElementAccess2.ts, 0, 13)) +>prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) +} +if (typeof config.works !== 'boolean') { +>config : Symbol(config, Decl(controlFlowElementAccess2.ts, 0, 13)) + + config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } +>config['works'].prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) +>config : Symbol(config, Decl(controlFlowElementAccess2.ts, 0, 13)) +>prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) + + config.works.prop = 'test'; // ok +>config.works.prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) +>config : Symbol(config, Decl(controlFlowElementAccess2.ts, 0, 13)) +>prop : Symbol(prop, Decl(controlFlowElementAccess2.ts, 1, 30)) +} + diff --git a/tests/baselines/reference/controlFlowElementAccess2.types b/tests/baselines/reference/controlFlowElementAccess2.types new file mode 100644 index 0000000000000..65dca4de50226 --- /dev/null +++ b/tests/baselines/reference/controlFlowElementAccess2.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/controlFlow/controlFlowElementAccess2.ts === +declare const config: { +>config : { [key: string]: boolean | { prop: string; }; } + + [key: string]: boolean | { prop: string }; +>key : string +>prop : string + +}; + +if (typeof config['works'] !== 'boolean') { +>typeof config['works'] !== 'boolean' : boolean +>typeof config['works'] : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>config['works'] : boolean | { prop: string; } +>config : { [key: string]: boolean | { prop: string; }; } +>'works' : "works" +>'boolean' : "boolean" + + config.works.prop = 'test'; // ok +>config.works.prop = 'test' : "test" +>config.works.prop : string +>config.works : { prop: string; } +>config : { [key: string]: boolean | { prop: string; }; } +>works : { prop: string; } +>prop : string +>'test' : "test" + + config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } +>config['works'].prop = 'test' : "test" +>config['works'].prop : string +>config['works'] : { prop: string; } +>config : { [key: string]: boolean | { prop: string; }; } +>'works' : "works" +>prop : string +>'test' : "test" +} +if (typeof config.works !== 'boolean') { +>typeof config.works !== 'boolean' : boolean +>typeof config.works : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" +>config.works : boolean | { prop: string; } +>config : { [key: string]: boolean | { prop: string; }; } +>works : boolean | { prop: string; } +>'boolean' : "boolean" + + config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } +>config['works'].prop = 'test' : "test" +>config['works'].prop : string +>config['works'] : { prop: string; } +>config : { [key: string]: boolean | { prop: string; }; } +>'works' : "works" +>prop : string +>'test' : "test" + + config.works.prop = 'test'; // ok +>config.works.prop = 'test' : "test" +>config.works.prop : string +>config.works : { prop: string; } +>config : { [key: string]: boolean | { prop: string; }; } +>works : { prop: string; } +>prop : string +>'test' : "test" +} + diff --git a/tests/cases/conformance/controlFlow/controlFlowElementAccess2.ts b/tests/cases/conformance/controlFlow/controlFlowElementAccess2.ts new file mode 100644 index 0000000000000..fa0592c973ee3 --- /dev/null +++ b/tests/cases/conformance/controlFlow/controlFlowElementAccess2.ts @@ -0,0 +1,13 @@ +// @strict: true +declare const config: { + [key: string]: boolean | { prop: string }; +}; + +if (typeof config['works'] !== 'boolean') { + config.works.prop = 'test'; // ok + config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } +} +if (typeof config.works !== 'boolean') { + config['works'].prop = 'test'; // error, config['works']: boolean | { 'prop': string } + config.works.prop = 'test'; // ok +} From 49ba408e4fed08e328dfff2614611c500ee53bb0 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 16 Jul 2019 10:14:06 -0700 Subject: [PATCH 26/43] Handle scoped package names in typing installer Fixes #32075 --- src/jsTyping/jsTyping.ts | 75 +++++++++++++------ .../unittests/tsserver/typingsInstaller.ts | 64 +++++++++++----- src/tsserver/server.ts | 2 +- src/typingsInstallerCore/typingsInstaller.ts | 29 +++---- 4 files changed, 114 insertions(+), 56 deletions(-) diff --git a/src/jsTyping/jsTyping.ts b/src/jsTyping/jsTyping.ts index c2b2ad3f5b39c..172d041cc0182 100644 --- a/src/jsTyping/jsTyping.ts +++ b/src/jsTyping/jsTyping.ts @@ -289,9 +289,8 @@ namespace ts.JsTyping { } - export const enum PackageNameValidationResult { + export const enum NameValidationResult { Ok, - ScopedPackagesNotSupported, EmptyName, NameTooLong, NameStartsWithDot, @@ -301,49 +300,77 @@ namespace ts.JsTyping { const maxPackageNameLength = 214; + export interface ScopedPackageNameValidationResult { + name: string; + isScopeName: boolean; + result: NameValidationResult; + } + export type PackageNameValidationResult = NameValidationResult | ScopedPackageNameValidationResult; + /** * Validates package name using rules defined at https://docs.npmjs.com/files/package.json */ export function validatePackageName(packageName: string): PackageNameValidationResult { + return validatePackageNameWorker(packageName, /*supportScopedPackage*/ true); + } + + function validatePackageNameWorker(packageName: string, supportScopedPackage: false): NameValidationResult; + function validatePackageNameWorker(packageName: string, supportScopedPackage: true): PackageNameValidationResult; + function validatePackageNameWorker(packageName: string, supportScopedPackage: boolean): PackageNameValidationResult { if (!packageName) { - return PackageNameValidationResult.EmptyName; + return NameValidationResult.EmptyName; } if (packageName.length > maxPackageNameLength) { - return PackageNameValidationResult.NameTooLong; + return NameValidationResult.NameTooLong; } if (packageName.charCodeAt(0) === CharacterCodes.dot) { - return PackageNameValidationResult.NameStartsWithDot; + return NameValidationResult.NameStartsWithDot; } if (packageName.charCodeAt(0) === CharacterCodes._) { - return PackageNameValidationResult.NameStartsWithUnderscore; + return NameValidationResult.NameStartsWithUnderscore; } // check if name is scope package like: starts with @ and has one '/' in the middle // scoped packages are not currently supported - // TODO: when support will be added we'll need to split and check both scope and package name - if (/^@[^/]+\/[^/]+$/.test(packageName)) { - return PackageNameValidationResult.ScopedPackagesNotSupported; + if (supportScopedPackage) { + const matches = /^@([^/]+)\/([^/]+)$/.exec(packageName); + if (matches) { + const scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false); + if (scopeResult !== NameValidationResult.Ok) { + return { name: matches[1], isScopeName: true, result: scopeResult }; + } + const packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false); + if (packageResult !== NameValidationResult.Ok) { + return { name: matches[2], isScopeName: false, result: packageResult }; + } + return NameValidationResult.Ok; + } } if (encodeURIComponent(packageName) !== packageName) { - return PackageNameValidationResult.NameContainsNonURISafeCharacters; + return NameValidationResult.NameContainsNonURISafeCharacters; } - return PackageNameValidationResult.Ok; + return NameValidationResult.Ok; } export function renderPackageNameValidationFailure(result: PackageNameValidationResult, typing: string): string { + return typeof result === "object" ? + renderPackageNameValidationFailureWorker(typing, result.result, result.name, result.isScopeName) : + renderPackageNameValidationFailureWorker(typing, result, typing, /*isScopeName*/ false); + } + + function renderPackageNameValidationFailureWorker(typing: string, result: NameValidationResult, name: string, isScopeName: boolean): string { + const kind = isScopeName ? "Scope" : "Package"; switch (result) { - case PackageNameValidationResult.EmptyName: - return `Package name '${typing}' cannot be empty`; - case PackageNameValidationResult.NameTooLong: - return `Package name '${typing}' should be less than ${maxPackageNameLength} characters`; - case PackageNameValidationResult.NameStartsWithDot: - return `Package name '${typing}' cannot start with '.'`; - case PackageNameValidationResult.NameStartsWithUnderscore: - return `Package name '${typing}' cannot start with '_'`; - case PackageNameValidationResult.ScopedPackagesNotSupported: - return `Package '${typing}' is scoped and currently is not supported`; - case PackageNameValidationResult.NameContainsNonURISafeCharacters: - return `Package name '${typing}' contains non URI safe characters`; - case PackageNameValidationResult.Ok: + case NameValidationResult.EmptyName: + return `'${typing}':: ${kind} name '${name}' cannot be empty`; + case NameValidationResult.NameTooLong: + return `'${typing}':: ${kind} name '${name}' should be less than ${maxPackageNameLength} characters`; + case NameValidationResult.NameStartsWithDot: + return `'${typing}':: ${kind} name '${name}' cannot start with '.'`; + case NameValidationResult.NameStartsWithUnderscore: + return `'${typing}':: ${kind} name '${name}' cannot start with '_'`; + case NameValidationResult.NameContainsNonURISafeCharacters: + return `'${typing}':: ${kind} name '${name}' contains non URI safe characters`; + case NameValidationResult.Ok: return Debug.fail(); // Shouldn't have called this. default: throw Debug.assertNever(result); diff --git a/src/testRunner/unittests/tsserver/typingsInstaller.ts b/src/testRunner/unittests/tsserver/typingsInstaller.ts index b02adbbd094aa..79b4f01aa06f9 100644 --- a/src/testRunner/unittests/tsserver/typingsInstaller.ts +++ b/src/testRunner/unittests/tsserver/typingsInstaller.ts @@ -1,6 +1,6 @@ namespace ts.projectSystem { import validatePackageName = JsTyping.validatePackageName; - import PackageNameValidationResult = JsTyping.PackageNameValidationResult; + import NameValidationResult = JsTyping.NameValidationResult; interface InstallerParams { globalTypingsCacheLocation?: string; @@ -948,7 +948,8 @@ namespace ts.projectSystem { path: "/a/b/app.js", content: ` import * as fs from "fs"; - import * as commander from "commander";` + import * as commander from "commander"; + import * as component from "@ember/component";` }; const cachePath = "/a/cache"; const node = { @@ -959,14 +960,19 @@ namespace ts.projectSystem { path: cachePath + "/node_modules/@types/commander/index.d.ts", content: "export let y: string" }; + const emberComponentDirectory = "ember__component"; + const emberComponent = { + path: `${cachePath}/node_modules/@types/${emberComponentDirectory}/index.d.ts`, + content: "export let x: number" + }; const host = createServerHost([file]); const installer = new (class extends Installer { constructor() { super(host, { globalTypingsCacheLocation: cachePath, typesRegistry: createTypesRegistry("node", "commander") }); } installWorker(_requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction) { - const installedTypings = ["@types/node", "@types/commander"]; - const typingFiles = [node, commander]; + const installedTypings = ["@types/node", "@types/commander", `@types/${emberComponentDirectory}`]; + const typingFiles = [node, commander, emberComponent]; executeCommand(this, host, installedTypings, typingFiles, cb); } })(); @@ -980,9 +986,10 @@ namespace ts.projectSystem { assert.isTrue(host.fileExists(node.path), "typings for 'node' should be created"); assert.isTrue(host.fileExists(commander.path), "typings for 'commander' should be created"); + assert.isTrue(host.fileExists(emberComponent.path), "typings for 'commander' should be created"); host.checkTimeoutQueueLengthAndRun(2); - checkProjectActualFiles(service.inferredProjects[0], [file.path, node.path, commander.path]); + checkProjectActualFiles(service.inferredProjects[0], [file.path, node.path, commander.path, emberComponent.path]); }); it("should redo resolution that resolved to '.js' file after typings are installed", () => { @@ -1263,21 +1270,44 @@ namespace ts.projectSystem { for (let i = 0; i < 8; i++) { packageName += packageName; } - assert.equal(validatePackageName(packageName), PackageNameValidationResult.NameTooLong); + assert.equal(validatePackageName(packageName), NameValidationResult.NameTooLong); + }); + it("package name cannot start with dot", () => { + assert.equal(validatePackageName(".foo"), NameValidationResult.NameStartsWithDot); + }); + it("package name cannot start with underscore", () => { + assert.equal(validatePackageName("_foo"), NameValidationResult.NameStartsWithUnderscore); + }); + it("package non URI safe characters are not supported", () => { + assert.equal(validatePackageName(" scope "), NameValidationResult.NameContainsNonURISafeCharacters); + assert.equal(validatePackageName("; say ‘Hello from TypeScript!’ #"), NameValidationResult.NameContainsNonURISafeCharacters); + assert.equal(validatePackageName("a/b/c"), NameValidationResult.NameContainsNonURISafeCharacters); + }); + it("scoped package name is supported", () => { + assert.equal(validatePackageName("@scope/bar"), NameValidationResult.Ok); + }); + it("scoped name in scoped package name cannot start with dot", () => { + assert.deepEqual(validatePackageName("@.scope/bar"), { name: ".scope", isScopeName: true, result: NameValidationResult.NameStartsWithDot }); + assert.deepEqual(validatePackageName("@.scope/.bar"), { name: ".scope", isScopeName: true, result: NameValidationResult.NameStartsWithDot }); + }); + it("scope name in scoped package name cannot start with underscore", () => { + assert.deepEqual(validatePackageName("@_scope/bar"), { name: "_scope", isScopeName: true, result: NameValidationResult.NameStartsWithUnderscore }); + assert.deepEqual(validatePackageName("@_scope/_bar"), { name: "_scope", isScopeName: true, result: NameValidationResult.NameStartsWithUnderscore }); }); - it("name cannot start with dot", () => { - assert.equal(validatePackageName(".foo"), PackageNameValidationResult.NameStartsWithDot); + it("scope name in scoped package name with non URI safe characters are not supported", () => { + assert.deepEqual(validatePackageName("@ scope /bar"), { name: " scope ", isScopeName: true, result: NameValidationResult.NameContainsNonURISafeCharacters }); + assert.deepEqual(validatePackageName("@; say ‘Hello from TypeScript!’ #/bar"), { name: "; say ‘Hello from TypeScript!’ #", isScopeName: true, result: NameValidationResult.NameContainsNonURISafeCharacters }); + assert.deepEqual(validatePackageName("@ scope / bar "), { name: " scope ", isScopeName: true, result: NameValidationResult.NameContainsNonURISafeCharacters }); }); - it("name cannot start with underscore", () => { - assert.equal(validatePackageName("_foo"), PackageNameValidationResult.NameStartsWithUnderscore); + it("package name in scoped package name cannot start with dot", () => { + assert.deepEqual(validatePackageName("@scope/.bar"), { name: ".bar", isScopeName: false, result: NameValidationResult.NameStartsWithDot }); }); - it("scoped packages not supported", () => { - assert.equal(validatePackageName("@scope/bar"), PackageNameValidationResult.ScopedPackagesNotSupported); + it("package name in scoped package name cannot start with underscore", () => { + assert.deepEqual(validatePackageName("@scope/_bar"), { name: "_bar", isScopeName: false, result: NameValidationResult.NameStartsWithUnderscore }); }); - it("non URI safe characters are not supported", () => { - assert.equal(validatePackageName(" scope "), PackageNameValidationResult.NameContainsNonURISafeCharacters); - assert.equal(validatePackageName("; say ‘Hello from TypeScript!’ #"), PackageNameValidationResult.NameContainsNonURISafeCharacters); - assert.equal(validatePackageName("a/b/c"), PackageNameValidationResult.NameContainsNonURISafeCharacters); + it("package name in scoped package name with non URI safe characters are not supported", () => { + assert.deepEqual(validatePackageName("@scope/ bar "), { name: " bar ", isScopeName: false, result: NameValidationResult.NameContainsNonURISafeCharacters }); + assert.deepEqual(validatePackageName("@scope/; say ‘Hello from TypeScript!’ #"), { name: "; say ‘Hello from TypeScript!’ #", isScopeName: false, result: NameValidationResult.NameContainsNonURISafeCharacters }); }); }); @@ -1309,7 +1339,7 @@ namespace ts.projectSystem { projectService.openClientFile(f1.path); installer.checkPendingCommands(/*expectedCount*/ 0); - assert.isTrue(messages.indexOf("Package name '; say ‘Hello from TypeScript!’ #' contains non URI safe characters") > 0, "should find package with invalid name"); + assert.isTrue(messages.indexOf("'; say ‘Hello from TypeScript!’ #':: Package name '; say ‘Hello from TypeScript!’ #' contains non URI safe characters") > 0, "should find package with invalid name"); }); }); diff --git a/src/tsserver/server.ts b/src/tsserver/server.ts index 43dc4638418ab..a9fbf2f3b6af8 100644 --- a/src/tsserver/server.ts +++ b/src/tsserver/server.ts @@ -248,7 +248,7 @@ namespace ts.server { isKnownTypesPackageName(name: string): boolean { // We want to avoid looking this up in the registry as that is expensive. So first check that it's actually an NPM package. const validationResult = JsTyping.validatePackageName(name); - if (validationResult !== JsTyping.PackageNameValidationResult.Ok) { + if (validationResult !== JsTyping.NameValidationResult.Ok) { return false; } diff --git a/src/typingsInstallerCore/typingsInstaller.ts b/src/typingsInstallerCore/typingsInstaller.ts index df83f1a677c39..17dae3b4dcb21 100644 --- a/src/typingsInstallerCore/typingsInstaller.ts +++ b/src/typingsInstallerCore/typingsInstaller.ts @@ -268,27 +268,28 @@ namespace ts.server.typingsInstaller { } private filterTypings(typingsToInstall: ReadonlyArray): ReadonlyArray { - return typingsToInstall.filter(typing => { - if (this.missingTypingsSet.get(typing)) { - if (this.log.isEnabled()) this.log.writeLine(`'${typing}' is in missingTypingsSet - skipping...`); - return false; + return mapDefined(typingsToInstall, typing => { + const typingKey = mangleScopedPackageName(typing); + if (this.missingTypingsSet.get(typingKey)) { + if (this.log.isEnabled()) this.log.writeLine(`'${typing}':: '${typingKey}' is in missingTypingsSet - skipping...`); + return undefined; } const validationResult = JsTyping.validatePackageName(typing); - if (validationResult !== JsTyping.PackageNameValidationResult.Ok) { + if (validationResult !== JsTyping.NameValidationResult.Ok) { // add typing name to missing set so we won't process it again - this.missingTypingsSet.set(typing, true); + this.missingTypingsSet.set(typingKey, true); if (this.log.isEnabled()) this.log.writeLine(JsTyping.renderPackageNameValidationFailure(validationResult, typing)); - return false; + return undefined; } - if (!this.typesRegistry.has(typing)) { - if (this.log.isEnabled()) this.log.writeLine(`Entry for package '${typing}' does not exist in local types registry - skipping...`); - return false; + if (!this.typesRegistry.has(typingKey)) { + if (this.log.isEnabled()) this.log.writeLine(`'${typing}':: Entry for package '${typingKey}' does not exist in local types registry - skipping...`); + return undefined; } - if (this.packageNameToTypingLocation.get(typing) && JsTyping.isTypingUpToDate(this.packageNameToTypingLocation.get(typing)!, this.typesRegistry.get(typing)!)) { - if (this.log.isEnabled()) this.log.writeLine(`'${typing}' already has an up-to-date typing - skipping...`); - return false; + if (this.packageNameToTypingLocation.get(typingKey) && JsTyping.isTypingUpToDate(this.packageNameToTypingLocation.get(typingKey)!, this.typesRegistry.get(typingKey)!)) { + if (this.log.isEnabled()) this.log.writeLine(`'${typing}':: '${typingKey}' already has an up-to-date typing - skipping...`); + return undefined; } - return true; + return typingKey; }); } From dc38aceb028765ff5e19a3fe920f3cbf09e14064 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 16 Jul 2019 11:38:09 -0700 Subject: [PATCH 27/43] Fix the export on TestServerHostCreationParameters to fix build break after LKG Its not detected currently is because LKG doesnt have #32156 --- src/harness/virtualFileSystemWithWatch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index f49f15cadc2ee..b8e3d189781a2 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -30,7 +30,7 @@ interface Array {}` return combinePaths(getDirectoryPath(libFile.path), "tsc.js"); } - interface TestServerHostCreationParameters { + export interface TestServerHostCreationParameters { useCaseSensitiveFileNames?: boolean; executingFilePath?: string; currentDirectory?: string; From 607c9c5e2681a86e1fa9807dded11248020c37a1 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 16 Jul 2019 13:13:02 -0700 Subject: [PATCH 28/43] Fix missing tokenToString for the backtick Fixes #32073 --- src/compiler/scanner.ts | 2 +- src/testRunner/unittests/publicApi.ts | 15 ++++++++++++++ .../jsdocParameterParsingInvalidName.js | 20 +++++++++++++++++++ .../jsdocParameterParsingInvalidName.symbols | 12 +++++++++++ .../jsdocParameterParsingInvalidName.types | 12 +++++++++++ .../jsdocParameterParsingInvalidName.ts | 7 +++++++ 6 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/jsdocParameterParsingInvalidName.js create mode 100644 tests/baselines/reference/jsdocParameterParsingInvalidName.symbols create mode 100644 tests/baselines/reference/jsdocParameterParsingInvalidName.types create mode 100644 tests/cases/compiler/jsdocParameterParsingInvalidName.ts diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 256e41629a1d8..f949893171a79 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -197,6 +197,7 @@ namespace ts { "|=": SyntaxKind.BarEqualsToken, "^=": SyntaxKind.CaretEqualsToken, "@": SyntaxKind.AtToken, + "`": SyntaxKind.BacktickToken }); /* @@ -298,7 +299,6 @@ namespace ts { } const tokenStrings = makeReverseMap(textToToken); - export function tokenToString(t: SyntaxKind): string | undefined { return tokenStrings[t]; } diff --git a/src/testRunner/unittests/publicApi.ts b/src/testRunner/unittests/publicApi.ts index 17b2519c9282c..a31104de62ac9 100644 --- a/src/testRunner/unittests/publicApi.ts +++ b/src/testRunner/unittests/publicApi.ts @@ -31,3 +31,18 @@ describe("Public APIs", () => { verifyApi("tsserverlibrary.d.ts"); }); }); + +describe("Public APIs:: token to string", () => { + function assertDefinedTokenToString(initial: ts.SyntaxKind, last: ts.SyntaxKind) { + for (let t = initial; t <= last; t++) { + assert.isDefined(ts.tokenToString(t), `Expected tokenToString defined for ${ts.Debug.formatSyntaxKind(t)}`); + } + } + + it("for punctuations", () => { + assertDefinedTokenToString(ts.SyntaxKind.FirstPunctuation, ts.SyntaxKind.LastPunctuation); + }); + it("for keywords", () => { + assertDefinedTokenToString(ts.SyntaxKind.FirstKeyword, ts.SyntaxKind.LastKeyword); + }); +}); diff --git a/tests/baselines/reference/jsdocParameterParsingInvalidName.js b/tests/baselines/reference/jsdocParameterParsingInvalidName.js new file mode 100644 index 0000000000000..4001ece1aec41 --- /dev/null +++ b/tests/baselines/reference/jsdocParameterParsingInvalidName.js @@ -0,0 +1,20 @@ +//// [jsdocParameterParsingInvalidName.ts] +class c { + /** + * @param {string} [`foo] + */ + method(foo) { + } +} + +//// [jsdocParameterParsingInvalidName.js] +var c = /** @class */ (function () { + function c() { + } + /** + * @param {string} [`foo] + */ + c.prototype.method = function (foo) { + }; + return c; +}()); diff --git a/tests/baselines/reference/jsdocParameterParsingInvalidName.symbols b/tests/baselines/reference/jsdocParameterParsingInvalidName.symbols new file mode 100644 index 0000000000000..037731d247779 --- /dev/null +++ b/tests/baselines/reference/jsdocParameterParsingInvalidName.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/jsdocParameterParsingInvalidName.ts === +class c { +>c : Symbol(c, Decl(jsdocParameterParsingInvalidName.ts, 0, 0)) + + /** + * @param {string} [`foo] + */ + method(foo) { +>method : Symbol(c.method, Decl(jsdocParameterParsingInvalidName.ts, 0, 9)) +>foo : Symbol(foo, Decl(jsdocParameterParsingInvalidName.ts, 4, 11)) + } +} diff --git a/tests/baselines/reference/jsdocParameterParsingInvalidName.types b/tests/baselines/reference/jsdocParameterParsingInvalidName.types new file mode 100644 index 0000000000000..d6ec561cdf22a --- /dev/null +++ b/tests/baselines/reference/jsdocParameterParsingInvalidName.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/jsdocParameterParsingInvalidName.ts === +class c { +>c : c + + /** + * @param {string} [`foo] + */ + method(foo) { +>method : (foo: any) => void +>foo : any + } +} diff --git a/tests/cases/compiler/jsdocParameterParsingInvalidName.ts b/tests/cases/compiler/jsdocParameterParsingInvalidName.ts new file mode 100644 index 0000000000000..6c3c93d182e65 --- /dev/null +++ b/tests/cases/compiler/jsdocParameterParsingInvalidName.ts @@ -0,0 +1,7 @@ +class c { + /** + * @param {string} [`foo] + */ + method(foo) { + } +} \ No newline at end of file From 049618f7daf63332d7f972eb0ae4e6af3bcd55bd Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 16 Jul 2019 17:16:21 -0700 Subject: [PATCH 29/43] Get contextual type of yield from contextual signature of containing function (#32433) * Get contextual type of yield from contextual signature of containing function * Add missing baseline --- src/compiler/checker.ts | 6 +++ .../reference/generatorTypeCheck25.types | 6 +-- .../reference/generatorTypeCheck28.types | 2 +- .../reference/generatorTypeCheck45.types | 2 +- .../reference/generatorTypeCheck46.types | 2 +- .../reference/generatorTypeCheck62.types | 6 +-- .../reference/generatorTypeCheck63.types | 4 +- .../generatorYieldContextualType.symbols | 44 +++++++++++++++++++ .../generatorYieldContextualType.types | 38 ++++++++++++++++ .../types.asyncGenerators.es2018.1.types | 12 ++--- .../types.asyncGenerators.es2018.2.types | 6 +-- tests/baselines/reference/uniqueSymbols.types | 4 +- .../reference/uniqueSymbolsDeclarations.types | 4 +- .../generatorYieldContextualType.ts | 14 ++++++ 14 files changed, 126 insertions(+), 24 deletions(-) create mode 100644 tests/baselines/reference/generatorYieldContextualType.symbols create mode 100644 tests/baselines/reference/generatorYieldContextualType.types create mode 100644 tests/cases/conformance/generators/generatorYieldContextualType.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 06395d935b7df..20a4246f37253 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -24740,6 +24740,12 @@ namespace ts { || anyType; } + const contextualReturnType = getContextualReturnType(func); + if (contextualReturnType) { + return getIterationTypeOfGeneratorFunctionReturnType(IterationTypeKind.Next, contextualReturnType, isAsync) + || anyType; + } + return anyType; } diff --git a/tests/baselines/reference/generatorTypeCheck25.types b/tests/baselines/reference/generatorTypeCheck25.types index d0498c2da16ea..12dbfeaede961 100644 --- a/tests/baselines/reference/generatorTypeCheck25.types +++ b/tests/baselines/reference/generatorTypeCheck25.types @@ -17,15 +17,15 @@ var g3: () => Iterable = function* () { >function* () { yield; yield new Bar; yield new Baz; yield *[new Bar]; yield *[new Baz];} : () => Generator yield; ->yield : any +>yield : undefined yield new Bar; ->yield new Bar : any +>yield new Bar : undefined >new Bar : Bar >Bar : typeof Bar yield new Baz; ->yield new Baz : any +>yield new Baz : undefined >new Baz : Baz >Baz : typeof Baz diff --git a/tests/baselines/reference/generatorTypeCheck28.types b/tests/baselines/reference/generatorTypeCheck28.types index 9cd4e5e82cecb..6921c946a39d7 100644 --- a/tests/baselines/reference/generatorTypeCheck28.types +++ b/tests/baselines/reference/generatorTypeCheck28.types @@ -14,7 +14,7 @@ function* g(): IterableIterator<(x: string) => number> { >iterator : symbol yield x => x.length; ->yield x => x.length : any +>yield x => x.length : undefined >x => x.length : (x: string) => number >x : string >x.length : number diff --git a/tests/baselines/reference/generatorTypeCheck45.types b/tests/baselines/reference/generatorTypeCheck45.types index cf40924194775..18d3e9a5fc2cb 100644 --- a/tests/baselines/reference/generatorTypeCheck45.types +++ b/tests/baselines/reference/generatorTypeCheck45.types @@ -12,7 +12,7 @@ foo("", function* () { yield x => x.length }, p => undefined); // T is fixed, sh >foo : (x: T, fun: () => Iterator<(x: T) => U, any, undefined>, fun2: (y: U) => T) => T >"" : "" >function* () { yield x => x.length } : () => Generator<(x: string) => number, void, unknown> ->yield x => x.length : any +>yield x => x.length : undefined >x => x.length : (x: string) => number >x : string >x.length : number diff --git a/tests/baselines/reference/generatorTypeCheck46.types b/tests/baselines/reference/generatorTypeCheck46.types index cd565d55911ee..283188193b77f 100644 --- a/tests/baselines/reference/generatorTypeCheck46.types +++ b/tests/baselines/reference/generatorTypeCheck46.types @@ -24,7 +24,7 @@ foo("", function* () { >iterator : symbol yield x => x.length ->yield x => x.length : any +>yield x => x.length : undefined >x => x.length : (x: string) => number >x : string >x.length : number diff --git a/tests/baselines/reference/generatorTypeCheck62.types b/tests/baselines/reference/generatorTypeCheck62.types index be5635a07fc66..ed957295c3123 100644 --- a/tests/baselines/reference/generatorTypeCheck62.types +++ b/tests/baselines/reference/generatorTypeCheck62.types @@ -32,7 +32,7 @@ export function strategy(stratName: string, gen: (a: T >stratName : string } yield next; ->yield next : any +>yield next : undefined >next : T } } @@ -70,7 +70,7 @@ export const Nothing2: Strategy = strategy("Nothing", function*(state: St >state : State yield state; ->yield state : any +>yield state : undefined >state : State }); @@ -84,7 +84,7 @@ export const Nothing3: Strategy = strategy("Nothing", function* (state: S >state : State yield ; ->yield : any +>yield : undefined return state; >state : State diff --git a/tests/baselines/reference/generatorTypeCheck63.types b/tests/baselines/reference/generatorTypeCheck63.types index 8a1d03dcb164c..64d67083e6173 100644 --- a/tests/baselines/reference/generatorTypeCheck63.types +++ b/tests/baselines/reference/generatorTypeCheck63.types @@ -32,7 +32,7 @@ export function strategy(stratName: string, gen: (a: T >stratName : string } yield next; ->yield next : any +>yield next : undefined >next : T } } @@ -97,7 +97,7 @@ export const Nothing3: Strategy = strategy("Nothing", function* (state: S >state : State yield state; ->yield state : any +>yield state : undefined >state : State return 1; diff --git a/tests/baselines/reference/generatorYieldContextualType.symbols b/tests/baselines/reference/generatorYieldContextualType.symbols new file mode 100644 index 0000000000000..80d20b90d752e --- /dev/null +++ b/tests/baselines/reference/generatorYieldContextualType.symbols @@ -0,0 +1,44 @@ +=== tests/cases/conformance/generators/generatorYieldContextualType.ts === +declare function f1(gen: () => Generator): void; +>f1 : Symbol(f1, Decl(generatorYieldContextualType.ts, 0, 0)) +>T : Symbol(T, Decl(generatorYieldContextualType.ts, 0, 20)) +>R : Symbol(R, Decl(generatorYieldContextualType.ts, 0, 22)) +>S : Symbol(S, Decl(generatorYieldContextualType.ts, 0, 25)) +>gen : Symbol(gen, Decl(generatorYieldContextualType.ts, 0, 29)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) +>R : Symbol(R, Decl(generatorYieldContextualType.ts, 0, 22)) +>T : Symbol(T, Decl(generatorYieldContextualType.ts, 0, 20)) +>S : Symbol(S, Decl(generatorYieldContextualType.ts, 0, 25)) + +f1<0, 0, 1>(function* () { +>f1 : Symbol(f1, Decl(generatorYieldContextualType.ts, 0, 0)) + + const a = yield 0; +>a : Symbol(a, Decl(generatorYieldContextualType.ts, 2, 6)) + + return 0; +}); + +declare function f2(gen: () => Generator | AsyncGenerator): void; +>f2 : Symbol(f2, Decl(generatorYieldContextualType.ts, 4, 3)) +>T : Symbol(T, Decl(generatorYieldContextualType.ts, 6, 20)) +>R : Symbol(R, Decl(generatorYieldContextualType.ts, 6, 22)) +>S : Symbol(S, Decl(generatorYieldContextualType.ts, 6, 25)) +>gen : Symbol(gen, Decl(generatorYieldContextualType.ts, 6, 29)) +>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --)) +>R : Symbol(R, Decl(generatorYieldContextualType.ts, 6, 22)) +>T : Symbol(T, Decl(generatorYieldContextualType.ts, 6, 20)) +>S : Symbol(S, Decl(generatorYieldContextualType.ts, 6, 25)) +>AsyncGenerator : Symbol(AsyncGenerator, Decl(lib.es2018.asyncgenerator.d.ts, --, --)) +>R : Symbol(R, Decl(generatorYieldContextualType.ts, 6, 22)) +>T : Symbol(T, Decl(generatorYieldContextualType.ts, 6, 20)) +>S : Symbol(S, Decl(generatorYieldContextualType.ts, 6, 25)) + +f2<0, 0, 1>(async function* () { +>f2 : Symbol(f2, Decl(generatorYieldContextualType.ts, 4, 3)) + + const a = yield 0; +>a : Symbol(a, Decl(generatorYieldContextualType.ts, 8, 6)) + + return 0; +}); diff --git a/tests/baselines/reference/generatorYieldContextualType.types b/tests/baselines/reference/generatorYieldContextualType.types new file mode 100644 index 0000000000000..5caccffa93399 --- /dev/null +++ b/tests/baselines/reference/generatorYieldContextualType.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/generators/generatorYieldContextualType.ts === +declare function f1(gen: () => Generator): void; +>f1 : (gen: () => Generator) => void +>gen : () => Generator + +f1<0, 0, 1>(function* () { +>f1<0, 0, 1>(function* () { const a = yield 0; return 0;}) : void +>f1 : (gen: () => Generator) => void +>function* () { const a = yield 0; return 0;} : () => Generator<0, 0, unknown> + + const a = yield 0; +>a : 1 +>yield 0 : 1 +>0 : 0 + + return 0; +>0 : 0 + +}); + +declare function f2(gen: () => Generator | AsyncGenerator): void; +>f2 : (gen: () => Generator | AsyncGenerator) => void +>gen : () => Generator | AsyncGenerator + +f2<0, 0, 1>(async function* () { +>f2<0, 0, 1>(async function* () { const a = yield 0; return 0;}) : void +>f2 : (gen: () => Generator | AsyncGenerator) => void +>async function* () { const a = yield 0; return 0;} : () => AsyncGenerator<0, 0, unknown> + + const a = yield 0; +>a : 1 +>yield 0 : 1 +>0 : 0 + + return 0; +>0 : 0 + +}); diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.1.types b/tests/baselines/reference/types.asyncGenerators.es2018.1.types index ad35f2a796f5c..24da9312c1537 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.1.types +++ b/tests/baselines/reference/types.asyncGenerators.es2018.1.types @@ -78,7 +78,7 @@ const assignability1: () => AsyncIterableIterator = async function * () >async function * () { yield 1;} : () => AsyncGenerator yield 1; ->yield 1 : any +>yield 1 : undefined >1 : 1 }; @@ -87,7 +87,7 @@ const assignability2: () => AsyncIterableIterator = async function * () >async function * () { yield Promise.resolve(1);} : () => AsyncGenerator yield Promise.resolve(1); ->yield Promise.resolve(1) : any +>yield Promise.resolve(1) : undefined >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor @@ -138,7 +138,7 @@ const assignability6: () => AsyncIterable = async function * () { >async function * () { yield 1;} : () => AsyncGenerator yield 1; ->yield 1 : any +>yield 1 : undefined >1 : 1 }; @@ -147,7 +147,7 @@ const assignability7: () => AsyncIterable = async function * () { >async function * () { yield Promise.resolve(1);} : () => AsyncGenerator yield Promise.resolve(1); ->yield Promise.resolve(1) : any +>yield Promise.resolve(1) : undefined >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor @@ -198,7 +198,7 @@ const assignability11: () => AsyncIterator = async function * () { >async function * () { yield 1;} : () => AsyncGenerator yield 1; ->yield 1 : any +>yield 1 : undefined >1 : 1 }; @@ -207,7 +207,7 @@ const assignability12: () => AsyncIterator = async function * () { >async function * () { yield Promise.resolve(1);} : () => AsyncGenerator yield Promise.resolve(1); ->yield Promise.resolve(1) : any +>yield Promise.resolve(1) : undefined >Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor diff --git a/tests/baselines/reference/types.asyncGenerators.es2018.2.types b/tests/baselines/reference/types.asyncGenerators.es2018.2.types index 23bf7225eb938..022ddd297a24f 100644 --- a/tests/baselines/reference/types.asyncGenerators.es2018.2.types +++ b/tests/baselines/reference/types.asyncGenerators.es2018.2.types @@ -32,7 +32,7 @@ const assignability1: () => AsyncIterableIterator = async function * () >async function * () { yield "a";} : () => AsyncGenerator yield "a"; ->yield "a" : any +>yield "a" : undefined >"a" : "a" }; @@ -65,7 +65,7 @@ const assignability4: () => AsyncIterable = async function * () { >async function * () { yield "a";} : () => AsyncGenerator yield "a"; ->yield "a" : any +>yield "a" : undefined >"a" : "a" }; @@ -98,7 +98,7 @@ const assignability7: () => AsyncIterator = async function * () { >async function * () { yield "a";} : () => AsyncGenerator yield "a"; ->yield "a" : any +>yield "a" : undefined >"a" : "a" }; diff --git a/tests/baselines/reference/uniqueSymbols.types b/tests/baselines/reference/uniqueSymbols.types index da2f989521805..02ededf7b1f99 100644 --- a/tests/baselines/reference/uniqueSymbols.types +++ b/tests/baselines/reference/uniqueSymbols.types @@ -839,7 +839,7 @@ const o3: Context = { >method3 : () => AsyncGenerator yield s; // yield type should not widen due to contextual type ->yield s : any +>yield s : undefined >s : unique symbol }, @@ -847,7 +847,7 @@ const o3: Context = { >method4 : () => Generator yield s; // yield type should not widen due to contextual type ->yield s : any +>yield s : undefined >s : unique symbol }, diff --git a/tests/baselines/reference/uniqueSymbolsDeclarations.types b/tests/baselines/reference/uniqueSymbolsDeclarations.types index b8c32385f4bc0..db198153153f9 100644 --- a/tests/baselines/reference/uniqueSymbolsDeclarations.types +++ b/tests/baselines/reference/uniqueSymbolsDeclarations.types @@ -832,7 +832,7 @@ const o4: Context = { >method3 : () => AsyncGenerator yield s; // yield type should not widen due to contextual type ->yield s : any +>yield s : undefined >s : unique symbol }, @@ -840,7 +840,7 @@ const o4: Context = { >method4 : () => Generator yield s; // yield type should not widen due to contextual type ->yield s : any +>yield s : undefined >s : unique symbol }, diff --git a/tests/cases/conformance/generators/generatorYieldContextualType.ts b/tests/cases/conformance/generators/generatorYieldContextualType.ts new file mode 100644 index 0000000000000..20cad6a91893c --- /dev/null +++ b/tests/cases/conformance/generators/generatorYieldContextualType.ts @@ -0,0 +1,14 @@ +// @target: esnext +// @strict: true +// @noEmit: true +declare function f1(gen: () => Generator): void; +f1<0, 0, 1>(function* () { + const a = yield 0; + return 0; +}); + +declare function f2(gen: () => Generator | AsyncGenerator): void; +f2<0, 0, 1>(async function* () { + const a = yield 0; + return 0; +}); \ No newline at end of file From e6c723dd2aefc851642ba3b7c534986ae33f3d9b Mon Sep 17 00:00:00 2001 From: csigs Date: Wed, 17 Jul 2019 16:10:08 +0000 Subject: [PATCH 30/43] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index 2c25256b2242f..07839d2447506 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1,4 +1,4 @@ - + @@ -3301,7 +3301,7 @@ - + @@ -4123,7 +4123,7 @@ - + From 246610957772c8801457ec9c8f32b0686edc0716 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 17 Jul 2019 13:07:10 -0700 Subject: [PATCH 31/43] Fix build/lint due to differences in master and LKG (#32450) --- src/compiler/emitter.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a1207c9b892c9..8681a452e2a56 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -411,7 +411,11 @@ namespace ts { } ); if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === SyntaxKind.SourceFile) { - const sourceFile = declarationTransform.transformed[0] as SourceFile; + // Improved narrowing in master/3.6 makes this cast unnecessary, triggering a lint rule. + // But at the same time, the LKG (3.5) necessitates it because it doesn’t narrow. + // Once the LKG is updated to 3.6, this comment, the cast to `SourceFile`, and the + // tslint directive can be all be removed. + const sourceFile = declarationTransform.transformed[0] as SourceFile; // tslint:disable-line exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } } From 8f2ed0ded88a978c283eab9a9184729b6f7e009f Mon Sep 17 00:00:00 2001 From: Milosz Piechocki Date: Wed, 17 Jul 2019 22:22:53 +0200 Subject: [PATCH 32/43] addTypeToIntersection performance improvement (#32388) --- src/compiler/checker.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 20a4246f37253..1d6b9e842cc4f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9890,7 +9890,7 @@ namespace ts { return links.resolvedType; } - function addTypeToIntersection(typeSet: Type[], includes: TypeFlags, type: Type) { + function addTypeToIntersection(typeSet: Map, includes: TypeFlags, type: Type) { const flags = type.flags; if (flags & TypeFlags.Intersection) { return addTypesToIntersection(typeSet, includes, (type).types); @@ -9898,20 +9898,20 @@ namespace ts { if (isEmptyAnonymousObjectType(type)) { if (!(includes & TypeFlags.IncludesEmptyObject)) { includes |= TypeFlags.IncludesEmptyObject; - typeSet.push(type); + typeSet.set(type.id.toString(), type); } } else { if (flags & TypeFlags.AnyOrUnknown) { if (type === wildcardType) includes |= TypeFlags.IncludesWildcard; } - else if ((strictNullChecks || !(flags & TypeFlags.Nullable)) && !contains(typeSet, type)) { + else if ((strictNullChecks || !(flags & TypeFlags.Nullable)) && !typeSet.has(type.id.toString())) { if (type.flags & TypeFlags.Unit && includes & TypeFlags.Unit) { // We have seen two distinct unit types which means we should reduce to an // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. includes |= TypeFlags.NonPrimitive; } - typeSet.push(type); + typeSet.set(type.id.toString(), type); } includes |= flags & TypeFlags.IncludesMask; } @@ -9920,7 +9920,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: Type[], includes: TypeFlags, types: ReadonlyArray) { + function addTypesToIntersection(typeSet: Map, includes: TypeFlags, types: ReadonlyArray) { for (const type of types) { includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } @@ -10027,8 +10027,9 @@ 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: ReadonlyArray, aliasSymbol?: Symbol, aliasTypeArguments?: ReadonlyArray): Type { - const typeSet: Type[] = []; - const includes = addTypesToIntersection(typeSet, 0, types); + const typeMembershipMap: Map = createMap(); + const includes = addTypesToIntersection(typeMembershipMap, 0, types); + const typeSet: Type[] = arrayFrom(typeMembershipMap.values()); // An intersection type is considered empty if it contains // the type never, or // more than one unit type or, From 387c917765793773a6f7184bab84e6f5956f44fc Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 17 Jul 2019 14:02:18 -0700 Subject: [PATCH 33/43] =?UTF-8?q?Revert=20"Proposal:=20If=20there=E2=80=99?= =?UTF-8?q?s=20a=20package.json,=20only=20auto-import=20things=20in=20it,?= =?UTF-8?q?=20more=20or=20less=20(#31893)"=20(#32448)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 60a1b1dc1a93ca792cf12bb0432cf7bc134c3ad1. --- src/compiler/utilities.ts | 2 +- src/harness/fourslash.ts | 2 +- src/services/codefixes/importFixes.ts | 124 +-------------- src/services/completions.ts | 150 ++++-------------- src/services/services.ts | 2 +- src/services/stringCompletions.ts | 49 ++++++ src/services/utilities.ts | 49 ------ ...rt_filteredByPackageJson_@typesImplicit.ts | 44 ----- ...Import_filteredByPackageJson_@typesOnly.ts | 44 ----- ...onsImport_filteredByPackageJson_ambient.ts | 30 ---- ...ionsImport_filteredByPackageJson_direct.ts | 46 ------ ...ionsImport_filteredByPackageJson_nested.ts | 66 -------- ...nsImport_filteredByPackageJson_reexport.ts | 58 ------- ...sImport_filteredByPackageJson_reexport2.ts | 58 ------- ...sImport_filteredByPackageJson_reexport3.ts | 48 ------ ...sImport_filteredByPackageJson_reexport4.ts | 57 ------- .../fourslash/completionsImport_ofAlias.ts | 17 +- .../importNameCodeFixNewImportNodeModules8.ts | 2 +- 18 files changed, 97 insertions(+), 751 deletions(-) delete mode 100644 tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesImplicit.ts delete mode 100644 tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesOnly.ts delete mode 100644 tests/cases/fourslash/completionsImport_filteredByPackageJson_ambient.ts delete mode 100644 tests/cases/fourslash/completionsImport_filteredByPackageJson_direct.ts delete mode 100644 tests/cases/fourslash/completionsImport_filteredByPackageJson_nested.ts delete mode 100644 tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport.ts delete mode 100644 tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport2.ts delete mode 100644 tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport3.ts delete mode 100644 tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport4.ts diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index fb5c69c637563..f3282d4372300 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -7485,7 +7485,7 @@ namespace ts { export function getDirectoryPath(path: Path): Path; /** * Returns the path except for its basename. Semantics align with NodeJS's `path.dirname` - * except that we support URLs as well. + * except that we support URL's as well. * * ```ts * getDirectoryPath("/path/to/file.ext") === "/path/to" diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 919352e1391b7..aa764e74cdc44 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -798,7 +798,7 @@ namespace FourSlash { const name = typeof include === "string" ? include : include.name; const found = nameToEntries.get(name); if (!found) throw this.raiseError(`No completion ${name} found`); - assert(found.length === 1, `Must use 'exact' for multiple completions with same name: '${name}'`); + assert(found.length === 1); // Must use 'exact' for multiple completions with same name this.verifyCompletionEntry(ts.first(found), include); } } diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 2fcc8cf5ccbe6..8006d1a0cfd04 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -283,25 +283,13 @@ namespace ts.codefix { preferences: UserPreferences, ): ReadonlyArray { const isJs = isSourceFileJS(sourceFile); - const { allowsImporting } = createLazyPackageJsonDependencyReader(sourceFile, host); const choicesForEachExportingModule = flatMap(moduleSymbols, ({ moduleSymbol, importKind, exportedSymbolIsTypeOnly }) => moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .map((moduleSpecifier): FixAddNewImport | FixUseImportType => // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. exportedSymbolIsTypeOnly && isJs ? { kind: ImportFixKind.ImportType, moduleSpecifier, position: Debug.assertDefined(position) } : { kind: ImportFixKind.AddNew, moduleSpecifier, importKind })); - - // Sort by presence in package.json, then shortest paths first - return sort(choicesForEachExportingModule, (a, b) => { - const allowsImportingA = allowsImporting(a.moduleSpecifier); - const allowsImportingB = allowsImporting(b.moduleSpecifier); - if (allowsImportingA && !allowsImportingB) { - return -1; - } - if (allowsImportingB && !allowsImportingA) { - return 1; - } - return a.moduleSpecifier.length - b.moduleSpecifier.length; - }); + // Sort to keep the shortest paths first + return sort(choicesForEachExportingModule, (a, b) => a.moduleSpecifier.length - b.moduleSpecifier.length); } function getFixesForAddImport( @@ -392,8 +380,7 @@ namespace ts.codefix { // "default" is a keyword and not a legal identifier for the import, so we don't expect it here Debug.assert(symbolName !== InternalSymbolName.Default); - const exportInfos = getExportInfos(symbolName, getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, preferences, host); - const fixes = arrayFrom(flatMapIterator(exportInfos.entries(), ([_, exportInfos]) => + const fixes = arrayFrom(flatMapIterator(getExportInfos(symbolName, getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), ([_, exportInfos]) => getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences))); return { fixes, symbolName }; } @@ -406,8 +393,6 @@ namespace ts.codefix { sourceFile: SourceFile, checker: TypeChecker, program: Program, - preferences: UserPreferences, - host: LanguageServiceHost ): ReadonlyMap> { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). @@ -415,7 +400,7 @@ namespace ts.codefix { function addSymbol(moduleSymbol: Symbol, exportedSymbol: Symbol, importKind: ImportKind): void { originalSymbolToExportInfos.add(getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol, importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); } - forEachExternalModuleToImportFrom(checker, host, preferences, program.redirectTargetsMap, sourceFile, program.getSourceFiles(), moduleSymbol => { + forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), moduleSymbol => { cancellationToken.throwIfCancellationRequested(); const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, program.getCompilerOptions()); @@ -576,44 +561,12 @@ namespace ts.codefix { return some(declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)); } - export function forEachExternalModuleToImportFrom(checker: TypeChecker, host: LanguageServiceHost, preferences: UserPreferences, redirectTargetsMap: RedirectTargetsMap, from: SourceFile, allSourceFiles: ReadonlyArray, cb: (module: Symbol) => void) { - const { allowsImporting } = createLazyPackageJsonDependencyReader(from, host); - const compilerOptions = host.getCompilationSettings(); - const getCanonicalFileName = hostGetCanonicalFileName(host); + export function forEachExternalModuleToImportFrom(checker: TypeChecker, from: SourceFile, allSourceFiles: ReadonlyArray, cb: (module: Symbol) => void) { forEachExternalModule(checker, allSourceFiles, (module, sourceFile) => { - if (sourceFile === undefined && allowsImporting(stripQuotes(module.getName()))) { + if (sourceFile === undefined || sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { cb(module); } - else if (sourceFile && sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { - const moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName); - if (!moduleSpecifier || allowsImporting(moduleSpecifier)) { - cb(module); - } - } }); - - function getNodeModulesPackageNameFromFileName(importedFileName: string): string | undefined { - const specifier = moduleSpecifiers.getModuleSpecifier( - compilerOptions, - from, - toPath(from.fileName, /*basePath*/ undefined, getCanonicalFileName), - importedFileName, - host, - allSourceFiles, - preferences, - redirectTargetsMap); - - // Paths here are not node_modules, so we don’t care about them; - // returning anything will trigger a lookup in package.json. - if (!pathIsRelative(specifier) && !isRootedDiskPath(specifier)) { - const components = getPathComponents(getPackageNameFromTypesPackageName(specifier)).slice(1); - // Scoped packages - if (startsWith(components[0], "@")) { - return `${components[0]}/${components[1]}`; - } - return components[0]; - } - } } function forEachExternalModule(checker: TypeChecker, allSourceFiles: ReadonlyArray, cb: (module: Symbol, sourceFile: SourceFile | undefined) => void) { @@ -667,69 +620,4 @@ namespace ts.codefix { // Need `|| "_"` to ensure result isn't empty. return !isStringANonContextualKeyword(res) ? res || "_" : `_${res}`; } - - function createLazyPackageJsonDependencyReader(fromFile: SourceFile, host: LanguageServiceHost) { - const packageJsonPaths = findPackageJsons(getDirectoryPath(fromFile.fileName), host); - const dependencyIterator = readPackageJsonDependencies(host, packageJsonPaths); - let seenDeps: Map | undefined; - let usesNodeCoreModules: boolean | undefined; - return { allowsImporting }; - - function containsDependency(dependency: string) { - if ((seenDeps || (seenDeps = createMap())).has(dependency)) { - return true; - } - let packageName: string | void; - while (packageName = dependencyIterator.next().value) { - seenDeps.set(packageName, true); - if (packageName === dependency) { - return true; - } - } - return false; - } - - function allowsImporting(moduleSpecifier: string): boolean { - if (!packageJsonPaths.length) { - return true; - } - - // If we’re in JavaScript, it can be difficult to tell whether the user wants to import - // from Node core modules or not. We can start by seeing if the user is actually using - // any node core modules, as opposed to simply having @types/node accidentally as a - // dependency of a dependency. - if (isSourceFileJS(fromFile) && JsTyping.nodeCoreModules.has(moduleSpecifier)) { - if (usesNodeCoreModules === undefined) { - usesNodeCoreModules = consumesNodeCoreModules(fromFile); - } - if (usesNodeCoreModules) { - return true; - } - } - - return containsDependency(moduleSpecifier) - || containsDependency(getTypesPackageName(moduleSpecifier)); - } - } - - function *readPackageJsonDependencies(host: LanguageServiceHost, packageJsonPaths: string[]) { - type PackageJson = Record | undefined>; - const dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies"] as const; - for (const fileName of packageJsonPaths) { - const content = readJson(fileName, { readFile: host.readFile ? host.readFile.bind(host) : sys.readFile }) as PackageJson; - for (const key of dependencyKeys) { - const dependencies = content[key]; - if (!dependencies) { - continue; - } - for (const packageName in dependencies) { - yield packageName; - } - } - } - } - - function consumesNodeCoreModules(sourceFile: SourceFile): boolean { - return some(sourceFile.imports, ({ text }) => JsTyping.nodeCoreModules.has(text)); - } } diff --git a/src/services/completions.ts b/src/services/completions.ts index d7b40d14587c3..b5c412a788ae4 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -64,7 +64,7 @@ namespace ts.Completions { return getLabelCompletionAtPosition(contextToken.parent); } - const completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined, host); + const completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined); if (!completionData) { return undefined; } @@ -407,10 +407,10 @@ namespace ts.Completions { previousToken: Node | undefined; readonly isJsxInitializer: IsJsxInitializer; } - function getSymbolCompletionFromEntryId(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier, host: LanguageServiceHost + function getSymbolCompletionFromEntryId(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier, ): SymbolCompletion | { type: "request", request: Request } | { type: "literal", literal: string | number | PseudoBigInt } | { type: "none" } { const compilerOptions = program.getCompilerOptions(); - const completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); + const completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); if (!completionData) { return { type: "none" }; } @@ -472,7 +472,7 @@ namespace ts.Completions { } // Compute all the completion symbols again. - const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); + const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); switch (symbolCompletion.type) { case "request": { const { request } = symbolCompletion; @@ -557,8 +557,8 @@ namespace ts.Completions { return { sourceDisplay: [textPart(moduleSpecifier)], codeActions: [codeAction] }; } - export function getCompletionEntrySymbol(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier, host: LanguageServiceHost): Symbol | undefined { - const completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); + export function getCompletionEntrySymbol(program: Program, log: Log, sourceFile: SourceFile, position: number, entryId: CompletionEntryIdentifier): Symbol | undefined { + const completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); return completion.type === "symbol" ? completion.symbol : undefined; } @@ -657,7 +657,6 @@ namespace ts.Completions { position: number, preferences: Pick, detailsEntryId: CompletionEntryIdentifier | undefined, - host: LanguageServiceHost ): CompletionData | Request | undefined { const typeChecker = program.getTypeChecker(); @@ -1150,7 +1149,7 @@ namespace ts.Completions { } if (shouldOfferImportCompletions()) { - getSymbolsFromOtherSourceFileExports(symbols, previousToken && isIdentifier(previousToken) ? previousToken.text : "", program.getCompilerOptions().target!, host); + getSymbolsFromOtherSourceFileExports(symbols, previousToken && isIdentifier(previousToken) ? previousToken.text : "", program.getCompilerOptions().target!); } filterGlobalCompletion(symbols); } @@ -1268,64 +1267,12 @@ namespace ts.Completions { typeChecker.getExportsOfModule(sym).some(e => symbolCanBeReferencedAtTypeLocation(e, seenModules)); } - /** - * Gathers symbols that can be imported from other files, deduplicating along the way. Symbols can be “duplicates” - * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but - * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, - * if and only if the the first can be imported (it may be excluded due to package.json filtering in - * `codefix.forEachExternalModuleToImportFrom`). - * - * Example. Imagine a chain of node_modules re-exporting one original symbol: - * - * ```js - * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js - * +-----------------------+ +--------------------------+ +--------------------------+ - * | | | | | | - * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | - * | | | | | | - * +-----------------------+ +--------------------------+ +--------------------------+ - * ``` - * - * Also imagine three buckets, which we’ll reference soon: - * - * ```md - * | | | | | | - * | **Bucket A** | | **Bucket B** | | **Bucket C** | - * | Symbols to | | Aliases to symbols | | Symbols to return | - * | definitely | | in Buckets A or C | | if nothing better | - * | return | | (don’t return these) | | comes along | - * |__________________| |______________________| |___________________| - * ``` - * - * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it - * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not - * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we - * may not be sure whether or not it should go in the list. So, we’ll take the following steps: - * - * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is - * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B - * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. - * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. - * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' - * should never be returned in the final list, so put it in Bucket B. - * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so - * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. - * Put this symbol in Bucket A. - * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t - * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move - * everything from Bucket C to Bucket A. - * - * Note: Bucket A is passed in as the parameter `symbols` and mutated. - */ - function getSymbolsFromOtherSourceFileExports(/** Bucket A */ symbols: Symbol[], tokenText: string, target: ScriptTarget, host: LanguageServiceHost): void { + function getSymbolsFromOtherSourceFileExports(symbols: Symbol[], tokenText: string, target: ScriptTarget): void { const tokenTextLowerCase = tokenText.toLowerCase(); + const seenResolvedModules = createMap(); - /** Bucket B */ - const aliasesToAlreadyIncludedSymbols = createMap(); - /** Bucket C */ - const aliasesToReturnIfOriginalsAreMissing = createMap<{ alias: Symbol, moduleSymbol: Symbol }>(); - codefix.forEachExternalModuleToImportFrom(typeChecker, host, preferences, program.redirectTargetsMap, sourceFile, program.getSourceFiles(), moduleSymbol => { + codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), moduleSymbol => { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; @@ -1346,58 +1293,32 @@ namespace ts.Completions { symbolToOriginInfoMap[getSymbolId(resolvedModuleSymbol)] = { kind: SymbolOriginInfoKind.Export, moduleSymbol, isDefaultExport: false }; } - for (const symbol of typeChecker.getExportsOfModule(moduleSymbol)) { - // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. - if (some(symbol.declarations, d => isExportSpecifier(d) && !!d.propertyName && isIdentifierANonContextualKeyword(d.name))) { + for (let symbol of typeChecker.getExportsOfModule(moduleSymbol)) { + // Don't add a completion for a re-export, only for the original. + // The actual import fix might end up coming from a re-export -- we don't compute that until getting completion details. + // This is just to avoid adding duplicate completion entries. + // + // If `symbol.parent !== ...`, this is an `export * from "foo"` re-export. Those don't create new symbols. + if (typeChecker.getMergedSymbol(symbol.parent!) !== resolvedModuleSymbol + || some(symbol.declarations, d => + // If `!!d.name.originalKeywordKind`, this is `export { _break as break };` -- skip this and prefer the keyword completion. + // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + isExportSpecifier(d) && (d.propertyName ? isIdentifierANonContextualKeyword(d.name) : !!d.parent.parent.moduleSpecifier))) { continue; } - // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. - const isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent!) !== resolvedModuleSymbol; - // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - if (isExportStarFromReExport || some(symbol.declarations, d => isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier)) { - // Walk the export chain back one module (step 1 or 2 in diagrammed example). - // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. - const nearestExportSymbolId = getSymbolId(isExportStarFromReExport ? symbol : Debug.assertDefined(getNearestExportSymbol(symbol))); - const symbolHasBeenSeen = !!symbolToOriginInfoMap[nearestExportSymbolId] || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId.toString()); - if (!symbolHasBeenSeen) { - aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId.toString(), { alias: symbol, moduleSymbol }); - aliasesToAlreadyIncludedSymbols.set(getSymbolId(symbol).toString(), true); - } - else { - // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here - // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. - addToSeen(aliasesToAlreadyIncludedSymbols, getSymbolId(symbol)); - } - } - else { - // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.delete(getSymbolId(symbol).toString()); - pushSymbol(symbol, moduleSymbol); - } - } - }); - // By this point, any potential duplicates that were actually duplicates have been - // removed, so the rest need to be added. (Step 4 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.forEach(({ alias, moduleSymbol }) => pushSymbol(alias, moduleSymbol)); + const isDefaultExport = symbol.escapedName === InternalSymbolName.Default; + if (isDefaultExport) { + symbol = getLocalSymbolForExportDefault(symbol) || symbol; + } - function pushSymbol(symbol: Symbol, moduleSymbol: Symbol) { - const isDefaultExport = symbol.escapedName === InternalSymbolName.Default; - if (isDefaultExport) { - symbol = getLocalSymbolForExportDefault(symbol) || symbol; - } - const origin: SymbolOriginInfoExport = { kind: SymbolOriginInfoKind.Export, moduleSymbol, isDefaultExport }; - if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) { - symbols.push(symbol); - symbolToSortTextMap[getSymbolId(symbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[getSymbolId(symbol)] = origin; + const origin: SymbolOriginInfoExport = { kind: SymbolOriginInfoKind.Export, moduleSymbol, isDefaultExport }; + if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) { + symbols.push(symbol); + symbolToSortTextMap[getSymbolId(symbol)] = SortText.AutoImportSuggestions; + symbolToOriginInfoMap[getSymbolId(symbol)] = origin; + } } - } - } - - function getNearestExportSymbol(fromSymbol: Symbol) { - return findAlias(typeChecker, fromSymbol, alias => { - return some(alias.declarations, d => isExportSpecifier(d) || !!d.localSymbol); }); } @@ -2322,13 +2243,4 @@ namespace ts.Completions { function binaryExpressionMayBeOpenTag({ left }: BinaryExpression): boolean { return nodeIsMissing(left); } - - function findAlias(typeChecker: TypeChecker, symbol: Symbol, predicate: (symbol: Symbol) => boolean): Symbol | undefined { - let currentAlias: Symbol | undefined = symbol; - while (currentAlias.flags & SymbolFlags.Alias && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { - if (predicate(currentAlias)) { - return currentAlias; - } - } - } } diff --git a/src/services/services.ts b/src/services/services.ts index 2f000bc0f2e95..fab6f88b779e0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1453,7 +1453,7 @@ namespace ts { function getCompletionEntrySymbol(fileName: string, position: number, name: string, source?: string): Symbol | undefined { synchronizeHostData(); - return Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name, source }, host); + return Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name, source }); } function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined { diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 58195b5cb3c50..b287ebdb406a9 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -627,6 +627,30 @@ namespace ts.Completions.StringCompletions { } } + function findPackageJsons(directory: string, host: LanguageServiceHost): string[] { + const paths: string[] = []; + forEachAncestorDirectory(directory, ancestor => { + const currentConfigPath = findConfigFile(ancestor, (f) => tryFileExists(host, f), "package.json"); + if (!currentConfigPath) { + return true; // break out + } + paths.push(currentConfigPath); + }); + return paths; + } + + function findPackageJson(directory: string, host: LanguageServiceHost): string | undefined { + let packageJson: string | undefined; + forEachAncestorDirectory(directory, ancestor => { + if (ancestor === "node_modules") return true; + packageJson = findConfigFile(ancestor, (f) => tryFileExists(host, f), "package.json"); + if (packageJson) { + return true; // break out + } + }); + return packageJson; + } + function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string): ReadonlyArray { if (!host.readFile || !host.fileExists) return emptyArray; @@ -682,6 +706,31 @@ namespace ts.Completions.StringCompletions { const nodeModulesDependencyKeys: ReadonlyArray = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]; + function tryGetDirectories(host: LanguageServiceHost, directoryName: string): string[] { + return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || []; + } + + function tryReadDirectory(host: LanguageServiceHost, path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray): ReadonlyArray { + return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include) || emptyArray; + } + + function tryFileExists(host: LanguageServiceHost, path: string): boolean { + return tryIOAndConsumeErrors(host, host.fileExists, path); + } + + function tryDirectoryExists(host: LanguageServiceHost, path: string): boolean { + return tryAndIgnoreErrors(() => directoryProbablyExists(path, host)) || false; + } + + function tryIOAndConsumeErrors(host: LanguageServiceHost, toApply: ((...a: any[]) => T) | undefined, ...args: any[]) { + return tryAndIgnoreErrors(() => toApply && toApply.apply(host, args)); + } + + function tryAndIgnoreErrors(cb: () => T): T | undefined { + try { return cb(); } + catch { return undefined; } + } + function containsSlash(fragment: string) { return stringContains(fragment, directorySeparator); } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 98406c6879cae..852d22106a28f 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -2022,53 +2022,4 @@ namespace ts { // If even 2/5 places have a semicolon, the user probably wants semicolons return withSemicolon / withoutSemicolon > 1 / nStatementsToObserve; } - - export function tryGetDirectories(host: LanguageServiceHost, directoryName: string): string[] { - return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || []; - } - - export function tryReadDirectory(host: LanguageServiceHost, path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray): ReadonlyArray { - return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include) || emptyArray; - } - - export function tryFileExists(host: LanguageServiceHost, path: string): boolean { - return tryIOAndConsumeErrors(host, host.fileExists, path); - } - - export function tryDirectoryExists(host: LanguageServiceHost, path: string): boolean { - return tryAndIgnoreErrors(() => directoryProbablyExists(path, host)) || false; - } - - export function tryAndIgnoreErrors(cb: () => T): T | undefined { - try { return cb(); } - catch { return undefined; } - } - - export function tryIOAndConsumeErrors(host: LanguageServiceHost, toApply: ((...a: any[]) => T) | undefined, ...args: any[]) { - return tryAndIgnoreErrors(() => toApply && toApply.apply(host, args)); - } - - export function findPackageJsons(directory: string, host: LanguageServiceHost): string[] { - const paths: string[] = []; - forEachAncestorDirectory(directory, ancestor => { - const currentConfigPath = findConfigFile(ancestor, (f) => tryFileExists(host, f), "package.json"); - if (!currentConfigPath) { - return true; // break out - } - paths.push(currentConfigPath); - }); - return paths; - } - - export function findPackageJson(directory: string, host: LanguageServiceHost): string | undefined { - let packageJson: string | undefined; - forEachAncestorDirectory(directory, ancestor => { - if (ancestor === "node_modules") return true; - packageJson = findConfigFile(ancestor, (f) => tryFileExists(host, f), "package.json"); - if (packageJson) { - return true; // break out - } - }); - return packageJson; - } } diff --git a/tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesImplicit.ts b/tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesImplicit.ts deleted file mode 100644 index 539a9cc8ff6c2..0000000000000 --- a/tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesImplicit.ts +++ /dev/null @@ -1,44 +0,0 @@ -/// - -//@noEmit: true - -//@Filename: /package.json -////{ -//// "dependencies": { -//// "react": "*" -//// } -////} - -//@Filename: /node_modules/@types/react/index.d.ts -////export declare var React: any; - -//@Filename: /node_modules/@types/react/package.json -////{ -//// "name": "@types/react" -////} - -//@Filename: /node_modules/@types/fake-react/index.d.ts -////export declare var ReactFake: any; - -//@Filename: /node_modules/@types/fake-react/package.json -////{ -//// "name": "@types/fake-react" -////} - -//@Filename: /src/index.ts -////const x = Re/**/ - -verify.completions({ - marker: test.marker(""), - isNewIdentifierLocation: true, - includes: { - name: "React", - hasAction: true, - source: "/node_modules/@types/react/index", - sortText: completion.SortText.AutoImportSuggestions - }, - excludes: "ReactFake", - preferences: { - includeCompletionsForModuleExports: true - } -}); diff --git a/tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesOnly.ts b/tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesOnly.ts deleted file mode 100644 index b0d2c01e3dbe9..0000000000000 --- a/tests/cases/fourslash/completionsImport_filteredByPackageJson_@typesOnly.ts +++ /dev/null @@ -1,44 +0,0 @@ -/// - -//@noEmit: true - -//@Filename: /package.json -////{ -//// "devDependencies": { -//// "@types/react": "*" -//// } -////} - -//@Filename: /node_modules/@types/react/index.d.ts -////export declare var React: any; - -//@Filename: /node_modules/@types/react/package.json -////{ -//// "name": "@types/react" -////} - -//@Filename: /node_modules/@types/fake-react/index.d.ts -////export declare var ReactFake: any; - -//@Filename: /node_modules/@types/fake-react/package.json -////{ -//// "name": "@types/fake-react" -////} - -//@Filename: /src/index.ts -////const x = Re/**/ - -verify.completions({ - marker: test.marker(""), - isNewIdentifierLocation: true, - includes: { - name: "React", - hasAction: true, - source: "/node_modules/@types/react/index", - sortText: completion.SortText.AutoImportSuggestions - }, - excludes: "ReactFake", - preferences: { - includeCompletionsForModuleExports: true - } -}); diff --git a/tests/cases/fourslash/completionsImport_filteredByPackageJson_ambient.ts b/tests/cases/fourslash/completionsImport_filteredByPackageJson_ambient.ts deleted file mode 100644 index 3dcb9eb66904f..0000000000000 --- a/tests/cases/fourslash/completionsImport_filteredByPackageJson_ambient.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - -//@noEmit: true - -//@Filename: /package.json -////{ -//// "dependencies": { -//// } -////} - -//@Filename: /node_modules/@types/node/timers.d.ts -////declare module "timers" { -//// function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timeout; -////} - -//@Filename: /node_modules/@types/node/package.json -////{ -//// "name": "@types/node", -////} - -//@Filename: /src/index.ts -////setTimeo/**/ - -verify.completions({ - marker: test.marker(""), - exact: completion.globals, - preferences: { - includeCompletionsForModuleExports: true - } -}); diff --git a/tests/cases/fourslash/completionsImport_filteredByPackageJson_direct.ts b/tests/cases/fourslash/completionsImport_filteredByPackageJson_direct.ts deleted file mode 100644 index aa7845daed3d1..0000000000000 --- a/tests/cases/fourslash/completionsImport_filteredByPackageJson_direct.ts +++ /dev/null @@ -1,46 +0,0 @@ -/// - -//@noEmit: true - -//@Filename: /package.json -////{ -//// "dependencies": { -//// "react": "*" -//// } -////} - -//@Filename: /node_modules/react/index.d.ts -////export declare var React: any; - -//@Filename: /node_modules/react/package.json -////{ -//// "name": "react", -//// "types": "./index.d.ts" -////} - -//@Filename: /node_modules/fake-react/index.d.ts -////export declare var ReactFake: any; - -//@Filename: /node_modules/fake-react/package.json -////{ -//// "name": "fake-react", -//// "types": "./index.d.ts" -////} - -//@Filename: /src/index.ts -////const x = Re/**/ - -verify.completions({ - marker: test.marker(""), - isNewIdentifierLocation: true, - includes: { - name: "React", - hasAction: true, - source: "/node_modules/react/index", - sortText: completion.SortText.AutoImportSuggestions - }, - excludes: "ReactFake", - preferences: { - includeCompletionsForModuleExports: true - } -}); diff --git a/tests/cases/fourslash/completionsImport_filteredByPackageJson_nested.ts b/tests/cases/fourslash/completionsImport_filteredByPackageJson_nested.ts deleted file mode 100644 index e940c43e32c6d..0000000000000 --- a/tests/cases/fourslash/completionsImport_filteredByPackageJson_nested.ts +++ /dev/null @@ -1,66 +0,0 @@ -/// - -//@noEmit: true - -//@Filename: /package.json -////{ -//// "dependencies": { -//// "react": "*" -//// } -////} - -//@Filename: /node_modules/react/index.d.ts -////export declare var React: any; - -//@Filename: /node_modules/react/package.json -////{ -//// "name": "react", -//// "types": "./index.d.ts" -////} - -//@Filename: /dir/package.json -////{ -//// "dependencies": { -//// "redux": "*" -//// } -////} - -//@Filename: /dir/node_modules/redux/package.json -////{ -//// "name": "redux", -//// "types": "./index.d.ts" -////} - -//@Filename: /dir/node_modules/redux/index.d.ts -////export declare var Redux: any; - -//@Filename: /dir/index.ts -////const x = Re/**/ - -verify.completions({ - marker: test.marker(""), - isNewIdentifierLocation: true, - includes: { - name: "React", - hasAction: true, - source: "/node_modules/react/index", - sortText: completion.SortText.AutoImportSuggestions - }, - preferences: { - includeCompletionsForModuleExports: true - } -}); - -verify.completions({ - marker: test.marker(""), - isNewIdentifierLocation: true, - includes: { - name: "Redux", - hasAction: true, - source: "/dir/node_modules/redux/index", - sortText: completion.SortText.AutoImportSuggestions - }, - preferences: { - includeCompletionsForModuleExports: true - } -}); diff --git a/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport.ts b/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport.ts deleted file mode 100644 index 8e17a3c3a449b..0000000000000 --- a/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport.ts +++ /dev/null @@ -1,58 +0,0 @@ -/// - -//@noEmit: true - -//@Filename: /package.json -////{ -//// "dependencies": { -//// "@emotion/core": "*" -//// } -////} - -//@Filename: /node_modules/@emotion/css/index.d.ts -////export declare const css: any; -////const css2: any; -////export { css2 }; - -//@Filename: /node_modules/@emotion/css/package.json -////{ -//// "name": "@emotion/css", -//// "types": "./index.d.ts" -////} - -//@Filename: /node_modules/@emotion/core/index.d.ts -////import { css2 } from "@emotion/css"; -////export { css } from "@emotion/css"; -////export { css2 }; - -//@Filename: /node_modules/@emotion/core/package.json -////{ -//// "name": "@emotion/core", -//// "types": "./index.d.ts" -////} - -//@Filename: /src/index.ts -////cs/**/ - -verify.completions({ - marker: test.marker(""), - includes: [ - completion.undefinedVarEntry, - { - name: "css", - source: "/node_modules/@emotion/core/index", - hasAction: true, - sortText: completion.SortText.AutoImportSuggestions - }, - { - name: "css2", - source: "/node_modules/@emotion/core/index", - hasAction: true, - sortText: completion.SortText.AutoImportSuggestions - }, - ...completion.statementKeywordsWithTypes - ], - preferences: { - includeCompletionsForModuleExports: true - } -}); diff --git a/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport2.ts b/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport2.ts deleted file mode 100644 index eb946ce17b42c..0000000000000 --- a/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport2.ts +++ /dev/null @@ -1,58 +0,0 @@ -/// - -//@noEmit: true - -//@Filename: /package.json -////{ -//// "dependencies": { -//// "b_": "*", -//// "_c": "*" -//// } -////} - -//@Filename: /node_modules/a/index.d.ts -////export const foo = 0; - -//@Filename: /node_modules/a/package.json -////{ -//// "name": "a", -//// "types": "./index.d.ts" -////} - -//@Filename: /node_modules/b_/index.d.ts -////export { foo } from "a"; - -//@Filename: /node_modules/b_/package.json -////{ -//// "name": "b_", -//// "types": "./index.d.ts" -////} - -//@Filename: /node_modules/_c/index.d.ts -////export { foo } from "b_"; - -//@Filename: /node_modules/_c/package.json -////{ -//// "name": "_c", -//// "types": "./index.d.ts" -////} - -//@Filename: /src/index.ts -////fo/**/ - -verify.completions({ - marker: test.marker(""), - includes: [ - completion.undefinedVarEntry, - { - name: "foo", - source: "/node_modules/b_/index", - hasAction: true, - sortText: completion.SortText.AutoImportSuggestions - }, - ...completion.statementKeywordsWithTypes - ], - preferences: { - includeCompletionsForModuleExports: true - } -}); diff --git a/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport3.ts b/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport3.ts deleted file mode 100644 index 8533461e0b805..0000000000000 --- a/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport3.ts +++ /dev/null @@ -1,48 +0,0 @@ -/// - -//@noEmit: true - -//@Filename: /package.json -////{ -//// "dependencies": { -//// "b": "*", -//// } -////} - -//@Filename: /node_modules/a/index.d.ts -////export const foo = 0; - -//@Filename: /node_modules/a/package.json -////{ -//// "name": "a", -//// "types": "./index.d.ts" -////} - -//@Filename: /node_modules/b/index.d.ts -////export * from "a"; - -//@Filename: /node_modules/b/package.json -////{ -//// "name": "b", -//// "types": "./index.d.ts" -////} - -//@Filename: /src/index.ts -////fo/**/ - -verify.completions({ - marker: test.marker(""), - includes: [ - completion.undefinedVarEntry, - { - name: "foo", - source: "/node_modules/b/index", - hasAction: true, - sortText: completion.SortText.AutoImportSuggestions - }, - ...completion.statementKeywordsWithTypes - ], - preferences: { - includeCompletionsForModuleExports: true - } -}); diff --git a/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport4.ts b/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport4.ts deleted file mode 100644 index 83ac6526b2586..0000000000000 --- a/tests/cases/fourslash/completionsImport_filteredByPackageJson_reexport4.ts +++ /dev/null @@ -1,57 +0,0 @@ -/// - -//@noEmit: true - -//@Filename: /package.json -////{ -//// "dependencies": { -//// "c": "*", -//// } -////} - -//@Filename: /node_modules/a/index.d.ts -////export const foo = 0; - -//@Filename: /node_modules/a/package.json -////{ -//// "name": "a", -//// "types": "./index.d.ts" -////} - -//@Filename: /node_modules/b/index.d.ts -////export * from "a"; - -//@Filename: /node_modules/b/package.json -////{ -//// "name": "b", -//// "types": "./index.d.ts" -////} - -//@Filename: /node_modules/c/index.d.ts -////export * from "a"; - -//@Filename: /node_modules/c/package.json -////{ -//// "name": "c", -//// "types": "./index.d.ts" -////} - -//@Filename: /src/index.ts -////fo/**/ - -verify.completions({ - marker: test.marker(""), - includes: [ - completion.undefinedVarEntry, - { - name: "foo", - source: "/node_modules/c/index", - hasAction: true, - sortText: completion.SortText.AutoImportSuggestions - }, - ...completion.statementKeywordsWithTypes - ], - preferences: { - includeCompletionsForModuleExports: true - } -}); diff --git a/tests/cases/fourslash/completionsImport_ofAlias.ts b/tests/cases/fourslash/completionsImport_ofAlias.ts index 1319391eb0bf1..9a9cb4a2b18c1 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias.ts @@ -16,9 +16,6 @@ // @Filename: /a_reexport_2.ts ////export * from "./a"; -// @Filename: /a_reexport_3.ts -////export { foo } from "./a_reexport"; - // @Filename: /b.ts ////fo/**/ @@ -27,13 +24,13 @@ verify.completions({ includes: [ completion.undefinedVarEntry, { - name: "foo", - source: "/a", - sourceDisplay: "./a", - text: "(alias) const foo: 0\nexport foo", - kind: "alias", - hasAction: true, - sortText: completion.SortText.AutoImportSuggestions + name: "foo", + source: "/a", + sourceDisplay: "./a", + text: "(alias) const foo: 0\nexport foo", + kind: "alias", + hasAction: true, + sortText: completion.SortText.AutoImportSuggestions }, ...completion.statementKeywordsWithTypes, ], diff --git a/tests/cases/fourslash/importNameCodeFixNewImportNodeModules8.ts b/tests/cases/fourslash/importNameCodeFixNewImportNodeModules8.ts index acfddd587f7ae..f048f0d30d253 100644 --- a/tests/cases/fourslash/importNameCodeFixNewImportNodeModules8.ts +++ b/tests/cases/fourslash/importNameCodeFixNewImportNodeModules8.ts @@ -3,7 +3,7 @@ //// [|f1/*0*/('');|] // @Filename: package.json -//// { "dependencies": { "@scope/package-name": "latest" } } +//// { "dependencies": { "package-name": "latest" } } // @Filename: node_modules/@scope/package-name/bin/lib/index.d.ts //// export function f1(text: string): string; From 69ec5e03663bc2ad25ae11b20baf0eb767ce3d5d Mon Sep 17 00:00:00 2001 From: csigs Date: Wed, 17 Jul 2019 22:10:20 +0000 Subject: [PATCH 34/43] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index 8d7a0a4acbd72..5ba07d067e16f 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1,4 +1,4 @@ - + @@ -3300,7 +3300,7 @@ - + @@ -4122,7 +4122,7 @@ - + From 7f071d2a1bda299cf3ac4eacb8abae951a095534 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Wed, 17 Jul 2019 18:21:53 -0400 Subject: [PATCH 35/43] Set the ScriptTarget of ESNext to be 99 so it doesn't change between releases --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 439dfb5f98ec9..6d46d36d167f4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4808,7 +4808,7 @@ namespace ts { ES2018 = 5, ES2019 = 6, ES2020 = 7, - ESNext = 8, + ESNext = 99, JSON = 100, Latest = ESNext, } From a24e4b0d2ca34b6ad12aae9218ea4e2f9ddd32f4 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Wed, 17 Jul 2019 18:24:35 -0400 Subject: [PATCH 36/43] Undo accidental push to master --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6d46d36d167f4..439dfb5f98ec9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4808,7 +4808,7 @@ namespace ts { ES2018 = 5, ES2019 = 6, ES2020 = 7, - ESNext = 99, + ESNext = 8, JSON = 100, Latest = ESNext, } From 5f6cdf17ea0441f42190610254c9d7f0c024459e Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Wed, 17 Jul 2019 18:27:29 -0400 Subject: [PATCH 37/43] Set the ScriptTarget of ESNext to be 99 so it doesn't change between releases --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 439dfb5f98ec9..6d46d36d167f4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4808,7 +4808,7 @@ namespace ts { ES2018 = 5, ES2019 = 6, ES2020 = 7, - ESNext = 8, + ESNext = 99, JSON = 100, Latest = ESNext, } From 282e72419b2421c2d3b86d18a15256602df530a1 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Wed, 17 Jul 2019 22:56:28 -0400 Subject: [PATCH 38/43] Set the ModuleKind value for ESNext to be 99 so it doesn't change between releases (and yet another module system?!) --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6d46d36d167f4..67c85147aed22 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4760,7 +4760,7 @@ namespace ts { UMD = 3, System = 4, ES2015 = 5, - ESNext = 6 + ESNext = 99 } export const enum JsxEmit { From 0c4422e47203cc3a5b3680aac443ab031c03c1fb Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Thu, 18 Jul 2019 11:08:39 -0400 Subject: [PATCH 39/43] Adds baseline updates --- tests/baselines/reference/api/tsserverlibrary.d.ts | 6 +++--- tests/baselines/reference/api/typescript.d.ts | 6 +++--- .../sample1/initial-Build/when-target-option-changes.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 1810cb020e337..c2bad61505ba7 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2600,7 +2600,7 @@ declare namespace ts { UMD = 3, System = 4, ES2015 = 5, - ESNext = 6 + ESNext = 99 } enum JsxEmit { None = 0, @@ -2640,9 +2640,9 @@ declare namespace ts { ES2018 = 5, ES2019 = 6, ES2020 = 7, - ESNext = 8, + ESNext = 99, JSON = 100, - Latest = 8 + Latest = 99 } enum LanguageVariant { Standard = 0, diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index f74b4b1468397..7a2559bbc2242 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2600,7 +2600,7 @@ declare namespace ts { UMD = 3, System = 4, ES2015 = 5, - ESNext = 6 + ESNext = 99 } enum JsxEmit { None = 0, @@ -2640,9 +2640,9 @@ declare namespace ts { ES2018 = 5, ES2019 = 6, ES2020 = 7, - ESNext = 8, + ESNext = 99, JSON = 100, - Latest = 8 + Latest = 99 } enum LanguageVariant { Standard = 0, diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-target-option-changes.js b/tests/baselines/reference/tsbuild/sample1/initial-Build/when-target-option-changes.js index 895ac5e4bc5b1..c31d39c06474b 100644 --- a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-target-option-changes.js +++ b/tests/baselines/reference/tsbuild/sample1/initial-Build/when-target-option-changes.js @@ -70,7 +70,7 @@ export function multiply(a, b) { return a * b; } "incremental": true, "listFiles": true, "listEmittedFiles": true, - "target": 8, + "target": 99, "configFilePath": "./tsconfig.json" }, "referencedMap": {}, From c30ba7884c76a9e94772c0c89604cb6cbfaced99 Mon Sep 17 00:00:00 2001 From: Jake Boone Date: Thu, 18 Jul 2019 12:38:14 -0700 Subject: [PATCH 40/43] Fix capitalization in parseInt description --- src/lib/es5.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 0d1481dd7d26b..2594344decc25 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -12,7 +12,7 @@ declare var Infinity: number; declare function eval(x: string): any; /** - * Converts A string to an integer. + * Converts a string to an integer. * @param s A string to convert into a number. * @param radix A value between 2 and 36 that specifies the base of the number in numString. * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. From 90afd6d620f30bc47e862970a931ca0e207e6b28 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Fri, 19 Jul 2019 09:01:05 -0700 Subject: [PATCH 41/43] Update user baselines (#32483) --- .../baselines/reference/docker/azure-sdk.log | 58 ++++++------------- .../reference/docker/office-ui-fabric.log | 16 ++--- .../reference/user/adonis-framework.log | 2 +- .../user/chrome-devtools-frontend.log | 3 +- tests/baselines/reference/user/lodash.log | 2 - tests/baselines/reference/user/npmlog.log | 6 +- 6 files changed, 33 insertions(+), 54 deletions(-) diff --git a/tests/baselines/reference/docker/azure-sdk.log b/tests/baselines/reference/docker/azure-sdk.log index a1e33524e6e1c..a75af93aee143 100644 --- a/tests/baselines/reference/docker/azure-sdk.log +++ b/tests/baselines/reference/docker/azure-sdk.log @@ -5,16 +5,11 @@ Rush Multi-Project Build Tool 5.10.1 - https://rushjs.io Starting "rush rebuild" Executing a maximum of 1 simultaneous processes... [@azure/cosmos] started -npm ERR! code ELIFECYCLE -npm ERR! errno 2 -npm ERR! @azure/cosmos@X.X.X compile: `echo Using TypeScript && tsc --version && tsc -p tsconfig.prod.json --pretty` -npm ERR! Exit status 2 -npm ERR! -npm ERR! Failed at the @azure/cosmos@X.X.X compile script. -npm ERR! This is probably not a problem with npm. There is likely additional logging output above. -npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-15T13_35_10_789Z-debug.log +XX of XX: [@azure/cosmos] completed successfully in ? seconds +[@azure/event-processor-host] started +XX of XX: [@azure/event-processor-host] completed successfully in ? seconds [@azure/service-bus] started +Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md [@azure/storage-blob] started XX of XX: [@azure/storage-blob] completed successfully in ? seconds [@azure/storage-file] started @@ -23,6 +18,8 @@ XX of XX: [@azure/storage-file] completed successfully in ? seconds XX of XX: [@azure/storage-queue] completed successfully in ? seconds [@azure/template] started XX of XX: [@azure/template] completed successfully in ? seconds +[testhub] started +XX of XX: [testhub] completed successfully in ? seconds [@azure/abort-controller] started XX of XX: [@azure/abort-controller] completed successfully in ? seconds [@azure/core-asynciterator-polyfill] started @@ -38,7 +35,7 @@ npm ERR! npm ERR! Failed at the @azure/core-http@X.X.X-preview.1 build:tsc script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-15T13_36_24_862Z-debug.log +npm ERR! /root/.npm/_logs/2019-07-19T13_40_31_496Z-debug.log ERROR: "build:tsc" exited with 2. npm ERR! code ELIFECYCLE npm ERR! errno 1 @@ -48,20 +45,17 @@ npm ERR! npm ERR! Failed at the @azure/core-http@X.X.X-preview.1 build:lib script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-15T13_36_24_938Z-debug.log +npm ERR! /root/.npm/_logs/2019-07-19T13_40_31_533Z-debug.log ERROR: "build:lib" exited with 1. [@azure/core-paging] started XX of XX: [@azure/core-paging] completed successfully in ? seconds -[@azure/event-processor-host] started -XX of XX: [@azure/event-processor-host] completed successfully in ? seconds -[testhub] started -XX of XX: [testhub] completed successfully in ? seconds -SUCCESS (10) +SUCCESS (11) ================================ @azure/abort-controller (? seconds) @azure/core-asynciterator-polyfill (? seconds) @azure/core-auth (? seconds) @azure/core-paging (? seconds) +@azure/cosmos (? seconds) @azure/event-processor-host (? seconds) @azure/storage-blob (? seconds) @azure/storage-file (? seconds) @@ -69,6 +63,11 @@ SUCCESS (10) @azure/template (? seconds) testhub (? seconds) ================================ +SUCCESS WITH WARNINGS (1) +================================ +@azure/service-bus (? seconds) +Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md +================================ BLOCKED (7) ================================ @azure/core-amqp @@ -79,7 +78,7 @@ BLOCKED (7) @azure/keyvault-keys @azure/keyvault-secrets ================================ -FAILURE (3) +FAILURE (1) ================================ @azure/core-http (? seconds) npm ERR! code ELIFECYCLE @@ -90,7 +89,7 @@ npm ERR! npm ERR! Failed at the @azure/core-http@X.X.X-preview.1 build:tsc script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-15T13_36_24_862Z-debug.log +npm ERR! /root/.npm/_logs/2019-07-19T13_40_31_496Z-debug.log ERROR: "build:tsc" exited with 2. npm ERR! code ELIFECYCLE npm ERR! errno 1 @@ -100,24 +99,8 @@ npm ERR! npm ERR! Failed at the @azure/core-http@X.X.X-preview.1 build:lib script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-15T13_36_24_938Z-debug.log +npm ERR! /root/.npm/_logs/2019-07-19T13_40_31_533Z-debug.log ERROR: "build:lib" exited with 1. -@azure/cosmos ( ? seconds) -npm ERR! code ELIFECYCLE -npm ERR! errno 2 -npm ERR! @azure/cosmos@X.X.X compile: `echo Using TypeScript && tsc --version && tsc -p tsconfig.prod.json --pretty` -npm ERR! Exit status 2 -npm ERR! -npm ERR! Failed at the @azure/cosmos@X.X.X compile script. -npm ERR! This is probably not a problem with npm. There is likely additional logging output above. -npm ERR! A complete log of this run can be found in: -npm ERR! /root/.npm/_logs/2019-07-15T13_35_10_789Z-debug.log -@azure/service-bus ( ? seconds) ->>> @azure/service-bus -tsc -p . && rollup -c 2>&1 && npm run extract-api -error TS2318: Cannot find global type 'AsyncGenerator'. -src/receiver.ts(193,32): error TS2739: Type '{}' is missing the following properties from type 'AsyncIterableIterator': [Symbol.asyncIterator], next -src/receiver.ts(742,32): error TS2322: Type '{}' is not assignable to type 'AsyncIterableIterator'. ================================ Error: Project(s) failed to build rush rebuild - Errors! ( ? seconds) @@ -126,8 +109,7 @@ rush rebuild - Errors! ( ? seconds) Standard error: Your version of Node.js (X.X.X) has not been tested with this release of Rush. The Rush team will not accept issue reports for it. Please consider upgrading Rush or downgrading Node.js. -XX of XX: [@azure/cosmos] failed to build! -XX of XX: [@azure/service-bus] failed to build! +XX of XX: [@azure/service-bus] completed with warnings in ? seconds XX of XX: [@azure/core-http] failed to build! XX of XX: [@azure/core-arm] blocked by [@azure/core-http]! XX of XX: [@azure/identity] blocked by [@azure/core-http]! @@ -137,5 +119,3 @@ XX of XX: [@azure/keyvault-certificates] blocked by [@azure/core-http]! XX of XX: [@azure/keyvault-keys] blocked by [@azure/core-http]! XX of XX: [@azure/keyvault-secrets] blocked by [@azure/core-http]! [@azure/core-http] Returned error code: 1 -[@azure/cosmos] Returned error code: 2 -[@azure/service-bus] Returned error code: 2 diff --git a/tests/baselines/reference/docker/office-ui-fabric.log b/tests/baselines/reference/docker/office-ui-fabric.log index c3a55fc3f6b9e..888e20cac4b10 100644 --- a/tests/baselines/reference/docker/office-ui-fabric.log +++ b/tests/baselines/reference/docker/office-ui-fabric.log @@ -12,11 +12,11 @@ XX of XX: [@uifabric/tslint-rules] completed successfully in ? seconds ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. PASS src/__tests__/codepenTransform.test.ts codepen transform - ✓ handles examples with function components (225ms) + ✓ handles examples with function components (256ms) ✓ handles examples with class components (38ms) - ✓ handles examples importing exampleData (115ms) - ✓ handles examples importing TestImages (45ms) - ✓ handles examples importing PeopleExampleData (288ms) + ✓ handles examples importing exampleData (125ms) + ✓ handles examples importing TestImages (33ms) + ✓ handles examples importing PeopleExampleData (270ms) Test Suites: 1 passed, 1 total Tests: 5 passed, 5 total Snapshots: 4 passed, 4 total @@ -246,11 +246,11 @@ SUCCESS WITH WARNINGS (5) ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. PASS src/__tests__/codepenTransform.test.ts codepen transform - ✓ handles examples with function components (225ms) + ✓ handles examples with function components (256ms) ✓ handles examples with class components (38ms) - ✓ handles examples importing exampleData (115ms) - ✓ handles examples importing TestImages (45ms) - ✓ handles examples importing PeopleExampleData (288ms) + ✓ handles examples importing exampleData (125ms) + ✓ handles examples importing TestImages (33ms) + ✓ handles examples importing PeopleExampleData (270ms) Test Suites: 1 passed, 1 total Tests: 5 passed, 5 total Snapshots: 4 passed, 4 total diff --git a/tests/baselines/reference/user/adonis-framework.log b/tests/baselines/reference/user/adonis-framework.log index e3b19b5de04f0..6243a7a15dba3 100644 --- a/tests/baselines/reference/user/adonis-framework.log +++ b/tests/baselines/reference/user/adonis-framework.log @@ -30,7 +30,7 @@ node_modules/adonis-framework/src/Encryption/index.js(87,15): error TS2304: Cann node_modules/adonis-framework/src/Encryption/index.js(101,21): error TS2769: No overload matches this call. Overload 1 of 4, '(data: Binary, input_encoding: undefined, output_encoding: Utf8AsciiBinaryEncoding): string', gave the following error. Argument of type '"base64"' is not assignable to parameter of type 'undefined'. - Overload 2 of 4, '(data: string, input_encoding: "binary" | "base64" | "hex" | undefined, output_encoding: Utf8AsciiBinaryEncoding): string', gave the following error. + Overload 2 of 4, '(data: string, input_encoding: "base64" | "binary" | "hex" | undefined, output_encoding: Utf8AsciiBinaryEncoding): string', gave the following error. Argument of type 'string' is not assignable to parameter of type 'Utf8AsciiBinaryEncoding'. node_modules/adonis-framework/src/Encryption/index.js(114,15): error TS2304: Cannot find name 'Mixed'. node_modules/adonis-framework/src/Encryption/index.js(119,23): error TS2554: Expected 2 arguments, but got 1. diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 3f4fa8d5b95f1..2d4e456d7593a 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -6501,7 +6501,8 @@ node_modules/chrome-devtools-frontend/front_end/formatter_worker/acorn/acorn_loo node_modules/chrome-devtools-frontend/front_end/formatter_worker/acorn/acorn_loose.js(258,55): error TS2339: Property 'end' does not exist on type 'true'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/acorn/acorn_loose.js(1365,5): error TS2339: Property 'next' does not exist on type 'LooseParser'. node_modules/chrome-devtools-frontend/front_end/formatter_worker/acorn/acorn_loose.js(1366,12): error TS2339: Property 'parseTopLevel' does not exist on type 'LooseParser'. -node_modules/chrome-devtools-frontend/front_end/har_importer/HARImporter.js(26,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'page' must be of type 'any', but here has type 'HARPage'. +node_modules/chrome-devtools-frontend/front_end/har_importer/HARImporter.js(16,32): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. +node_modules/chrome-devtools-frontend/front_end/har_importer/HARImporter.js(16,52): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. node_modules/chrome-devtools-frontend/front_end/har_importer/HARImporter.js(46,5): error TS2322: Type 'Date' is not assignable to type 'number'. node_modules/chrome-devtools-frontend/front_end/heap_profiler_test_runner/HeapProfilerTestRunner.js(320,70): error TS2339: Property 'heap_profiler' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/heap_profiler_test_runner/HeapProfilerTestRunner.js(321,35): error TS2339: Property 'heap_profiler' does not exist on type 'any[]'. diff --git a/tests/baselines/reference/user/lodash.log b/tests/baselines/reference/user/lodash.log index 954077ce729c7..1c358238f8d5c 100644 --- a/tests/baselines/reference/user/lodash.log +++ b/tests/baselines/reference/user/lodash.log @@ -382,8 +382,6 @@ node_modules/lodash/nthArg.js(28,26): error TS2345: Argument of type 'number | u node_modules/lodash/omit.js(48,32): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. node_modules/lodash/orderBy.js(18,10): error TS1003: Identifier expected. node_modules/lodash/orderBy.js(18,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. -node_modules/lodash/org.js(8,22): error TS2307: Cannot find module 'moment'. -node_modules/lodash/org.js(9,19): error TS2307: Cannot find module 'ncp'. node_modules/lodash/parseInt.js(24,10): error TS1003: Identifier expected. node_modules/lodash/parseInt.js(24,10): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. node_modules/lodash/partial.js(48,9): error TS2339: Property 'placeholder' does not exist on type 'Function'. diff --git a/tests/baselines/reference/user/npmlog.log b/tests/baselines/reference/user/npmlog.log index 1e6284674e3ea..6b6e315d99628 100644 --- a/tests/baselines/reference/user/npmlog.log +++ b/tests/baselines/reference/user/npmlog.log @@ -8,9 +8,9 @@ node_modules/npmlog/log.js(194,37): error TS2345: Argument of type 'any[]' is no Property '0' is missing in type 'any[]' but required in type '[any, ...any[]]'. node_modules/npmlog/log.js(218,12): error TS2551: Property '_paused' does not exist on type 'typeof EventEmitter'. Did you mean 'pause'? node_modules/npmlog/log.js(271,16): error TS2769: No overload matches this call. - Overload 1 of 2, '(buffer: string | Uint8Array | Buffer, cb?: ((err?: Error | null | undefined) => void) | undefined): boolean', gave the following error. - Argument of type 'string | undefined' is not assignable to parameter of type 'string | Uint8Array | Buffer'. - Type 'undefined' is not assignable to type 'string | Uint8Array | Buffer'. + Overload 1 of 2, '(buffer: string | Uint8Array, cb?: ((err?: Error | null | undefined) => void) | undefined): boolean', gave the following error. + Argument of type 'string | undefined' is not assignable to parameter of type 'string | Uint8Array'. + Type 'undefined' is not assignable to type 'string | Uint8Array'. Overload 2 of 2, '(str: string, encoding?: string | undefined, cb?: ((err?: Error | null | undefined) => void) | undefined): boolean', gave the following error. Argument of type 'string | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable to type 'string'. From e543d8bc5a17bdee931ac1a0d2b9ddd32a7164a9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 19 Jul 2019 15:22:04 -0700 Subject: [PATCH 42/43] Fix type keyword completions (#32474) * Fix type keyword completions 1. In functions, type keywords were omitted. 2. In All context, no keywords were omitted. (1) fixes #28737 (2) removes 17 keywords that should not be suggested, even at the toplevel of a typescript file: * private * protected * public * static * abstract * as * constructor * get * infer * is * namespace * require * set * type * from * global * of I don't know whether we have a bug tracking this or not. * Change keyword filter in filterGlobalCompletion Instead of changing FunctionLikeBodyKeywords * Add more tests cases * Make type-only completions after < more common Because isPossiblyTypeArgumentPosition doesn't give false positives now that it uses type information. --- src/harness/fourslash.ts | 43 +------------------ src/services/completions.ts | 38 +++++++++------- ...FunctionLikeBody_includesPrimitiveTypes.ts | 27 ++++++++++++ .../completionListInUnclosedTypeArguments.ts | 9 ++-- .../completionListIsGlobalCompletion.ts | 2 +- ...mpletionsIsPossiblyTypeArgumentPosition.ts | 17 +++----- tests/cases/fourslash/fourslash.ts | 1 - tests/cases/user/prettier/prettier | 2 +- 8 files changed, 64 insertions(+), 75 deletions(-) create mode 100644 tests/cases/fourslash/completionInFunctionLikeBody_includesPrimitiveTypes.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index aa764e74cdc44..f12506be2fb27 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -797,7 +797,7 @@ namespace FourSlash { for (const include of toArray(options.includes)) { const name = typeof include === "string" ? include : include.name; const found = nameToEntries.get(name); - if (!found) throw this.raiseError(`No completion ${name} found`); + if (!found) throw this.raiseError(`Includes: completion '${name}' not found.`); assert(found.length === 1); // Must use 'exact' for multiple completions with same name this.verifyCompletionEntry(ts.first(found), include); } @@ -806,7 +806,7 @@ namespace FourSlash { for (const exclude of toArray(options.excludes)) { assert(typeof exclude === "string"); if (nameToEntries.has(exclude)) { - this.raiseError(`Did not expect to get a completion named ${exclude}`); + this.raiseError(`Excludes: unexpected completion '${exclude}' found.`); } } } @@ -4827,40 +4827,23 @@ namespace FourSlashInterface { "interface", "let", "package", - "private", - "protected", - "public", - "static", "yield", - "abstract", - "as", "any", "async", "await", "boolean", - "constructor", "declare", - "get", - "infer", - "is", "keyof", "module", - "namespace", "never", "readonly", - "require", "number", "object", - "set", "string", "symbol", - "type", "unique", "unknown", - "from", - "global", "bigint", - "of", ].map(keywordEntry); export const statementKeywords: ReadonlyArray = statementKeywordsWithTypes.filter(k => { @@ -5041,40 +5024,23 @@ namespace FourSlashInterface { "interface", "let", "package", - "private", - "protected", - "public", - "static", "yield", - "abstract", - "as", "any", "async", "await", "boolean", - "constructor", "declare", - "get", - "infer", - "is", "keyof", "module", - "namespace", "never", "readonly", - "require", "number", "object", - "set", "string", "symbol", - "type", "unique", "unknown", - "from", - "global", "bigint", - "of", ].map(keywordEntry); export const globalInJsKeywords = getInJsKeywords(globalKeywords); @@ -5127,11 +5093,6 @@ namespace FourSlashInterface { export const insideMethodInJsKeywords = getInJsKeywords(insideMethodKeywords); - export const globalKeywordsPlusUndefined: ReadonlyArray = (() => { - const i = ts.findIndex(globalKeywords, x => x.name === "unique"); - return [...globalKeywords.slice(0, i), keywordEntry("undefined"), ...globalKeywords.slice(i)]; - })(); - export const globals: ReadonlyArray = [ globalThisEntry, ...globalsVars, diff --git a/src/services/completions.ts b/src/services/completions.ts index b5c412a788ae4..e9a38fb1516db 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -947,11 +947,13 @@ namespace ts.Completions { // Right of dot member completion list completionKind = CompletionKind.PropertyAccess; - // Since this is qualified name check its a type node location + // Since this is qualified name check it's a type node location const isImportType = isLiteralImportTypeNode(node); - const isTypeLocation = insideJsDocTagTypeExpression || (isImportType && !(node as ImportTypeNode).isTypeOf) || isPartOfTypeNode(node.parent); + const isTypeLocation = insideJsDocTagTypeExpression + || (isImportType && !(node as ImportTypeNode).isTypeOf) + || isPartOfTypeNode(node.parent) + || isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker); const isRhsOfImportDeclaration = isInRightSideOfInternalImportEqualsDeclaration(node); - const allowTypeOrValue = isRhsOfImportDeclaration || (!isTypeLocation && isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker)); if (isEntityName(node) || isImportType) { const isNamespaceName = isModuleDeclaration(node.parent); if (isNamespaceName) isNewIdentifierLocation = true; @@ -968,7 +970,7 @@ namespace ts.Completions { isNamespaceName // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. ? symbol => !!(symbol.flags & SymbolFlags.Namespace) && !symbol.declarations.every(d => d.parent === node.parent) - : allowTypeOrValue ? + : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration symbol => isValidTypeAccess(symbol) || isValidValueAccess(symbol) : isTypeLocation ? isValidTypeAccess : isValidValueAccess; @@ -1181,7 +1183,6 @@ namespace ts.Completions { function filterGlobalCompletion(symbols: Symbol[]): void { const isTypeOnly = isTypeOnlyCompletion(); - const allowTypes = isTypeOnly || !isContextTokenValueLocation(contextToken) && isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker); if (isTypeOnly) { keywordFilters = isTypeAssertion() ? KeywordCompletionFilters.TypeAssertionKeywords @@ -1202,12 +1203,9 @@ namespace ts.Completions { return !!(symbol.flags & SymbolFlags.Namespace); } - if (allowTypes) { - // Its a type, but you can reach it by namespace.type as well - const symbolAllowedAsType = symbolCanBeReferencedAtTypeLocation(symbol); - if (symbolAllowedAsType || isTypeOnly) { - return symbolAllowedAsType; - } + if (isTypeOnly) { + // It's a type, but you can reach it by namespace.type as well + return symbolCanBeReferencedAtTypeLocation(symbol); } } @@ -1221,7 +1219,11 @@ namespace ts.Completions { } function isTypeOnlyCompletion(): boolean { - return insideJsDocTagTypeExpression || !isContextTokenValueLocation(contextToken) && (isPartOfTypeNode(location) || isContextTokenTypeLocation(contextToken)); + return insideJsDocTagTypeExpression + || !isContextTokenValueLocation(contextToken) && + (isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker) + || isPartOfTypeNode(location) + || isContextTokenTypeLocation(contextToken)); } function isContextTokenValueLocation(contextToken: Node) { @@ -2060,16 +2062,18 @@ namespace ts.Completions { case KeywordCompletionFilters.None: return false; case KeywordCompletionFilters.All: - return kind === SyntaxKind.AsyncKeyword || SyntaxKind.AwaitKeyword || !isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind) || kind === SyntaxKind.DeclareKeyword || kind === SyntaxKind.ModuleKeyword + return isFunctionLikeBodyKeyword(kind) + || kind === SyntaxKind.DeclareKeyword + || kind === SyntaxKind.ModuleKeyword || isTypeKeyword(kind) && kind !== SyntaxKind.UndefinedKeyword; + case KeywordCompletionFilters.FunctionLikeBodyKeywords: + return isFunctionLikeBodyKeyword(kind); case KeywordCompletionFilters.ClassElementKeywords: return isClassMemberCompletionKeyword(kind); case KeywordCompletionFilters.InterfaceElementKeywords: return isInterfaceOrTypeLiteralCompletionKeyword(kind); case KeywordCompletionFilters.ConstructorParameterKeywords: return isParameterPropertyModifier(kind); - case KeywordCompletionFilters.FunctionLikeBodyKeywords: - return isFunctionLikeBodyKeyword(kind); case KeywordCompletionFilters.TypeAssertionKeywords: return isTypeKeyword(kind) || kind === SyntaxKind.ConstKeyword; case KeywordCompletionFilters.TypeKeywords: @@ -2132,7 +2136,9 @@ namespace ts.Completions { } function isFunctionLikeBodyKeyword(kind: SyntaxKind) { - return kind === SyntaxKind.AsyncKeyword || kind === SyntaxKind.AwaitKeyword || !isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); + return kind === SyntaxKind.AsyncKeyword + || kind === SyntaxKind.AwaitKeyword + || !isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node: Node): SyntaxKind { diff --git a/tests/cases/fourslash/completionInFunctionLikeBody_includesPrimitiveTypes.ts b/tests/cases/fourslash/completionInFunctionLikeBody_includesPrimitiveTypes.ts new file mode 100644 index 0000000000000..bc94936ab4353 --- /dev/null +++ b/tests/cases/fourslash/completionInFunctionLikeBody_includesPrimitiveTypes.ts @@ -0,0 +1,27 @@ +/// + +//// class Foo { } +//// class Bar { } +//// function includesTypes() { +//// new Foo ////f -////f(); +////f(); //// ////f2 ////f2 -////f2(); +////f2(); //// ////f2 { const markerName = test.markerName(marker) || ""; - const typeOnly = markerName.endsWith("TypeOnly") || marker.data && marker.data.typeOnly; const valueOnly = markerName.endsWith("ValueOnly"); verify.completions({ marker, - includes: typeOnly ? "Type" : valueOnly ? "x" : ["Type", "x"], - excludes: typeOnly ? "x" : valueOnly ? "Type" : [], + includes: valueOnly ? "x" : "Type", + excludes: valueOnly ? "Type" : "x", isNewIdentifierLocation: marker.data && marker.data.newId || false, }); }); diff --git a/tests/cases/fourslash/completionListIsGlobalCompletion.ts b/tests/cases/fourslash/completionListIsGlobalCompletion.ts index ea89155a771c4..91cd1a0f9c7e5 100644 --- a/tests/cases/fourslash/completionListIsGlobalCompletion.ts +++ b/tests/cases/fourslash/completionListIsGlobalCompletion.ts @@ -48,5 +48,5 @@ verify.completions( { marker: "13", exact: globals, isGlobalCompletion: false }, { marker: "15", exact: globals, isGlobalCompletion: true, isNewIdentifierLocation: true }, { marker: "16", exact: [...x, completion.globalThisEntry, ...completion.globalsVars, completion.undefinedVarEntry], isGlobalCompletion: false }, - { marker: "17", exact: completion.globalKeywordsPlusUndefined, isGlobalCompletion: false }, + { marker: "17", exact: completion.globalKeywords, isGlobalCompletion: false }, ); diff --git a/tests/cases/fourslash/completionsIsPossiblyTypeArgumentPosition.ts b/tests/cases/fourslash/completionsIsPossiblyTypeArgumentPosition.ts index 1ea8416d70be7..704fe0d8347a0 100644 --- a/tests/cases/fourslash/completionsIsPossiblyTypeArgumentPosition.ts +++ b/tests/cases/fourslash/completionsIsPossiblyTypeArgumentPosition.ts @@ -9,25 +9,22 @@ ////x + {| "valueOnly": true |} ////x < {| "valueOnly": true |} ////f < {| "valueOnly": true |} -////g < {| "valueOnly": false |} -////const something: C<{| "typeOnly": true |}; -////const something2: C(): callAndConstruct; (): string; }; ////interface callAndConstruct {} ////new callAndConstruct; export const insideMethodKeywords: ReadonlyArray; export const insideMethodInJsKeywords: ReadonlyArray; - export const globalKeywordsPlusUndefined: ReadonlyArray; export const globalsVars: ReadonlyArray; export function globalsInsideFunction(plus: ReadonlyArray): ReadonlyArray; export function globalsInJsInsideFunction(plus: ReadonlyArray): ReadonlyArray; diff --git a/tests/cases/user/prettier/prettier b/tests/cases/user/prettier/prettier index 1e471a007968b..7f938c71ffda2 160000 --- a/tests/cases/user/prettier/prettier +++ b/tests/cases/user/prettier/prettier @@ -1 +1 @@ -Subproject commit 1e471a007968b7490563b91ed6909ae6046f3fe8 +Subproject commit 7f938c71ffda293eb1b69adf8bd12b7c11f9113b From aab3069e643952f5ddfe750fe3e5f196c16c3915 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 19 Jul 2019 15:55:22 -0700 Subject: [PATCH 43/43] Fix the assert of reporting file infos still attached to the project for circular json reference --- src/server/editorServices.ts | 19 ++++++++++++++++++- src/testRunner/unittests/tsserver/projects.ts | 17 +++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 81c56bb179b65..df9f0e3ee0134 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1087,7 +1087,24 @@ namespace ts.server { project.close(); if (Debug.shouldAssert(AssertionLevel.Normal)) { - this.filenameToScriptInfo.forEach(info => Debug.assert(!info.isAttached(project), "Found script Info still attached to project", () => `${project.projectName}: ScriptInfos still attached: ${JSON.stringify(mapDefined(arrayFrom(this.filenameToScriptInfo.values()), info => info.isAttached(project) ? info : undefined))}`)); + this.filenameToScriptInfo.forEach(info => Debug.assert( + !info.isAttached(project), + "Found script Info still attached to project", + () => `${project.projectName}: ScriptInfos still attached: ${JSON.stringify( + arrayFrom( + mapDefinedIterator( + this.filenameToScriptInfo.values(), + info => info.isAttached(project) ? + { + fileName: info.fileName, + projects: info.containingProjects.map(p => p.projectName), + hasMixedContent: info.hasMixedContent + } : undefined + ) + ), + /*replacer*/ undefined, + " " + )}`)); } // Remove the project from pending project updates this.pendingProjectUpdates.delete(project.getProjectName()); diff --git a/src/testRunner/unittests/tsserver/projects.ts b/src/testRunner/unittests/tsserver/projects.ts index 409ce5c525f74..abb21669f8a4a 100644 --- a/src/testRunner/unittests/tsserver/projects.ts +++ b/src/testRunner/unittests/tsserver/projects.ts @@ -1467,5 +1467,22 @@ var x = 10;` openFilesForSession([{ file, projectRootPath }], session); } }); + + it("assert when removing project", () => { + const host = createServerHost([commonFile1, commonFile2, libFile]); + const service = createProjectService(host); + service.openClientFile(commonFile1.path); + const project = service.inferredProjects[0]; + checkProjectActualFiles(project, [commonFile1.path, libFile.path]); + // Intentionally create scriptinfo and attach it to project + const info = service.getOrCreateScriptInfoForNormalizedPath(commonFile2.path as server.NormalizedPath, /*openedByClient*/ false)!; + info.attachToProject(project); + try { + service.applyChangesInOpenFiles(/*openFiles*/ undefined, /*changedFiles*/ undefined, [commonFile1.path]); + } + catch (e) { + assert.isTrue(e.message.indexOf("Debug Failure. False expression: Found script Info still attached to project") === 0); + } + }); }); }