From 5f46d42ad111e8cfc689b47c0532b120d42d2698 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 13 Apr 2020 08:30:59 -0700 Subject: [PATCH 01/74] Error on missing BigInt in es2020 (#37899) * Error on missing BigInt in ES2020 too. Previously it was only on ESNext, but bigint ships in ES 2020. There are no tests for this; passing `false` doesn't cause any tests to fail at least. * add tests --- src/compiler/checker.ts | 2 +- .../baselines/reference/bigintMissingES2019.js | 13 +++++++++++++ .../reference/bigintMissingES2019.symbols | 17 +++++++++++++++++ .../reference/bigintMissingES2019.types | 16 ++++++++++++++++ .../reference/bigintMissingES2020.errors.txt | 12 ++++++++++++ .../baselines/reference/bigintMissingES2020.js | 13 +++++++++++++ .../reference/bigintMissingES2020.symbols | 17 +++++++++++++++++ .../reference/bigintMissingES2020.types | 16 ++++++++++++++++ .../reference/bigintMissingESNext.errors.txt | 12 ++++++++++++ .../baselines/reference/bigintMissingESNext.js | 13 +++++++++++++ .../reference/bigintMissingESNext.symbols | 17 +++++++++++++++++ .../reference/bigintMissingESNext.types | 16 ++++++++++++++++ .../conformance/es2020/bigintMissingES2019.ts | 8 ++++++++ .../conformance/es2020/bigintMissingES2020.ts | 8 ++++++++ .../conformance/es2020/bigintMissingESNext.ts | 8 ++++++++ 15 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/bigintMissingES2019.js create mode 100644 tests/baselines/reference/bigintMissingES2019.symbols create mode 100644 tests/baselines/reference/bigintMissingES2019.types create mode 100644 tests/baselines/reference/bigintMissingES2020.errors.txt create mode 100644 tests/baselines/reference/bigintMissingES2020.js create mode 100644 tests/baselines/reference/bigintMissingES2020.symbols create mode 100644 tests/baselines/reference/bigintMissingES2020.types create mode 100644 tests/baselines/reference/bigintMissingESNext.errors.txt create mode 100644 tests/baselines/reference/bigintMissingESNext.js create mode 100644 tests/baselines/reference/bigintMissingESNext.symbols create mode 100644 tests/baselines/reference/bigintMissingESNext.types create mode 100644 tests/cases/conformance/es2020/bigintMissingES2019.ts create mode 100644 tests/cases/conformance/es2020/bigintMissingES2020.ts create mode 100644 tests/cases/conformance/es2020/bigintMissingESNext.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5cab127293b..ae1f4c4dd84 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10358,7 +10358,7 @@ namespace ts { t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(t) : t.flags & TypeFlags.StringLike ? globalStringType : t.flags & TypeFlags.NumberLike ? globalNumberType : - t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= ScriptTarget.ESNext) : + t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2020) : t.flags & TypeFlags.BooleanLike ? globalBooleanType : t.flags & TypeFlags.ESSymbolLike ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) : t.flags & TypeFlags.NonPrimitive ? emptyObjectType : diff --git a/tests/baselines/reference/bigintMissingES2019.js b/tests/baselines/reference/bigintMissingES2019.js new file mode 100644 index 00000000000..85c82e8da67 --- /dev/null +++ b/tests/baselines/reference/bigintMissingES2019.js @@ -0,0 +1,13 @@ +//// [bigintMissingES2019.ts] +declare function test(): void; + +test<{t?: string}, object>(); +test<{t?: string}, bigint>(); + +// no error when bigint is used even when ES2020 lib is not present + + +//// [bigintMissingES2019.js] +test(); +test(); +// no error when bigint is used even when ES2020 lib is not present diff --git a/tests/baselines/reference/bigintMissingES2019.symbols b/tests/baselines/reference/bigintMissingES2019.symbols new file mode 100644 index 00000000000..d0f2102df04 --- /dev/null +++ b/tests/baselines/reference/bigintMissingES2019.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es2020/bigintMissingES2019.ts === +declare function test(): void; +>test : Symbol(test, Decl(bigintMissingES2019.ts, 0, 0)) +>A : Symbol(A, Decl(bigintMissingES2019.ts, 0, 22)) +>B : Symbol(B, Decl(bigintMissingES2019.ts, 0, 24)) +>A : Symbol(A, Decl(bigintMissingES2019.ts, 0, 22)) + +test<{t?: string}, object>(); +>test : Symbol(test, Decl(bigintMissingES2019.ts, 0, 0)) +>t : Symbol(t, Decl(bigintMissingES2019.ts, 2, 6)) + +test<{t?: string}, bigint>(); +>test : Symbol(test, Decl(bigintMissingES2019.ts, 0, 0)) +>t : Symbol(t, Decl(bigintMissingES2019.ts, 3, 6)) + +// no error when bigint is used even when ES2020 lib is not present + diff --git a/tests/baselines/reference/bigintMissingES2019.types b/tests/baselines/reference/bigintMissingES2019.types new file mode 100644 index 00000000000..a757652768d --- /dev/null +++ b/tests/baselines/reference/bigintMissingES2019.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/es2020/bigintMissingES2019.ts === +declare function test(): void; +>test : () => void + +test<{t?: string}, object>(); +>test<{t?: string}, object>() : void +>test : () => void +>t : string + +test<{t?: string}, bigint>(); +>test<{t?: string}, bigint>() : void +>test : () => void +>t : string + +// no error when bigint is used even when ES2020 lib is not present + diff --git a/tests/baselines/reference/bigintMissingES2020.errors.txt b/tests/baselines/reference/bigintMissingES2020.errors.txt new file mode 100644 index 00000000000..768ee7214c8 --- /dev/null +++ b/tests/baselines/reference/bigintMissingES2020.errors.txt @@ -0,0 +1,12 @@ +error TS2318: Cannot find global type 'BigInt'. + + +!!! error TS2318: Cannot find global type 'BigInt'. +==== tests/cases/conformance/es2020/bigintMissingES2020.ts (0 errors) ==== + declare function test(): void; + + test<{t?: string}, object>(); + test<{t?: string}, bigint>(); + + // should have global error when bigint is used but ES2020 lib is not present + \ No newline at end of file diff --git a/tests/baselines/reference/bigintMissingES2020.js b/tests/baselines/reference/bigintMissingES2020.js new file mode 100644 index 00000000000..83e2cde68e0 --- /dev/null +++ b/tests/baselines/reference/bigintMissingES2020.js @@ -0,0 +1,13 @@ +//// [bigintMissingES2020.ts] +declare function test(): void; + +test<{t?: string}, object>(); +test<{t?: string}, bigint>(); + +// should have global error when bigint is used but ES2020 lib is not present + + +//// [bigintMissingES2020.js] +test(); +test(); +// should have global error when bigint is used but ES2020 lib is not present diff --git a/tests/baselines/reference/bigintMissingES2020.symbols b/tests/baselines/reference/bigintMissingES2020.symbols new file mode 100644 index 00000000000..0757f97759e --- /dev/null +++ b/tests/baselines/reference/bigintMissingES2020.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es2020/bigintMissingES2020.ts === +declare function test(): void; +>test : Symbol(test, Decl(bigintMissingES2020.ts, 0, 0)) +>A : Symbol(A, Decl(bigintMissingES2020.ts, 0, 22)) +>B : Symbol(B, Decl(bigintMissingES2020.ts, 0, 24)) +>A : Symbol(A, Decl(bigintMissingES2020.ts, 0, 22)) + +test<{t?: string}, object>(); +>test : Symbol(test, Decl(bigintMissingES2020.ts, 0, 0)) +>t : Symbol(t, Decl(bigintMissingES2020.ts, 2, 6)) + +test<{t?: string}, bigint>(); +>test : Symbol(test, Decl(bigintMissingES2020.ts, 0, 0)) +>t : Symbol(t, Decl(bigintMissingES2020.ts, 3, 6)) + +// should have global error when bigint is used but ES2020 lib is not present + diff --git a/tests/baselines/reference/bigintMissingES2020.types b/tests/baselines/reference/bigintMissingES2020.types new file mode 100644 index 00000000000..36b26c3a43d --- /dev/null +++ b/tests/baselines/reference/bigintMissingES2020.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/es2020/bigintMissingES2020.ts === +declare function test(): void; +>test : () => void + +test<{t?: string}, object>(); +>test<{t?: string}, object>() : void +>test : () => void +>t : string + +test<{t?: string}, bigint>(); +>test<{t?: string}, bigint>() : void +>test : () => void +>t : string + +// should have global error when bigint is used but ES2020 lib is not present + diff --git a/tests/baselines/reference/bigintMissingESNext.errors.txt b/tests/baselines/reference/bigintMissingESNext.errors.txt new file mode 100644 index 00000000000..381223a9451 --- /dev/null +++ b/tests/baselines/reference/bigintMissingESNext.errors.txt @@ -0,0 +1,12 @@ +error TS2318: Cannot find global type 'BigInt'. + + +!!! error TS2318: Cannot find global type 'BigInt'. +==== tests/cases/conformance/es2020/bigintMissingESNext.ts (0 errors) ==== + declare function test(): void; + + test<{t?: string}, object>(); + test<{t?: string}, bigint>(); + + // should have global error when bigint is used but ES2020 lib is not present + \ No newline at end of file diff --git a/tests/baselines/reference/bigintMissingESNext.js b/tests/baselines/reference/bigintMissingESNext.js new file mode 100644 index 00000000000..5029ca536c2 --- /dev/null +++ b/tests/baselines/reference/bigintMissingESNext.js @@ -0,0 +1,13 @@ +//// [bigintMissingESNext.ts] +declare function test(): void; + +test<{t?: string}, object>(); +test<{t?: string}, bigint>(); + +// should have global error when bigint is used but ES2020 lib is not present + + +//// [bigintMissingESNext.js] +test(); +test(); +// should have global error when bigint is used but ES2020 lib is not present diff --git a/tests/baselines/reference/bigintMissingESNext.symbols b/tests/baselines/reference/bigintMissingESNext.symbols new file mode 100644 index 00000000000..bd500ba04b0 --- /dev/null +++ b/tests/baselines/reference/bigintMissingESNext.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es2020/bigintMissingESNext.ts === +declare function test(): void; +>test : Symbol(test, Decl(bigintMissingESNext.ts, 0, 0)) +>A : Symbol(A, Decl(bigintMissingESNext.ts, 0, 22)) +>B : Symbol(B, Decl(bigintMissingESNext.ts, 0, 24)) +>A : Symbol(A, Decl(bigintMissingESNext.ts, 0, 22)) + +test<{t?: string}, object>(); +>test : Symbol(test, Decl(bigintMissingESNext.ts, 0, 0)) +>t : Symbol(t, Decl(bigintMissingESNext.ts, 2, 6)) + +test<{t?: string}, bigint>(); +>test : Symbol(test, Decl(bigintMissingESNext.ts, 0, 0)) +>t : Symbol(t, Decl(bigintMissingESNext.ts, 3, 6)) + +// should have global error when bigint is used but ES2020 lib is not present + diff --git a/tests/baselines/reference/bigintMissingESNext.types b/tests/baselines/reference/bigintMissingESNext.types new file mode 100644 index 00000000000..6665aac1d5c --- /dev/null +++ b/tests/baselines/reference/bigintMissingESNext.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/es2020/bigintMissingESNext.ts === +declare function test(): void; +>test : () => void + +test<{t?: string}, object>(); +>test<{t?: string}, object>() : void +>test : () => void +>t : string + +test<{t?: string}, bigint>(); +>test<{t?: string}, bigint>() : void +>test : () => void +>t : string + +// should have global error when bigint is used but ES2020 lib is not present + diff --git a/tests/cases/conformance/es2020/bigintMissingES2019.ts b/tests/cases/conformance/es2020/bigintMissingES2019.ts new file mode 100644 index 00000000000..eb43cef7986 --- /dev/null +++ b/tests/cases/conformance/es2020/bigintMissingES2019.ts @@ -0,0 +1,8 @@ +// @target: es2019 +// @lib: dom,es2019 +declare function test(): void; + +test<{t?: string}, object>(); +test<{t?: string}, bigint>(); + +// no error when bigint is used even when ES2020 lib is not present diff --git a/tests/cases/conformance/es2020/bigintMissingES2020.ts b/tests/cases/conformance/es2020/bigintMissingES2020.ts new file mode 100644 index 00000000000..dc2f459e034 --- /dev/null +++ b/tests/cases/conformance/es2020/bigintMissingES2020.ts @@ -0,0 +1,8 @@ +// @target: es2020 +// @lib: dom,es2017 +declare function test(): void; + +test<{t?: string}, object>(); +test<{t?: string}, bigint>(); + +// should have global error when bigint is used but ES2020 lib is not present diff --git a/tests/cases/conformance/es2020/bigintMissingESNext.ts b/tests/cases/conformance/es2020/bigintMissingESNext.ts new file mode 100644 index 00000000000..f3d90f64bde --- /dev/null +++ b/tests/cases/conformance/es2020/bigintMissingESNext.ts @@ -0,0 +1,8 @@ +// @target: esnext +// @lib: dom,es2017 +declare function test(): void; + +test<{t?: string}, object>(); +test<{t?: string}, bigint>(); + +// should have global error when bigint is used but ES2020 lib is not present From a8e1ad4e6204b919d82d453a94238c1808fae14f Mon Sep 17 00:00:00 2001 From: Alexander T Date: Mon, 13 Apr 2020 20:23:12 +0300 Subject: [PATCH 02/74] fix(37781): import missing argument types for a new method (#37857) --- src/services/codefixes/fixAddMissingMember.ts | 19 ++++---- src/services/codefixes/helpers.ts | 20 ++++++--- .../codeFixUndeclaredAcrossFiles3.ts | 2 +- ...edMethodFunctionArgs_importArgumentType.ts | 31 +++++++++++++ ...dMethodFunctionArgs_importArgumentType1.ts | 38 ++++++++++++++++ ...dMethodFunctionArgs_importArgumentType2.ts | 45 +++++++++++++++++++ 6 files changed, 139 insertions(+), 16 deletions(-) create mode 100644 tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType.ts create mode 100644 tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType1.ts create mode 100644 tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType2.ts diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 7a5098d6065..7f5cd59e94c 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -21,7 +21,7 @@ namespace ts.codefix { return [createCodeFixAction(fixName, changes, [Diagnostics.Add_missing_enum_member_0, token.text], fixId, Diagnostics.Add_all_missing_members)]; } const { parentDeclaration, declSourceFile, inJs, makeStatic, token, call } = info; - const methodCodeAction = call && getActionForMethodDeclaration(context, declSourceFile, parentDeclaration, token, call, makeStatic, inJs, context.preferences); + const methodCodeAction = call && getActionForMethodDeclaration(context, declSourceFile, parentDeclaration, token, call, makeStatic, inJs); const addMember = inJs && !isInterfaceDeclaration(parentDeclaration) ? singleElementArray(getActionsForAddMissingMemberInJavascriptFile(context, declSourceFile, parentDeclaration, token, makeStatic)) : getActionsForAddMissingMemberInTypeScriptFile(context, declSourceFile, parentDeclaration, token, makeStatic); @@ -29,7 +29,7 @@ namespace ts.codefix { }, fixIds: [fixId], getAllCodeActions: context => { - const { program, preferences } = context; + const { program } = context; const checker = program.getTypeChecker(); const seen = createMap(); @@ -66,7 +66,7 @@ namespace ts.codefix { // Always prefer to add a method declaration if possible. if (call && !isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, declSourceFile, parentDeclaration, token, call, makeStatic, inJs, preferences); + addMethodDeclaration(context, changes, declSourceFile, parentDeclaration, token, call, makeStatic, inJs); } else { if (inJs && !isInterfaceDeclaration(parentDeclaration)) { @@ -304,12 +304,11 @@ namespace ts.codefix { token: Identifier | PrivateIdentifier, callExpression: CallExpression, makeStatic: boolean, - inJs: boolean, - preferences: UserPreferences, + inJs: boolean ): CodeFixAction | undefined { // Private methods are not implemented yet. if (isPrivateIdentifier(token)) { return undefined; } - const changes = textChanges.ChangeTracker.with(context, t => addMethodDeclaration(context, t, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences)); + const changes = textChanges.ChangeTracker.with(context, t => addMethodDeclaration(context, t, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs)); return createCodeFixAction(fixName, changes, [makeStatic ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0, token.text], fixId, Diagnostics.Add_all_missing_members); } @@ -321,18 +320,18 @@ namespace ts.codefix { token: Identifier, callExpression: CallExpression, makeStatic: boolean, - inJs: boolean, - preferences: UserPreferences, + inJs: boolean ): void { - const methodDeclaration = createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl); + const importAdder = createImportAdder(declSourceFile, context.program, context.preferences, context.host); + const methodDeclaration = createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, typeDecl, importAdder); const containingMethodDeclaration = getAncestor(callExpression, SyntaxKind.MethodDeclaration); - if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } else { changeTracker.insertNodeAtClassStart(declSourceFile, typeDecl, methodDeclaration); } + importAdder.writeFixes(changeTracker); } function addEnumMemberDeclaration(changes: textChanges.ChangeTracker, checker: TypeChecker, token: Identifier, enumDeclaration: EnumDeclaration) { diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 48f2ee98584..7f14de02c61 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -218,16 +218,26 @@ namespace ts.codefix { methodName: string, inJs: boolean, makeStatic: boolean, - preferences: UserPreferences, contextNode: Node, + importAdder: ImportAdder ): MethodDeclaration { const body = !isInterfaceDeclaration(contextNode); const { typeArguments, arguments: args, parent } = call; + const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions()); const checker = context.program.getTypeChecker(); const tracker = getNoopSymbolTrackerWithResolver(context); - const types = map(args, arg => - // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" - checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker)); + const types = map(args, arg => { + const type = checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)); + const typeNode = checker.typeToTypeNode(type, contextNode, /*flags*/ undefined, tracker); + if (typeNode?.kind === SyntaxKind.ImportType) { + const importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget); + if (importableReference) { + importSymbols(importAdder, importableReference.symbols); + return importableReference.typeReference; + } + } + return typeNode; + }); const names = map(args, arg => isIdentifier(arg) ? arg.text : isPropertyAccessExpression(arg) && isIdentifier(arg.name) ? arg.name.text : undefined); const contextualType = checker.getContextualType(call); @@ -242,7 +252,7 @@ namespace ts.codefix { createTypeParameterDeclaration(CharacterCodes.T + typeArguments!.length - 1 <= CharacterCodes.Z ? String.fromCharCode(CharacterCodes.T + i) : `T${i}`)), /*parameters*/ createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, inJs), /*type*/ returnType, - body ? createStubbedMethodBody(preferences) : undefined); + body ? createStubbedMethodBody(context.preferences) : undefined); } function createDummyParameters(argCount: number, names: (string | undefined)[] | undefined, types: (TypeNode | undefined)[] | undefined, minArgumentCount: number | undefined, inJs: boolean): ParameterDeclaration[] { diff --git a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts index 9ea5ac1a165..dce1ca38a9d 100644 --- a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts +++ b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts @@ -20,7 +20,7 @@ verify.getAndApplyCodeFix(/*errorCode*/ undefined, 0); verify.rangeIs(` - m0(arg0: import("./f2").D) { + m0(arg0: D) { throw new Error("Method not implemented."); } `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType.ts b/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType.ts new file mode 100644 index 00000000000..b9410c03583 --- /dev/null +++ b/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType.ts @@ -0,0 +1,31 @@ +/// + +// @Filename: a.ts +////export interface A { +//// x: number; +////} +////export function create(fn: (args: A) => void) {} + +// @Filename: b.ts +////import { create } from "./a"; +////class B { +//// bar() { +//// create(args => this.foo(args)); +//// } +////} + +goTo.file("b.ts"); +verify.codeFix({ + description: [ts.Diagnostics.Declare_method_0.message, "foo"], + index: 0, + newFileContent: +`import { create, A } from "./a"; +class B { + bar() { + create(args => this.foo(args)); + } + foo(args: A): void { + throw new Error("Method not implemented."); + } +}` +}); diff --git a/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType1.ts b/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType1.ts new file mode 100644 index 00000000000..4a7afe32b53 --- /dev/null +++ b/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType1.ts @@ -0,0 +1,38 @@ +/// + +// @Filename: a.ts +////export interface A { +//// x: number; +////} + +// @Filename: b.ts +////import { A } from "./a"; +////export interface B { +//// payload: T; +////} +////export function create(fn: (args: B) => void) {} + +// @Filename: c.ts +////import { create } from "./b"; +////class C { +//// bar() { +//// create(args => this.foo(args)); +//// } +////} + +goTo.file("c.ts"); +verify.codeFix({ + description: [ts.Diagnostics.Declare_method_0.message, "foo"], + index: 0, + newFileContent: +`import { create, B } from "./b"; +import { A } from "./a"; +class C { + bar() { + create(args => this.foo(args)); + } + foo(args: B): void { + throw new Error("Method not implemented."); + } +}` +}); diff --git a/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType2.ts b/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType2.ts new file mode 100644 index 00000000000..05755845534 --- /dev/null +++ b/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs_importArgumentType2.ts @@ -0,0 +1,45 @@ +/// + +// @Filename: a.ts +////export interface A { +//// x: number; +////} + +// @Filename: b.ts +////export interface B { +//// payload: T; +////} + +// @Filename: c.ts +////import { A } from "./a"; +////import { B } from "./b"; +////export interface C { +//// payload: T; +////} +////export function create(fn: (args: C>) => void) {} + +// @Filename: d.ts +////import { create } from "./c"; +////class D { +//// bar() { +//// create(args => this.foo(args)); +//// } +////} + +goTo.file("d.ts"); +verify.codeFix({ + description: [ts.Diagnostics.Declare_method_0.message, "foo"], + index: 0, + newFileContent: +`import { create, C } from "./c"; +import { B } from "./b"; +import { A } from "./a"; +class D { + bar() { + create(args => this.foo(args)); + } + foo(args: C>): void { + throw new Error("Method not implemented."); + } +}` +}); From 141ee01c8cd5e04a69b66db7e8d3da6da13c7499 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Apr 2020 12:31:14 -0700 Subject: [PATCH 03/74] Retain imports in declaration emit if they augment an export of the importing file (#37820) * Retain imports in declaration emit if they augment an export of the importing file * (sp) * Check that a merge occurs, just because --- src/compiler/checker.ts | 24 +++++++- src/compiler/emitter.ts | 1 + src/compiler/transformers/declarations.ts | 10 ++++ src/compiler/types.ts | 1 + ...mportingModuleAugmentationRetainsImport.js | 56 +++++++++++++++++++ ...ingModuleAugmentationRetainsImport.symbols | 46 +++++++++++++++ ...rtingModuleAugmentationRetainsImport.types | 46 +++++++++++++++ ...mportingModuleAugmentationRetainsImport.ts | 20 +++++++ 8 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.js create mode 100644 tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.symbols create mode 100644 tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.types create mode 100644 tests/cases/compiler/declarationEmitForModuleImportingModuleAugmentationRetainsImport.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ae1f4c4dd84..d627a55ce8b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -36118,9 +36118,31 @@ namespace ts { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); } return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); - } + }, + isImportRequiredByAugmentation, }; + function isImportRequiredByAugmentation(node: ImportDeclaration) { + const file = getSourceFileOfNode(node); + if (!file.symbol) return false; + const importTarget = getExternalModuleFileFromDeclaration(node); + if (!importTarget) return false; + if (importTarget === file) return false; + const exports = getExportsOfModule(file.symbol); + for (const s of arrayFrom(exports.values())) { + if (s.mergeId) { + const merged = getMergedSymbol(s); + for (const d of merged.declarations) { + const declFile = getSourceFileOfNode(d); + if (declFile === importTarget) { + return true; + } + } + } + } + return false; + } + function isInHeritageClause(node: PropertyAccessEntityNameExpression) { return node.parent && node.parent.kind === SyntaxKind.ExpressionWithTypeArguments && node.parent.parent && node.parent.parent.kind === SyntaxKind.HeritageClause; } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 3f52f4e9ee9..d558ce785a8 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -664,6 +664,7 @@ namespace ts { getSymbolOfExternalModuleSpecifier: notImplemented, isBindingCapturedByNode: notImplemented, getDeclarationStatementsForSourceFile: notImplemented, + isImportRequiredByAugmentation: notImplemented, }; /*@internal*/ diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 743aa1b4769..70f70a98c3e 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -717,6 +717,16 @@ namespace ts { rewriteModuleSpecifier(decl, decl.moduleSpecifier) ); } + // Augmentation of export depends on import + if (resolver.isImportRequiredByAugmentation(decl)) { + return updateImportDeclaration( + decl, + /*decorators*/ undefined, + decl.modifiers, + /*importClause*/ undefined, + rewriteModuleSpecifier(decl, decl.moduleSpecifier) + ); + } // Nothing visible } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b0a0658130b..5e1b0a9fca8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4004,6 +4004,7 @@ namespace ts { getSymbolOfExternalModuleSpecifier(node: StringLiteralLike): Symbol | undefined; isBindingCapturedByNode(node: Node, decl: VariableDeclaration | BindingElement): boolean; getDeclarationStatementsForSourceFile(node: SourceFile, flags: NodeBuilderFlags, tracker: SymbolTracker, bundled?: boolean): Statement[] | undefined; + isImportRequiredByAugmentation(decl: ImportDeclaration): boolean; } export const enum SymbolFlags { diff --git a/tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.js b/tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.js new file mode 100644 index 00000000000..576b8dffbde --- /dev/null +++ b/tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.js @@ -0,0 +1,56 @@ +//// [tests/cases/compiler/declarationEmitForModuleImportingModuleAugmentationRetainsImport.ts] //// + +//// [child1.ts] +import { ParentThing } from './parent'; + +declare module './parent' { + interface ParentThing { + add: (a: number, b: number) => number; + } +} + +export function child1(prototype: ParentThing) { + prototype.add = (a: number, b: number) => a + b; +} + +//// [parent.ts] +import { child1 } from './child1'; // this import should still exist in some form in the output, since it augments this module + +export class ParentThing implements ParentThing {} + +child1(ParentThing.prototype); + +//// [parent.js] +"use strict"; +exports.__esModule = true; +exports.ParentThing = void 0; +var child1_1 = require("./child1"); // this import should still exist in some form in the output, since it augments this module +var ParentThing = /** @class */ (function () { + function ParentThing() { + } + return ParentThing; +}()); +exports.ParentThing = ParentThing; +child1_1.child1(ParentThing.prototype); +//// [child1.js] +"use strict"; +exports.__esModule = true; +exports.child1 = void 0; +function child1(prototype) { + prototype.add = function (a, b) { return a + b; }; +} +exports.child1 = child1; + + +//// [parent.d.ts] +import './child1'; +export declare class ParentThing implements ParentThing { +} +//// [child1.d.ts] +import { ParentThing } from './parent'; +declare module './parent' { + interface ParentThing { + add: (a: number, b: number) => number; + } +} +export declare function child1(prototype: ParentThing): void; diff --git a/tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.symbols b/tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.symbols new file mode 100644 index 00000000000..f7026a83b1b --- /dev/null +++ b/tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.symbols @@ -0,0 +1,46 @@ +=== tests/cases/compiler/child1.ts === +import { ParentThing } from './parent'; +>ParentThing : Symbol(ParentThing, Decl(child1.ts, 0, 8)) + +declare module './parent' { +>'./parent' : Symbol("tests/cases/compiler/parent", Decl(parent.ts, 0, 0), Decl(child1.ts, 0, 39)) + + interface ParentThing { +>ParentThing : Symbol(ParentThing, Decl(parent.ts, 0, 34), Decl(child1.ts, 2, 27)) + + add: (a: number, b: number) => number; +>add : Symbol(ParentThing.add, Decl(child1.ts, 3, 27)) +>a : Symbol(a, Decl(child1.ts, 4, 14)) +>b : Symbol(b, Decl(child1.ts, 4, 24)) + } +} + +export function child1(prototype: ParentThing) { +>child1 : Symbol(child1, Decl(child1.ts, 6, 1)) +>prototype : Symbol(prototype, Decl(child1.ts, 8, 23)) +>ParentThing : Symbol(ParentThing, Decl(child1.ts, 0, 8)) + + prototype.add = (a: number, b: number) => a + b; +>prototype.add : Symbol(ParentThing.add, Decl(child1.ts, 3, 27)) +>prototype : Symbol(prototype, Decl(child1.ts, 8, 23)) +>add : Symbol(ParentThing.add, Decl(child1.ts, 3, 27)) +>a : Symbol(a, Decl(child1.ts, 9, 21)) +>b : Symbol(b, Decl(child1.ts, 9, 31)) +>a : Symbol(a, Decl(child1.ts, 9, 21)) +>b : Symbol(b, Decl(child1.ts, 9, 31)) +} + +=== tests/cases/compiler/parent.ts === +import { child1 } from './child1'; // this import should still exist in some form in the output, since it augments this module +>child1 : Symbol(child1, Decl(parent.ts, 0, 8)) + +export class ParentThing implements ParentThing {} +>ParentThing : Symbol(ParentThing, Decl(parent.ts, 0, 34), Decl(child1.ts, 2, 27)) +>ParentThing : Symbol(ParentThing, Decl(parent.ts, 0, 34), Decl(child1.ts, 2, 27)) + +child1(ParentThing.prototype); +>child1 : Symbol(child1, Decl(parent.ts, 0, 8)) +>ParentThing.prototype : Symbol(ParentThing.prototype) +>ParentThing : Symbol(ParentThing, Decl(parent.ts, 0, 34), Decl(child1.ts, 2, 27)) +>prototype : Symbol(ParentThing.prototype) + diff --git a/tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.types b/tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.types new file mode 100644 index 00000000000..bcb3f3a0666 --- /dev/null +++ b/tests/baselines/reference/declarationEmitForModuleImportingModuleAugmentationRetainsImport.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/child1.ts === +import { ParentThing } from './parent'; +>ParentThing : typeof ParentThing + +declare module './parent' { +>'./parent' : typeof import("tests/cases/compiler/parent") + + interface ParentThing { + add: (a: number, b: number) => number; +>add : (a: number, b: number) => number +>a : number +>b : number + } +} + +export function child1(prototype: ParentThing) { +>child1 : (prototype: ParentThing) => void +>prototype : ParentThing + + prototype.add = (a: number, b: number) => a + b; +>prototype.add = (a: number, b: number) => a + b : (a: number, b: number) => number +>prototype.add : (a: number, b: number) => number +>prototype : ParentThing +>add : (a: number, b: number) => number +>(a: number, b: number) => a + b : (a: number, b: number) => number +>a : number +>b : number +>a + b : number +>a : number +>b : number +} + +=== tests/cases/compiler/parent.ts === +import { child1 } from './child1'; // this import should still exist in some form in the output, since it augments this module +>child1 : (prototype: ParentThing) => void + +export class ParentThing implements ParentThing {} +>ParentThing : ParentThing + +child1(ParentThing.prototype); +>child1(ParentThing.prototype) : void +>child1 : (prototype: ParentThing) => void +>ParentThing.prototype : ParentThing +>ParentThing : typeof ParentThing +>prototype : ParentThing + diff --git a/tests/cases/compiler/declarationEmitForModuleImportingModuleAugmentationRetainsImport.ts b/tests/cases/compiler/declarationEmitForModuleImportingModuleAugmentationRetainsImport.ts new file mode 100644 index 00000000000..5d6268864fe --- /dev/null +++ b/tests/cases/compiler/declarationEmitForModuleImportingModuleAugmentationRetainsImport.ts @@ -0,0 +1,20 @@ +// @declaration: true +// @filename: child1.ts +import { ParentThing } from './parent'; + +declare module './parent' { + interface ParentThing { + add: (a: number, b: number) => number; + } +} + +export function child1(prototype: ParentThing) { + prototype.add = (a: number, b: number) => a + b; +} + +// @filename: parent.ts +import { child1 } from './child1'; // this import should still exist in some form in the output, since it augments this module + +export class ParentThing implements ParentThing {} + +child1(ParentThing.prototype); \ No newline at end of file From eb569a5c74720b55ad30e109f635ebf0060ac7f9 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Mills Date: Mon, 13 Apr 2020 21:32:01 +0200 Subject: [PATCH 04/74] chore(ts-toolbelt): remove deprecated test (#37932) --- tests/cases/user/ts-toolbelt/index.ts | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/tests/cases/user/ts-toolbelt/index.ts b/tests/cases/user/ts-toolbelt/index.ts index 218db6ba38d..6549c08f893 100644 --- a/tests/cases/user/ts-toolbelt/index.ts +++ b/tests/cases/user/ts-toolbelt/index.ts @@ -12,7 +12,7 @@ type StdRecursiveIteration extends T.Length // this form of recursion is preferred ? 1 // because it will let the user know if : 0 // the instantiation depth has been hit -]; // (but error is sometimes swallowed (?)) +]; checks([ check, 40, Test.Pass>(), // max length is 40 ]); - -// iterates over `T` and returns the `Iteration` position when finished -type SafeRecursiveIteration> = { - 0: SafeRecursiveIteration>; - 1: I.Pos; -}[ - I.Key extends T.Length // this form of recursion is the safest - ? 1 // because `T.Length` will force - : 0 // the length to comply with the limits -]; // => won't compute if excessive length - -checks([ - check, 0, Test.Pass>() // did not compute -]); From 6a5508b34356438f3c470cd486bffb6473a1d47e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Apr 2020 13:10:24 -0700 Subject: [PATCH 05/74] Update __exportStar helper to skip default and __esModule members (#37236) * Update __exportStar helper to skip default and __esModule * Accept new baselines * Remove esmodule check from helper --- src/compiler/transformers/module/module.ts | 2 +- tests/baselines/reference/ambientShorthand_reExport.js | 2 +- .../baselines/reference/declarationEmitAliasExportStar.js | 2 +- .../declarationEmitReexportedSymlinkReference.js | 2 +- .../declarationEmitReexportedSymlinkReference2.js | 2 +- .../declarationEmitReexportedSymlinkReference3.js | 2 +- .../reference/doubleUnderscoreExportStarConflict.js | 2 +- tests/baselines/reference/es6ExportAllInEs5.js | 2 +- tests/baselines/reference/es6ExportEqualsInterop.js | 2 +- .../esModuleInteropWithExportStar(target=es3).js | 2 +- .../esModuleInteropWithExportStar(target=es5).js | 2 +- tests/baselines/reference/exportNamespace1.js | 2 +- tests/baselines/reference/exportStar-amd.js | 2 +- tests/baselines/reference/exportStar.js | 2 +- tests/baselines/reference/exportStarForValues.js | 2 +- tests/baselines/reference/exportStarForValues2.js | 4 ++-- tests/baselines/reference/exportStarForValues3.js | 8 ++++---- tests/baselines/reference/exportStarForValues4.js | 4 ++-- tests/baselines/reference/exportStarForValues5.js | 2 +- tests/baselines/reference/exportStarForValues7.js | 4 ++-- tests/baselines/reference/exportStarForValues8.js | 8 ++++---- tests/baselines/reference/exportStarForValues9.js | 4 ++-- tests/baselines/reference/exportStarFromEmptyModule.js | 2 +- tests/baselines/reference/exportStarNotElided.js | 2 +- tests/baselines/reference/inlineJsxFactoryDeclarations.js | 2 +- tests/baselines/reference/jsDeclarationsExportForms.js | 4 ++-- tests/baselines/reference/jsDeclarationsExportFormsErr.js | 2 +- ...oduleDeclarationExportStarShadowingGlobalIsNameable.js | 2 +- .../moduleSameValueDuplicateExportedBindings1.js | 4 ++-- .../moduleSameValueDuplicateExportedBindings2.js | 2 +- .../reference/symbolLinkDeclarationEmitModuleNames.js | 2 +- .../transformsCorrectly.transformAddCommentToImport.js | 2 +- .../watchMode/reexport/Reports-errors-correctly.js | 2 +- ...g-package-through-indirect-symlink-moduleCaseChange.js | 2 +- ...references-sibling-package-through-indirect-symlink.js | 2 +- .../when-there-are-circular-import-and-exports.js | 6 +++--- .../when-there-are-no-circular-import-and-exports.js | 6 +++--- .../when-there-are-circular-import-and-exports.js | 6 +++--- .../when-there-are-no-circular-import-and-exports.js | 6 +++--- .../when-there-are-circular-import-and-exports.js | 6 +++--- .../when-there-are-no-circular-import-and-exports.js | 6 +++--- .../when-there-are-circular-import-and-exports.js | 6 +++--- .../when-there-are-no-circular-import-and-exports.js | 6 +++--- .../when-there-are-circular-import-and-exports.js | 6 +++--- .../when-there-are-no-circular-import-and-exports.js | 6 +++--- .../when-there-are-circular-import-and-exports.js | 6 +++--- .../when-there-are-no-circular-import-and-exports.js | 6 +++--- ...changes-in-files-are-reflected-in-project-structure.js | 4 ++-- .../deleted-files-affect-project-structure-2.js | 4 ++-- .../deleted-files-affect-project-structure.js | 4 ++-- 50 files changed, 89 insertions(+), 89 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index d6b64c696ed..2bb81ff255c 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1886,7 +1886,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( priority: 2, text: ` var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); }` }; diff --git a/tests/baselines/reference/ambientShorthand_reExport.js b/tests/baselines/reference/ambientShorthand_reExport.js index a9fef57c1c6..56a8cbaa427 100644 --- a/tests/baselines/reference/ambientShorthand_reExport.js +++ b/tests/baselines/reference/ambientShorthand_reExport.js @@ -38,7 +38,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("jquery"), exports); diff --git a/tests/baselines/reference/declarationEmitAliasExportStar.js b/tests/baselines/reference/declarationEmitAliasExportStar.js index 79b7a388ab2..e4dc99a7074 100644 --- a/tests/baselines/reference/declarationEmitAliasExportStar.js +++ b/tests/baselines/reference/declarationEmitAliasExportStar.js @@ -22,7 +22,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./thingB"), exports); diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js index 4f96e3bdb97..930ab97bfec 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference.js @@ -59,7 +59,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./keys"), exports); diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js index e0101b04d9f..ccda718f60c 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference2.js @@ -62,7 +62,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./keys"), exports); diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js index a5f0a1663be..3f27689c985 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js @@ -59,7 +59,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./keys"), exports); diff --git a/tests/baselines/reference/doubleUnderscoreExportStarConflict.js b/tests/baselines/reference/doubleUnderscoreExportStarConflict.js index ca547f8f1bc..a5d60f02159 100644 --- a/tests/baselines/reference/doubleUnderscoreExportStarConflict.js +++ b/tests/baselines/reference/doubleUnderscoreExportStarConflict.js @@ -33,7 +33,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./b"), exports); diff --git a/tests/baselines/reference/es6ExportAllInEs5.js b/tests/baselines/reference/es6ExportAllInEs5.js index 3992d7c293c..72ec47714d8 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.js +++ b/tests/baselines/reference/es6ExportAllInEs5.js @@ -40,7 +40,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./server"), exports); diff --git a/tests/baselines/reference/es6ExportEqualsInterop.js b/tests/baselines/reference/es6ExportEqualsInterop.js index b31dc3b77d4..6f24e91d8fd 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.js +++ b/tests/baselines/reference/es6ExportEqualsInterop.js @@ -217,7 +217,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; var z2 = require("variable"); diff --git a/tests/baselines/reference/esModuleInteropWithExportStar(target=es3).js b/tests/baselines/reference/esModuleInteropWithExportStar(target=es3).js index ec8b93e9f9d..3db289c7f1a 100644 --- a/tests/baselines/reference/esModuleInteropWithExportStar(target=es3).js +++ b/tests/baselines/reference/esModuleInteropWithExportStar(target=es3).js @@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; var fs = __importStar(require("./fs")); diff --git a/tests/baselines/reference/esModuleInteropWithExportStar(target=es5).js b/tests/baselines/reference/esModuleInteropWithExportStar(target=es5).js index 77459782f1d..1ebde18e428 100644 --- a/tests/baselines/reference/esModuleInteropWithExportStar(target=es5).js +++ b/tests/baselines/reference/esModuleInteropWithExportStar(target=es5).js @@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); var fs = __importStar(require("./fs")); diff --git a/tests/baselines/reference/exportNamespace1.js b/tests/baselines/reference/exportNamespace1.js index 910be35f30c..ff02a98707e 100644 --- a/tests/baselines/reference/exportNamespace1.js +++ b/tests/baselines/reference/exportNamespace1.js @@ -37,7 +37,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./b"), exports); diff --git a/tests/baselines/reference/exportStar-amd.js b/tests/baselines/reference/exportStar-amd.js index 08de5b36e37..a2a062a7501 100644 --- a/tests/baselines/reference/exportStar-amd.js +++ b/tests/baselines/reference/exportStar-amd.js @@ -66,7 +66,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "./t1", "./t2", "./t3"], function (require, exports, t1_1, t2_1, t3_1) { "use strict"; diff --git a/tests/baselines/reference/exportStar.js b/tests/baselines/reference/exportStar.js index 36a61f6abd8..bf65527a104 100644 --- a/tests/baselines/reference/exportStar.js +++ b/tests/baselines/reference/exportStar.js @@ -61,7 +61,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./t1"), exports); diff --git a/tests/baselines/reference/exportStarForValues.js b/tests/baselines/reference/exportStarForValues.js index b6016529742..277b953d353 100644 --- a/tests/baselines/reference/exportStarForValues.js +++ b/tests/baselines/reference/exportStarForValues.js @@ -21,7 +21,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file1"], function (require, exports, file1_1) { "use strict"; diff --git a/tests/baselines/reference/exportStarForValues2.js b/tests/baselines/reference/exportStarForValues2.js index de75ba8743b..01ded620485 100644 --- a/tests/baselines/reference/exportStarForValues2.js +++ b/tests/baselines/reference/exportStarForValues2.js @@ -25,7 +25,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file1"], function (require, exports, file1_1) { "use strict"; @@ -42,7 +42,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file2"], function (require, exports, file2_1) { "use strict"; diff --git a/tests/baselines/reference/exportStarForValues3.js b/tests/baselines/reference/exportStarForValues3.js index 2d9cdfad003..e31102f3f7f 100644 --- a/tests/baselines/reference/exportStarForValues3.js +++ b/tests/baselines/reference/exportStarForValues3.js @@ -37,7 +37,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file1"], function (require, exports, file1_1) { "use strict"; @@ -54,7 +54,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file1"], function (require, exports, file1_1) { "use strict"; @@ -71,7 +71,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file2", "file3"], function (require, exports, file2_1, file3_1) { "use strict"; @@ -89,7 +89,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file4"], function (require, exports, file4_1) { "use strict"; diff --git a/tests/baselines/reference/exportStarForValues4.js b/tests/baselines/reference/exportStarForValues4.js index 7be7e9af0b1..527df22d292 100644 --- a/tests/baselines/reference/exportStarForValues4.js +++ b/tests/baselines/reference/exportStarForValues4.js @@ -29,7 +29,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file2"], function (require, exports, file2_1) { "use strict"; @@ -46,7 +46,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file1", "file3"], function (require, exports, file1_1, file3_1) { "use strict"; diff --git a/tests/baselines/reference/exportStarForValues5.js b/tests/baselines/reference/exportStarForValues5.js index 8c11ea25813..6a5c2e6755f 100644 --- a/tests/baselines/reference/exportStarForValues5.js +++ b/tests/baselines/reference/exportStarForValues5.js @@ -21,7 +21,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file1"], function (require, exports, file1_1) { "use strict"; diff --git a/tests/baselines/reference/exportStarForValues7.js b/tests/baselines/reference/exportStarForValues7.js index 5bf4d7ed77a..3fe3020756c 100644 --- a/tests/baselines/reference/exportStarForValues7.js +++ b/tests/baselines/reference/exportStarForValues7.js @@ -25,7 +25,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file1"], function (require, exports, file1_1) { "use strict"; @@ -43,7 +43,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file2"], function (require, exports, file2_1) { "use strict"; diff --git a/tests/baselines/reference/exportStarForValues8.js b/tests/baselines/reference/exportStarForValues8.js index fcf94740752..3458e5f6a38 100644 --- a/tests/baselines/reference/exportStarForValues8.js +++ b/tests/baselines/reference/exportStarForValues8.js @@ -37,7 +37,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file1"], function (require, exports, file1_1) { "use strict"; @@ -55,7 +55,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file1"], function (require, exports, file1_1) { "use strict"; @@ -73,7 +73,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file2", "file3"], function (require, exports, file2_1, file3_1) { "use strict"; @@ -92,7 +92,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file4"], function (require, exports, file4_1) { "use strict"; diff --git a/tests/baselines/reference/exportStarForValues9.js b/tests/baselines/reference/exportStarForValues9.js index 37e62802093..70ab46eafeb 100644 --- a/tests/baselines/reference/exportStarForValues9.js +++ b/tests/baselines/reference/exportStarForValues9.js @@ -29,7 +29,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file2"], function (require, exports, file2_1) { "use strict"; @@ -47,7 +47,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } define(["require", "exports", "file1", "file3"], function (require, exports, file1_1, file3_1) { "use strict"; diff --git a/tests/baselines/reference/exportStarFromEmptyModule.js b/tests/baselines/reference/exportStarFromEmptyModule.js index 5b630a3e227..450bbafe424 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.js +++ b/tests/baselines/reference/exportStarFromEmptyModule.js @@ -44,7 +44,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); exports.A = void 0; diff --git a/tests/baselines/reference/exportStarNotElided.js b/tests/baselines/reference/exportStarNotElided.js index 588feb7b7ae..41d2b55483b 100644 --- a/tests/baselines/reference/exportStarNotElided.js +++ b/tests/baselines/reference/exportStarNotElided.js @@ -32,7 +32,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./register"), exports); diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarations.js b/tests/baselines/reference/inlineJsxFactoryDeclarations.js index e2b58881e8d..c4909439e54 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarations.js +++ b/tests/baselines/reference/inlineJsxFactoryDeclarations.js @@ -73,7 +73,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; /** @jsx dom */ diff --git a/tests/baselines/reference/jsDeclarationsExportForms.js b/tests/baselines/reference/jsDeclarationsExportForms.js index 80edd493755..2ff100c4eda 100644 --- a/tests/baselines/reference/jsDeclarationsExportForms.js +++ b/tests/baselines/reference/jsDeclarationsExportForms.js @@ -84,7 +84,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./cls"), exports); @@ -98,7 +98,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./func"), exports); diff --git a/tests/baselines/reference/jsDeclarationsExportFormsErr.js b/tests/baselines/reference/jsDeclarationsExportFormsErr.js index b37459e3a30..f30b0a90ab0 100644 --- a/tests/baselines/reference/jsDeclarationsExportFormsErr.js +++ b/tests/baselines/reference/jsDeclarationsExportFormsErr.js @@ -50,7 +50,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./cls"), exports); diff --git a/tests/baselines/reference/moduleDeclarationExportStarShadowingGlobalIsNameable.js b/tests/baselines/reference/moduleDeclarationExportStarShadowingGlobalIsNameable.js index b7d9dc5503c..9e49c965bfa 100644 --- a/tests/baselines/reference/moduleDeclarationExportStarShadowingGlobalIsNameable.js +++ b/tests/baselines/reference/moduleDeclarationExportStarShadowingGlobalIsNameable.js @@ -38,7 +38,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./account"), exports); diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js index 323bdf22fa4..ab43c82628d 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.js @@ -25,7 +25,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./c"), exports); @@ -39,7 +39,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./b"), exports); diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js index a29dd0f4738..456cc75fe8b 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.js @@ -45,7 +45,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./b"), exports); diff --git a/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js index 3115ad790b8..a4f5f4e177c 100644 --- a/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js +++ b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNames.js @@ -50,7 +50,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./src/value-promise"), exports); diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js b/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js index 8ccb9eb2010..2cadc1e1ec5 100644 --- a/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js +++ b/tests/baselines/reference/transformApi/transformsCorrectly.transformAddCommentToImport.js @@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); exports.Value = void 0; diff --git a/tests/baselines/reference/tsbuild/watchMode/reexport/Reports-errors-correctly.js b/tests/baselines/reference/tsbuild/watchMode/reexport/Reports-errors-correctly.js index d78f7fdbb2a..deeefd1ad04 100644 --- a/tests/baselines/reference/tsbuild/watchMode/reexport/Reports-errors-correctly.js +++ b/tests/baselines/reference/tsbuild/watchMode/reexport/Reports-errors-correctly.js @@ -84,7 +84,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./session"), exports); diff --git a/tests/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink-moduleCaseChange.js b/tests/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink-moduleCaseChange.js index bceccd56fb1..649de585df5 100644 --- a/tests/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink-moduleCaseChange.js +++ b/tests/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink-moduleCaseChange.js @@ -72,7 +72,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./keys"), exports); diff --git a/tests/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js b/tests/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js index c2f243696e3..4a223fe9c6d 100644 --- a/tests/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js +++ b/tests/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js @@ -72,7 +72,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } Object.defineProperty(exports, "__esModule", { value: true }); __exportStar(require("./keys"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js index fadfd97abb0..9c1f665cca0 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js @@ -69,7 +69,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -85,7 +85,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -131,7 +131,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js index 79306254aa4..20027ce38f1 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js @@ -63,7 +63,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -79,7 +79,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -113,7 +113,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js index 346527fec47..e51fe281ec1 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js @@ -75,7 +75,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -95,7 +95,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -161,7 +161,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js index 7dd6c059a81..6c1de9a4deb 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js @@ -69,7 +69,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -89,7 +89,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -134,7 +134,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js index 72f301a5f3d..f72345ccc56 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js @@ -69,7 +69,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -85,7 +85,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -131,7 +131,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js index a1589a5c222..8de8338f4bb 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js @@ -63,7 +63,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -79,7 +79,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -113,7 +113,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js index cf140e274bd..071013c5e81 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js @@ -75,7 +75,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -95,7 +95,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -161,7 +161,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js index ca03eceed66..547418b8fce 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js @@ -69,7 +69,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -89,7 +89,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -134,7 +134,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js index 9e71a6c06f6..b1eead4925a 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js @@ -69,7 +69,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -85,7 +85,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -131,7 +131,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js index bc2e63d3f60..bda31bf5c1f 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js @@ -63,7 +63,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -79,7 +79,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -113,7 +113,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js index b1df9816444..cfe43df46a1 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-circular-import-and-exports.js @@ -75,7 +75,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -95,7 +95,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -161,7 +161,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js index 5b4e307af7a..c0a64ac97a5 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/updates-errors-when-file-transitively-exported-file-changes/when-there-are-no-circular-import-and-exports.js @@ -69,7 +69,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools.interface"), exports); @@ -89,7 +89,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./tools/public"), exports); @@ -134,7 +134,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./data"), exports); diff --git a/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js b/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js index ad5648f6240..2345c69fd19 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js +++ b/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js @@ -38,7 +38,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./f2"), exports); @@ -95,7 +95,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("../c/f3"), exports); diff --git a/tests/baselines/reference/tscWatch/programUpdates/deleted-files-affect-project-structure-2.js b/tests/baselines/reference/tscWatch/programUpdates/deleted-files-affect-project-structure-2.js index 230b885505a..6db5d9bcb60 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/deleted-files-affect-project-structure-2.js +++ b/tests/baselines/reference/tscWatch/programUpdates/deleted-files-affect-project-structure-2.js @@ -38,7 +38,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("../c/f3"), exports); @@ -54,7 +54,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./f2"), exports); diff --git a/tests/baselines/reference/tscWatch/programUpdates/deleted-files-affect-project-structure.js b/tests/baselines/reference/tscWatch/programUpdates/deleted-files-affect-project-structure.js index f8bed52fc9c..75dd1b1443f 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/deleted-files-affect-project-structure.js +++ b/tests/baselines/reference/tscWatch/programUpdates/deleted-files-affect-project-structure.js @@ -38,7 +38,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("../c/f3"), exports); @@ -54,7 +54,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./f2"), exports); From cede6ef30ebf674583c71ba5b201b750d1630f46 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Mon, 13 Apr 2020 15:08:41 -0700 Subject: [PATCH 06/74] Update user baselines (#37935) Co-authored-by: typescript-bot --- .../reference/docker/office-ui-fabric.log | 495 +----------------- tests/baselines/reference/docker/vscode.log | 16 +- tests/baselines/reference/docker/vue-next.log | 18 +- .../user/chrome-devtools-frontend.log | 79 ++- tests/baselines/reference/user/npm.log | 1 + tests/baselines/reference/user/puppeteer.log | 95 +--- tests/baselines/reference/user/uglify-js.log | 105 ++-- tests/baselines/reference/user/zone.js.log | 7 - 8 files changed, 172 insertions(+), 644 deletions(-) delete mode 100644 tests/baselines/reference/user/zone.js.log diff --git a/tests/baselines/reference/docker/office-ui-fabric.log b/tests/baselines/reference/docker/office-ui-fabric.log index e8d6e94e151..f83c2358427 100644 --- a/tests/baselines/reference/docker/office-ui-fabric.log +++ b/tests/baselines/reference/docker/office-ui-fabric.log @@ -40,299 +40,7 @@ Standard output: @fluentui/keyboard-key: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/keyboard-key/tsconfig.json @fluentui/keyboard-key: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib --module esnext --project "/office-ui-fabric-react/packages/keyboard-key/tsconfig.json" @fluentui/keyboard-key: [XX:XX:XX XM] ■ Extracting Public API surface from '/office-ui-fabric-react/packages/keyboard-key/lib/index.d.ts' -@fluentui/keyboard-key: Done in ?s. -@uifabric/migration: yarn run vX.X.X -@uifabric/migration: $ just-scripts build -@uifabric/migration: [XX:XX:XX XM] ■ Removing [lib, temp, dist, lib-amd, lib-commonjs, lib-es2015, coverage, src/**/*.scss.ts] -@uifabric/migration: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/migration/tsconfig.json -@uifabric/migration: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib --module commonjs --project "/office-ui-fabric-react/packages/migration/tsconfig.json" -@uifabric/migration: Done in ?s. -@uifabric/monaco-editor: yarn run vX.X.X -@uifabric/monaco-editor: $ just-scripts build -@uifabric/monaco-editor: [XX:XX:XX XM] ■ Removing [esm, lib, lib-commonjs] -@uifabric/monaco-editor: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/monaco-editor/tsconfig.json -@uifabric/monaco-editor: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib --module esnext --project "/office-ui-fabric-react/packages/monaco-editor/tsconfig.json" -@uifabric/monaco-editor: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/monaco-editor/tsconfig.json -@uifabric/monaco-editor: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib-commonjs --module commonjs --project "/office-ui-fabric-react/packages/monaco-editor/tsconfig.json" -@uifabric/monaco-editor: Done in ?s. -@uifabric/set-version: yarn run vX.X.X -@uifabric/set-version: $ just-scripts build -@uifabric/set-version: [XX:XX:XX XM] ■ Removing [lib, temp, dist, lib-amd, lib-commonjs, lib-es2015, coverage, src/**/*.scss.ts] -@uifabric/set-version: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/set-version/tsconfig.json -@uifabric/set-version: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib-commonjs --module commonjs --project "/office-ui-fabric-react/packages/set-version/tsconfig.json" -@uifabric/set-version: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/set-version/tsconfig.json -@uifabric/set-version: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib --module esnext --project "/office-ui-fabric-react/packages/set-version/tsconfig.json" -@uifabric/set-version: Done in ?s. -@uifabric/webpack-utils: yarn run vX.X.X -@uifabric/webpack-utils: $ just-scripts build -@uifabric/webpack-utils: [XX:XX:XX XM] ■ Removing [lib, temp, dist, lib-amd, lib-commonjs, lib-es2015, coverage, src/**/*.scss.ts] -@uifabric/webpack-utils: [XX:XX:XX XM] ■ Running /office-ui-fabric-react/node_modules/typescript/lib/tsc.js with /office-ui-fabric-react/packages/webpack-utils/tsconfig.json -@uifabric/webpack-utils: [XX:XX:XX XM] ■ Executing: /usr/local/bin/node "/office-ui-fabric-react/node_modules/typescript/lib/tsc.js" --pretty --target es5 --outDir lib --module commonjs --project "/office-ui-fabric-react/packages/webpack-utils/tsconfig.json" -@uifabric/webpack-utils: Done in ?s. -@fluentui/accessibility: yarn run vX.X.X -@fluentui/accessibility: $ gulp bundle:package:no-umd -@fluentui/accessibility: [XX:XX:XX] Requiring external module @uifabric/build/babel/register -@fluentui/accessibility: [XX:XX:XX] Using gulpfile /office-ui-fabric-react/packages/fluentui/accessibility/gulpfile.ts -@fluentui/accessibility: Done in ?s. -@fluentui/docs: yarn run vX.X.X -@fluentui/docs: $ gulp build:docs -@fluentui/docs: [XX:XX:XX] Requiring external module @uifabric/build/babel/register -@fluentui/docs: [XX:XX:XX] Working directory changed to /office-ui-fabric-react -@fluentui/docs: [XX:XX:XX] Using gulpfile /office-ui-fabric-react/gulpfile.ts -@fluentui/docs: DocToccing single file "/office-ui-fabric-react/packages/fluentui/CONTRIBUTING.md" for github.com. -@fluentui/docs: ================== -@fluentui/docs: > @fluentui/ability-attributes@X.X.X schema /office-ui-fabric-react/packages/fluentui/ability-attributes -@fluentui/docs: > allyschema -c "process.env.NODE_ENV !== 'production'" schema.json > ./src/schema.ts -@fluentui/docs: "/office-ui-fabric-react/packages/fluentui/CONTRIBUTING.md" will be updated -@fluentui/docs: Everything is OK. -@fluentui/docs: DocToccing single file "/office-ui-fabric-react/packages/fluentui/README.md" for github.com. -@fluentui/docs: ================== -@fluentui/docs: "/office-ui-fabric-react/packages/fluentui/README.md" will be updated -@fluentui/docs: Everything is OK. -@fluentui/docs: DocToccing single file "/office-ui-fabric-react/packages/fluentui/add-a-feature.md" for github.com. -@fluentui/docs: ================== -@fluentui/docs: "/office-ui-fabric-react/packages/fluentui/add-a-feature.md" will be updated -@fluentui/docs: Everything is OK. -@fluentui/docs: DocToccing single file "/office-ui-fabric-react/packages/fluentui/document-a-feature.md" for github.com. -@fluentui/docs: ================== -@fluentui/docs: "/office-ui-fabric-react/packages/fluentui/document-a-feature.md" will be updated -@fluentui/docs: Everything is OK. -@fluentui/docs: DocToccing single file "/office-ui-fabric-react/packages/fluentui/setup-local-development.md" for github.com. -@fluentui/docs: ================== -@fluentui/docs: "/office-ui-fabric-react/packages/fluentui/setup-local-development.md" will be updated -@fluentui/docs: Everything is OK. -@fluentui/docs: DocToccing single file "/office-ui-fabric-react/packages/fluentui/test-a-feature.md" for github.com. -@fluentui/docs: ================== -@fluentui/docs: "/office-ui-fabric-react/packages/fluentui/test-a-feature.md" will be updated -@fluentui/docs: Everything is OK. -@fluentui/docs: Starting type checking service... -@fluentui/docs: Using 1 worker with 2048MB memory limit -@fluentui/docs: [XX:XX:XX] Time: ?s -@fluentui/docs: Built at: XX/XX/XX XX:XX:XX XM -@fluentui/docs: Entrypoint app = runtime~app.js 2.js app.js -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/docs/src/examples/components/Toolbar/Content/ToolbarExampleMenuRadioGroup.shorthand.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/docs/src/examples/components/Toolbar/Content/ToolbarExampleMenuRadioGroup.shorthand.tsx(35,25): -@fluentui/docs: TS2345: Argument of type 'boolean' is not assignable to parameter of type '(prevState: undefined) => undefined'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/docs/src/prototypes/VirtualizedTree/VirtualizedTree.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/docs/src/prototypes/VirtualizedTree/VirtualizedTree.tsx(34,22): -@fluentui/docs: TS2345: Argument of type 'number' is not assignable to parameter of type '(prevState: undefined) => undefined'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/docs/src/prototypes/VirtualizedTree/VirtualizedTree.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/docs/src/prototypes/VirtualizedTree/VirtualizedTree.tsx(64,31): -@fluentui/docs: TS2538: Type 'undefined' cannot be used as an index type. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Avatar/Avatar.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Avatar/Avatar.tsx(153,1): -@fluentui/docs: TS2322: Type '{ name: PropTypes.Requireable; image: (props: Record, propName: string, componentName: string, ...args: any[]) => any; label: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 12 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Box/Box.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Box/Box.tsx(71,1): -@fluentui/docs: TS2322: Type '{ styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; display: PropTypes.Requireable<...>; ... 19 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: The types of 'design[nominalTypeHack].position' are incompatible between these types. -@fluentui/docs: Type 'string' is not assignable to type 'PositionProperty'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Button/Button.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Button/Button.tsx(249,1): -@fluentui/docs: TS2322: Type '{ circular: PropTypes.Requireable; disabled: PropTypes.Requireable; fluid: PropTypes.Requireable; icon: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 19 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Button/ButtonContent.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Button/ButtonContent.tsx(59,1): -@fluentui/docs: TS2322: Type '{ size: Requireable; styles: Requireable; variables: Requireable; design: Requireable; ... 20 more ...; maxHeight: Requireable<...>; }>>; ... 5 more ...; accessibility: Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/Card.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/Card.tsx(133,1): -@fluentui/docs: TS2322: Type '{ onClick: PropTypes.Requireable<(...args: any[]) => any>; compact: PropTypes.Requireable; horizontal: PropTypes.Requireable; centered: PropTypes.Requireable<...>; ... 8 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardBody.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardBody.tsx(64,1): -@fluentui/docs: TS2322: Type '{ fitted: PropTypes.Requireable; styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; ... 20 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardColumn.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardColumn.tsx(59,1): -@fluentui/docs: TS2322: Type '{ styles: Requireable; variables: Requireable; design: Requireable; display: Requireable; ... 19 more ...; maxHeight: Requireable<...>; }>>; ... 5 more ...; accessibility: Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardFooter.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardFooter.tsx(64,1): -@fluentui/docs: TS2322: Type '{ fitted: PropTypes.Requireable; styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; ... 20 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardHeader.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardHeader.tsx(64,1): -@fluentui/docs: TS2322: Type '{ fitted: PropTypes.Requireable; styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; ... 20 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardPreview.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardPreview.tsx(67,1): -@fluentui/docs: TS2322: Type '{ horizontal: PropTypes.Requireable; fitted: PropTypes.Requireable; styles: PropTypes.Requireable; variables: PropTypes.Requireable; ... 6 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardTopControls.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardTopControls.tsx(60,1): -@fluentui/docs: TS2322: Type '{ styles: Requireable; variables: Requireable; design: Requireable; display: Requireable; ... 19 more ...; maxHeight: Requireable<...>; }>>; ... 5 more ...; accessibility: Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Carousel/CarouselPaddle.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Carousel/CarouselPaddle.tsx(166,1): -@fluentui/docs: TS2322: Type '{ disabled: PropTypes.Requireable; hidden: PropTypes.Requireable; onClick: PropTypes.Requireable<(...args: any[]) => any>; next: (props: Record<...>, propName: string, componentName: string, ...args: any[]) => any; ... 9 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/Chat.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/Chat.tsx(105,1): -@fluentui/docs: TS2322: Type '{ items: PropTypes.Requireable[]>; styles: PropTypes.Requireable; ... 7 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/ChatItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/ChatItem.tsx(150,1): -@fluentui/docs: TS2322: Type '{ attached: PropTypes.Requireable; gutter: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 10 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/ChatMessage.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/ChatMessage.tsx(365,1): -@fluentui/docs: TS2322: Type '{ actionMenu: PropTypes.Requireable; attached: PropTypes.Requireable; author: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 19 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Checkbox/Checkbox.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Checkbox/Checkbox.tsx(200,1): -@fluentui/docs: TS2322: Type '{ checked: PropTypes.Requireable; defaultChecked: PropTypes.Requireable; disabled: PropTypes.Requireable; indicator: PropTypes.Requireable<...>; ... 13 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Dropdown/DropdownItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Dropdown/DropdownItem.tsx(181,1): -@fluentui/docs: TS2322: Type '{ accessibilityItemProps: PropTypes.Requireable; active: PropTypes.Requireable; content: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 15 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Flex/Flex.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Flex/Flex.tsx(124,1): -@fluentui/docs: TS2322: Type '{ inline: PropTypes.Requireable; column: PropTypes.Requireable; wrap: PropTypes.Requireable; hAlign: PropTypes.Requireable<"stretch" | "center" | "end" | "start">; ... 14 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Flex/FlexItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Flex/FlexItem.tsx(122,1): -@fluentui/docs: TS2322: Type '{ children: PropTypes.Requireable any)>; align: PropTypes.Requireable<"stretch" | "center" | "end" | "start" | "baseline" | "auto">; ... 11 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Icon/Icon.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Icon/Icon.tsx(133,1): -@fluentui/docs: TS2322: Type '{ bordered: PropTypes.Requireable; circular: PropTypes.Requireable; disabled: PropTypes.Requireable; name: PropTypes.Validator; ... 12 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Image/Image.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Image/Image.tsx(94,1): -@fluentui/docs: TS2322: Type '{ avatar: PropTypes.Requireable; circular: PropTypes.Requireable; fluid: PropTypes.Requireable; styles: PropTypes.Requireable; ... 7 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Label/Label.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Label/Label.tsx(178,1): -@fluentui/docs: TS2322: Type '{ circular: PropTypes.Requireable; icon: (props: Record, propName: string, componentName: string, ...args: any[]) => any; iconPosition: PropTypes.Requireable<"end" | "start">; ... 11 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/List/List.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/List/List.tsx(186,1): -@fluentui/docs: TS2322: Type '{ debug: PropTypes.Requireable; items: (props: Record, propName: string, componentName: string, ...args: any[]) => any; selectable: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 16 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/List/ListItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/List/ListItem.tsx(244,1): -@fluentui/docs: TS2322: Type '{ contentMedia: PropTypes.Requireable; content: PropTypes.Requireable; debug: PropTypes.Requireable; header: PropTypes.Requireable; ... 18 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Provider/Provider.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Provider/Provider.tsx(210,3): -@fluentui/docs: TS2322: Type 'Requireable; componentVariables: Requireable; componentStyles: Requireable; fontFaces: Requireable[]>; staticStyles: Requireable<...>; animations: Requireable<...>; }>>' is not assignable to type 'Validator>'. -@fluentui/docs: The types of '[nominalTypeHack].componentStyles' are incompatible between these types. -@fluentui/docs: Type 'object' is not assignable to type 'ThemeComponentStylesInput'. -@fluentui/docs: Type 'object' is not assignable to type 'Record>'. -@fluentui/docs: Index signature is missing in type '{}'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Slider/Slider.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Slider/Slider.tsx(276,1): -@fluentui/docs: TS2322: Type '{ defaultValue: PropTypes.Requireable; fluid: PropTypes.Requireable; getA11yValueMessageOnChange: PropTypes.Requireable<...>; ... 16 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/SplitButton/SplitButtonToggle.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/SplitButton/SplitButtonToggle.tsx(134,1): -@fluentui/docs: TS2322: Type '{ disabled: PropTypes.Requireable; onClick: PropTypes.Requireable<(...args: any[]) => any>; primary: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 10 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Status/Status.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Status/Status.tsx(85,1): -@fluentui/docs: TS2322: Type '{ color: PropTypes.Requireable; icon: (props: Record, propName: string, componentName: string, ...args: any[]) => any; size: PropTypes.Requireable; ... 8 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Table/TableCell.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Table/TableCell.tsx(126,1): -@fluentui/docs: TS2322: Type '{ content: (props: Record, propName: string, componentName: string, ...args: any[]) => any; truncateContent: PropTypes.Requireable; styles: PropTypes.Requireable<...>; ... 6 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Text/Text.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Text/Text.tsx(166,1): -@fluentui/docs: TS2322: Type '{ atMention: PropTypes.Requireable; disabled: PropTypes.Requireable; error: PropTypes.Requireable; important: PropTypes.Requireable; ... 15 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarCustomItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarCustomItem.tsx(119,1): -@fluentui/docs: TS2322: Type '{ fitted: PropTypes.Requireable; focusable: PropTypes.Requireable; onFocus: PropTypes.Requireable<(...args: any[]) => any>; ... 9 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarDivider.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarDivider.tsx(63,1): -@fluentui/docs: TS2322: Type '{ styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; display: PropTypes.Requireable<...>; ... 19 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarItem.tsx(365,1): -@fluentui/docs: TS2322: Type '{ active: PropTypes.Requireable; disabled: PropTypes.Requireable; icon: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 16 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenu.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenu.tsx(168,1): -@fluentui/docs: TS2322: Type '{ items: (props: Record, propName: string, componentName: string, ...args: any[]) => any; onItemClick: PropTypes.Requireable<(...args: any[]) => any>; submenu: PropTypes.Requireable<...>; ... 9 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuDivider.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuDivider.tsx(63,1): -@fluentui/docs: TS2322: Type '{ styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; display: PropTypes.Requireable<...>; ... 19 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuItem.tsx(447,1): -@fluentui/docs: TS2322: Type '{ active: PropTypes.Requireable; activeIndicator: PropTypes.Requireable; defaultMenuOpen: PropTypes.Requireable; ... 19 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuRadioGroup.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuRadioGroup.tsx(152,1): -@fluentui/docs: TS2322: Type '{ activeIndex: PropTypes.Requireable; items: (props: Record, propName: string, componentName: string, ...args: any[]) => any; onItemClick: PropTypes.Requireable<(...args: any[]) => any>; ... 9 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarRadioGroup.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarRadioGroup.tsx(163,1): -@fluentui/docs: TS2322: Type '{ activeIndex: PropTypes.Requireable; items: (props: Record, propName: string, componentName: string, ...args: any[]) => any; styles: PropTypes.Requireable; ... 7 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tooltip/TooltipContent.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tooltip/TooltipContent.tsx(108,1): -@fluentui/docs: TS2322: Type '{ placement: PropTypes.Requireable; pointing: PropTypes.Requireable; pointerRef: PropTypes.Requireable<((...args: any[]) => any) | { current: any; }>; ... 8 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tree/TreeItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tree/TreeItem.tsx(243,1): -@fluentui/docs: TS2322: Type '{ contentRef: PropTypes.Requireable<((...args: any[]) => any) | { current: any; }>; id: PropTypes.Validator; index: PropTypes.Requireable; ... 19 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tree/TreeTitle.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tree/TreeTitle.tsx(129,1): -@fluentui/docs: TS2322: Type '{ hasSubtree: PropTypes.Requireable; index: PropTypes.Requireable; level: PropTypes.Requireable; onClick: PropTypes.Requireable<(...args: any[]) => any>; ... 10 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'. -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/utilities/src/object.ts -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/utilities/src/object.ts(15,42): -@fluentui/docs: TS2536: Type 'Extract' cannot be used to index type 'TB'. -@fluentui/docs: Child HtmlWebpackCompiler: -@fluentui/docs: Entrypoint HtmlWebpackPlugin_0 = __child-HtmlWebpackPlugin_0 -@fluentui/docs: [XX:XX:XX] Webpack compiler encountered errors. -@fluentui/docs: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. +@fluentui/keyboard-key: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. @@ -341,189 +49,18 @@ info cli using local version of lerna @fluentui/ability-attributes: npm WARN lifecycle The node binary used for scripts is but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. @uifabric/example-data: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect @fluentui/keyboard-key: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect -@uifabric/set-version: [XX:XX:XX XM] ▲ One of these [node-sass, postcss, autoprefixer] is not installed, so this task has no effect -@fluentui/docs: npm WARN lifecycle The node binary used for scripts is but npm is using /usr/local/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. -@fluentui/docs: @fluentui/react-northstar: You are running Fela in production mode. This limits your ability to edit styles in browsers development tools. To enable development mode please paste `window.localStorage.felaDevMode = true` to your browsers console and reload the page. -@fluentui/docs: [XX:XX:XX] 'build:docs:webpack' errored after -@fluentui/docs: [XX:XX:XX] Error in plugin 'webpack' -@fluentui/docs: Message: -@fluentui/docs: /office-ui-fabric-react/packages/fluentui/docs/src/examples/components/Toolbar/Content/ToolbarExampleMenuRadioGroup.shorthand.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/docs/src/examples/components/Toolbar/Content/ToolbarExampleMenuRadioGroup.shorthand.tsx(35,25): -@fluentui/docs: TS2345: Argument of type 'boolean' is not assignable to parameter of type '(prevState: undefined) => undefined'.,/office-ui-fabric-react/packages/fluentui/docs/src/prototypes/VirtualizedTree/VirtualizedTree.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/docs/src/prototypes/VirtualizedTree/VirtualizedTree.tsx(34,22): -@fluentui/docs: TS2345: Argument of type 'number' is not assignable to parameter of type '(prevState: undefined) => undefined'.,/office-ui-fabric-react/packages/fluentui/docs/src/prototypes/VirtualizedTree/VirtualizedTree.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/docs/src/prototypes/VirtualizedTree/VirtualizedTree.tsx(64,31): -@fluentui/docs: TS2538: Type 'undefined' cannot be used as an index type.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Avatar/Avatar.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Avatar/Avatar.tsx(153,1): -@fluentui/docs: TS2322: Type '{ name: PropTypes.Requireable; image: (props: Record, propName: string, componentName: string, ...args: any[]) => any; label: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 12 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Box/Box.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Box/Box.tsx(71,1): -@fluentui/docs: TS2322: Type '{ styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; display: PropTypes.Requireable<...>; ... 19 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: The types of 'design[nominalTypeHack].position' are incompatible between these types. -@fluentui/docs: Type 'string' is not assignable to type 'PositionProperty'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Button/Button.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Button/Button.tsx(249,1): -@fluentui/docs: TS2322: Type '{ circular: PropTypes.Requireable; disabled: PropTypes.Requireable; fluid: PropTypes.Requireable; icon: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 19 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Button/ButtonContent.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Button/ButtonContent.tsx(59,1): -@fluentui/docs: TS2322: Type '{ size: Requireable; styles: Requireable; variables: Requireable; design: Requireable; ... 20 more ...; maxHeight: Requireable<...>; }>>; ... 5 more ...; accessibility: Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/Card.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/Card.tsx(133,1): -@fluentui/docs: TS2322: Type '{ onClick: PropTypes.Requireable<(...args: any[]) => any>; compact: PropTypes.Requireable; horizontal: PropTypes.Requireable; centered: PropTypes.Requireable<...>; ... 8 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardBody.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardBody.tsx(64,1): -@fluentui/docs: TS2322: Type '{ fitted: PropTypes.Requireable; styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; ... 20 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardColumn.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardColumn.tsx(59,1): -@fluentui/docs: TS2322: Type '{ styles: Requireable; variables: Requireable; design: Requireable; display: Requireable; ... 19 more ...; maxHeight: Requireable<...>; }>>; ... 5 more ...; accessibility: Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardFooter.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardFooter.tsx(64,1): -@fluentui/docs: TS2322: Type '{ fitted: PropTypes.Requireable; styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; ... 20 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardHeader.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardHeader.tsx(64,1): -@fluentui/docs: TS2322: Type '{ fitted: PropTypes.Requireable; styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; ... 20 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardPreview.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardPreview.tsx(67,1): -@fluentui/docs: TS2322: Type '{ horizontal: PropTypes.Requireable; fitted: PropTypes.Requireable; styles: PropTypes.Requireable; variables: PropTypes.Requireable; ... 6 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardTopControls.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Card/CardTopControls.tsx(60,1): -@fluentui/docs: TS2322: Type '{ styles: Requireable; variables: Requireable; design: Requireable; display: Requireable; ... 19 more ...; maxHeight: Requireable<...>; }>>; ... 5 more ...; accessibility: Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Carousel/CarouselPaddle.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Carousel/CarouselPaddle.tsx(166,1): -@fluentui/docs: TS2322: Type '{ disabled: PropTypes.Requireable; hidden: PropTypes.Requireable; onClick: PropTypes.Requireable<(...args: any[]) => any>; next: (props: Record<...>, propName: string, componentName: string, ...args: any[]) => any; ... 9 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/Chat.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/Chat.tsx(105,1): -@fluentui/docs: TS2322: Type '{ items: PropTypes.Requireable[]>; styles: PropTypes.Requireable; ... 7 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/ChatItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/ChatItem.tsx(150,1): -@fluentui/docs: TS2322: Type '{ attached: PropTypes.Requireable; gutter: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 10 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/ChatMessage.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Chat/ChatMessage.tsx(365,1): -@fluentui/docs: TS2322: Type '{ actionMenu: PropTypes.Requireable; attached: PropTypes.Requireable; author: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 19 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Checkbox/Checkbox.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Checkbox/Checkbox.tsx(200,1): -@fluentui/docs: TS2322: Type '{ checked: PropTypes.Requireable; defaultChecked: PropTypes.Requireable; disabled: PropTypes.Requireable; indicator: PropTypes.Requireable<...>; ... 13 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Dropdown/DropdownItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Dropdown/DropdownItem.tsx(181,1): -@fluentui/docs: TS2322: Type '{ accessibilityItemProps: PropTypes.Requireable; active: PropTypes.Requireable; content: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 15 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Flex/Flex.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Flex/Flex.tsx(124,1): -@fluentui/docs: TS2322: Type '{ inline: PropTypes.Requireable; column: PropTypes.Requireable; wrap: PropTypes.Requireable; hAlign: PropTypes.Requireable<"stretch" | "center" | "end" | "start">; ... 14 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Flex/FlexItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Flex/FlexItem.tsx(122,1): -@fluentui/docs: TS2322: Type '{ children: PropTypes.Requireable any)>; align: PropTypes.Requireable<"stretch" | "center" | "end" | "start" | "baseline" | "auto">; ... 11 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Icon/Icon.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Icon/Icon.tsx(133,1): -@fluentui/docs: TS2322: Type '{ bordered: PropTypes.Requireable; circular: PropTypes.Requireable; disabled: PropTypes.Requireable; name: PropTypes.Validator; ... 12 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Image/Image.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Image/Image.tsx(94,1): -@fluentui/docs: TS2322: Type '{ avatar: PropTypes.Requireable; circular: PropTypes.Requireable; fluid: PropTypes.Requireable; styles: PropTypes.Requireable; ... 7 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Label/Label.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Label/Label.tsx(178,1): -@fluentui/docs: TS2322: Type '{ circular: PropTypes.Requireable; icon: (props: Record, propName: string, componentName: string, ...args: any[]) => any; iconPosition: PropTypes.Requireable<"end" | "start">; ... 11 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/List/List.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/List/List.tsx(186,1): -@fluentui/docs: TS2322: Type '{ debug: PropTypes.Requireable; items: (props: Record, propName: string, componentName: string, ...args: any[]) => any; selectable: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 16 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/List/ListItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/List/ListItem.tsx(244,1): -@fluentui/docs: TS2322: Type '{ contentMedia: PropTypes.Requireable; content: PropTypes.Requireable; debug: PropTypes.Requireable; header: PropTypes.Requireable; ... 18 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Provider/Provider.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Provider/Provider.tsx(210,3): -@fluentui/docs: TS2322: Type 'Requireable; componentVariables: Requireable; componentStyles: Requireable; fontFaces: Requireable[]>; staticStyles: Requireable<...>; animations: Requireable<...>; }>>' is not assignable to type 'Validator>'. -@fluentui/docs: The types of '[nominalTypeHack].componentStyles' are incompatible between these types. -@fluentui/docs: Type 'object' is not assignable to type 'ThemeComponentStylesInput'. -@fluentui/docs: Type 'object' is not assignable to type 'Record>'. -@fluentui/docs: Index signature is missing in type '{}'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Slider/Slider.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Slider/Slider.tsx(276,1): -@fluentui/docs: TS2322: Type '{ defaultValue: PropTypes.Requireable; fluid: PropTypes.Requireable; getA11yValueMessageOnChange: PropTypes.Requireable<...>; ... 16 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/SplitButton/SplitButtonToggle.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/SplitButton/SplitButtonToggle.tsx(134,1): -@fluentui/docs: TS2322: Type '{ disabled: PropTypes.Requireable; onClick: PropTypes.Requireable<(...args: any[]) => any>; primary: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 10 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Status/Status.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Status/Status.tsx(85,1): -@fluentui/docs: TS2322: Type '{ color: PropTypes.Requireable; icon: (props: Record, propName: string, componentName: string, ...args: any[]) => any; size: PropTypes.Requireable; ... 8 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Table/TableCell.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Table/TableCell.tsx(126,1): -@fluentui/docs: TS2322: Type '{ content: (props: Record, propName: string, componentName: string, ...args: any[]) => any; truncateContent: PropTypes.Requireable; styles: PropTypes.Requireable<...>; ... 6 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Text/Text.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Text/Text.tsx(166,1): -@fluentui/docs: TS2322: Type '{ atMention: PropTypes.Requireable; disabled: PropTypes.Requireable; error: PropTypes.Requireable; important: PropTypes.Requireable; ... 15 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarCustomItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarCustomItem.tsx(119,1): -@fluentui/docs: TS2322: Type '{ fitted: PropTypes.Requireable; focusable: PropTypes.Requireable; onFocus: PropTypes.Requireable<(...args: any[]) => any>; ... 9 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarDivider.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarDivider.tsx(63,1): -@fluentui/docs: TS2322: Type '{ styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; display: PropTypes.Requireable<...>; ... 19 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarItem.tsx(365,1): -@fluentui/docs: TS2322: Type '{ active: PropTypes.Requireable; disabled: PropTypes.Requireable; icon: (props: Record, propName: string, componentName: string, ...args: any[]) => any; ... 16 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenu.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenu.tsx(168,1): -@fluentui/docs: TS2322: Type '{ items: (props: Record, propName: string, componentName: string, ...args: any[]) => any; onItemClick: PropTypes.Requireable<(...args: any[]) => any>; submenu: PropTypes.Requireable<...>; ... 9 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuDivider.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuDivider.tsx(63,1): -@fluentui/docs: TS2322: Type '{ styles: PropTypes.Requireable; variables: PropTypes.Requireable; design: PropTypes.Requireable; display: PropTypes.Requireable<...>; ... 19 more ...; maxHeight: PropTypes.Requireable<...>; }>>; ... 5 more ...; accessibility: PropTypes.R...' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuItem.tsx(447,1): -@fluentui/docs: TS2322: Type '{ active: PropTypes.Requireable; activeIndicator: PropTypes.Requireable; defaultMenuOpen: PropTypes.Requireable; ... 19 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuRadioGroup.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarMenuRadioGroup.tsx(152,1): -@fluentui/docs: TS2322: Type '{ activeIndex: PropTypes.Requireable; items: (props: Record, propName: string, componentName: string, ...args: any[]) => any; onItemClick: PropTypes.Requireable<(...args: any[]) => any>; ... 9 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarRadioGroup.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Toolbar/ToolbarRadioGroup.tsx(163,1): -@fluentui/docs: TS2322: Type '{ activeIndex: PropTypes.Requireable; items: (props: Record, propName: string, componentName: string, ...args: any[]) => any; styles: PropTypes.Requireable; ... 7 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tooltip/TooltipContent.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tooltip/TooltipContent.tsx(108,1): -@fluentui/docs: TS2322: Type '{ placement: PropTypes.Requireable; pointing: PropTypes.Requireable; pointerRef: PropTypes.Requireable<((...args: any[]) => any) | { current: any; }>; ... 8 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tree/TreeItem.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tree/TreeItem.tsx(243,1): -@fluentui/docs: TS2322: Type '{ contentRef: PropTypes.Requireable<((...args: any[]) => any) | { current: any; }>; id: PropTypes.Validator; index: PropTypes.Requireable; ... 19 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tree/TreeTitle.tsx -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/fluentui/react-northstar/src/components/Tree/TreeTitle.tsx(129,1): -@fluentui/docs: TS2322: Type '{ hasSubtree: PropTypes.Requireable; index: PropTypes.Requireable; level: PropTypes.Requireable; onClick: PropTypes.Requireable<(...args: any[]) => any>; ... 10 more ...; accessibility: PropTypes.Requireable<...>; }' is not assignable to type 'WeakValidationMap>'. -@fluentui/docs: Types of property 'design' are incompatible. -@fluentui/docs: Type 'Requireable; display: Requireable; top: Requireable; right: Requireable; bottom: Requireable<...>; ... 16 more ...; maxHeight: Requireable<...>; }>>' is not assignable to type 'Validator'.,/office-ui-fabric-react/packages/utilities/src/object.ts -@fluentui/docs: ERROR in /office-ui-fabric-react/packages/utilities/src/object.ts(15,42): -@fluentui/docs: TS2536: Type 'Extract' cannot be used to index type 'TB'. -@fluentui/docs: Details: -@fluentui/docs: domainThrown: true -@fluentui/docs: [XX:XX:XX] 'build:docs' errored after -@fluentui/docs: error Command failed with exit code 1. -lerna ERR! yarn run build exited 1 in '@fluentui/docs' +@fluentui/keyboard-key: Warning: You have changed the public API signature for this project. Please copy the file "temp/keyboard-key.api.md" to "etc/keyboard-key.api.md", or perform a local build (which does this automatically). See the Git repo documentation for more info. +@fluentui/keyboard-key: [XX:XX:XX XM] x Error detected while running 'api-extractor:verify' +@fluentui/keyboard-key: [XX:XX:XX XM] x ------------------------------------ +@fluentui/keyboard-key: [XX:XX:XX XM] x Error: The public API file is out of date. Please run the API snapshot and commit the updated API file. +@fluentui/keyboard-key: at apiExtractorVerify (/office-ui-fabric-react/node_modules/just-scripts/src/tasks/apiExtractorTask.ts:73:13) +@fluentui/keyboard-key: at _wrapFunction (/office-ui-fabric-react/node_modules/just-task/lib/wrapTask.js:13:36) +@fluentui/keyboard-key: at api-extractor:verify (/office-ui-fabric-react/node_modules/undertaker/lib/set-task.js:13:15) +@fluentui/keyboard-key: at bound (domain.js:426:14) +@fluentui/keyboard-key: at runBound (domain.js:439:12) +@fluentui/keyboard-key: at asyncRunner (/office-ui-fabric-react/node_modules/async-done/index.js:55:18) +@fluentui/keyboard-key: at processTicksAndRejections (internal/process/task_queues.js:79:11) +@fluentui/keyboard-key: [XX:XX:XX XM] x ------------------------------------ +@fluentui/keyboard-key: [XX:XX:XX XM] x Error previously detected. See above for error messages. +@fluentui/keyboard-key: error Command failed with exit code 1. +lerna ERR! yarn run build exited 1 in '@fluentui/keyboard-key' diff --git a/tests/baselines/reference/docker/vscode.log b/tests/baselines/reference/docker/vscode.log index 6c793934526..b4a91c0057a 100644 --- a/tests/baselines/reference/docker/vscode.log +++ b/tests/baselines/reference/docker/vscode.log @@ -4,10 +4,13 @@ yarn run vX.X.X $ gulp compile --max_old_space_size=4095 [XX:XX:XX] Node flags detected: --max_old_space_size=4095 [XX:XX:XX] Using gulpfile /vscode/gulpfile.js -[XX:XX:XX] Error: /vscode/src/vs/workbench/services/search/common/search.ts(617,20): This condition will always return true since the function is always defined. Did you mean to call it instead? +[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts(70,7): This condition will always return true since the function is always defined. Did you mean to call it instead? +[XX:XX:XX] Error: /vscode/src/vs/workbench/services/search/common/search.ts(620,20): This condition will always return true since the function is always defined. Did you mean to call it instead? [XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/webview/electron-browser/webviewCommands.ts(156,13): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/scm/browser/repositoryPane.ts(809,7): This condition will always return true since the function is always defined. Did you mean to call it instead? +[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/scm/browser/repositoryPane.ts(823,7): This condition will always return true since the function is always defined. Did you mean to call it instead? [XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts(522,18): This condition will always return true since the function is always defined. Did you mean to call it instead? +[XX:XX:XX] Error: /vscode/src/vs/workbench/test/browser/workbenchTestServices.ts(1039,183): Property 'getTypeId' does not exist on type 'never'. + The intersection 'TestEditorInput & TestFileEditorInput' was reduced to 'never' because property 'typeId' exists in multiple constituents and is private in some. [XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1075,7): This condition will always return true since the function is always defined. Did you mean to call it instead? [XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1087,7): This condition will always return true since the function is always defined. Did you mean to call it instead? [XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1093,7): This condition will always return true since the function is always defined. Did you mean to call it instead? @@ -17,10 +20,13 @@ $ gulp compile --max_old_space_size=4095 [XX:XX:XX] Error: /vscode/src/vs/base/browser/mouseEvent.ts(89,7): This condition will always return true since the function is always defined. Did you mean to call it instead? [XX:XX:XX] Error: /vscode/src/vs/base/browser/mouseEvent.ts(211,8): This condition will always return true since the function is always defined. Did you mean to call it instead? [XX:XX:XX] Error: /vscode/src/vs/base/browser/mouseEvent.ts(219,8): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/services/search/common/search.ts(617,20): This condition will always return true since the function is always defined. Did you mean to call it instead? +[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts(70,7): This condition will always return true since the function is always defined. Did you mean to call it instead? +[XX:XX:XX] Error: /vscode/src/vs/workbench/services/search/common/search.ts(620,20): This condition will always return true since the function is always defined. Did you mean to call it instead? [XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/webview/electron-browser/webviewCommands.ts(156,13): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/scm/browser/repositoryPane.ts(809,7): This condition will always return true since the function is always defined. Did you mean to call it instead? +[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/scm/browser/repositoryPane.ts(823,7): This condition will always return true since the function is always defined. Did you mean to call it instead? [XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts(522,18): This condition will always return true since the function is always defined. Did you mean to call it instead? +[XX:XX:XX] Error: /vscode/src/vs/workbench/test/browser/workbenchTestServices.ts(1039,183): Property 'getTypeId' does not exist on type 'never'. + The intersection 'TestEditorInput & TestFileEditorInput' was reduced to 'never' because property 'typeId' exists in multiple constituents and is private in some. [XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1075,7): This condition will always return true since the function is always defined. Did you mean to call it instead? [XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1087,7): This condition will always return true since the function is always defined. Did you mean to call it instead? [XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1093,7): This condition will always return true since the function is always defined. Did you mean to call it instead? @@ -36,7 +42,7 @@ info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this comm Standard error: [XX:XX:XX] 'compile' errored after -[XX:XX:XX] Error: Found 13 errors +[XX:XX:XX] Error: Found 15 errors at Stream. (/vscode/build/lib/reporter.js:75:29) at _end (/vscode/node_modules/through/index.js:65:9) at Stream.stream.end (/vscode/node_modules/through/index.js:74:5) diff --git a/tests/baselines/reference/docker/vue-next.log b/tests/baselines/reference/docker/vue-next.log index dd16f9c6676..109fe7259d0 100644 --- a/tests/baselines/reference/docker/vue-next.log +++ b/tests/baselines/reference/docker/vue-next.log @@ -1,7 +1,7 @@ Exit Code: 0 Standard output: -> @X.X.X-alpha.10 build /vue-next +> @X.X.X-alpha.12 build /vue-next > node scripts/build.js "--types" Rolling up type definitions for compiler-core... Writing: /vue-next/temp/compiler-core.api.json @@ -75,22 +75,22 @@ created packages/reactivity/dist/reactivity.global.prod.js in ?s /vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.esm.prod.js... created packages/reactivity/dist/reactivity.esm.prod.js in ?s /vue-next/packages/runtime-core/src/index.ts → packages/runtime-core/dist/runtime-core.esm-bundler.js... -[!] (plugin rpt2) Error: /vue-next/packages/runtime-core/src/apiOptions.ts(143,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. +[!] (plugin rpt2) Error: /vue-next/packages/runtime-core/src/componentOptions.ts(160,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. Type 'Function' provides no match for the signature '(...args: any): any'. -packages/runtime-core/src/apiOptions.ts -Error: /vue-next/packages/runtime-core/src/apiOptions.ts(143,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. +packages/runtime-core/src/componentOptions.ts +Error: /vue-next/packages/runtime-core/src/componentOptions.ts(160,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. Type 'Function' provides no match for the signature '(...args: any): any'. - at error (/vue-next/node_modules/rollup/dist/shared/rollup.js:10120:30) - at throwPluginError (/vue-next/node_modules/rollup/dist/shared/rollup.js:16247:12) - at Object.error (/vue-next/node_modules/rollup/dist/shared/rollup.js:17255:24) - at Object.error (/vue-next/node_modules/rollup/dist/shared/rollup.js:16420:38) + at error (/vue-next/node_modules/rollup/dist/shared/rollup.js:10399:30) + at throwPluginError (/vue-next/node_modules/rollup/dist/shared/rollup.js:16617:12) + at Object.error (/vue-next/node_modules/rollup/dist/shared/rollup.js:17634:24) + at Object.error (/vue-next/node_modules/rollup/dist/shared/rollup.js:16790:38) at RollupContext.error (/vue-next/node_modules/rollup-plugin-typescript2/src/rollupcontext.ts:37:18) at /vue-next/node_modules/rollup-plugin-typescript2/src/print-diagnostics.ts:41:11 at arrayEach (/vue-next/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:516:11) at forEach (/vue-next/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:9342:14) at _.each (/vue-next/node_modules/rollup-plugin-typescript2/src/print-diagnostics.ts:9:2) at Object.transform (/vue-next/node_modules/rollup-plugin-typescript2/src/index.ts:242:5) -(node:17) UnhandledPromiseRejectionWarning: Error: Command failed with exit code 1 (EPERM): rollup -c --environment COMMIT:94562da,NODE_ENV:production,TARGET:runtime-core,TYPES:true +(node:17) UnhandledPromiseRejectionWarning: Error: Command failed with exit code 1 (EPERM): rollup -c --environment COMMIT:a35e297,NODE_ENV:production,TARGET:runtime-core,TYPES:true at makeError (/vue-next/node_modules/execa/lib/error.js:59:11) at handlePromise (/vue-next/node_modules/execa/index.js:112:26) at processTicksAndRejections (internal/process/task_queues.js:97:5) diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 8bcaacd2794..0985a9094a0 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -3086,6 +3086,11 @@ node_modules/chrome-devtools-frontend/front_end/bindings/BlackboxManager.js(341, node_modules/chrome-devtools-frontend/front_end/bindings/BlackboxManager.js(351,31): error TS2694: Namespace 'Protocol' has no exported member 'Debugger'. node_modules/chrome-devtools-frontend/front_end/bindings/BlackboxManager.js(362,31): error TS2694: Namespace 'Protocol' has no exported member 'Debugger'. node_modules/chrome-devtools-frontend/front_end/bindings/BlackboxManager.js(375,9): error TS2322: Type 'Promise' is not assignable to type 'Promise'. +node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(54,5): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. + Type 'string | K' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string | K'. + Type 'string' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(60,52): error TS2345: Argument of type 'this' is not assignable to parameter of type 'SDKModelObserver'. Type 'BreakpointManager' is not assignable to type 'SDKModelObserver'. Types of property 'modelAdded' are incompatible. @@ -3170,6 +3175,16 @@ node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js( node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(106,20): error TS2339: Property 'pushAll' does not exist on type 'CSSLocation[]'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(126,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(132,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(153,5): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. + Type 'K | CSSStyleSheetHeader' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'K | CSSStyleSheetHeader'. + Type 'CSSStyleSheetHeader' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'CSSStyleSheetHeader'. +node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(155,5): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. + Type 'string | K' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string | K'. + Type 'string' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string'. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(160,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/bindings/CSSWorkspaceBinding.js(169,27): error TS2345: Argument of type 'CSSStyleSheetHeader' is not assignable to parameter of type 'K'. 'K' could be instantiated with an arbitrary type which could be unrelated to 'CSSStyleSheetHeader'. @@ -3220,6 +3235,11 @@ node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBindin 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(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(207,34): error TS2339: Property 'valuesArray' does not exist on type 'Set'. +node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(260,5): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. + Type 'K | Script' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'K | Script'. + Type 'Script' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'Script'. node_modules/chrome-devtools-frontend/front_end/bindings/DebuggerWorkspaceBinding.js(267,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(276,25): error TS2345: Argument of type 'Script' is not assignable to parameter of type 'K'. 'K' could be instantiated with an arbitrary type which could be unrelated to 'Script'. @@ -4284,6 +4304,11 @@ node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(416 node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(461,42): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(470,51): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/cookie_table/CookiesTable.js(489,56): error TS2555: Expected at least 2 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(24,5): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. + Type 'K | ContentProvider' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'K | ContentProvider'. + Type 'ContentProvider' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'ContentProvider'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(50,72): error TS2345: Argument of type 'ContentProvider' is not assignable to parameter of type 'K'. 'K' could be instantiated with an arbitrary type which could be unrelated to 'ContentProvider'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageDecorationManager.js(51,22): error TS2339: Property 'removeDecorationsForType' does not exist on type 'V'. @@ -4332,6 +4357,7 @@ node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(230,25 node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(267,37): error TS2339: Property 'peekLast' does not exist on type '{ end: number; count: number; }[]'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(268,21): error TS2345: Argument of type '{ end: number; }' is not assignable to parameter of type '{ end: number; count: number; }'. Property 'count' is missing in type '{ end: number; }' but required in type '{ end: number; count: number; }'. +node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(418,32): error TS2339: Property 'upperBound' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageModel.js(441,25): error TS2339: Property 'peekLast' does not exist on type '{ end: number; count: number; }[]'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageView.js(20,48): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/coverage/CoverageView.js(32,53): error TS2555: Expected at least 2 arguments, but got 1. @@ -7188,7 +7214,7 @@ node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(531,31): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(645,19): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(646,22): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(651,5): error TS2322: Type '{ id: string; title: string; subtitle: string; visible: true; weight: number; hideable: false; nonSelectable: false; alwaysVisible: boolean; sortingFunction: (a: NetworkNode, b: NetworkNode) => number; }' is not assignable to type '{ id: string; title: string; titleDOMFragment: DocumentFragment; subtitle: string; visible: boolean; weight: number; hideable: boolean; nonSelectable: boolean; sortable: boolean; align: string; isResponseHeader: boolean; sortingFunction: (arg0: NetworkNode, arg1: NetworkNode) => number; isCustomHeader: boolean; }'. +node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(651,5): error TS2322: Type '{ id: string; title: string; subtitle: string; visible: true; weight: number; hideable: false; nonSelectable: false; alwaysVisible: true; sortingFunction: (a: NetworkNode, b: NetworkNode) => number; }' is not assignable to type '{ id: string; title: string; titleDOMFragment: DocumentFragment; subtitle: string; visible: boolean; weight: number; hideable: boolean; nonSelectable: boolean; sortable: boolean; align: string; isResponseHeader: boolean; sortingFunction: (arg0: NetworkNode, arg1: NetworkNode) => number; isCustomHeader: boolean; }'. Object literal may only specify known properties, and 'alwaysVisible' does not exist in type '{ id: string; title: string; titleDOMFragment: DocumentFragment; subtitle: string; visible: boolean; weight: number; hideable: boolean; nonSelectable: boolean; sortable: boolean; align: string; isResponseHeader: boolean; sortingFunction: (arg0: NetworkNode, arg1: NetworkNode) => number; isCustomHeader: boolean; }'. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(654,3): error TS2740: Type '{ id: string; title: string; sortingFunction: any; }' is missing the following properties from type '{ id: string; title: string; titleDOMFragment: DocumentFragment; subtitle: string; visible: boolean; weight: number; hideable: boolean; nonSelectable: boolean; sortable: boolean; align: string; isResponseHeader: boolean; sortingFunction: (arg0: NetworkNode, arg1: NetworkNode) => number; isCustomHeader: boolean; }': titleDOMFragment, subtitle, visible, weight, and 6 more. node_modules/chrome-devtools-frontend/front_end/network/NetworkLogViewColumns.js(656,19): error TS2555: Expected at least 2 arguments, but got 1. @@ -7912,14 +7938,19 @@ node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemMa node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(62,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(73,27): error TS2339: Property 'events' does not exist on type 'InspectorFrontendHostAPI'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(162,7): error TS2739: Type 'IsolatedFileSystem' is missing the following properties from type '{ type: string; fileSystemName: string; rootURL: string; fileSystemPath: string; }': fileSystemName, rootURL, fileSystemPath -node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(211,21): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. - 'K' could be instantiated with an arbitrary type which could be unrelated to 'string'. +node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(211,37): error TS2345: Argument of type 'string' is not assignable to parameter of type 'V'. + 'V' could be instantiated with an arbitrary type which could be unrelated to 'string'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(222,30): error TS2339: Property 'valuesArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/persistence/IsolatedFileSystemManager.js(264,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/persistence/NetworkPersistenceManager.js(140,55): error TS2339: Property 'hashCode' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/persistence/NetworkPersistenceManager.js(299,56): error TS2339: Property 'fileSystemPath' does not exist on type 'Project'. node_modules/chrome-devtools-frontend/front_end/persistence/NetworkPersistenceManager.js(424,30): error TS2339: Property 'fileSystemPath' does not exist on type 'Project'. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(21,51): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. +node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(22,5): error TS2322: Type 'Multimap any)>.Multimap any)>' is not assignable to type 'Multimap any>'. + Type 'UISourceCode | K' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'UISourceCode | K'. + Type 'UISourceCode' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'UISourceCode'. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(58,23): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(58,66): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/persistence/Persistence.js(62,5): error TS2322: Type 'MappingSystem' is not assignable to type 'Automapping | DefaultMapping'. @@ -9691,6 +9722,11 @@ node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(777,24): e node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(779,24): error TS2694: Namespace 'Protocol' has no exported member 'Network'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(782,24): error TS2694: Namespace 'Protocol' has no exported member 'Network'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(799,31): error TS2694: Namespace 'Protocol' has no exported member 'NetworkAgent'. +node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(813,5): error TS2322: Type 'Multimap Promise), V | { urlPattern: string; interceptionStage: any; }>.Multimap Promise<...>), V | { ...; }>' is not assignable to type 'Multimap<(arg0: InterceptedRequest) => Promise, { urlPattern: string; interceptionStage: any; }>'. + Type 'K | ((arg0: InterceptedRequest) => Promise)' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'K | ((arg0: InterceptedRequest) => Promise)'. + Type '(arg0: InterceptedRequest) => Promise' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to '(arg0: InterceptedRequest) => Promise'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(827,21): error TS2339: Property 'sprintf' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(836,31): error TS2339: Property 'networkAgent' does not exist on type 'Target'. node_modules/chrome-devtools-frontend/front_end/sdk/NetworkManager.js(855,32): error TS2339: Property 'networkAgent' does not exist on type 'Target'. @@ -10078,6 +10114,12 @@ node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(507,20): error node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(527,37): error TS2339: Property '_base64Map' does not exist on type 'typeof TextSourceMap'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(558,18): error TS2339: Property 'lowerBound' does not exist on type 'SourceMapEntry[]'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMap.js(559,29): error TS2339: Property 'upperBound' does not exist on type 'SourceMapEntry[]'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(28,5): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. + Type 'string | K' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string | K'. + Type 'string' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string'. +node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(30,5): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(85,41): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. 'K' could be instantiated with an arbitrary type which could be unrelated to 'string'. node_modules/chrome-devtools-frontend/front_end/sdk/SourceMapManager.js(86,46): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. @@ -10648,6 +10690,11 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSid node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(34,41): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(41,27): error TS2339: Property 'removeChildren' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(42,47): error TS2339: Property 'createChild' does not exist on type 'Element'. +node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(49,9): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. + Type 'string | K' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string | K'. + Type 'string' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(53,28): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. 'K' could be instantiated with an arbitrary type which could be unrelated to 'string'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(66,35): error TS2339: Property 'createChild' does not exist on type 'Element'. @@ -10738,6 +10785,11 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1473,94): error TS2339: Property 'metaKey' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1476,52): error TS2339: Property 'shiftKey' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptSourceFrame.js(1477,17): error TS2339: Property 'consume' does not exist on type 'Event'. +node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(44,5): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. + Type 'UISourceCode | K' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'UISourceCode | K'. + Type 'UISourceCode' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'UISourceCode'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(87,21): error TS2339: Property '_boostOrder' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(90,32): error TS2339: Property '_typeOrders' does not exist on type 'typeof NavigatorView'. node_modules/chrome-devtools-frontend/front_end/sources/NavigatorView.js(102,29): error TS2339: Property '_typeOrders' does not exist on type 'typeof NavigatorView'. @@ -11301,6 +11353,11 @@ node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(1426,2 node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(1427,48): error TS2339: Property '_instanceForTest' does not exist on type 'typeof Main'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(47,35): error TS2339: Property 'CodeMirror' does not exist on type 'Window & typeof globalThis'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(165,18): error TS2339: Property 'style' does not exist on type 'Element'. +node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(170,5): error TS2322: Type 'Multimap any; }>.Multimap any; }>' is not assignable to type 'Multimap any; }>'. + Type 'number | K' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'number | K'. + Type 'number' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'number'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(198,45): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(207,16): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. node_modules/chrome-devtools-frontend/front_end/text_editor/CodeMirrorTextEditor.js(214,16): error TS2339: Property '_codeMirrorTextEditor' does not exist on type 'CodeMirror'. @@ -12479,7 +12536,6 @@ node_modules/chrome-devtools-frontend/front_end/ui/ListControl.js(523,39): error node_modules/chrome-devtools-frontend/front_end/ui/ListControl.js(529,35): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/ui/ListControl.js(557,33): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/ui/ListControl.js(592,18): error TS2339: Property 'removeChildren' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/ui/ListControl.js(637,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'index' must be of type 'number', but here has type 'any'. node_modules/chrome-devtools-frontend/front_end/ui/ListWidget.js(16,38): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/ListWidget.js(17,18): error TS2339: Property 'tabIndex' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/ListWidget.js(127,14): error TS2339: Property 'createChild' does not exist on type 'Element'. @@ -12577,6 +12633,16 @@ node_modules/chrome-devtools-frontend/front_end/ui/SettingsUI.js(107,25): error node_modules/chrome-devtools-frontend/front_end/ui/SettingsUI.js(119,27): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/SettingsUI.js(133,24): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/ui/SettingsUI.js(155,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/ShortcutRegistry.js(15,5): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. + Type 'string | K' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string | K'. + Type 'string' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string'. +node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(17,5): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. + Type 'string | K' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string | K'. + Type 'string' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(26,83): error TS2339: Property 'valuesArray' does not exist on type 'Set'. node_modules/chrome-devtools-frontend/front_end/ui/ShortcutRegistry.js(34,5): error TS2322: Type 'Set' is not assignable to type 'Set'. Type 'V' is not assignable to type 'string'. @@ -13228,6 +13294,11 @@ node_modules/chrome-devtools-frontend/front_end/workspace/SearchConfig.js(164,20 node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(45,25): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(136,21): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(298,33): error TS2555: Expected at least 2 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(545,7): error TS2322: Type 'Multimap.Multimap' is not assignable to type 'Multimap'. + Type 'string | K' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string | K'. + Type 'string' is not assignable to type 'K'. + 'K' could be instantiated with an arbitrary type which could be unrelated to 'string'. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(546,27): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. 'K' could be instantiated with an arbitrary type which could be unrelated to 'string'. node_modules/chrome-devtools-frontend/front_end/workspace/UISourceCode.js(556,41): error TS2345: Argument of type 'string' is not assignable to parameter of type 'K'. diff --git a/tests/baselines/reference/user/npm.log b/tests/baselines/reference/user/npm.log index 8569e9fb2e1..0bc07705d00 100644 --- a/tests/baselines/reference/user/npm.log +++ b/tests/baselines/reference/user/npm.log @@ -1781,6 +1781,7 @@ node_modules/npm/test/tap/unsupported.js(2,20): error TS2307: Cannot find module node_modules/npm/test/tap/update-examples.js(2,20): error TS2307: Cannot find module 'tap' or its corresponding type declarations. node_modules/npm/test/tap/update-examples.js(6,18): error TS2307: Cannot find module 'npm-registry-mock' or its corresponding type declarations. node_modules/npm/test/tap/update-examples.js(10,29): error TS2307: Cannot find module 'require-inject' or its corresponding type declarations. +node_modules/npm/test/tap/update-examples.js(127,15): error TS2565: Property 'prototype' is used before being assigned. node_modules/npm/test/tap/update-path.js(2,20): error TS2307: Cannot find module 'tap' or its corresponding type declarations. node_modules/npm/test/tap/update-path.js(3,29): error TS2307: Cannot find module 'require-inject' or its corresponding type declarations. node_modules/npm/test/tap/upgrade-lifecycles.js(3,20): error TS2307: Cannot find module 'tap' or its corresponding type declarations. diff --git a/tests/baselines/reference/user/puppeteer.log b/tests/baselines/reference/user/puppeteer.log index bc93c4c29f5..b0e6d8711bc 100644 --- a/tests/baselines/reference/user/puppeteer.log +++ b/tests/baselines/reference/user/puppeteer.log @@ -1,96 +1,9 @@ Exit Code: 1 Standard output: -lib/Accessibility.js(134,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Accessibility.js(344,7): error TS2322: Type 'string | number | boolean' is not assignable to type 'never'. - Type 'string' is not assignable to type 'never'. -lib/Accessibility.js(367,7): error TS2322: Type 'string | number | true' is not assignable to type 'never'. - Type 'string' is not assignable to type 'never'. -lib/Accessibility.js(379,7): error TS2322: Type 'boolean | "mixed"' is not assignable to type 'never'. - Type 'false' is not assignable to type 'never'. -lib/Accessibility.js(390,7): error TS2322: Type 'string | number | boolean' is not assignable to type 'never'. - Type 'string' is not assignable to type 'never'. -lib/Accessibility.js(403,7): error TS2322: Type 'string | number | true' is not assignable to type 'never'. - Type 'string' is not assignable to type 'never'. -lib/Accessibility.js(409,22): error TS2503: Cannot find namespace 'Protocol'. -lib/Browser.js(109,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Browser.js(116,58): error TS2322: Type 'Promise' is not assignable to type 'Promise'. - Type 'CDPSession' is not assignable to type 'Puppeteer.CDPSession'. -lib/Browser.js(141,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Connection.js(149,14): error TS2503: Cannot find namespace 'Protocol'. -lib/Coverage.js(115,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Coverage.js(208,15): error TS2503: Cannot find namespace 'Protocol'. -lib/EmulationManager.js(36,16): error TS2503: Cannot find namespace 'Protocol'. -lib/ExecutionContext.js(26,15): error TS2503: Cannot find namespace 'Protocol'. -lib/ExecutionContext.js(158,18): error TS2503: Cannot find namespace 'Protocol'. -lib/ExecutionContext.js(186,14): error TS2503: Cannot find namespace 'Protocol'. -lib/FrameManager.js(151,15): error TS2503: Cannot find namespace 'Protocol'. -lib/FrameManager.js(173,15): error TS2503: Cannot find namespace 'Protocol'. -lib/FrameManager.js(230,15): error TS2503: Cannot find namespace 'Protocol'. -lib/FrameManager.js(668,15): error TS2503: Cannot find namespace 'Protocol'. -lib/JSHandle.js(32,15): error TS2503: Cannot find namespace 'Protocol'. -lib/JSHandle.js(146,15): error TS2503: Cannot find namespace 'Protocol'. -lib/JSHandle.js(237,29): error TS2503: Cannot find namespace 'Protocol'. -lib/Launcher.js(181,17): error TS1003: Identifier expected. -lib/Launcher.js(359,17): error TS1003: Identifier expected. -lib/NetworkManager.js(32,30): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(159,15): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(178,15): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(197,15): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(218,15): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(239,15): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(249,15): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(263,15): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(276,15): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(295,15): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(319,15): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(529,15): error TS2503: Cannot find namespace 'Protocol'. -lib/NetworkManager.js(668,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(93,33): error TS2345: Argument of type 'CDPSession' is not assignable to parameter of type 'Puppeteer.CDPSession'. - Types of property 'on' are incompatible. - Type '(event: string | symbol, listener: (...args: any[]) => void) => CDPSession' is not assignable to type '(event: T, listener: (arg: any) => void) => CDPSession'. - Types of parameters 'event' and 'event' are incompatible. - Type 'T' is not assignable to type 'string | symbol'. - Type 'string | number | symbol' is not assignable to type 'string | symbol'. - Type 'number' is not assignable to type 'string | symbol'. - Type 'T' is not assignable to type 'symbol'. - Type 'string | number | symbol' is not assignable to type 'symbol'. - Type 'string' is not assignable to type 'symbol'. -lib/Page.js(94,42): error TS2345: Argument of type 'Worker' is not assignable to parameter of type 'Worker'. - Type 'Worker' is missing the following properties from type 'Worker': onmessage, onmessageerror, postMessage, terminate, and 4 more. -lib/Page.js(142,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(217,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(385,20): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(448,7): error TS2740: Type '(...args: any[]) => Promise' is missing the following properties from type 'Window': applicationCache, clientInformation, closed, customElements, and 221 more. -lib/Page.js(458,9): error TS2349: This expression is not callable. - Type 'Window' has no call signatures. -lib/Page.js(494,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(504,22): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(517,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(527,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(552,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(605,14): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(941,19): error TS2503: Cannot find namespace 'Protocol'. -lib/Page.js(1352,15): error TS2503: Cannot find namespace 'Protocol'. -lib/PipeTransport.js(19,17): error TS1003: Identifier expected. -lib/Target.js(23,15): error TS2503: Cannot find namespace 'Protocol'. -lib/Target.js(87,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. - Type 'Worker | Worker' is not assignable to type 'Worker'. - Type 'Worker' is not assignable to type 'Worker'. Two different types with this name exist, but they are unrelated. -lib/Target.js(135,15): error TS2503: Cannot find namespace 'Protocol'. -lib/WebSocketTransport.js(19,17): error TS1003: Identifier expected. -lib/WebSocketTransport.js(32,72): error TS2345: Argument of type 'import("/puppeteer/puppeteer/node_modules/@types/ws/index")' is not assignable to parameter of type 'WebSocket'. - Property 'dispatchEvent' is missing in type 'import("/puppeteer/puppeteer/node_modules/@types/ws/index")' but required in type 'WebSocket'. -lib/Worker.js(25,50): error TS2503: Cannot find namespace 'Protocol'. -lib/Worker.js(26,24): error TS2503: Cannot find namespace 'Protocol'. -lib/Worker.js(33,26): error TS2503: Cannot find namespace 'Protocol'. -lib/externs.d.ts(18,26): error TS2503: Cannot find namespace 'Protocol'. -lib/externs.d.ts(18,69): error TS2503: Cannot find namespace 'Protocol'. -lib/externs.d.ts(19,28): error TS2503: Cannot find namespace 'Protocol'. -lib/externs.d.ts(19,81): error TS2503: Cannot find namespace 'Protocol'. -lib/externs.d.ts(19,121): error TS2503: Cannot find namespace 'Protocol'. -lib/helper.js(45,15): error TS2503: Cannot find namespace 'Protocol'. -lib/helper.js(63,15): error TS2503: Cannot find namespace 'Protocol'. -lib/helper.js(89,15): error TS2503: Cannot find namespace 'Protocol'. +src/Launcher.js(181,17): error TS1003: Identifier expected. +src/Launcher.js(359,17): error TS1003: Identifier expected. +src/PipeTransport.js(19,17): error TS1003: Identifier expected. +src/WebSocketTransport.js(19,17): error TS1003: Identifier expected. diff --git a/tests/baselines/reference/user/uglify-js.log b/tests/baselines/reference/user/uglify-js.log index 56d77b49d24..216e2f5d2fd 100644 --- a/tests/baselines/reference/user/uglify-js.log +++ b/tests/baselines/reference/user/uglify-js.log @@ -16,38 +16,38 @@ node_modules/uglify-js/lib/compress.js(163,24): error TS2554: Expected 2 argumen node_modules/uglify-js/lib/compress.js(188,42): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/compress.js(248,18): error TS2554: Expected 2 arguments, but got 1. node_modules/uglify-js/lib/compress.js(536,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(876,33): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(881,12): error TS2339: Property 'defun_ids' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(882,12): error TS2339: Property 'defun_visited' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(884,12): error TS2339: Property 'in_loop' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(885,12): error TS2339: Property 'loop_ids' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(890,12): error TS2339: Property 'safe_ids' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(1141,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1156,51): error TS2349: This expression is not callable. +node_modules/uglify-js/lib/compress.js(877,33): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(882,12): error TS2339: Property 'defun_ids' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(883,12): error TS2339: Property 'defun_visited' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(885,12): error TS2339: Property 'in_loop' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(886,12): error TS2339: Property 'loop_ids' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(891,12): error TS2339: Property 'safe_ids' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(1140,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1155,51): error TS2349: This expression is not callable. Not all constituents of type 'true | ((node: any, tw: any) => any)' are callable. Type 'true' has no call signatures. -node_modules/uglify-js/lib/compress.js(1230,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1251,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1297,112): error TS2454: Variable 'args' is used before being assigned. -node_modules/uglify-js/lib/compress.js(1298,29): error TS2532: Object is possibly 'undefined'. -node_modules/uglify-js/lib/compress.js(1316,29): error TS2322: Type 'false' is not assignable to type 'number'. -node_modules/uglify-js/lib/compress.js(1324,29): error TS2322: Type 'false' is not assignable to type 'never'. -node_modules/uglify-js/lib/compress.js(1472,53): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1583,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1607,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1622,46): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1653,39): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1685,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1701,39): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. -node_modules/uglify-js/lib/compress.js(1798,42): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1829,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(1951,49): error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, (number | undefined)?]'. +node_modules/uglify-js/lib/compress.js(1229,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1250,53): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1296,112): error TS2454: Variable 'args' is used before being assigned. +node_modules/uglify-js/lib/compress.js(1297,29): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(1315,29): error TS2322: Type 'false' is not assignable to type 'number'. +node_modules/uglify-js/lib/compress.js(1323,29): error TS2322: Type 'false' is not assignable to type 'never'. +node_modules/uglify-js/lib/compress.js(1471,53): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1582,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1606,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1621,46): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1652,39): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1684,38): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1700,39): error TS2339: Property 'parent' does not exist on type 'TreeTransformer'. +node_modules/uglify-js/lib/compress.js(1797,42): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1828,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(1950,49): error TS2345: Argument of type 'number[]' is not assignable to parameter of type '[number, (number | undefined)?]'. Property '0' is missing in type 'number[]' but required in type '[number, (number | undefined)?]'. -node_modules/uglify-js/lib/compress.js(2282,59): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(2320,53): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[number, (number | undefined)?]'. +node_modules/uglify-js/lib/compress.js(2281,59): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(2319,53): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[number, (number | undefined)?]'. Property '0' is missing in type 'any[]' but required in type '[number, (number | undefined)?]'. -node_modules/uglify-js/lib/compress.js(2468,34): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(2913,35): error TS2554: Expected 2 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(2467,34): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(2912,35): error TS2554: Expected 2 arguments, but got 1. node_modules/uglify-js/lib/compress.js(3256,55): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. node_modules/uglify-js/lib/compress.js(3257,25): error TS2531: Object is possibly 'null'. node_modules/uglify-js/lib/compress.js(3257,55): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. @@ -87,18 +87,24 @@ node_modules/uglify-js/lib/compress.js(5781,45): error TS2554: Expected 0 argume node_modules/uglify-js/lib/compress.js(5788,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'code' must be of type 'string', but here has type '{ get: () => string; toString: () => string; indent: (half: any) => void; indentation: () => number; current_width: () => number; should_break: () => boolean; has_parens: () => boolean; newline: () => void; print: (str: any) => void; ... 23 more ...; parent: (n: any) => any; }'. node_modules/uglify-js/lib/compress.js(5792,36): error TS2532: Object is possibly 'undefined'. node_modules/uglify-js/lib/compress.js(5797,41): error TS2339: Property 'get' does not exist on type 'string'. -node_modules/uglify-js/lib/compress.js(6325,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. -node_modules/uglify-js/lib/compress.js(6949,29): error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. -node_modules/uglify-js/lib/compress.js(6991,47): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(7072,39): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(7144,39): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(7150,41): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/compress.js(7153,41): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/compress.js(7715,43): error TS2454: Variable 'property' is used before being assigned. -node_modules/uglify-js/lib/compress.js(7730,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(7733,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. -node_modules/uglify-js/lib/compress.js(7739,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. -node_modules/uglify-js/lib/compress.js(7772,34): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5834,59): error TS2554: Expected 2 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5946,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(5950,21): error TS2322: Type 'null' is not assignable to type 'any[]'. +node_modules/uglify-js/lib/compress.js(5962,25): error TS2322: Type 'null' is not assignable to type 'any[]'. +node_modules/uglify-js/lib/compress.js(5974,32): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(5978,27): error TS2532: Object is possibly 'undefined'. +node_modules/uglify-js/lib/compress.js(6405,18): error TS2454: Variable 'is_strict_comparison' is used before being assigned. +node_modules/uglify-js/lib/compress.js(7029,29): error TS2367: This condition will always return 'false' since the types 'boolean' and 'string' have no overlap. +node_modules/uglify-js/lib/compress.js(7071,47): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(7152,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(7224,39): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(7230,41): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/compress.js(7233,41): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/compress.js(7795,43): error TS2454: Variable 'property' is used before being assigned. +node_modules/uglify-js/lib/compress.js(7810,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(7813,46): error TS2339: Property 'has_side_effects' does not exist on type 'number'. +node_modules/uglify-js/lib/compress.js(7819,25): error TS2403: Subsequent variable declarations must have the same type. Variable 'value' must be of type 'number', but here has type 'any'. +node_modules/uglify-js/lib/compress.js(7852,34): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/minify.js(186,42): error TS2554: Expected 2 arguments, but got 1. node_modules/uglify-js/lib/minify.js(186,75): error TS2339: Property 'compress' does not exist on type 'Compressor'. node_modules/uglify-js/lib/mozilla-ast.js(566,33): error TS2554: Expected 0 arguments, but got 1. @@ -145,15 +151,16 @@ node_modules/uglify-js/lib/scope.js(89,21): error TS2339: Property 'defun' does node_modules/uglify-js/lib/scope.js(89,35): error TS2339: Property 'defun' does not exist on type 'SymbolDef'. node_modules/uglify-js/lib/scope.js(103,29): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/scope.js(158,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(165,38): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/scope.js(193,47): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(243,17): error TS2554: Expected 3 arguments, but got 2. -node_modules/uglify-js/lib/scope.js(423,29): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(436,49): error TS2339: Property 'has_directive' does not exist on type 'TreeWalker'. -node_modules/uglify-js/lib/scope.js(491,30): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/scope.js(516,30): error TS2554: Expected 0 arguments, but got 1. -node_modules/uglify-js/lib/sourcemap.js(55,25): error TS2304: Cannot find name 'MOZ_SourceMap'. -node_modules/uglify-js/lib/sourcemap.js(61,23): error TS2304: Cannot find name 'MOZ_SourceMap'. +node_modules/uglify-js/lib/scope.js(172,33): error TS2339: Property 'parent' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/scope.js(198,47): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(248,17): error TS2554: Expected 3 arguments, but got 2. +node_modules/uglify-js/lib/scope.js(428,29): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(441,49): error TS2339: Property 'has_directive' does not exist on type 'TreeWalker'. +node_modules/uglify-js/lib/scope.js(496,30): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/scope.js(521,30): error TS2554: Expected 0 arguments, but got 1. +node_modules/uglify-js/lib/sourcemap.js(82,11): error TS2339: Property 'index' does not exist on type 'any[]'. +node_modules/uglify-js/lib/sourcemap.js(173,31): error TS2339: Property 'index' does not exist on type 'any[]'. +node_modules/uglify-js/lib/sourcemap.js(181,34): error TS2339: Property 'index' does not exist on type 'any[]'. node_modules/uglify-js/tools/exit.js(10,37): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[(number | undefined)?]'. Types of property 'length' are incompatible. Type 'number' is not assignable to type '0 | 1'. diff --git a/tests/baselines/reference/user/zone.js.log b/tests/baselines/reference/user/zone.js.log deleted file mode 100644 index 304b5ea6591..00000000000 --- a/tests/baselines/reference/user/zone.js.log +++ /dev/null @@ -1,7 +0,0 @@ -Exit Code: 1 -Standard output: -node_modules/zone.js/dist/zone.js.d.ts(600,21): error TS2503: Cannot find namespace 'NodeJS'. - - - -Standard error: From 8dd6b3a389255d5b09d4f6ec259631395ac44893 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Apr 2020 15:34:34 -0700 Subject: [PATCH 07/74] Accept recent tests with updated baseline code (#37945) --- .../reference/moduleAugmentationDoesInterfaceMergeOfReexport.js | 2 +- .../moduleAugmentationDoesNamespaceEnumMergeOfReexport.js | 2 +- .../reference/moduleAugmentationDoesNamespaceMergeOfReexport.js | 2 +- .../moduleAugmentationEnumClassMergeOfReexportIsError.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/moduleAugmentationDoesInterfaceMergeOfReexport.js b/tests/baselines/reference/moduleAugmentationDoesInterfaceMergeOfReexport.js index a9850728a38..1366f9cb258 100644 --- a/tests/baselines/reference/moduleAugmentationDoesInterfaceMergeOfReexport.js +++ b/tests/baselines/reference/moduleAugmentationDoesInterfaceMergeOfReexport.js @@ -35,7 +35,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./file"), exports); diff --git a/tests/baselines/reference/moduleAugmentationDoesNamespaceEnumMergeOfReexport.js b/tests/baselines/reference/moduleAugmentationDoesNamespaceEnumMergeOfReexport.js index d6e04e9935a..0cf02bb0c60 100644 --- a/tests/baselines/reference/moduleAugmentationDoesNamespaceEnumMergeOfReexport.js +++ b/tests/baselines/reference/moduleAugmentationDoesNamespaceEnumMergeOfReexport.js @@ -40,7 +40,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./file"), exports); diff --git a/tests/baselines/reference/moduleAugmentationDoesNamespaceMergeOfReexport.js b/tests/baselines/reference/moduleAugmentationDoesNamespaceMergeOfReexport.js index 9608ca76032..9ddd49666a8 100644 --- a/tests/baselines/reference/moduleAugmentationDoesNamespaceMergeOfReexport.js +++ b/tests/baselines/reference/moduleAugmentationDoesNamespaceMergeOfReexport.js @@ -39,7 +39,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./file"), exports); diff --git a/tests/baselines/reference/moduleAugmentationEnumClassMergeOfReexportIsError.js b/tests/baselines/reference/moduleAugmentationEnumClassMergeOfReexportIsError.js index e30558417bc..1bd7540e23f 100644 --- a/tests/baselines/reference/moduleAugmentationEnumClassMergeOfReexportIsError.js +++ b/tests/baselines/reference/moduleAugmentationEnumClassMergeOfReexportIsError.js @@ -38,7 +38,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (!exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); } exports.__esModule = true; __exportStar(require("./file"), exports); From edd4e0a42bc8bb124aab11ff89f42d72689faf4f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Apr 2020 15:54:37 -0700 Subject: [PATCH 08/74] Add fastpath to isRelatedTo for type references (#37481) * Add fastpath to isRelatedTo for type references * Do not check intersections or unions to ignore propegating reference flags, properly set comparing jsx flag * Re-remove unneeded check * Just check for TypeFlags.Object * Remove else clause --- src/compiler/checker.ts | 89 ++++++++----- .../reference/recursiveArrayNotCircular.js | 66 +++++++++ .../recursiveArrayNotCircular.symbols | 126 ++++++++++++++++++ .../reference/recursiveArrayNotCircular.types | 114 ++++++++++++++++ .../compiler/recursiveArrayNotCircular.ts | 36 +++++ 5 files changed, 394 insertions(+), 37 deletions(-) create mode 100644 tests/baselines/reference/recursiveArrayNotCircular.js create mode 100644 tests/baselines/reference/recursiveArrayNotCircular.symbols create mode 100644 tests/baselines/reference/recursiveArrayNotCircular.types create mode 100644 tests/cases/compiler/recursiveArrayNotCircular.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d627a55ce8b..4e2495aceae 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15541,11 +15541,21 @@ namespace ts { * * Ternary.False if they are not related. */ function isRelatedTo(originalSource: Type, originalTarget: Type, reportErrors = false, headMessage?: DiagnosticMessage, intersectionState = IntersectionState.None): Ternary { + // Before normalization: if `source` is type an object type, and `target` is primitive, + // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result + if (originalSource.flags & TypeFlags.Object && originalTarget.flags & TypeFlags.Primitive) { + if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { + return Ternary.True; + } + reportErrorResults(originalSource, originalTarget, Ternary.False, !!(getObjectFlags(originalSource) & ObjectFlags.JsxAttributes)); + return Ternary.False; + } + // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and // conditional types, and resolve substitution types to either the substitution (on the source // side) or the type variable (on the target side). - let source = getNormalizedType(originalSource, /*writing*/ false); + const source = getNormalizedType(originalSource, /*writing*/ false); let target = getNormalizedType(originalTarget, /*writing*/ true); if (source === target) return Ternary.True; @@ -15679,6 +15689,7 @@ namespace ts { } } } + // For certain combinations involving intersections and optional, excess, or mismatched properties we need // an extra property check where the intersection is viewed as a single object. The following are motivating // examples that all should be errors, but aren't without this extra property check: @@ -15702,47 +15713,51 @@ namespace ts { inPropertyCheck = false; } - if (!result && reportErrors) { - source = originalSource.aliasSymbol ? originalSource : source; - target = originalTarget.aliasSymbol ? originalTarget : target; - let maybeSuppress = overrideNextErrorInfo > 0; - if (maybeSuppress) { - overrideNextErrorInfo--; - } - if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { - const currentError = errorInfo; - tryElaborateArrayLikeErrors(source, target, reportErrors); - if (errorInfo !== currentError) { - maybeSuppress = !!errorInfo; + reportErrorResults(source, target, result, isComparingJsxAttributes); + return result; + + function reportErrorResults(source: Type, target: Type, result: Ternary, isComparingJsxAttributes: boolean) { + if (!result && reportErrors) { + source = originalSource.aliasSymbol ? originalSource : source; + target = originalTarget.aliasSymbol ? originalTarget : target; + let maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; } - } - if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Primitive) { - tryElaborateErrorsForPrimitivesAndObjects(source, target); - } - else if (source.symbol && source.flags & TypeFlags.Object && globalObjectType === source) { - reportError(Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); - } - else if (isComparingJsxAttributes && target.flags & TypeFlags.Intersection) { - const targetTypes = (target as IntersectionType).types; - const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); - const intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); - if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType && - (contains(targetTypes, intrinsicAttributes) || contains(targetTypes, intrinsicClassAttributes))) { - // do not report top error + if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { + const currentError = errorInfo; + tryElaborateArrayLikeErrors(source, target, reportErrors); + if (errorInfo !== currentError) { + maybeSuppress = !!errorInfo; + } + } + if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Primitive) { + tryElaborateErrorsForPrimitivesAndObjects(source, target); + } + else if (source.symbol && source.flags & TypeFlags.Object && globalObjectType === source) { + reportError(Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); + } + else if (isComparingJsxAttributes && target.flags & TypeFlags.Intersection) { + const targetTypes = (target as IntersectionType).types; + const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); + const intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); + if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType && + (contains(targetTypes, intrinsicAttributes) || contains(targetTypes, intrinsicClassAttributes))) { + // do not report top error + return result; + } + } + else { + errorInfo = elaborateNeverIntersection(errorInfo, originalTarget); + } + if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; + // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } + reportRelationError(headMessage, source, target); } - else { - errorInfo = elaborateNeverIntersection(errorInfo, originalTarget); - } - if (!headMessage && maybeSuppress) { - lastSkippedInfo = [source, target]; - // Used by, eg, missing property checking to replace the top-level message with a more informative one - return result; - } - reportRelationError(headMessage, source, target); } - return result; } function isIdenticalTo(source: Type, target: Type): Ternary { diff --git a/tests/baselines/reference/recursiveArrayNotCircular.js b/tests/baselines/reference/recursiveArrayNotCircular.js new file mode 100644 index 00000000000..50f612bfcbf --- /dev/null +++ b/tests/baselines/reference/recursiveArrayNotCircular.js @@ -0,0 +1,66 @@ +//// [recursiveArrayNotCircular.ts] +type Action = P extends void ? { type : T } : { type: T, payload: P } + +enum ActionType { + Foo, + Bar, + Baz, + Batch +} + +type ReducerAction = + | Action + | Action + | Action + | Action + +function assertNever(a: never): never { + throw new Error("Unreachable!"); +} + +function reducer(action: ReducerAction): void { + switch(action.type) { + case ActionType.Bar: + const x: number = action.payload; + break; + case ActionType.Baz: + const y: boolean = action.payload; + break; + case ActionType.Foo: + const z: string = action.payload; + break; + case ActionType.Batch: + action.payload.map(reducer); + break; + default: return assertNever(action); + } +} + +//// [recursiveArrayNotCircular.js] +var ActionType; +(function (ActionType) { + ActionType[ActionType["Foo"] = 0] = "Foo"; + ActionType[ActionType["Bar"] = 1] = "Bar"; + ActionType[ActionType["Baz"] = 2] = "Baz"; + ActionType[ActionType["Batch"] = 3] = "Batch"; +})(ActionType || (ActionType = {})); +function assertNever(a) { + throw new Error("Unreachable!"); +} +function reducer(action) { + switch (action.type) { + case ActionType.Bar: + var x = action.payload; + break; + case ActionType.Baz: + var y = action.payload; + break; + case ActionType.Foo: + var z = action.payload; + break; + case ActionType.Batch: + action.payload.map(reducer); + break; + default: return assertNever(action); + } +} diff --git a/tests/baselines/reference/recursiveArrayNotCircular.symbols b/tests/baselines/reference/recursiveArrayNotCircular.symbols new file mode 100644 index 00000000000..83a1610e9f4 --- /dev/null +++ b/tests/baselines/reference/recursiveArrayNotCircular.symbols @@ -0,0 +1,126 @@ +=== tests/cases/compiler/recursiveArrayNotCircular.ts === +type Action = P extends void ? { type : T } : { type: T, payload: P } +>Action : Symbol(Action, Decl(recursiveArrayNotCircular.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveArrayNotCircular.ts, 0, 12)) +>P : Symbol(P, Decl(recursiveArrayNotCircular.ts, 0, 14)) +>P : Symbol(P, Decl(recursiveArrayNotCircular.ts, 0, 14)) +>type : Symbol(type, Decl(recursiveArrayNotCircular.ts, 0, 38)) +>T : Symbol(T, Decl(recursiveArrayNotCircular.ts, 0, 12)) +>type : Symbol(type, Decl(recursiveArrayNotCircular.ts, 0, 53)) +>T : Symbol(T, Decl(recursiveArrayNotCircular.ts, 0, 12)) +>payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) +>P : Symbol(P, Decl(recursiveArrayNotCircular.ts, 0, 14)) + +enum ActionType { +>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) + + Foo, +>Foo : Symbol(ActionType.Foo, Decl(recursiveArrayNotCircular.ts, 2, 17)) + + Bar, +>Bar : Symbol(ActionType.Bar, Decl(recursiveArrayNotCircular.ts, 3, 8)) + + Baz, +>Baz : Symbol(ActionType.Baz, Decl(recursiveArrayNotCircular.ts, 4, 8)) + + Batch +>Batch : Symbol(ActionType.Batch, Decl(recursiveArrayNotCircular.ts, 5, 8)) +} + +type ReducerAction = +>ReducerAction : Symbol(ReducerAction, Decl(recursiveArrayNotCircular.ts, 7, 1)) + + | Action +>Action : Symbol(Action, Decl(recursiveArrayNotCircular.ts, 0, 0)) +>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) +>Bar : Symbol(ActionType.Bar, Decl(recursiveArrayNotCircular.ts, 3, 8)) + + | Action +>Action : Symbol(Action, Decl(recursiveArrayNotCircular.ts, 0, 0)) +>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) +>Baz : Symbol(ActionType.Baz, Decl(recursiveArrayNotCircular.ts, 4, 8)) + + | Action +>Action : Symbol(Action, Decl(recursiveArrayNotCircular.ts, 0, 0)) +>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) +>Foo : Symbol(ActionType.Foo, Decl(recursiveArrayNotCircular.ts, 2, 17)) + + | Action +>Action : Symbol(Action, Decl(recursiveArrayNotCircular.ts, 0, 0)) +>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) +>Batch : Symbol(ActionType.Batch, Decl(recursiveArrayNotCircular.ts, 5, 8)) +>ReducerAction : Symbol(ReducerAction, Decl(recursiveArrayNotCircular.ts, 7, 1)) + +function assertNever(a: never): never { +>assertNever : Symbol(assertNever, Decl(recursiveArrayNotCircular.ts, 13, 45)) +>a : Symbol(a, Decl(recursiveArrayNotCircular.ts, 15, 21)) + + throw new Error("Unreachable!"); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} + +function reducer(action: ReducerAction): void { +>reducer : Symbol(reducer, Decl(recursiveArrayNotCircular.ts, 17, 1)) +>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) +>ReducerAction : Symbol(ReducerAction, Decl(recursiveArrayNotCircular.ts, 7, 1)) + + switch(action.type) { +>action.type : Symbol(type, Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53)) +>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) +>type : Symbol(type, Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53), Decl(recursiveArrayNotCircular.ts, 0, 53)) + + case ActionType.Bar: +>ActionType.Bar : Symbol(ActionType.Bar, Decl(recursiveArrayNotCircular.ts, 3, 8)) +>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) +>Bar : Symbol(ActionType.Bar, Decl(recursiveArrayNotCircular.ts, 3, 8)) + + const x: number = action.payload; +>x : Symbol(x, Decl(recursiveArrayNotCircular.ts, 22, 17)) +>action.payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) +>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) +>payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) + + break; + case ActionType.Baz: +>ActionType.Baz : Symbol(ActionType.Baz, Decl(recursiveArrayNotCircular.ts, 4, 8)) +>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) +>Baz : Symbol(ActionType.Baz, Decl(recursiveArrayNotCircular.ts, 4, 8)) + + const y: boolean = action.payload; +>y : Symbol(y, Decl(recursiveArrayNotCircular.ts, 25, 17)) +>action.payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62), Decl(recursiveArrayNotCircular.ts, 0, 62)) +>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) +>payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62), Decl(recursiveArrayNotCircular.ts, 0, 62)) + + break; + case ActionType.Foo: +>ActionType.Foo : Symbol(ActionType.Foo, Decl(recursiveArrayNotCircular.ts, 2, 17)) +>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) +>Foo : Symbol(ActionType.Foo, Decl(recursiveArrayNotCircular.ts, 2, 17)) + + const z: string = action.payload; +>z : Symbol(z, Decl(recursiveArrayNotCircular.ts, 28, 17)) +>action.payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) +>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) +>payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) + + break; + case ActionType.Batch: +>ActionType.Batch : Symbol(ActionType.Batch, Decl(recursiveArrayNotCircular.ts, 5, 8)) +>ActionType : Symbol(ActionType, Decl(recursiveArrayNotCircular.ts, 0, 75)) +>Batch : Symbol(ActionType.Batch, Decl(recursiveArrayNotCircular.ts, 5, 8)) + + action.payload.map(reducer); +>action.payload.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>action.payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) +>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) +>payload : Symbol(payload, Decl(recursiveArrayNotCircular.ts, 0, 62)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>reducer : Symbol(reducer, Decl(recursiveArrayNotCircular.ts, 17, 1)) + + break; + default: return assertNever(action); +>assertNever : Symbol(assertNever, Decl(recursiveArrayNotCircular.ts, 13, 45)) +>action : Symbol(action, Decl(recursiveArrayNotCircular.ts, 19, 17)) + } +} diff --git a/tests/baselines/reference/recursiveArrayNotCircular.types b/tests/baselines/reference/recursiveArrayNotCircular.types new file mode 100644 index 00000000000..1d0c76523af --- /dev/null +++ b/tests/baselines/reference/recursiveArrayNotCircular.types @@ -0,0 +1,114 @@ +=== tests/cases/compiler/recursiveArrayNotCircular.ts === +type Action = P extends void ? { type : T } : { type: T, payload: P } +>Action : Action +>type : T +>type : T +>payload : P + +enum ActionType { +>ActionType : ActionType + + Foo, +>Foo : ActionType.Foo + + Bar, +>Bar : ActionType.Bar + + Baz, +>Baz : ActionType.Baz + + Batch +>Batch : ActionType.Batch +} + +type ReducerAction = +>ReducerAction : ReducerAction + + | Action +>ActionType : any + + | Action +>ActionType : any + + | Action +>ActionType : any + + | Action +>ActionType : any + +function assertNever(a: never): never { +>assertNever : (a: never) => never +>a : never + + throw new Error("Unreachable!"); +>new Error("Unreachable!") : Error +>Error : ErrorConstructor +>"Unreachable!" : "Unreachable!" +} + +function reducer(action: ReducerAction): void { +>reducer : (action: ReducerAction) => void +>action : ReducerAction + + switch(action.type) { +>action.type : ActionType +>action : ReducerAction +>type : ActionType + + case ActionType.Bar: +>ActionType.Bar : ActionType.Bar +>ActionType : typeof ActionType +>Bar : ActionType.Bar + + const x: number = action.payload; +>x : number +>action.payload : number +>action : { type: ActionType.Bar; payload: number; } +>payload : number + + break; + case ActionType.Baz: +>ActionType.Baz : ActionType.Baz +>ActionType : typeof ActionType +>Baz : ActionType.Baz + + const y: boolean = action.payload; +>y : boolean +>action.payload : boolean +>action : { type: ActionType.Baz; payload: false; } | { type: ActionType.Baz; payload: true; } +>payload : boolean + + break; + case ActionType.Foo: +>ActionType.Foo : ActionType.Foo +>ActionType : typeof ActionType +>Foo : ActionType.Foo + + const z: string = action.payload; +>z : string +>action.payload : string +>action : { type: ActionType.Foo; payload: string; } +>payload : string + + break; + case ActionType.Batch: +>ActionType.Batch : ActionType.Batch +>ActionType : typeof ActionType +>Batch : ActionType.Batch + + action.payload.map(reducer); +>action.payload.map(reducer) : void[] +>action.payload.map : (callbackfn: (value: ReducerAction, index: number, array: ReducerAction[]) => U, thisArg?: any) => U[] +>action.payload : ReducerAction[] +>action : { type: ActionType.Batch; payload: ReducerAction[]; } +>payload : ReducerAction[] +>map : (callbackfn: (value: ReducerAction, index: number, array: ReducerAction[]) => U, thisArg?: any) => U[] +>reducer : (action: ReducerAction) => void + + break; + default: return assertNever(action); +>assertNever(action) : never +>assertNever : (a: never) => never +>action : never + } +} diff --git a/tests/cases/compiler/recursiveArrayNotCircular.ts b/tests/cases/compiler/recursiveArrayNotCircular.ts new file mode 100644 index 00000000000..3bf2b419f3a --- /dev/null +++ b/tests/cases/compiler/recursiveArrayNotCircular.ts @@ -0,0 +1,36 @@ +type Action = P extends void ? { type : T } : { type: T, payload: P } + +enum ActionType { + Foo, + Bar, + Baz, + Batch +} + +type ReducerAction = + | Action + | Action + | Action + | Action + +function assertNever(a: never): never { + throw new Error("Unreachable!"); +} + +function reducer(action: ReducerAction): void { + switch(action.type) { + case ActionType.Bar: + const x: number = action.payload; + break; + case ActionType.Baz: + const y: boolean = action.payload; + break; + case ActionType.Foo: + const z: string = action.payload; + break; + case ActionType.Batch: + action.payload.map(reducer); + break; + default: return assertNever(action); + } +} \ No newline at end of file From 4538640d8a99ff0f6044479462ae844abb69e910 Mon Sep 17 00:00:00 2001 From: Ashley Claymore Date: Tue, 14 Apr 2020 20:20:19 +0100 Subject: [PATCH 09/74] Added error when Enum member initaliser references itself (#34655) Fixes #34606 --- src/compiler/checker.ts | 3 +++ ...opertyAccessBeforeInitalisation.errors.txt | 22 +++++++++++++++ .../enumPropertyAccessBeforeInitalisation.js | 17 ++++++++++++ ...mPropertyAccessBeforeInitalisation.symbols | 24 +++++++++++++++++ ...numPropertyAccessBeforeInitalisation.types | 27 +++++++++++++++++++ .../enumPropertyAccessBeforeInitalisation.ts | 6 +++++ 6 files changed, 99 insertions(+) create mode 100644 tests/baselines/reference/enumPropertyAccessBeforeInitalisation.errors.txt create mode 100644 tests/baselines/reference/enumPropertyAccessBeforeInitalisation.js create mode 100644 tests/baselines/reference/enumPropertyAccessBeforeInitalisation.symbols create mode 100644 tests/baselines/reference/enumPropertyAccessBeforeInitalisation.types create mode 100644 tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4e2495aceae..a0d21dbc49d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -33764,6 +33764,9 @@ namespace ts { error(expr, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return 0; } + else { + error(expr, Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(memberSymbol)); + } } return undefined; } diff --git a/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.errors.txt b/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.errors.txt new file mode 100644 index 00000000000..417a1e3e175 --- /dev/null +++ b/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts(2,9): error TS2565: Property 'A' is used before being assigned. +tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts(3,9): error TS2565: Property 'B' is used before being assigned. +tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts(4,9): error TS2565: Property 'C' is used before being assigned. +tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts(5,13): error TS2565: Property 'D' is used before being assigned. + + +==== tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts (4 errors) ==== + enum E { + A = A, + ~ +!!! error TS2565: Property 'A' is used before being assigned. + B = E.B, + ~~~ +!!! error TS2565: Property 'B' is used before being assigned. + C = E["C"], + ~~~~~~ +!!! error TS2565: Property 'C' is used before being assigned. + D = 1 + D + ~ +!!! error TS2565: Property 'D' is used before being assigned. + } + \ No newline at end of file diff --git a/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.js b/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.js new file mode 100644 index 00000000000..cef3fdc8ebb --- /dev/null +++ b/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.js @@ -0,0 +1,17 @@ +//// [enumPropertyAccessBeforeInitalisation.ts] +enum E { + A = A, + B = E.B, + C = E["C"], + D = 1 + D +} + + +//// [enumPropertyAccessBeforeInitalisation.js] +var E; +(function (E) { + E[E["A"] = E.A] = "A"; + E[E["B"] = E.B] = "B"; + E[E["C"] = E["C"]] = "C"; + E[E["D"] = 1 + E.D] = "D"; +})(E || (E = {})); diff --git a/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.symbols b/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.symbols new file mode 100644 index 00000000000..faa130d4ce4 --- /dev/null +++ b/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts === +enum E { +>E : Symbol(E, Decl(enumPropertyAccessBeforeInitalisation.ts, 0, 0)) + + A = A, +>A : Symbol(E.A, Decl(enumPropertyAccessBeforeInitalisation.ts, 0, 8)) +>A : Symbol(E.A, Decl(enumPropertyAccessBeforeInitalisation.ts, 0, 8)) + + B = E.B, +>B : Symbol(E.B, Decl(enumPropertyAccessBeforeInitalisation.ts, 1, 10)) +>E.B : Symbol(E.B, Decl(enumPropertyAccessBeforeInitalisation.ts, 1, 10)) +>E : Symbol(E, Decl(enumPropertyAccessBeforeInitalisation.ts, 0, 0)) +>B : Symbol(E.B, Decl(enumPropertyAccessBeforeInitalisation.ts, 1, 10)) + + C = E["C"], +>C : Symbol(E.C, Decl(enumPropertyAccessBeforeInitalisation.ts, 2, 12)) +>E : Symbol(E, Decl(enumPropertyAccessBeforeInitalisation.ts, 0, 0)) +>"C" : Symbol(E.C, Decl(enumPropertyAccessBeforeInitalisation.ts, 2, 12)) + + D = 1 + D +>D : Symbol(E.D, Decl(enumPropertyAccessBeforeInitalisation.ts, 3, 15)) +>D : Symbol(E.D, Decl(enumPropertyAccessBeforeInitalisation.ts, 3, 15)) +} + diff --git a/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.types b/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.types new file mode 100644 index 00000000000..eb101b2ad76 --- /dev/null +++ b/tests/baselines/reference/enumPropertyAccessBeforeInitalisation.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts === +enum E { +>E : E + + A = A, +>A : E +>A : E + + B = E.B, +>B : E +>E.B : E +>E : typeof E +>B : E + + C = E["C"], +>C : E +>E["C"] : E +>E : typeof E +>"C" : "C" + + D = 1 + D +>D : E +>1 + D : number +>1 : 1 +>D : E +} + diff --git a/tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts b/tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts new file mode 100644 index 00000000000..335a61f778b --- /dev/null +++ b/tests/cases/compiler/enumPropertyAccessBeforeInitalisation.ts @@ -0,0 +1,6 @@ +enum E { + A = A, + B = E.B, + C = E["C"], + D = 1 + D +} From 49f5fbb2c76309cd17a7aba0f0663705e2239ff9 Mon Sep 17 00:00:00 2001 From: csigs Date: Tue, 14 Apr 2020 22:10:38 +0000 Subject: [PATCH 10/74] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 27 ++++++++ .../diagnosticMessages.generated.json.lcl | 63 ++++++++++++++++--- .../diagnosticMessages.generated.json.lcl | 48 +++++++++++--- .../diagnosticMessages.generated.json.lcl | 27 ++++++++ .../diagnosticMessages.generated.json.lcl | 27 ++++++++ .../diagnosticMessages.generated.json.lcl | 48 +++++++++++--- .../diagnosticMessages.generated.json.lcl | 27 ++++++++ .../diagnosticMessages.generated.json.lcl | 27 ++++++++ .../diagnosticMessages.generated.json.lcl | 27 ++++++++ .../diagnosticMessages.generated.json.lcl | 27 ++++++++ .../diagnosticMessages.generated.json.lcl | 27 ++++++++ 11 files changed, 348 insertions(+), 27 deletions(-) diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 6dc7816a2f5..13031a428dc 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1017,6 +1017,9 @@ + + + @@ -1059,6 +1062,9 @@ + + + @@ -1845,6 +1851,9 @@ + + + @@ -8562,6 +8571,9 @@ + + + @@ -8595,6 +8607,9 @@ + + + @@ -9969,12 +9984,18 @@ + + + + + + @@ -11799,6 +11820,9 @@ + + + @@ -11814,6 +11838,9 @@ + + + diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index 933871a745f..d41aca93740 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1017,6 +1017,9 @@ + + + @@ -1059,6 +1062,9 @@ + + + @@ -1845,6 +1851,9 @@ + + + @@ -6009,18 +6018,27 @@ + + + + + + + + + @@ -8052,15 +8070,6 @@ - - - - - - - - - @@ -8562,6 +8571,9 @@ + + + @@ -8595,6 +8607,9 @@ + + + @@ -9966,6 +9981,24 @@ + + + + + + + + + + + + + + + + + + @@ -11742,6 +11775,9 @@ + + + @@ -11784,6 +11820,9 @@ + + + @@ -11799,6 +11838,9 @@ + + + @@ -11913,6 +11955,9 @@ + + + diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 3cd87943b03..33a4a6e0b65 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1026,6 +1026,9 @@ + + + @@ -1068,6 +1071,9 @@ + + + @@ -1854,6 +1860,9 @@ + + + @@ -8070,15 +8079,6 @@ - - - - - - - - - @@ -8580,6 +8580,9 @@ + + + @@ -8613,6 +8616,9 @@ + + + @@ -9984,6 +9990,24 @@ + + + + + + + + + + + + + + + + + + @@ -11805,6 +11829,9 @@ + + + @@ -11820,6 +11847,9 @@ + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 26a938ee8a7..4dcd83c6c97 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1014,6 +1014,9 @@ + + + @@ -1056,6 +1059,9 @@ + + + @@ -1842,6 +1848,9 @@ + + + @@ -8556,6 +8565,9 @@ + + + @@ -8589,6 +8601,9 @@ + + + @@ -9963,12 +9978,18 @@ + + + + + + @@ -11793,6 +11814,9 @@ + + + @@ -11808,6 +11832,9 @@ + + + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 44fc107a4de..2a8fd334faf 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1026,6 +1026,9 @@ + + + @@ -1068,6 +1071,9 @@ + + + @@ -1857,6 +1863,9 @@ + + + @@ -8574,6 +8583,9 @@ + + + @@ -8607,6 +8619,9 @@ + + + @@ -9981,12 +9996,18 @@ + + + + + + @@ -11811,6 +11832,9 @@ + + + @@ -11826,6 +11850,9 @@ + + + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 3afa5c3f587..5532d3dd2ad 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1026,6 +1026,9 @@ + + + @@ -1068,6 +1071,9 @@ + + + @@ -1857,6 +1863,9 @@ + + + @@ -8073,15 +8082,6 @@ - - - - - - - - - @@ -8583,6 +8583,9 @@ + + + @@ -8616,6 +8619,9 @@ + + + @@ -9987,6 +9993,24 @@ + + + + + + + + + + + + + + + + + + @@ -11808,6 +11832,9 @@ + + + @@ -11823,6 +11850,9 @@ + + + diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index e00dace4d75..f83a7972c05 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1017,6 +1017,9 @@ + + + @@ -1059,6 +1062,9 @@ + + + @@ -1845,6 +1851,9 @@ + + + @@ -8562,6 +8571,9 @@ + + + @@ -8595,6 +8607,9 @@ + + + @@ -9969,12 +9984,18 @@ + + + + + + @@ -11799,6 +11820,9 @@ + + + @@ -11814,6 +11838,9 @@ + + + diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 34bea79798d..43e653f9110 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1017,6 +1017,9 @@ + + + @@ -1059,6 +1062,9 @@ + + + @@ -1845,6 +1851,9 @@ + + + @@ -8562,6 +8571,9 @@ + + + @@ -8595,6 +8607,9 @@ + + + @@ -9969,12 +9984,18 @@ + + + + + + @@ -11799,6 +11820,9 @@ + + + @@ -11814,6 +11838,9 @@ + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 65ee2644c27..40d74176e06 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1017,6 +1017,9 @@ + + + @@ -1059,6 +1062,9 @@ + + + @@ -1845,6 +1851,9 @@ + + + @@ -8562,6 +8571,9 @@ + + + @@ -8595,6 +8607,9 @@ + + + @@ -9969,12 +9984,18 @@ + + + + + + @@ -11799,6 +11820,9 @@ + + + @@ -11814,6 +11838,9 @@ + + + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index f4b5d3154f2..0d4fa3864a9 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1007,6 +1007,9 @@ + + + @@ -1049,6 +1052,9 @@ + + + @@ -1835,6 +1841,9 @@ + + + @@ -8549,6 +8558,9 @@ + + + @@ -8582,6 +8594,9 @@ + + + @@ -9956,12 +9971,18 @@ + + + + + + @@ -11786,6 +11807,9 @@ + + + @@ -11801,6 +11825,9 @@ + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index c24f1a82f8f..50e3c9757c3 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1016,6 +1016,9 @@ + + + @@ -1058,6 +1061,9 @@ + + + @@ -1844,6 +1850,9 @@ + + + @@ -8561,6 +8570,9 @@ + + + @@ -8594,6 +8606,9 @@ + + + @@ -9968,12 +9983,18 @@ + + + + + + @@ -11798,6 +11819,9 @@ + + + @@ -11813,6 +11837,9 @@ + + + From e505c79091cfd5729f5ef54b50711ffcbbfe5aa3 Mon Sep 17 00:00:00 2001 From: csigs Date: Wed, 15 Apr 2020 04:10:28 +0000 Subject: [PATCH 11/74] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 48 +++++++++++++++---- .../diagnosticMessages.generated.json.lcl | 27 +++++++++++ 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index a0ba6df8f57..1c9300f3102 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1007,6 +1007,9 @@ + + + @@ -1049,6 +1052,9 @@ + + + @@ -1838,6 +1844,9 @@ + + + @@ -8051,15 +8060,6 @@ - - - - - - - - - @@ -8561,6 +8561,9 @@ + + + @@ -8594,6 +8597,9 @@ + + + @@ -9965,6 +9971,24 @@ + + + + + + + + + + + + + + + + + + @@ -11786,6 +11810,9 @@ + + + @@ -11801,6 +11828,9 @@ + + + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index e83157d5e1a..650602aae1a 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1010,6 +1010,9 @@ + + + @@ -1052,6 +1055,9 @@ + + + @@ -1838,6 +1844,9 @@ + + + @@ -8555,6 +8564,9 @@ + + + @@ -8588,6 +8600,9 @@ + + + @@ -9962,12 +9977,18 @@ + + + + + + @@ -11792,6 +11813,9 @@ + + + @@ -11807,6 +11831,9 @@ + + + From 92cd3ae299df987083f2f2c15f088bf97f7d1c24 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 15 Apr 2020 10:34:07 -0700 Subject: [PATCH 12/74] No iteration type errors during CFA (#37965) * No iteration type errors during CFA * Add regression test --- src/compiler/checker.ts | 13 +++---- .../reference/noIterationTypeErrorsInCFA.js | 25 +++++++++++++ .../noIterationTypeErrorsInCFA.symbols | 36 ++++++++++++++++++ .../noIterationTypeErrorsInCFA.types | 37 +++++++++++++++++++ .../compiler/noIterationTypeErrorsInCFA.ts | 15 ++++++++ 5 files changed, 118 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/noIterationTypeErrorsInCFA.js create mode 100644 tests/baselines/reference/noIterationTypeErrorsInCFA.symbols create mode 100644 tests/baselines/reference/noIterationTypeErrorsInCFA.types create mode 100644 tests/cases/compiler/noIterationTypeErrorsInCFA.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a0d21dbc49d..a7d45e0ab8c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19793,9 +19793,11 @@ namespace ts { return getTypeOfSymbol(symbol); } if (isVariableDeclaration(declaration) && declaration.parent.parent.kind === SyntaxKind.ForOfStatement) { - const expressionType = getTypeOfDottedName(declaration.parent.parent.expression, /*diagnostic*/ undefined); + const statement = declaration.parent.parent; + const expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { - return getForOfIterationType(declaration.parent.parent, expressionType); + const use = statement.awaitModifier ? IterationUse.ForAwaitOf : IterationUse.ForOf; + return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); } } if (diagnostic) { @@ -32025,19 +32027,14 @@ namespace ts { } function checkRightHandSideOfForOf(statement: ForOfStatement): Type { - return getForOfIterationType(statement, checkNonNullExpression(statement.expression)); - } - - function getForOfIterationType(statement: ForOfStatement, expressionType: Type) { const use = statement.awaitModifier ? IterationUse.ForAwaitOf : IterationUse.ForOf; - return checkIteratedTypeOrElementType(use, expressionType, undefinedType, statement.expression); + return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use: IterationUse, inputType: Type, sentType: Type, errorNode: Node | undefined): Type { if (isTypeAny(inputType)) { return inputType; } - return getIteratedTypeOrElementType(use, inputType, sentType, errorNode, /*checkAssignability*/ true) || anyType; } diff --git a/tests/baselines/reference/noIterationTypeErrorsInCFA.js b/tests/baselines/reference/noIterationTypeErrorsInCFA.js new file mode 100644 index 00000000000..20cfca447af --- /dev/null +++ b/tests/baselines/reference/noIterationTypeErrorsInCFA.js @@ -0,0 +1,25 @@ +//// [noIterationTypeErrorsInCFA.ts] +interface F { + d(): void +} +export function doRemove(dds: F | F[]) { + if (!Array.isArray(dds)) { + dds = [dds] + } + for (let n of dds) { + n.d() + } + return dds +} + + +//// [noIterationTypeErrorsInCFA.js] +export function doRemove(dds) { + if (!Array.isArray(dds)) { + dds = [dds]; + } + for (let n of dds) { + n.d(); + } + return dds; +} diff --git a/tests/baselines/reference/noIterationTypeErrorsInCFA.symbols b/tests/baselines/reference/noIterationTypeErrorsInCFA.symbols new file mode 100644 index 00000000000..3498f52d456 --- /dev/null +++ b/tests/baselines/reference/noIterationTypeErrorsInCFA.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/noIterationTypeErrorsInCFA.ts === +interface F { +>F : Symbol(F, Decl(noIterationTypeErrorsInCFA.ts, 0, 0)) + + d(): void +>d : Symbol(F.d, Decl(noIterationTypeErrorsInCFA.ts, 0, 13)) +} +export function doRemove(dds: F | F[]) { +>doRemove : Symbol(doRemove, Decl(noIterationTypeErrorsInCFA.ts, 2, 1)) +>dds : Symbol(dds, Decl(noIterationTypeErrorsInCFA.ts, 3, 25)) +>F : Symbol(F, Decl(noIterationTypeErrorsInCFA.ts, 0, 0)) +>F : Symbol(F, Decl(noIterationTypeErrorsInCFA.ts, 0, 0)) + + if (!Array.isArray(dds)) { +>Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 2 more) +>isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --)) +>dds : Symbol(dds, Decl(noIterationTypeErrorsInCFA.ts, 3, 25)) + + dds = [dds] +>dds : Symbol(dds, Decl(noIterationTypeErrorsInCFA.ts, 3, 25)) +>dds : Symbol(dds, Decl(noIterationTypeErrorsInCFA.ts, 3, 25)) + } + for (let n of dds) { +>n : Symbol(n, Decl(noIterationTypeErrorsInCFA.ts, 7, 12)) +>dds : Symbol(dds, Decl(noIterationTypeErrorsInCFA.ts, 3, 25)) + + n.d() +>n.d : Symbol(F.d, Decl(noIterationTypeErrorsInCFA.ts, 0, 13)) +>n : Symbol(n, Decl(noIterationTypeErrorsInCFA.ts, 7, 12)) +>d : Symbol(F.d, Decl(noIterationTypeErrorsInCFA.ts, 0, 13)) + } + return dds +>dds : Symbol(dds, Decl(noIterationTypeErrorsInCFA.ts, 3, 25)) +} + diff --git a/tests/baselines/reference/noIterationTypeErrorsInCFA.types b/tests/baselines/reference/noIterationTypeErrorsInCFA.types new file mode 100644 index 00000000000..9d0122627ff --- /dev/null +++ b/tests/baselines/reference/noIterationTypeErrorsInCFA.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/noIterationTypeErrorsInCFA.ts === +interface F { + d(): void +>d : () => void +} +export function doRemove(dds: F | F[]) { +>doRemove : (dds: F | F[]) => F[] +>dds : F | F[] + + if (!Array.isArray(dds)) { +>!Array.isArray(dds) : boolean +>Array.isArray(dds) : boolean +>Array.isArray : (arg: any) => arg is any[] +>Array : ArrayConstructor +>isArray : (arg: any) => arg is any[] +>dds : F | F[] + + dds = [dds] +>dds = [dds] : F[] +>dds : F | F[] +>[dds] : F[] +>dds : F + } + for (let n of dds) { +>n : F +>dds : F[] + + n.d() +>n.d() : void +>n.d : () => void +>n : F +>d : () => void + } + return dds +>dds : F[] +} + diff --git a/tests/cases/compiler/noIterationTypeErrorsInCFA.ts b/tests/cases/compiler/noIterationTypeErrorsInCFA.ts new file mode 100644 index 00000000000..5505eb9b11c --- /dev/null +++ b/tests/cases/compiler/noIterationTypeErrorsInCFA.ts @@ -0,0 +1,15 @@ +// @strict: true +// @target: esnext + +interface F { + d(): void +} +export function doRemove(dds: F | F[]) { + if (!Array.isArray(dds)) { + dds = [dds] + } + for (let n of dds) { + n.d() + } + return dds +} From 06e05f25e18998beb47bdae3e545ed8eb2de0331 Mon Sep 17 00:00:00 2001 From: okmttdhr Date: Thu, 16 Apr 2020 02:50:33 +0900 Subject: [PATCH 13/74] Improve error message for computed enums (#37790) * Add error message for computed enums * Add test case for computed enums * Accept baselines * Fix returned value when error --- src/compiler/checker.ts | 8 ++- src/compiler/diagnosticMessages.json | 4 ++ .../arrowFunctionContexts.errors.txt | 8 +-- .../baselines/reference/enumErrors.errors.txt | 54 +++++++++++-------- tests/baselines/reference/enumErrors.js | 6 ++- tests/baselines/reference/enumErrors.symbols | 52 ++++++++++-------- tests/baselines/reference/enumErrors.types | 16 +++++- tests/cases/conformance/enums/enumErrors.ts | 4 +- 8 files changed, 98 insertions(+), 54 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a7d45e0ab8c..c1c994d9f3b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -33676,7 +33676,13 @@ namespace ts { } else { // Only here do we need to check that the initializer is assignable to the enum type. - checkTypeAssignableTo(checkExpression(initializer), getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, /*headMessage*/ undefined); + const source = checkExpression(initializer); + if (!isTypeAssignableToKind(source, TypeFlags.NumberLike)) { + error(initializer, Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); + } + else { + checkTypeAssignableTo(source, getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, /*headMessage*/ undefined); + } } return value; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 29bf61b2f75..ab45cbe0cf4 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -5737,5 +5737,9 @@ "The intersection '{0}' was reduced to 'never' because property '{1}' exists in multiple constituents and is private in some.": { "category": "Error", "code": 18032 + }, + "Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead.": { + "category": "Error", + "code": 18033 } } diff --git a/tests/baselines/reference/arrowFunctionContexts.errors.txt b/tests/baselines/reference/arrowFunctionContexts.errors.txt index b0d5d1dfc25..2a8fcbd2ca7 100644 --- a/tests/baselines/reference/arrowFunctionContexts.errors.txt +++ b/tests/baselines/reference/arrowFunctionContexts.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(2,1): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'. -tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(30,9): error TS2322: Type '() => number' is not assignable to type 'E'. +tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(30,9): error TS18033: Only numeric enums can have computed members, but this expression has type '() => number'. If you do not need exhaustiveness checks, consider using an object literal instead. tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(31,16): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(43,5): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'. -tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(71,13): error TS2322: Type '() => number' is not assignable to type 'E'. +tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(71,13): error TS18033: Only numeric enums can have computed members, but this expression has type '() => number'. If you do not need exhaustiveness checks, consider using an object literal instead. tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(72,20): error TS2332: 'this' cannot be referenced in current location. @@ -40,7 +40,7 @@ tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(72,20): e enum E { x = () => 4, // Error expected ~~~~~~~ -!!! error TS2322: Type '() => number' is not assignable to type 'E'. +!!! error TS18033: Only numeric enums can have computed members, but this expression has type '() => number'. If you do not need exhaustiveness checks, consider using an object literal instead. y = (() => this).length // error, can't use this in enum ~~~~ !!! error TS2332: 'this' cannot be referenced in current location. @@ -87,7 +87,7 @@ tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts(72,20): e enum E { x = () => 4, // Error expected ~~~~~~~ -!!! error TS2322: Type '() => number' is not assignable to type 'E'. +!!! error TS18033: Only numeric enums can have computed members, but this expression has type '() => number'. If you do not need exhaustiveness checks, consider using an object literal instead. y = (() => this).length ~~~~ !!! error TS2332: 'this' cannot be referenced in current location. diff --git a/tests/baselines/reference/enumErrors.errors.txt b/tests/baselines/reference/enumErrors.errors.txt index 23b5e97e71b..ed2c1d2a3ed 100644 --- a/tests/baselines/reference/enumErrors.errors.txt +++ b/tests/baselines/reference/enumErrors.errors.txt @@ -2,28 +2,30 @@ tests/cases/conformance/enums/enumErrors.ts(2,6): error TS2431: Enum name cannot tests/cases/conformance/enums/enumErrors.ts(3,6): error TS2431: Enum name cannot be 'number'. tests/cases/conformance/enums/enumErrors.ts(4,6): error TS2431: Enum name cannot be 'string'. tests/cases/conformance/enums/enumErrors.ts(5,6): error TS2431: Enum name cannot be 'boolean'. -tests/cases/conformance/enums/enumErrors.ts(9,9): error TS2322: Type 'Number' is not assignable to type 'E5'. -tests/cases/conformance/enums/enumErrors.ts(26,9): error TS2322: Type 'true' is not assignable to type 'E11'. -tests/cases/conformance/enums/enumErrors.ts(27,9): error TS2322: Type 'Date' is not assignable to type 'E11'. -tests/cases/conformance/enums/enumErrors.ts(28,9): error TS2322: Type 'Window & typeof globalThis' is not assignable to type 'E11'. -tests/cases/conformance/enums/enumErrors.ts(29,9): error TS2322: Type '{}' is not assignable to type 'E11'. -tests/cases/conformance/enums/enumErrors.ts(35,9): error TS2553: Computed values are not permitted in an enum with string valued members. +tests/cases/conformance/enums/enumErrors.ts(9,9): error TS18033: Only numeric enums can have computed members, but this expression has type 'Number'. If you do not need exhaustiveness checks, consider using an object literal instead. +tests/cases/conformance/enums/enumErrors.ts(26,9): error TS18033: Only numeric enums can have computed members, but this expression has type 'true'. If you do not need exhaustiveness checks, consider using an object literal instead. +tests/cases/conformance/enums/enumErrors.ts(27,9): error TS18033: Only numeric enums can have computed members, but this expression has type 'Date'. If you do not need exhaustiveness checks, consider using an object literal instead. +tests/cases/conformance/enums/enumErrors.ts(28,9): error TS18033: Only numeric enums can have computed members, but this expression has type 'Window & typeof globalThis'. If you do not need exhaustiveness checks, consider using an object literal instead. +tests/cases/conformance/enums/enumErrors.ts(29,9): error TS18033: Only numeric enums can have computed members, but this expression has type '{}'. If you do not need exhaustiveness checks, consider using an object literal instead. +tests/cases/conformance/enums/enumErrors.ts(30,9): error TS18033: Only numeric enums can have computed members, but this expression has type 'string'. If you do not need exhaustiveness checks, consider using an object literal instead. tests/cases/conformance/enums/enumErrors.ts(36,9): error TS2553: Computed values are not permitted in an enum with string valued members. tests/cases/conformance/enums/enumErrors.ts(37,9): error TS2553: Computed values are not permitted in an enum with string valued members. tests/cases/conformance/enums/enumErrors.ts(38,9): error TS2553: Computed values are not permitted in an enum with string valued members. -tests/cases/conformance/enums/enumErrors.ts(46,18): error TS1357: An enum member name must be followed by a ',', '=', or '}'. -tests/cases/conformance/enums/enumErrors.ts(47,24): error TS1357: An enum member name must be followed by a ',', '=', or '}'. -tests/cases/conformance/enums/enumErrors.ts(47,26): error TS2452: An enum member cannot have a numeric name. -tests/cases/conformance/enums/enumErrors.ts(48,28): error TS1357: An enum member name must be followed by a ',', '=', or '}'. -tests/cases/conformance/enums/enumErrors.ts(48,30): error TS2452: An enum member cannot have a numeric name. -tests/cases/conformance/enums/enumErrors.ts(48,31): error TS1357: An enum member name must be followed by a ',', '=', or '}'. -tests/cases/conformance/enums/enumErrors.ts(51,16): error TS1357: An enum member name must be followed by a ',', '=', or '}'. -tests/cases/conformance/enums/enumErrors.ts(51,22): error TS1357: An enum member name must be followed by a ',', '=', or '}'. -tests/cases/conformance/enums/enumErrors.ts(51,30): error TS1357: An enum member name must be followed by a ',', '=', or '}'. -tests/cases/conformance/enums/enumErrors.ts(51,33): error TS2452: An enum member cannot have a numeric name. +tests/cases/conformance/enums/enumErrors.ts(39,9): error TS2553: Computed values are not permitted in an enum with string valued members. +tests/cases/conformance/enums/enumErrors.ts(40,9): error TS2553: Computed values are not permitted in an enum with string valued members. +tests/cases/conformance/enums/enumErrors.ts(48,18): error TS1357: An enum member name must be followed by a ',', '=', or '}'. +tests/cases/conformance/enums/enumErrors.ts(49,24): error TS1357: An enum member name must be followed by a ',', '=', or '}'. +tests/cases/conformance/enums/enumErrors.ts(49,26): error TS2452: An enum member cannot have a numeric name. +tests/cases/conformance/enums/enumErrors.ts(50,28): error TS1357: An enum member name must be followed by a ',', '=', or '}'. +tests/cases/conformance/enums/enumErrors.ts(50,30): error TS2452: An enum member cannot have a numeric name. +tests/cases/conformance/enums/enumErrors.ts(50,31): error TS1357: An enum member name must be followed by a ',', '=', or '}'. +tests/cases/conformance/enums/enumErrors.ts(53,16): error TS1357: An enum member name must be followed by a ',', '=', or '}'. +tests/cases/conformance/enums/enumErrors.ts(53,22): error TS1357: An enum member name must be followed by a ',', '=', or '}'. +tests/cases/conformance/enums/enumErrors.ts(53,30): error TS1357: An enum member name must be followed by a ',', '=', or '}'. +tests/cases/conformance/enums/enumErrors.ts(53,33): error TS2452: An enum member cannot have a numeric name. -==== tests/cases/conformance/enums/enumErrors.ts (23 errors) ==== +==== tests/cases/conformance/enums/enumErrors.ts (25 errors) ==== // Enum named with PredefinedTypes enum any { } ~~~ @@ -42,7 +44,7 @@ tests/cases/conformance/enums/enumErrors.ts(51,33): error TS2452: An enum member enum E5 { C = new Number(30) ~~~~~~~~~~~~~~ -!!! error TS2322: Type 'Number' is not assignable to type 'E5'. +!!! error TS18033: Only numeric enums can have computed members, but this expression has type 'Number'. If you do not need exhaustiveness checks, consider using an object literal instead. } enum E9 { @@ -61,16 +63,19 @@ tests/cases/conformance/enums/enumErrors.ts(51,33): error TS2452: An enum member enum E11 { A = true, ~~~~ -!!! error TS2322: Type 'true' is not assignable to type 'E11'. +!!! error TS18033: Only numeric enums can have computed members, but this expression has type 'true'. If you do not need exhaustiveness checks, consider using an object literal instead. B = new Date(), ~~~~~~~~~~ -!!! error TS2322: Type 'Date' is not assignable to type 'E11'. +!!! error TS18033: Only numeric enums can have computed members, but this expression has type 'Date'. If you do not need exhaustiveness checks, consider using an object literal instead. C = window, ~~~~~~ -!!! error TS2322: Type 'Window & typeof globalThis' is not assignable to type 'E11'. - D = {} +!!! error TS18033: Only numeric enums can have computed members, but this expression has type 'Window & typeof globalThis'. If you do not need exhaustiveness checks, consider using an object literal instead. + D = {}, ~~ -!!! error TS2322: Type '{}' is not assignable to type 'E11'. +!!! error TS18033: Only numeric enums can have computed members, but this expression has type '{}'. If you do not need exhaustiveness checks, consider using an object literal instead. + E = (() => 'foo')(), + ~~~~~~~~~~~~~~~ +!!! error TS18033: Only numeric enums can have computed members, but this expression has type 'string'. If you do not need exhaustiveness checks, consider using an object literal instead. } // Enum with string valued member and computed member initializers @@ -87,6 +92,9 @@ tests/cases/conformance/enums/enumErrors.ts(51,33): error TS2452: An enum member !!! error TS2553: Computed values are not permitted in an enum with string valued members. E = 1 + 1, ~~~~~ +!!! error TS2553: Computed values are not permitted in an enum with string valued members. + F = (() => 'foo')(), + ~~~~~~~~~~~~~~~ !!! error TS2553: Computed values are not permitted in an enum with string valued members. } diff --git a/tests/baselines/reference/enumErrors.js b/tests/baselines/reference/enumErrors.js index 64a884a0979..71c2393bd43 100644 --- a/tests/baselines/reference/enumErrors.js +++ b/tests/baselines/reference/enumErrors.js @@ -27,7 +27,8 @@ enum E11 { A = true, B = new Date(), C = window, - D = {} + D = {}, + E = (() => 'foo')(), } // Enum with string valued member and computed member initializers @@ -37,6 +38,7 @@ enum E12 { C = window, D = {}, E = 1 + 1, + F = (() => 'foo')(), } // Enum with incorrect syntax @@ -90,6 +92,7 @@ var E11; E11[E11["B"] = new Date()] = "B"; E11[E11["C"] = window] = "C"; E11[E11["D"] = {}] = "D"; + E11[E11["E"] = (function () { return 'foo'; })()] = "E"; })(E11 || (E11 = {})); // Enum with string valued member and computed member initializers var E12; @@ -99,6 +102,7 @@ var E12; E12[E12["C"] = 0] = "C"; E12[E12["D"] = 0] = "D"; E12[E12["E"] = 0] = "E"; + E12[E12["F"] = 0] = "F"; })(E12 || (E12 = {})); // Enum with incorrect syntax var E13; diff --git a/tests/baselines/reference/enumErrors.symbols b/tests/baselines/reference/enumErrors.symbols index d20fea828b1..0c10e392c90 100644 --- a/tests/baselines/reference/enumErrors.symbols +++ b/tests/baselines/reference/enumErrors.symbols @@ -65,62 +65,68 @@ enum E11 { >C : Symbol(E11.C, Decl(enumErrors.ts, 26, 19)) >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) - D = {} + D = {}, >D : Symbol(E11.D, Decl(enumErrors.ts, 27, 15)) + + E = (() => 'foo')(), +>E : Symbol(E11.E, Decl(enumErrors.ts, 28, 11)) } // Enum with string valued member and computed member initializers enum E12 { ->E12 : Symbol(E12, Decl(enumErrors.ts, 29, 1)) +>E12 : Symbol(E12, Decl(enumErrors.ts, 30, 1)) A = '', ->A : Symbol(E12.A, Decl(enumErrors.ts, 32, 10)) +>A : Symbol(E12.A, Decl(enumErrors.ts, 33, 10)) B = new Date(), ->B : Symbol(E12.B, Decl(enumErrors.ts, 33, 11)) +>B : Symbol(E12.B, Decl(enumErrors.ts, 34, 11)) >Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) C = window, ->C : Symbol(E12.C, Decl(enumErrors.ts, 34, 19)) +>C : Symbol(E12.C, Decl(enumErrors.ts, 35, 19)) >window : Symbol(window, Decl(lib.dom.d.ts, --, --)) D = {}, ->D : Symbol(E12.D, Decl(enumErrors.ts, 35, 15)) +>D : Symbol(E12.D, Decl(enumErrors.ts, 36, 15)) E = 1 + 1, ->E : Symbol(E12.E, Decl(enumErrors.ts, 36, 11)) +>E : Symbol(E12.E, Decl(enumErrors.ts, 37, 11)) + + F = (() => 'foo')(), +>F : Symbol(E12.F, Decl(enumErrors.ts, 38, 14)) } // Enum with incorrect syntax enum E13 { ->E13 : Symbol(E13, Decl(enumErrors.ts, 38, 1)) +>E13 : Symbol(E13, Decl(enumErrors.ts, 40, 1)) postComma, ->postComma : Symbol(E13.postComma, Decl(enumErrors.ts, 41, 10)) +>postComma : Symbol(E13.postComma, Decl(enumErrors.ts, 43, 10)) postValueComma = 1, ->postValueComma : Symbol(E13.postValueComma, Decl(enumErrors.ts, 42, 14)) +>postValueComma : Symbol(E13.postValueComma, Decl(enumErrors.ts, 44, 14)) postSemicolon; ->postSemicolon : Symbol(E13.postSemicolon, Decl(enumErrors.ts, 43, 23)) +>postSemicolon : Symbol(E13.postSemicolon, Decl(enumErrors.ts, 45, 23)) postColonValueComma: 2, ->postColonValueComma : Symbol(E13.postColonValueComma, Decl(enumErrors.ts, 45, 18)) ->2 : Symbol(E13[2], Decl(enumErrors.ts, 46, 24)) +>postColonValueComma : Symbol(E13.postColonValueComma, Decl(enumErrors.ts, 47, 18)) +>2 : Symbol(E13[2], Decl(enumErrors.ts, 48, 24)) postColonValueSemicolon: 3; ->postColonValueSemicolon : Symbol(E13.postColonValueSemicolon, Decl(enumErrors.ts, 46, 27)) ->3 : Symbol(E13[3], Decl(enumErrors.ts, 47, 28)) +>postColonValueSemicolon : Symbol(E13.postColonValueSemicolon, Decl(enumErrors.ts, 48, 27)) +>3 : Symbol(E13[3], Decl(enumErrors.ts, 49, 28)) }; enum E14 { a, b: any "hello" += 1, c, d} ->E14 : Symbol(E14, Decl(enumErrors.ts, 48, 2)) ->a : Symbol(E14.a, Decl(enumErrors.ts, 50, 10)) ->b : Symbol(E14.b, Decl(enumErrors.ts, 50, 13)) ->any : Symbol(E14.any, Decl(enumErrors.ts, 50, 16)) ->"hello" : Symbol(E14["hello"], Decl(enumErrors.ts, 50, 20)) ->1 : Symbol(E14[1], Decl(enumErrors.ts, 50, 31)) ->c : Symbol(E14.c, Decl(enumErrors.ts, 50, 34)) ->d : Symbol(E14.d, Decl(enumErrors.ts, 50, 37)) +>E14 : Symbol(E14, Decl(enumErrors.ts, 50, 2)) +>a : Symbol(E14.a, Decl(enumErrors.ts, 52, 10)) +>b : Symbol(E14.b, Decl(enumErrors.ts, 52, 13)) +>any : Symbol(E14.any, Decl(enumErrors.ts, 52, 16)) +>"hello" : Symbol(E14["hello"], Decl(enumErrors.ts, 52, 20)) +>1 : Symbol(E14[1], Decl(enumErrors.ts, 52, 31)) +>c : Symbol(E14.c, Decl(enumErrors.ts, 52, 34)) +>d : Symbol(E14.d, Decl(enumErrors.ts, 52, 37)) diff --git a/tests/baselines/reference/enumErrors.types b/tests/baselines/reference/enumErrors.types index 24859e89b97..8a4884b5405 100644 --- a/tests/baselines/reference/enumErrors.types +++ b/tests/baselines/reference/enumErrors.types @@ -69,9 +69,16 @@ enum E11 { >C : E11 >window : Window & typeof globalThis - D = {} + D = {}, >D : E11 >{} : {} + + E = (() => 'foo')(), +>E : E11 +>(() => 'foo')() : string +>(() => 'foo') : () => string +>() => 'foo' : () => string +>'foo' : "foo" } // Enum with string valued member and computed member initializers @@ -100,6 +107,13 @@ enum E12 { >1 + 1 : number >1 : 1 >1 : 1 + + F = (() => 'foo')(), +>F : E12.B +>(() => 'foo')() : string +>(() => 'foo') : () => string +>() => 'foo' : () => string +>'foo' : "foo" } // Enum with incorrect syntax diff --git a/tests/cases/conformance/enums/enumErrors.ts b/tests/cases/conformance/enums/enumErrors.ts index 16360574167..cbb3168af18 100644 --- a/tests/cases/conformance/enums/enumErrors.ts +++ b/tests/cases/conformance/enums/enumErrors.ts @@ -26,7 +26,8 @@ enum E11 { A = true, B = new Date(), C = window, - D = {} + D = {}, + E = (() => 'foo')(), } // Enum with string valued member and computed member initializers @@ -36,6 +37,7 @@ enum E12 { C = window, D = {}, E = 1 + 1, + F = (() => 'foo')(), } // Enum with incorrect syntax From 583e70b3d1aeb752090ccba9477bde6b769d4c24 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 15 Apr 2020 11:06:04 -0700 Subject: [PATCH 14/74] fix(refactor): keep comments after refactor (#35937) * add two tests: Refactor: Remove braces from arrow function * refactor: simplify test and add another test * fix: copyTrailingAsLeadingComments in addOrRemoveBracesToArrowFunction * test: add additional test * fix: clean up changes * fix: add check for newEdit * fix: add function for semi colon modifier * feat: grab all comments during refactor * refactor: update addOrRemoveBraces logic * fix: remove duplicate function call * Update src/services/refactors/addOrRemoveBracesToArrowFunction.ts * remove blank line remove blank line Co-authored-by: Jesse Trinity <42591254+jessetrinity@users.noreply.github.com> --- .../refactors/addOrRemoveBracesToArrowFunction.ts | 8 +++++++- .../refactorAddOrRemoveBracesToArrowFunction24.ts | 11 +++++++++++ .../refactorAddOrRemoveBracesToArrowFunction25.ts | 11 +++++++++++ .../refactorAddOrRemoveBracesToArrowFunction26.ts | 11 +++++++++++ .../refactorAddOrRemoveBracesToArrowFunction27.ts | 13 +++++++++++++ .../refactorAddOrRemoveBracesToArrowFunction28.ts | 11 +++++++++++ 6 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction24.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction25.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction26.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction27.ts create mode 100644 tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction28.ts diff --git a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts index 7f423f4df05..c7c3a04e8d3 100644 --- a/src/services/refactors/addOrRemoveBracesToArrowFunction.ts +++ b/src/services/refactors/addOrRemoveBracesToArrowFunction.ts @@ -44,6 +44,7 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { const { expression, returnStatement, func } = info; let body: ConciseBody; + if (actionName === addBracesActionName) { const returnStatement = createReturn(expression); body = createBlock([returnStatement], /* multiLine */ true); @@ -54,13 +55,18 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { const actualExpression = expression || createVoidZero(); body = needsParentheses(actualExpression) ? createParen(actualExpression) : actualExpression; suppressLeadingAndTrailingTrivia(body); + copyTrailingAsLeadingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false); copyLeadingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false); + copyTrailingComments(returnStatement, body, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false); } else { Debug.fail("invalid action"); } - const edits = textChanges.ChangeTracker.with(context, t => t.replaceNode(file, func.body, body)); + const edits = textChanges.ChangeTracker.with(context, t => { + t.replaceNode(file, func.body, body); + }); + return { renameFilename: undefined, renameLocation: undefined, edits }; } diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction24.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction24.ts new file mode 100644 index 00000000000..3bee61a201c --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction24.ts @@ -0,0 +1,11 @@ +/// + +//// const a = (a: number) /*a*/=>/*b*/ {/* comment */ return a;}; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const a = (a: number) => /* comment */ a;`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction25.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction25.ts new file mode 100644 index 00000000000..5f7226c2e93 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction25.ts @@ -0,0 +1,11 @@ +/// + +//// const a = (a: number) /*a*/=>/*b*/ { return a; /* trailing */}; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const a = (a: number) => a /* trailing */;`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction26.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction26.ts new file mode 100644 index 00000000000..24234c7107d --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction26.ts @@ -0,0 +1,11 @@ +/// + +//// const a = (a: number) /*a*/=>/*b*/ {/* leading */ return a; /* trailing */}; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const a = (a: number) => /* leading */ a /* trailing */;`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction27.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction27.ts new file mode 100644 index 00000000000..7f36317a233 --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction27.ts @@ -0,0 +1,13 @@ +/// + +//// const b = (a: number) /*a*/=>/*b*/ { /* leading */ +//// return a; /* trailing */ +//// } + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const b = (a: number) => /* leading */ a /* trailing */`, +}); diff --git a/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction28.ts b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction28.ts new file mode 100644 index 00000000000..a79b89c9f2f --- /dev/null +++ b/tests/cases/fourslash/refactorAddOrRemoveBracesToArrowFunction28.ts @@ -0,0 +1,11 @@ +/// + +//// const a = (a: number) /*a*/=>/*b*/ { return a; /* c */ /* d */ }; + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Add or remove braces in an arrow function", + actionName: "Remove braces from arrow function", + actionDescription: "Remove braces from arrow function", + newContent: `const a = (a: number) => a /* c */ /* d */;`, +}); From 6fbaeeb42f7e4fbf3a0c19c4ea5b1821393581c5 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 15 Apr 2020 11:40:33 -0700 Subject: [PATCH 15/74] Typo at Uint8Array[Symbol.toStringTag] (#37989) * Update es2015.symbol.wellknown.d.ts * Update baselines Co-authored-by: sirian --- src/lib/es2015.symbol.wellknown.d.ts | 2 +- ...typedArraysCrossAssignability01.errors.txt | 60 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index 5418cb4d5ea..89d7b82eae0 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -254,7 +254,7 @@ interface Int8Array { } interface Uint8Array { - readonly [Symbol.toStringTag]: "UInt8Array"; + readonly [Symbol.toStringTag]: "Uint8Array"; } interface Uint8ClampedArray { diff --git a/tests/baselines/reference/typedArraysCrossAssignability01.errors.txt b/tests/baselines/reference/typedArraysCrossAssignability01.errors.txt index ad949806429..5e014ace5c4 100644 --- a/tests/baselines/reference/typedArraysCrossAssignability01.errors.txt +++ b/tests/baselines/reference/typedArraysCrossAssignability01.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(13,5): error TS2322: Type 'Uint8Array' is not assignable to type 'Int8Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"UInt8Array"' is not assignable to type '"Int8Array"'. + Type '"Uint8Array"' is not assignable to type '"Int8Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(14,5): error TS2322: Type 'Int16Array' is not assignable to type 'Int8Array'. Types of property '[Symbol.toStringTag]' are incompatible. Type '"Int16Array"' is not assignable to type '"Int8Array"'. @@ -24,34 +24,34 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(20,5): error TS2322: Typ Type '"Uint8ClampedArray"' is not assignable to type '"Int8Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(22,5): error TS2322: Type 'Int8Array' is not assignable to type 'Uint8Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"Int8Array"' is not assignable to type '"UInt8Array"'. + Type '"Int8Array"' is not assignable to type '"Uint8Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(24,5): error TS2322: Type 'Int16Array' is not assignable to type 'Uint8Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"Int16Array"' is not assignable to type '"UInt8Array"'. + Type '"Int16Array"' is not assignable to type '"Uint8Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(25,5): error TS2322: Type 'Uint16Array' is not assignable to type 'Uint8Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"Uint16Array"' is not assignable to type '"UInt8Array"'. + Type '"Uint16Array"' is not assignable to type '"Uint8Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(26,5): error TS2322: Type 'Int32Array' is not assignable to type 'Uint8Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"Int32Array"' is not assignable to type '"UInt8Array"'. + Type '"Int32Array"' is not assignable to type '"Uint8Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(27,5): error TS2322: Type 'Uint32Array' is not assignable to type 'Uint8Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"Uint32Array"' is not assignable to type '"UInt8Array"'. + Type '"Uint32Array"' is not assignable to type '"Uint8Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(28,5): error TS2322: Type 'Float32Array' is not assignable to type 'Uint8Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"Float32Array"' is not assignable to type '"UInt8Array"'. + Type '"Float32Array"' is not assignable to type '"Uint8Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(29,5): error TS2322: Type 'Float64Array' is not assignable to type 'Uint8Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"Float64Array"' is not assignable to type '"UInt8Array"'. + Type '"Float64Array"' is not assignable to type '"Uint8Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(30,5): error TS2322: Type 'Uint8ClampedArray' is not assignable to type 'Uint8Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"Uint8ClampedArray"' is not assignable to type '"UInt8Array"'. + Type '"Uint8ClampedArray"' is not assignable to type '"Uint8Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(32,5): error TS2322: Type 'Int8Array' is not assignable to type 'Int16Array'. Types of property '[Symbol.toStringTag]' are incompatible. Type '"Int8Array"' is not assignable to type '"Int16Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(33,5): error TS2322: Type 'Uint8Array' is not assignable to type 'Int16Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"UInt8Array"' is not assignable to type '"Int16Array"'. + Type '"Uint8Array"' is not assignable to type '"Int16Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(35,5): error TS2322: Type 'Uint16Array' is not assignable to type 'Int16Array'. Types of property '[Symbol.toStringTag]' are incompatible. Type '"Uint16Array"' is not assignable to type '"Int16Array"'. @@ -75,7 +75,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(42,5): error TS2322: Typ Type '"Int8Array"' is not assignable to type '"Uint16Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(43,5): error TS2322: Type 'Uint8Array' is not assignable to type 'Uint16Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"UInt8Array"' is not assignable to type '"Uint16Array"'. + Type '"Uint8Array"' is not assignable to type '"Uint16Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(44,5): error TS2322: Type 'Int16Array' is not assignable to type 'Uint16Array'. Types of property '[Symbol.toStringTag]' are incompatible. Type '"Int16Array"' is not assignable to type '"Uint16Array"'. @@ -99,7 +99,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(52,5): error TS2322: Typ Type '"Int8Array"' is not assignable to type '"Int32Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(53,5): error TS2322: Type 'Uint8Array' is not assignable to type 'Int32Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"UInt8Array"' is not assignable to type '"Int32Array"'. + Type '"Uint8Array"' is not assignable to type '"Int32Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(54,5): error TS2322: Type 'Int16Array' is not assignable to type 'Int32Array'. Types of property '[Symbol.toStringTag]' are incompatible. Type '"Int16Array"' is not assignable to type '"Int32Array"'. @@ -123,7 +123,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(62,5): error TS2322: Typ Type '"Int8Array"' is not assignable to type '"Float32Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(63,5): error TS2322: Type 'Uint8Array' is not assignable to type 'Float32Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"UInt8Array"' is not assignable to type '"Float32Array"'. + Type '"Uint8Array"' is not assignable to type '"Float32Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(64,5): error TS2322: Type 'Int16Array' is not assignable to type 'Float32Array'. Types of property '[Symbol.toStringTag]' are incompatible. Type '"Int16Array"' is not assignable to type '"Float32Array"'. @@ -147,7 +147,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(72,5): error TS2322: Typ Type '"Int8Array"' is not assignable to type '"Float64Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(73,5): error TS2322: Type 'Uint8Array' is not assignable to type 'Float64Array'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"UInt8Array"' is not assignable to type '"Float64Array"'. + Type '"Uint8Array"' is not assignable to type '"Float64Array"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(74,5): error TS2322: Type 'Int16Array' is not assignable to type 'Float64Array'. Types of property '[Symbol.toStringTag]' are incompatible. Type '"Int16Array"' is not assignable to type '"Float64Array"'. @@ -171,7 +171,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(82,5): error TS2322: Typ Type '"Int8Array"' is not assignable to type '"Uint8ClampedArray"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(83,5): error TS2322: Type 'Uint8Array' is not assignable to type 'Uint8ClampedArray'. Types of property '[Symbol.toStringTag]' are incompatible. - Type '"UInt8Array"' is not assignable to type '"Uint8ClampedArray"'. + Type '"Uint8Array"' is not assignable to type '"Uint8ClampedArray"'. tests/cases/compiler/typedArraysCrossAssignability01.ts(84,5): error TS2322: Type 'Int16Array' is not assignable to type 'Uint8ClampedArray'. Types of property '[Symbol.toStringTag]' are incompatible. Type '"Int16Array"' is not assignable to type '"Uint8ClampedArray"'. @@ -209,7 +209,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(89,5): error TS2322: Typ ~~~~~~~~~~~~~ !!! error TS2322: Type 'Uint8Array' is not assignable to type 'Int8Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"UInt8Array"' is not assignable to type '"Int8Array"'. +!!! error TS2322: Type '"Uint8Array"' is not assignable to type '"Int8Array"'. arr_Int8Array = arr_Int16Array; ~~~~~~~~~~~~~ !!! error TS2322: Type 'Int16Array' is not assignable to type 'Int8Array'. @@ -250,43 +250,43 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(89,5): error TS2322: Typ ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Int8Array' is not assignable to type 'Uint8Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"Int8Array"' is not assignable to type '"UInt8Array"'. +!!! error TS2322: Type '"Int8Array"' is not assignable to type '"Uint8Array"'. arr_Uint8Array = arr_Uint8Array; arr_Uint8Array = arr_Int16Array; ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Int16Array' is not assignable to type 'Uint8Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"Int16Array"' is not assignable to type '"UInt8Array"'. +!!! error TS2322: Type '"Int16Array"' is not assignable to type '"Uint8Array"'. arr_Uint8Array = arr_Uint16Array; ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Uint16Array' is not assignable to type 'Uint8Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"Uint16Array"' is not assignable to type '"UInt8Array"'. +!!! error TS2322: Type '"Uint16Array"' is not assignable to type '"Uint8Array"'. arr_Uint8Array = arr_Int32Array; ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Int32Array' is not assignable to type 'Uint8Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"Int32Array"' is not assignable to type '"UInt8Array"'. +!!! error TS2322: Type '"Int32Array"' is not assignable to type '"Uint8Array"'. arr_Uint8Array = arr_Uint32Array; ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Uint32Array' is not assignable to type 'Uint8Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"Uint32Array"' is not assignable to type '"UInt8Array"'. +!!! error TS2322: Type '"Uint32Array"' is not assignable to type '"Uint8Array"'. arr_Uint8Array = arr_Float32Array; ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Float32Array' is not assignable to type 'Uint8Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"Float32Array"' is not assignable to type '"UInt8Array"'. +!!! error TS2322: Type '"Float32Array"' is not assignable to type '"Uint8Array"'. arr_Uint8Array = arr_Float64Array; ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Float64Array' is not assignable to type 'Uint8Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"Float64Array"' is not assignable to type '"UInt8Array"'. +!!! error TS2322: Type '"Float64Array"' is not assignable to type '"Uint8Array"'. arr_Uint8Array = arr_Uint8ClampedArray; ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Uint8ClampedArray' is not assignable to type 'Uint8Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"Uint8ClampedArray"' is not assignable to type '"UInt8Array"'. +!!! error TS2322: Type '"Uint8ClampedArray"' is not assignable to type '"Uint8Array"'. arr_Int16Array = arr_Int8Array; ~~~~~~~~~~~~~~ @@ -297,7 +297,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(89,5): error TS2322: Typ ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Uint8Array' is not assignable to type 'Int16Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"UInt8Array"' is not assignable to type '"Int16Array"'. +!!! error TS2322: Type '"Uint8Array"' is not assignable to type '"Int16Array"'. arr_Int16Array = arr_Int16Array; arr_Int16Array = arr_Uint16Array; ~~~~~~~~~~~~~~ @@ -339,7 +339,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(89,5): error TS2322: Typ ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Uint8Array' is not assignable to type 'Uint16Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"UInt8Array"' is not assignable to type '"Uint16Array"'. +!!! error TS2322: Type '"Uint8Array"' is not assignable to type '"Uint16Array"'. arr_Uint16Array = arr_Int16Array; ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Int16Array' is not assignable to type 'Uint16Array'. @@ -381,7 +381,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(89,5): error TS2322: Typ ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Uint8Array' is not assignable to type 'Int32Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"UInt8Array"' is not assignable to type '"Int32Array"'. +!!! error TS2322: Type '"Uint8Array"' is not assignable to type '"Int32Array"'. arr_Int32Array = arr_Int16Array; ~~~~~~~~~~~~~~ !!! error TS2322: Type 'Int16Array' is not assignable to type 'Int32Array'. @@ -423,7 +423,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(89,5): error TS2322: Typ ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Uint8Array' is not assignable to type 'Float32Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"UInt8Array"' is not assignable to type '"Float32Array"'. +!!! error TS2322: Type '"Uint8Array"' is not assignable to type '"Float32Array"'. arr_Float32Array = arr_Int16Array; ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Int16Array' is not assignable to type 'Float32Array'. @@ -465,7 +465,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(89,5): error TS2322: Typ ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Uint8Array' is not assignable to type 'Float64Array'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"UInt8Array"' is not assignable to type '"Float64Array"'. +!!! error TS2322: Type '"Uint8Array"' is not assignable to type '"Float64Array"'. arr_Float64Array = arr_Int16Array; ~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Int16Array' is not assignable to type 'Float64Array'. @@ -507,7 +507,7 @@ tests/cases/compiler/typedArraysCrossAssignability01.ts(89,5): error TS2322: Typ ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Uint8Array' is not assignable to type 'Uint8ClampedArray'. !!! error TS2322: Types of property '[Symbol.toStringTag]' are incompatible. -!!! error TS2322: Type '"UInt8Array"' is not assignable to type '"Uint8ClampedArray"'. +!!! error TS2322: Type '"Uint8Array"' is not assignable to type '"Uint8ClampedArray"'. arr_Uint8ClampedArray = arr_Int16Array; ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Int16Array' is not assignable to type 'Uint8ClampedArray'. From a16c44180a921e9f4b18fa275d3cba6f3f69c97a Mon Sep 17 00:00:00 2001 From: Alexander T Date: Wed, 15 Apr 2020 21:42:29 +0300 Subject: [PATCH 16/74] fix(37940): add space after parameter decorator (#37959) --- src/compiler/emitter.ts | 2 +- src/compiler/types.ts | 3 +- .../reference/api/tsserverlibrary.d.ts | 3 +- tests/baselines/reference/api/typescript.d.ts | 3 +- .../fourslash/moveToNewFile_decorators.ts | 34 +++++++++++++++++++ .../fourslash/moveToNewFile_decorators1.ts | 28 +++++++++++++++ .../fourslash/moveToNewFile_decorators2.ts | 22 ++++++++++++ .../fourslash/moveToNewFile_decorators3.ts | 24 +++++++++++++ 8 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/moveToNewFile_decorators.ts create mode 100644 tests/cases/fourslash/moveToNewFile_decorators1.ts create mode 100644 tests/cases/fourslash/moveToNewFile_decorators2.ts create mode 100644 tests/cases/fourslash/moveToNewFile_decorators3.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d558ce785a8..94b03cfcb36 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4133,7 +4133,7 @@ namespace ts { if (closingLineTerminatorCount) { writeLine(closingLineTerminatorCount); } - else if (format & ListFormat.SpaceBetweenBraces) { + else if (format & (ListFormat.SpaceAfterList | ListFormat.SpaceBetweenBraces)) { writeSpace(); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5e1b0a9fca8..8e781b23ee7 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6546,6 +6546,7 @@ namespace ts { NoSpaceIfEmpty = 1 << 19, // If the literal is empty, do not add spaces between braces. SingleElement = 1 << 20, + SpaceAfterList = 1 << 21, // Add space after list // Precomputed Formats Modifiers = SingleLine | SpaceBetweenSiblings | NoInterveningComments, @@ -6580,7 +6581,7 @@ namespace ts { CaseOrDefaultClauseStatements = Indented | MultiLine | NoTrailingNewLine | OptionalIfEmpty, HeritageClauseTypes = CommaDelimited | SpaceBetweenSiblings | SingleLine, SourceFileStatements = MultiLine | NoTrailingNewLine, - Decorators = MultiLine | Optional, + Decorators = MultiLine | Optional | SpaceAfterList, TypeArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | AngleBrackets | Optional, TypeParameters = CommaDelimited | SpaceBetweenSiblings | SingleLine | AngleBrackets | Optional, Parameters = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5e91796d880..5e322bae86f 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3227,6 +3227,7 @@ declare namespace ts { NoInterveningComments = 262144, NoSpaceIfEmpty = 524288, SingleElement = 1048576, + SpaceAfterList = 2097152, Modifiers = 262656, HeritageClauses = 512, SingleLineTypeLiteralMembers = 768, @@ -3258,7 +3259,7 @@ declare namespace ts { CaseOrDefaultClauseStatements = 163969, HeritageClauseTypes = 528, SourceFileStatements = 131073, - Decorators = 49153, + Decorators = 2146305, TypeArguments = 53776, TypeParameters = 53776, Parameters = 2576, diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index bca7c4c4ab7..3ec2b8046b9 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3227,6 +3227,7 @@ declare namespace ts { NoInterveningComments = 262144, NoSpaceIfEmpty = 524288, SingleElement = 1048576, + SpaceAfterList = 2097152, Modifiers = 262656, HeritageClauses = 512, SingleLineTypeLiteralMembers = 768, @@ -3258,7 +3259,7 @@ declare namespace ts { CaseOrDefaultClauseStatements = 163969, HeritageClauseTypes = 528, SourceFileStatements = 131073, - Decorators = 49153, + Decorators = 2146305, TypeArguments = 53776, TypeParameters = 53776, Parameters = 2576, diff --git a/tests/cases/fourslash/moveToNewFile_decorators.ts b/tests/cases/fourslash/moveToNewFile_decorators.ts new file mode 100644 index 00000000000..a44ff9cb5cd --- /dev/null +++ b/tests/cases/fourslash/moveToNewFile_decorators.ts @@ -0,0 +1,34 @@ +/// + +// @experimentalDecorators: true + +// @Filename: /a.ts +////const decorator1: any = () => {}; +////const decorator2: any = () => {}; +////[|class Foo { +//// constructor(@decorator1 private readonly x: number, +//// @decorator1 @decorator2 private readonly y: number) { } +//// +//// method1(@decorator1 x: number) { } +//// method2(@decorator1 @decorator2 x: number) { } +////}|] + +verify.noErrors(); + +verify.moveToNewFile({ + newFileContents: { + "/a.ts": +`const decorator1: any = () => {}; +const decorator2: any = () => {}; +`, + "/Foo.ts": +`class Foo { + constructor(@decorator1 private readonly x: number, + @decorator1 @decorator2 private readonly y: number) { } + + method1(@decorator1 x: number) { } + method2(@decorator1 @decorator2 x: number) { } +} +` + } +}); diff --git a/tests/cases/fourslash/moveToNewFile_decorators1.ts b/tests/cases/fourslash/moveToNewFile_decorators1.ts new file mode 100644 index 00000000000..3f2ca9a30f4 --- /dev/null +++ b/tests/cases/fourslash/moveToNewFile_decorators1.ts @@ -0,0 +1,28 @@ +/// + +// @experimentalDecorators: true + +// @Filename: /a.ts +////const decorator1: any = () => {}; +////const decorator2: any = () => {}; +////[|class Foo { +//// @decorator1 method1() { } +//// @decorator1 @decorator2 method2() { } +////}|] + +verify.noErrors(); + +verify.moveToNewFile({ + newFileContents: { + "/a.ts": +`const decorator1: any = () => {}; +const decorator2: any = () => {}; +`, + "/Foo.ts": +`class Foo { + @decorator1 method1() { } + @decorator1 @decorator2 method2() { } +} +` + } +}); diff --git a/tests/cases/fourslash/moveToNewFile_decorators2.ts b/tests/cases/fourslash/moveToNewFile_decorators2.ts new file mode 100644 index 00000000000..41daa532eea --- /dev/null +++ b/tests/cases/fourslash/moveToNewFile_decorators2.ts @@ -0,0 +1,22 @@ +/// + +// @experimentalDecorators: true + +// @Filename: /a.ts +////const decorator1: any = () => {}; +////[|@decorator1 class Foo { +////}|] + +verify.noErrors(); + +verify.moveToNewFile({ + newFileContents: { + "/a.ts": +`const decorator1: any = () => {}; +`, + "/Foo.ts": +`@decorator1 class Foo { +} +` + } +}); diff --git a/tests/cases/fourslash/moveToNewFile_decorators3.ts b/tests/cases/fourslash/moveToNewFile_decorators3.ts new file mode 100644 index 00000000000..dc75ce48969 --- /dev/null +++ b/tests/cases/fourslash/moveToNewFile_decorators3.ts @@ -0,0 +1,24 @@ +/// + +// @experimentalDecorators: true + +// @Filename: /a.ts +////const decorator1: any = () => {}; +////const decorator2: any = () => {}; +////[|@decorator1 @decorator2 class Foo { +////}|] + +verify.noErrors(); + +verify.moveToNewFile({ + newFileContents: { + "/a.ts": +`const decorator1: any = () => {}; +const decorator2: any = () => {}; +`, + "/Foo.ts": +`@decorator1 @decorator2 class Foo { +} +` + } +}); From cdc384006c96720654297488abbd91e854f99950 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 15 Apr 2020 13:37:51 -0700 Subject: [PATCH 17/74] Fix crash on declaration emit for globalThis (#37992) --- src/compiler/checker.ts | 2 +- .../globalThisDeclarationEmit.errors.txt | 11 +++++++ .../reference/globalThisDeclarationEmit.js | 24 +++++++++++++++ .../globalThisDeclarationEmit.symbols | 13 ++++++++ .../reference/globalThisDeclarationEmit.types | 13 ++++++++ .../reference/globalThisDeclarationEmit2.js | 27 +++++++++++++++++ .../globalThisDeclarationEmit2.symbols | 13 ++++++++ .../globalThisDeclarationEmit2.types | 13 ++++++++ .../reference/globalThisDeclarationEmit3.js | 30 +++++++++++++++++++ .../globalThisDeclarationEmit3.symbols | 17 +++++++++++ .../globalThisDeclarationEmit3.types | 17 +++++++++++ .../compiler/globalThisDeclarationEmit.ts | 7 +++++ .../compiler/globalThisDeclarationEmit2.ts | 7 +++++ .../compiler/globalThisDeclarationEmit3.ts | 8 +++++ 14 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/globalThisDeclarationEmit.errors.txt create mode 100644 tests/baselines/reference/globalThisDeclarationEmit.js create mode 100644 tests/baselines/reference/globalThisDeclarationEmit.symbols create mode 100644 tests/baselines/reference/globalThisDeclarationEmit.types create mode 100644 tests/baselines/reference/globalThisDeclarationEmit2.js create mode 100644 tests/baselines/reference/globalThisDeclarationEmit2.symbols create mode 100644 tests/baselines/reference/globalThisDeclarationEmit2.types create mode 100644 tests/baselines/reference/globalThisDeclarationEmit3.js create mode 100644 tests/baselines/reference/globalThisDeclarationEmit3.symbols create mode 100644 tests/baselines/reference/globalThisDeclarationEmit3.types create mode 100644 tests/cases/compiler/globalThisDeclarationEmit.ts create mode 100644 tests/cases/compiler/globalThisDeclarationEmit2.ts create mode 100644 tests/cases/compiler/globalThisDeclarationEmit3.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c1c994d9f3b..e4d31eb8493 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3845,7 +3845,7 @@ namespace ts { // If we're trying to reference some object literal in, eg `var a = { x: 1 }`, the symbol for the literal, `__object`, is distinct // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. - const firstDecl: Node = first(symbol.declarations); + const firstDecl: Node | false = !!length(symbol.declarations) && first(symbol.declarations); if (!length(containers) && meaning & SymbolFlags.Value && firstDecl && isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; diff --git a/tests/baselines/reference/globalThisDeclarationEmit.errors.txt b/tests/baselines/reference/globalThisDeclarationEmit.errors.txt new file mode 100644 index 00000000000..8d536b0fd1c --- /dev/null +++ b/tests/baselines/reference/globalThisDeclarationEmit.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/index.ts(2,14): error TS4025: Exported variable 'globalThis' has or is using private name 'globalThis'. + + +==== tests/cases/compiler/index.ts (1 errors) ==== + import { variable } from "./variable"; + export const globalThis = variable; + ~~~~~~~~~~ +!!! error TS4025: Exported variable 'globalThis' has or is using private name 'globalThis'. + +==== tests/cases/compiler/variable.ts (0 errors) ==== + export const variable = globalThis; \ No newline at end of file diff --git a/tests/baselines/reference/globalThisDeclarationEmit.js b/tests/baselines/reference/globalThisDeclarationEmit.js new file mode 100644 index 00000000000..52793067733 --- /dev/null +++ b/tests/baselines/reference/globalThisDeclarationEmit.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/globalThisDeclarationEmit.ts] //// + +//// [index.ts] +import { variable } from "./variable"; +export const globalThis = variable; + +//// [variable.ts] +export const variable = globalThis; + +//// [variable.js] +"use strict"; +exports.__esModule = true; +exports.variable = void 0; +exports.variable = globalThis; +//// [index.js] +"use strict"; +exports.__esModule = true; +exports.globalThis = void 0; +var variable_1 = require("./variable"); +exports.globalThis = variable_1.variable; + + +//// [variable.d.ts] +export declare const variable: typeof globalThis; diff --git a/tests/baselines/reference/globalThisDeclarationEmit.symbols b/tests/baselines/reference/globalThisDeclarationEmit.symbols new file mode 100644 index 00000000000..782d3315e48 --- /dev/null +++ b/tests/baselines/reference/globalThisDeclarationEmit.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/index.ts === +import { variable } from "./variable"; +>variable : Symbol(variable, Decl(index.ts, 0, 8)) + +export const globalThis = variable; +>globalThis : Symbol(globalThis, Decl(index.ts, 1, 12)) +>variable : Symbol(variable, Decl(index.ts, 0, 8)) + +=== tests/cases/compiler/variable.ts === +export const variable = globalThis; +>variable : Symbol(variable, Decl(variable.ts, 0, 12)) +>globalThis : Symbol(globalThis) + diff --git a/tests/baselines/reference/globalThisDeclarationEmit.types b/tests/baselines/reference/globalThisDeclarationEmit.types new file mode 100644 index 00000000000..ed60137fb08 --- /dev/null +++ b/tests/baselines/reference/globalThisDeclarationEmit.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/index.ts === +import { variable } from "./variable"; +>variable : typeof globalThis + +export const globalThis = variable; +>globalThis : typeof globalThis +>variable : typeof globalThis + +=== tests/cases/compiler/variable.ts === +export const variable = globalThis; +>variable : typeof globalThis +>globalThis : typeof globalThis + diff --git a/tests/baselines/reference/globalThisDeclarationEmit2.js b/tests/baselines/reference/globalThisDeclarationEmit2.js new file mode 100644 index 00000000000..ac6f9ecd036 --- /dev/null +++ b/tests/baselines/reference/globalThisDeclarationEmit2.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/globalThisDeclarationEmit2.ts] //// + +//// [index.ts] +import { variable } from "./variable"; +export { variable as globalThis }; + +//// [variable.ts] +export const variable = globalThis; + +//// [variable.js] +"use strict"; +exports.__esModule = true; +exports.variable = void 0; +exports.variable = globalThis; +//// [index.js] +"use strict"; +exports.__esModule = true; +exports.globalThis = void 0; +var variable_1 = require("./variable"); +exports.globalThis = variable_1.variable; + + +//// [variable.d.ts] +export declare const variable: typeof globalThis; +//// [index.d.ts] +import { variable } from "./variable"; +export { variable as globalThis }; diff --git a/tests/baselines/reference/globalThisDeclarationEmit2.symbols b/tests/baselines/reference/globalThisDeclarationEmit2.symbols new file mode 100644 index 00000000000..1b17abe4e94 --- /dev/null +++ b/tests/baselines/reference/globalThisDeclarationEmit2.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/index.ts === +import { variable } from "./variable"; +>variable : Symbol(variable, Decl(index.ts, 0, 8)) + +export { variable as globalThis }; +>variable : Symbol(variable, Decl(index.ts, 0, 8)) +>globalThis : Symbol(globalThis, Decl(index.ts, 1, 8)) + +=== tests/cases/compiler/variable.ts === +export const variable = globalThis; +>variable : Symbol(variable, Decl(variable.ts, 0, 12)) +>globalThis : Symbol(globalThis) + diff --git a/tests/baselines/reference/globalThisDeclarationEmit2.types b/tests/baselines/reference/globalThisDeclarationEmit2.types new file mode 100644 index 00000000000..cd399a150c2 --- /dev/null +++ b/tests/baselines/reference/globalThisDeclarationEmit2.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/index.ts === +import { variable } from "./variable"; +>variable : typeof globalThis + +export { variable as globalThis }; +>variable : typeof globalThis +>globalThis : typeof globalThis + +=== tests/cases/compiler/variable.ts === +export const variable = globalThis; +>variable : typeof globalThis +>globalThis : typeof globalThis + diff --git a/tests/baselines/reference/globalThisDeclarationEmit3.js b/tests/baselines/reference/globalThisDeclarationEmit3.js new file mode 100644 index 00000000000..060c2330ac2 --- /dev/null +++ b/tests/baselines/reference/globalThisDeclarationEmit3.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/globalThisDeclarationEmit3.ts] //// + +//// [index.ts] +import { variable } from "./variable"; +export { variable as globalThis }; + +//// [variable.ts] +import mod = globalThis; +export { mod as variable }; + +//// [variable.js] +"use strict"; +exports.__esModule = true; +exports.variable = void 0; +var mod = globalThis; +exports.variable = mod; +//// [index.js] +"use strict"; +exports.__esModule = true; +exports.globalThis = void 0; +var variable_1 = require("./variable"); +exports.globalThis = variable_1.variable; + + +//// [variable.d.ts] +import mod = globalThis; +export { mod as variable }; +//// [index.d.ts] +import { variable } from "./variable"; +export { variable as globalThis }; diff --git a/tests/baselines/reference/globalThisDeclarationEmit3.symbols b/tests/baselines/reference/globalThisDeclarationEmit3.symbols new file mode 100644 index 00000000000..566b7c7fc6f --- /dev/null +++ b/tests/baselines/reference/globalThisDeclarationEmit3.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/index.ts === +import { variable } from "./variable"; +>variable : Symbol(variable, Decl(index.ts, 0, 8)) + +export { variable as globalThis }; +>variable : Symbol(variable, Decl(index.ts, 0, 8)) +>globalThis : Symbol(globalThis, Decl(index.ts, 1, 8)) + +=== tests/cases/compiler/variable.ts === +import mod = globalThis; +>mod : Symbol(mod, Decl(variable.ts, 0, 0)) +>globalThis : Symbol(mod) + +export { mod as variable }; +>mod : Symbol(mod, Decl(variable.ts, 0, 0)) +>variable : Symbol(variable, Decl(variable.ts, 1, 8)) + diff --git a/tests/baselines/reference/globalThisDeclarationEmit3.types b/tests/baselines/reference/globalThisDeclarationEmit3.types new file mode 100644 index 00000000000..13f59963062 --- /dev/null +++ b/tests/baselines/reference/globalThisDeclarationEmit3.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/index.ts === +import { variable } from "./variable"; +>variable : typeof variable + +export { variable as globalThis }; +>variable : typeof variable +>globalThis : typeof variable + +=== tests/cases/compiler/variable.ts === +import mod = globalThis; +>mod : typeof mod +>globalThis : typeof mod + +export { mod as variable }; +>mod : typeof mod +>variable : typeof mod + diff --git a/tests/cases/compiler/globalThisDeclarationEmit.ts b/tests/cases/compiler/globalThisDeclarationEmit.ts new file mode 100644 index 00000000000..4bc08520f8f --- /dev/null +++ b/tests/cases/compiler/globalThisDeclarationEmit.ts @@ -0,0 +1,7 @@ +// @declaration: true +// @filename: index.ts +import { variable } from "./variable"; +export const globalThis = variable; + +// @filename: variable.ts +export const variable = globalThis; \ No newline at end of file diff --git a/tests/cases/compiler/globalThisDeclarationEmit2.ts b/tests/cases/compiler/globalThisDeclarationEmit2.ts new file mode 100644 index 00000000000..e190ed08521 --- /dev/null +++ b/tests/cases/compiler/globalThisDeclarationEmit2.ts @@ -0,0 +1,7 @@ +// @declaration: true +// @filename: index.ts +import { variable } from "./variable"; +export { variable as globalThis }; + +// @filename: variable.ts +export const variable = globalThis; \ No newline at end of file diff --git a/tests/cases/compiler/globalThisDeclarationEmit3.ts b/tests/cases/compiler/globalThisDeclarationEmit3.ts new file mode 100644 index 00000000000..40a3712391e --- /dev/null +++ b/tests/cases/compiler/globalThisDeclarationEmit3.ts @@ -0,0 +1,8 @@ +// @declaration: true +// @filename: index.ts +import { variable } from "./variable"; +export { variable as globalThis }; + +// @filename: variable.ts +import mod = globalThis; +export { mod as variable }; \ No newline at end of file From ca1f4672339aefacbf494484d4b3451077dc6400 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Wed, 15 Apr 2020 13:55:30 -0700 Subject: [PATCH 18/74] Update user baselines (#37946) Co-authored-by: typescript-bot --- tests/baselines/reference/docker/vscode.log | 49 +------------------ tests/baselines/reference/docker/vue-next.log | 8 +-- tests/baselines/reference/user/uglify-js.log | 4 +- 3 files changed, 8 insertions(+), 53 deletions(-) diff --git a/tests/baselines/reference/docker/vscode.log b/tests/baselines/reference/docker/vscode.log index b4a91c0057a..45c7728bdb5 100644 --- a/tests/baselines/reference/docker/vscode.log +++ b/tests/baselines/reference/docker/vscode.log @@ -1,56 +1,11 @@ -Exit Code: 1 +Exit Code: 0 Standard output: yarn run vX.X.X $ gulp compile --max_old_space_size=4095 [XX:XX:XX] Node flags detected: --max_old_space_size=4095 [XX:XX:XX] Using gulpfile /vscode/gulpfile.js -[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts(70,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/services/search/common/search.ts(620,20): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/webview/electron-browser/webviewCommands.ts(156,13): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/scm/browser/repositoryPane.ts(823,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts(522,18): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/test/browser/workbenchTestServices.ts(1039,183): Property 'getTypeId' does not exist on type 'never'. - The intersection 'TestEditorInput & TestFileEditorInput' was reduced to 'never' because property 'typeId' exists in multiple constituents and is private in some. -[XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1075,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1087,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1093,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/editor/contrib/hover/hoverOperation.ts(146,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/editor/contrib/hover/hoverOperation.ts(160,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/base/browser/mouseEvent.ts(83,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/base/browser/mouseEvent.ts(89,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/base/browser/mouseEvent.ts(211,8): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/base/browser/mouseEvent.ts(219,8): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts(70,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/services/search/common/search.ts(620,20): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/webview/electron-browser/webviewCommands.ts(156,13): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/scm/browser/repositoryPane.ts(823,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/contrib/preferences/browser/preferencesSearch.ts(522,18): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/test/browser/workbenchTestServices.ts(1039,183): Property 'getTypeId' does not exist on type 'never'. - The intersection 'TestEditorInput & TestFileEditorInput' was reduced to 'never' because property 'typeId' exists in multiple constituents and is private in some. -[XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1075,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1087,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/workbench/api/common/extHostDebugService.ts(1093,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/editor/contrib/hover/hoverOperation.ts(146,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/editor/contrib/hover/hoverOperation.ts(160,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/base/browser/mouseEvent.ts(83,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/base/browser/mouseEvent.ts(89,7): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/base/browser/mouseEvent.ts(211,8): This condition will always return true since the function is always defined. Did you mean to call it instead? -[XX:XX:XX] Error: /vscode/src/vs/base/browser/mouseEvent.ts(219,8): This condition will always return true since the function is always defined. Did you mean to call it instead? -info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. +Done in ?s. Standard error: -[XX:XX:XX] 'compile' errored after -[XX:XX:XX] Error: Found 15 errors - at Stream. (/vscode/build/lib/reporter.js:75:29) - at _end (/vscode/node_modules/through/index.js:65:9) - at Stream.stream.end (/vscode/node_modules/through/index.js:74:5) - at Stream.onend (internal/streams/legacy.js:42:10) - at Stream.emit (events.js:203:15) - at Stream.EventEmitter.emit (domain.js:466:23) - at drain (/vscode/node_modules/through/index.js:34:23) - at Stream.stream.queue.stream.push (/vscode/node_modules/through/index.js:45:5) - at Stream.end (/vscode/node_modules/through/index.js:15:35) - at _end (/vscode/node_modules/through/index.js:65:9) -error Command failed with exit code 1. diff --git a/tests/baselines/reference/docker/vue-next.log b/tests/baselines/reference/docker/vue-next.log index 109fe7259d0..7e673ffe7c8 100644 --- a/tests/baselines/reference/docker/vue-next.log +++ b/tests/baselines/reference/docker/vue-next.log @@ -1,7 +1,7 @@ Exit Code: 0 Standard output: -> @X.X.X-alpha.12 build /vue-next +> @X.X.X-alpha.13 build /vue-next > node scripts/build.js "--types" Rolling up type definitions for compiler-core... Writing: /vue-next/temp/compiler-core.api.json @@ -75,10 +75,10 @@ created packages/reactivity/dist/reactivity.global.prod.js in ?s /vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.esm.prod.js... created packages/reactivity/dist/reactivity.esm.prod.js in ?s /vue-next/packages/runtime-core/src/index.ts → packages/runtime-core/dist/runtime-core.esm-bundler.js... -[!] (plugin rpt2) Error: /vue-next/packages/runtime-core/src/componentOptions.ts(160,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. +[!] (plugin rpt2) Error: /vue-next/packages/runtime-core/src/componentOptions.ts(161,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. Type 'Function' provides no match for the signature '(...args: any): any'. packages/runtime-core/src/componentOptions.ts -Error: /vue-next/packages/runtime-core/src/componentOptions.ts(160,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. +Error: /vue-next/packages/runtime-core/src/componentOptions.ts(161,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. Type 'Function' provides no match for the signature '(...args: any): any'. at error (/vue-next/node_modules/rollup/dist/shared/rollup.js:10399:30) at throwPluginError (/vue-next/node_modules/rollup/dist/shared/rollup.js:16617:12) @@ -90,7 +90,7 @@ Error: /vue-next/packages/runtime-core/src/componentOptions.ts(160,18): semantic at forEach (/vue-next/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:9342:14) at _.each (/vue-next/node_modules/rollup-plugin-typescript2/src/print-diagnostics.ts:9:2) at Object.transform (/vue-next/node_modules/rollup-plugin-typescript2/src/index.ts:242:5) -(node:17) UnhandledPromiseRejectionWarning: Error: Command failed with exit code 1 (EPERM): rollup -c --environment COMMIT:a35e297,NODE_ENV:production,TARGET:runtime-core,TYPES:true +(node:17) UnhandledPromiseRejectionWarning: Error: Command failed with exit code 1 (EPERM): rollup -c --environment COMMIT:11654a6,NODE_ENV:production,TARGET:runtime-core,TYPES:true at makeError (/vue-next/node_modules/execa/lib/error.js:59:11) at handlePromise (/vue-next/node_modules/execa/index.js:112:26) at processTicksAndRejections (internal/process/task_queues.js:97:5) diff --git a/tests/baselines/reference/user/uglify-js.log b/tests/baselines/reference/user/uglify-js.log index 216e2f5d2fd..87f285a8cd5 100644 --- a/tests/baselines/reference/user/uglify-js.log +++ b/tests/baselines/reference/user/uglify-js.log @@ -159,8 +159,8 @@ node_modules/uglify-js/lib/scope.js(441,49): error TS2339: Property 'has_directi node_modules/uglify-js/lib/scope.js(496,30): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/scope.js(521,30): error TS2554: Expected 0 arguments, but got 1. node_modules/uglify-js/lib/sourcemap.js(82,11): error TS2339: Property 'index' does not exist on type 'any[]'. -node_modules/uglify-js/lib/sourcemap.js(173,31): error TS2339: Property 'index' does not exist on type 'any[]'. -node_modules/uglify-js/lib/sourcemap.js(181,34): error TS2339: Property 'index' does not exist on type 'any[]'. +node_modules/uglify-js/lib/sourcemap.js(177,31): error TS2339: Property 'index' does not exist on type 'any[]'. +node_modules/uglify-js/lib/sourcemap.js(185,34): error TS2339: Property 'index' does not exist on type 'any[]'. node_modules/uglify-js/tools/exit.js(10,37): error TS2345: Argument of type 'any[]' is not assignable to parameter of type '[(number | undefined)?]'. Types of property 'length' are incompatible. Type 'number' is not assignable to type '0 | 1'. From deb5bac520a1134e188fc6f01fa4f52b66d2899b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 15 Apr 2020 21:11:05 -0700 Subject: [PATCH 19/74] Use string representation for negative numeric property names (#37936) --- src/compiler/checker.ts | 2 +- ...otedAsObjectPropertiesInDeclarationEmit.js | 59 ++++++++++++++++ ...sObjectPropertiesInDeclarationEmit.symbols | 63 +++++++++++++++++ ...dAsObjectPropertiesInDeclarationEmit.types | 70 +++++++++++++++++++ ...ctTypeWithStringNamedNumericProperty.types | 30 ++++---- ...otedAsObjectPropertiesInDeclarationEmit.ts | 18 +++++ 6 files changed, 226 insertions(+), 16 deletions(-) create mode 100644 tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js create mode 100644 tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.symbols create mode 100644 tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types create mode 100644 tests/cases/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e4d31eb8493..087353fb9fd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5393,7 +5393,7 @@ namespace ts { } function createPropertyNameNodeForIdentifierOrLiteral(name: string, singleQuote?: boolean) { - return isIdentifierText(name, compilerOptions.target) ? createIdentifier(name) : createLiteral(isNumericLiteralName(name) ? +name : name, !!singleQuote); + return isIdentifierText(name, compilerOptions.target) ? createIdentifier(name) : createLiteral(isNumericLiteralName(name) && +name >= 0 ? +name : name, !!singleQuote); } function cloneNodeBuilderContext(context: NodeBuilderContext): NodeBuilderContext { diff --git a/tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js b/tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js new file mode 100644 index 00000000000..c3a36c0ba71 --- /dev/null +++ b/tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js @@ -0,0 +1,59 @@ +//// [enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts] +export enum MouseButton { + LEFT_BUTTON = 1, + RIGHT_BUTTON = 2, + MIDDLE_BUTTON = 4, + XBUTTON1_BUTTON = 5, + XBUTTON2_BUTTON = 6, + NO_BUTTON = 0, +} + +export const DOMMouseButton = { + '-1': MouseButton.NO_BUTTON, + "0": MouseButton.LEFT_BUTTON, + "1": MouseButton.MIDDLE_BUTTON, + "2": MouseButton.RIGHT_BUTTON, + "3": MouseButton.XBUTTON1_BUTTON, + "4": MouseButton.XBUTTON2_BUTTON, +}; + +//// [enumKeysQuotedAsObjectPropertiesInDeclarationEmit.js] +"use strict"; +exports.__esModule = true; +exports.DOMMouseButton = exports.MouseButton = void 0; +var MouseButton; +(function (MouseButton) { + MouseButton[MouseButton["LEFT_BUTTON"] = 1] = "LEFT_BUTTON"; + MouseButton[MouseButton["RIGHT_BUTTON"] = 2] = "RIGHT_BUTTON"; + MouseButton[MouseButton["MIDDLE_BUTTON"] = 4] = "MIDDLE_BUTTON"; + MouseButton[MouseButton["XBUTTON1_BUTTON"] = 5] = "XBUTTON1_BUTTON"; + MouseButton[MouseButton["XBUTTON2_BUTTON"] = 6] = "XBUTTON2_BUTTON"; + MouseButton[MouseButton["NO_BUTTON"] = 0] = "NO_BUTTON"; +})(MouseButton = exports.MouseButton || (exports.MouseButton = {})); +exports.DOMMouseButton = { + '-1': MouseButton.NO_BUTTON, + "0": MouseButton.LEFT_BUTTON, + "1": MouseButton.MIDDLE_BUTTON, + "2": MouseButton.RIGHT_BUTTON, + "3": MouseButton.XBUTTON1_BUTTON, + "4": MouseButton.XBUTTON2_BUTTON +}; + + +//// [enumKeysQuotedAsObjectPropertiesInDeclarationEmit.d.ts] +export declare enum MouseButton { + LEFT_BUTTON = 1, + RIGHT_BUTTON = 2, + MIDDLE_BUTTON = 4, + XBUTTON1_BUTTON = 5, + XBUTTON2_BUTTON = 6, + NO_BUTTON = 0 +} +export declare const DOMMouseButton: { + '-1': MouseButton; + 0: MouseButton; + 1: MouseButton; + 2: MouseButton; + 3: MouseButton; + 4: MouseButton; +}; diff --git a/tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.symbols b/tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.symbols new file mode 100644 index 00000000000..51313bcdd3e --- /dev/null +++ b/tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.symbols @@ -0,0 +1,63 @@ +=== tests/cases/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts === +export enum MouseButton { +>MouseButton : Symbol(MouseButton, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 0, 0)) + + LEFT_BUTTON = 1, +>LEFT_BUTTON : Symbol(MouseButton.LEFT_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 0, 25)) + + RIGHT_BUTTON = 2, +>RIGHT_BUTTON : Symbol(MouseButton.RIGHT_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 1, 17)) + + MIDDLE_BUTTON = 4, +>MIDDLE_BUTTON : Symbol(MouseButton.MIDDLE_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 2, 18)) + + XBUTTON1_BUTTON = 5, +>XBUTTON1_BUTTON : Symbol(MouseButton.XBUTTON1_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 3, 19)) + + XBUTTON2_BUTTON = 6, +>XBUTTON2_BUTTON : Symbol(MouseButton.XBUTTON2_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 4, 21)) + + NO_BUTTON = 0, +>NO_BUTTON : Symbol(MouseButton.NO_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 5, 21)) +} + +export const DOMMouseButton = { +>DOMMouseButton : Symbol(DOMMouseButton, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 9, 12)) + + '-1': MouseButton.NO_BUTTON, +>'-1' : Symbol('-1', Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 9, 31)) +>MouseButton.NO_BUTTON : Symbol(MouseButton.NO_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 5, 21)) +>MouseButton : Symbol(MouseButton, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 0, 0)) +>NO_BUTTON : Symbol(MouseButton.NO_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 5, 21)) + + "0": MouseButton.LEFT_BUTTON, +>"0" : Symbol("0", Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 10, 29)) +>MouseButton.LEFT_BUTTON : Symbol(MouseButton.LEFT_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 0, 25)) +>MouseButton : Symbol(MouseButton, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 0, 0)) +>LEFT_BUTTON : Symbol(MouseButton.LEFT_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 0, 25)) + + "1": MouseButton.MIDDLE_BUTTON, +>"1" : Symbol("1", Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 11, 30)) +>MouseButton.MIDDLE_BUTTON : Symbol(MouseButton.MIDDLE_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 2, 18)) +>MouseButton : Symbol(MouseButton, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 0, 0)) +>MIDDLE_BUTTON : Symbol(MouseButton.MIDDLE_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 2, 18)) + + "2": MouseButton.RIGHT_BUTTON, +>"2" : Symbol("2", Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 12, 32)) +>MouseButton.RIGHT_BUTTON : Symbol(MouseButton.RIGHT_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 1, 17)) +>MouseButton : Symbol(MouseButton, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 0, 0)) +>RIGHT_BUTTON : Symbol(MouseButton.RIGHT_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 1, 17)) + + "3": MouseButton.XBUTTON1_BUTTON, +>"3" : Symbol("3", Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 13, 31)) +>MouseButton.XBUTTON1_BUTTON : Symbol(MouseButton.XBUTTON1_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 3, 19)) +>MouseButton : Symbol(MouseButton, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 0, 0)) +>XBUTTON1_BUTTON : Symbol(MouseButton.XBUTTON1_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 3, 19)) + + "4": MouseButton.XBUTTON2_BUTTON, +>"4" : Symbol("4", Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 14, 34)) +>MouseButton.XBUTTON2_BUTTON : Symbol(MouseButton.XBUTTON2_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 4, 21)) +>MouseButton : Symbol(MouseButton, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 0, 0)) +>XBUTTON2_BUTTON : Symbol(MouseButton.XBUTTON2_BUTTON, Decl(enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts, 4, 21)) + +}; diff --git a/tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types b/tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types new file mode 100644 index 00000000000..955e942460f --- /dev/null +++ b/tests/baselines/reference/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.types @@ -0,0 +1,70 @@ +=== tests/cases/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts === +export enum MouseButton { +>MouseButton : MouseButton + + LEFT_BUTTON = 1, +>LEFT_BUTTON : MouseButton.LEFT_BUTTON +>1 : 1 + + RIGHT_BUTTON = 2, +>RIGHT_BUTTON : MouseButton.RIGHT_BUTTON +>2 : 2 + + MIDDLE_BUTTON = 4, +>MIDDLE_BUTTON : MouseButton.MIDDLE_BUTTON +>4 : 4 + + XBUTTON1_BUTTON = 5, +>XBUTTON1_BUTTON : MouseButton.XBUTTON1_BUTTON +>5 : 5 + + XBUTTON2_BUTTON = 6, +>XBUTTON2_BUTTON : MouseButton.XBUTTON2_BUTTON +>6 : 6 + + NO_BUTTON = 0, +>NO_BUTTON : MouseButton.NO_BUTTON +>0 : 0 +} + +export const DOMMouseButton = { +>DOMMouseButton : { '-1': MouseButton; 0: MouseButton; 1: MouseButton; 2: MouseButton; 3: MouseButton; 4: MouseButton; } +>{ '-1': MouseButton.NO_BUTTON, "0": MouseButton.LEFT_BUTTON, "1": MouseButton.MIDDLE_BUTTON, "2": MouseButton.RIGHT_BUTTON, "3": MouseButton.XBUTTON1_BUTTON, "4": MouseButton.XBUTTON2_BUTTON,} : { '-1': MouseButton; 0: MouseButton; 1: MouseButton; 2: MouseButton; 3: MouseButton; 4: MouseButton; } + + '-1': MouseButton.NO_BUTTON, +>'-1' : MouseButton +>MouseButton.NO_BUTTON : MouseButton.NO_BUTTON +>MouseButton : typeof MouseButton +>NO_BUTTON : MouseButton.NO_BUTTON + + "0": MouseButton.LEFT_BUTTON, +>"0" : MouseButton +>MouseButton.LEFT_BUTTON : MouseButton.LEFT_BUTTON +>MouseButton : typeof MouseButton +>LEFT_BUTTON : MouseButton.LEFT_BUTTON + + "1": MouseButton.MIDDLE_BUTTON, +>"1" : MouseButton +>MouseButton.MIDDLE_BUTTON : MouseButton.MIDDLE_BUTTON +>MouseButton : typeof MouseButton +>MIDDLE_BUTTON : MouseButton.MIDDLE_BUTTON + + "2": MouseButton.RIGHT_BUTTON, +>"2" : MouseButton +>MouseButton.RIGHT_BUTTON : MouseButton.RIGHT_BUTTON +>MouseButton : typeof MouseButton +>RIGHT_BUTTON : MouseButton.RIGHT_BUTTON + + "3": MouseButton.XBUTTON1_BUTTON, +>"3" : MouseButton +>MouseButton.XBUTTON1_BUTTON : MouseButton.XBUTTON1_BUTTON +>MouseButton : typeof MouseButton +>XBUTTON1_BUTTON : MouseButton.XBUTTON1_BUTTON + + "4": MouseButton.XBUTTON2_BUTTON, +>"4" : MouseButton +>MouseButton.XBUTTON2_BUTTON : MouseButton.XBUTTON2_BUTTON +>MouseButton : typeof MouseButton +>XBUTTON2_BUTTON : MouseButton.XBUTTON2_BUTTON + +}; diff --git a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types index df5e6ace60f..156ad554043 100644 --- a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types +++ b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types @@ -278,7 +278,7 @@ var r13 = i[-01] >01 : 1 var a: { ->a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: Date; } +>a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } "0.1": void; >"0.1" : void @@ -308,19 +308,19 @@ var a: { var r1 = a['0.1']; >r1 : void >a['0.1'] : void ->a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: Date; } +>a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'0.1' : "0.1" var r2 = a['.1']; >r2 : Object >a['.1'] : Object ->a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: Date; } +>a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'.1' : ".1" var r3 = a['1']; >r3 : number >a['1'] : number ->a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: Date; } +>a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1' : "1" var r3 = c[1]; @@ -332,7 +332,7 @@ var r3 = c[1]; var r4 = a['1.']; >r4 : string >a['1.'] : string ->a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: Date; } +>a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically @@ -344,13 +344,13 @@ var r3 = c[1.]; // same as indexing by 1 when done numerically var r5 = a['1..']; >r5 : boolean >a['1..'] : boolean ->a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: Date; } +>a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1..' : "1.." var r6 = a['1.0']; >r6 : Date >a['1.0'] : Date ->a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: Date; } +>a : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } >'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically @@ -413,8 +413,8 @@ var r13 = i[-01] >01 : 1 var b = { ->b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: DateConstructor; } ->{ "0.1": null, ".1": new Object(), "1": 1, "1.": "", "1..": true, "1.0": new Date(), "-1.0": /123/, "-1": Date} : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: DateConstructor; } +>b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } +>{ "0.1": null, ".1": new Object(), "1": 1, "1.": "", "1..": true, "1.0": new Date(), "-1.0": /123/, "-1": Date} : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } "0.1": null, >"0.1" : void @@ -456,19 +456,19 @@ var b = { var r1 = b['0.1']; >r1 : void >b['0.1'] : void ->b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: DateConstructor; } +>b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'0.1' : "0.1" var r2 = b['.1']; >r2 : Object >b['.1'] : Object ->b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: DateConstructor; } +>b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'.1' : ".1" var r3 = b['1']; >r3 : number >b['1'] : number ->b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: DateConstructor; } +>b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1' : "1" var r3 = c[1]; @@ -480,7 +480,7 @@ var r3 = c[1]; var r4 = b['1.']; >r4 : string >b['1.'] : string ->b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: DateConstructor; } +>b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically @@ -492,13 +492,13 @@ var r3 = c[1.]; // same as indexing by 1 when done numerically var r5 = b['1..']; >r5 : boolean >b['1..'] : boolean ->b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: DateConstructor; } +>b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1..' : "1.." var r6 = b['1.0']; >r6 : Date >b['1.0'] : Date ->b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; -1: DateConstructor; } +>b : { 0.1: void; ".1": Object; 1: number; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } >'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically diff --git a/tests/cases/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts b/tests/cases/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts new file mode 100644 index 00000000000..e05252bb766 --- /dev/null +++ b/tests/cases/compiler/enumKeysQuotedAsObjectPropertiesInDeclarationEmit.ts @@ -0,0 +1,18 @@ +// @declaration: true +export enum MouseButton { + LEFT_BUTTON = 1, + RIGHT_BUTTON = 2, + MIDDLE_BUTTON = 4, + XBUTTON1_BUTTON = 5, + XBUTTON2_BUTTON = 6, + NO_BUTTON = 0, +} + +export const DOMMouseButton = { + '-1': MouseButton.NO_BUTTON, + "0": MouseButton.LEFT_BUTTON, + "1": MouseButton.MIDDLE_BUTTON, + "2": MouseButton.RIGHT_BUTTON, + "3": MouseButton.XBUTTON1_BUTTON, + "4": MouseButton.XBUTTON2_BUTTON, +}; \ No newline at end of file From a2628c90884dac88c4459b556c1bdd4bd6939c0a Mon Sep 17 00:00:00 2001 From: Alexander T Date: Sun, 12 Apr 2020 11:45:09 +0300 Subject: [PATCH 20/74] fix(37242): add reference to return type for JSDocFunctionType --- src/compiler/utilitiesPublic.ts | 2 +- .../reference/asyncArrowFunction_allowJs.errors.txt | 8 +++++++- .../reference/jsdocFunction_missingReturn.errors.txt | 9 +++++++++ .../reference/jsdocFunction_missingReturn.symbols | 5 +++++ .../reference/jsdocFunction_missingReturn.types | 5 +++++ .../conformance/jsdoc/jsdocFunction_missingReturn.ts | 8 ++++++++ 6 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/jsdocFunction_missingReturn.errors.txt create mode 100644 tests/baselines/reference/jsdocFunction_missingReturn.symbols create mode 100644 tests/baselines/reference/jsdocFunction_missingReturn.types create mode 100644 tests/cases/conformance/jsdoc/jsdocFunction_missingReturn.ts diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 4a07f2b0bd8..d38187b406a 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -769,7 +769,7 @@ namespace ts { const sig = find(type.members, isCallSignatureDeclaration); return sig && sig.type; } - if (isFunctionTypeNode(type)) { + if (isFunctionTypeNode(type) || isJSDocFunctionType(type)) { return type.type; } } diff --git a/tests/baselines/reference/asyncArrowFunction_allowJs.errors.txt b/tests/baselines/reference/asyncArrowFunction_allowJs.errors.txt index 6c8d0c370d2..e006f1668c1 100644 --- a/tests/baselines/reference/asyncArrowFunction_allowJs.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction_allowJs.errors.txt @@ -1,11 +1,13 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(3,17): error TS2322: Type '0' is not assignable to type 'string'. +tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(6,24): error TS1064: The return type of an async function or method must be the global Promise type. tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(7,23): error TS2322: Type '0' is not assignable to type 'string'. +tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(10,24): error TS1064: The return type of an async function or method must be the global Promise type. tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(12,2): error TS2322: Type '0' is not assignable to type 'string'. tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(19,3): error TS2345: Argument of type '() => Promise' is not assignable to parameter of type '() => string'. Type 'Promise' is not assignable to type 'string'. -==== tests/cases/conformance/async/es2017/asyncArrowFunction/file.js (4 errors) ==== +==== tests/cases/conformance/async/es2017/asyncArrowFunction/file.js (6 errors) ==== // Error (good) /** @type {function(): string} */ const a = () => 0 @@ -14,12 +16,16 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(19,3): error TS2 // Error (good) /** @type {function(): string} */ + ~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. const b = async () => 0 ~ !!! error TS2322: Type '0' is not assignable to type 'string'. // No error (bad) /** @type {function(): string} */ + ~~~~~~ +!!! error TS1064: The return type of an async function or method must be the global Promise type. const c = async () => { return 0 ~~~~~~~~ diff --git a/tests/baselines/reference/jsdocFunction_missingReturn.errors.txt b/tests/baselines/reference/jsdocFunction_missingReturn.errors.txt new file mode 100644 index 00000000000..646e03fcd6f --- /dev/null +++ b/tests/baselines/reference/jsdocFunction_missingReturn.errors.txt @@ -0,0 +1,9 @@ +/a.js(1,24): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. + + +==== /a.js (1 errors) ==== + /** @type {function(): number} */ + ~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. + function f() {} + \ No newline at end of file diff --git a/tests/baselines/reference/jsdocFunction_missingReturn.symbols b/tests/baselines/reference/jsdocFunction_missingReturn.symbols new file mode 100644 index 00000000000..85f75e30f29 --- /dev/null +++ b/tests/baselines/reference/jsdocFunction_missingReturn.symbols @@ -0,0 +1,5 @@ +=== /a.js === +/** @type {function(): number} */ +function f() {} +>f : Symbol(f, Decl(a.js, 0, 0)) + diff --git a/tests/baselines/reference/jsdocFunction_missingReturn.types b/tests/baselines/reference/jsdocFunction_missingReturn.types new file mode 100644 index 00000000000..ce3453a4a8c --- /dev/null +++ b/tests/baselines/reference/jsdocFunction_missingReturn.types @@ -0,0 +1,5 @@ +=== /a.js === +/** @type {function(): number} */ +function f() {} +>f : () => number + diff --git a/tests/cases/conformance/jsdoc/jsdocFunction_missingReturn.ts b/tests/cases/conformance/jsdoc/jsdocFunction_missingReturn.ts new file mode 100644 index 00000000000..1d3e938cda8 --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocFunction_missingReturn.ts @@ -0,0 +1,8 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true +// @strict: true + +// @Filename: /a.js +/** @type {function(): number} */ +function f() {} From b346f5764e4d500ebdeff7086e43690ea533a305 Mon Sep 17 00:00:00 2001 From: sergeir82 Date: Fri, 17 Apr 2020 23:18:05 +0300 Subject: [PATCH 21/74] prefix-unused-parameter-with-_ codefix now works in jsdoc @param (#36152) * Fix prepending unused TypeScript variables with underscore doesn't rename JSDoc @param. Fix test for quick fix "Prefix all unused declarations with '_' where possible". Fixes #33021. * Replace FindAllReferences.Core.eachSymbolReferenceInFile function call to more ligher call of getJSDocParameterTags when searching for a parameter in jsdoc. * Remove redundant constant declaration. * Add test for prefix single unused parameter in jsdoc. --- src/services/codefixes/fixUnusedIdentifier.ts | 7 ++++++ .../codeFixUnusedIdentifier_all_prefix.ts | 10 +++++++- .../codeFixUnusedIdentifier_prefix.ts | 25 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/codeFixUnusedIdentifier_prefix.ts diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index 8439c1e8fc3..7644c8df269 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -154,6 +154,13 @@ namespace ts.codefix { } if (isIdentifier(token) && canPrefix(token)) { changes.replaceNode(sourceFile, token, createIdentifier(`_${token.text}`)); + if (isParameter(token.parent)) { + getJSDocParameterTags(token.parent).forEach((tag) => { + if (isIdentifier(tag.name)) { + changes.replaceNode(sourceFile, tag.name, createIdentifier(`_${tag.name.text}`)); + } + }); + } } } diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_all_prefix.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_all_prefix.ts index f77fef6510f..4eb7137d365 100644 --- a/tests/cases/fourslash/codeFixUnusedIdentifier_all_prefix.ts +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_all_prefix.ts @@ -3,6 +3,10 @@ // @noUnusedLocals: true // @noUnusedParameters: true +/////** +//// * @param a First parameter. +//// * @param b Second parameter. +//// */ ////function f(a, b) { //// const x = 0; // Can't be prefixed, ignored ////} @@ -12,7 +16,11 @@ verify.codeFixAll({ fixId: "unusedIdentifier_prefix", fixAllDescription: "Prefix all unused declarations with '_' where possible", newFileContent: -`function f(_a, _b) { +`/** + * @param _a First parameter. + * @param _b Second parameter. + */ +function f(_a, _b) { const x = 0; // Can't be prefixed, ignored } type Length = T extends ArrayLike ? number : never;`, diff --git a/tests/cases/fourslash/codeFixUnusedIdentifier_prefix.ts b/tests/cases/fourslash/codeFixUnusedIdentifier_prefix.ts new file mode 100644 index 00000000000..80b2b9bb75c --- /dev/null +++ b/tests/cases/fourslash/codeFixUnusedIdentifier_prefix.ts @@ -0,0 +1,25 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true + +/////** +//// * @param a +//// * @param b +//// */ +////function f(a, b) { +//// const x = a; +////} + +verify.codeFix({ + description: "Prefix 'b' with an underscore", + index: 1, + newFileContent: +`/** + * @param a + * @param _b + */ +function f(a, _b) { + const x = a; +}`, +}); From c0f64f1821a0fde196b08ee4f33c58af1b23744f Mon Sep 17 00:00:00 2001 From: csigs Date: Mon, 20 Apr 2020 16:10:20 +0000 Subject: [PATCH 22/74] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 9 +++++++++ .../diagnosticMessages.generated.json.lcl | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 33a4a6e0b65..9202ae5f4c0 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -7197,6 +7197,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 0d4fa3864a9..abb6254bdc0 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -7178,6 +7178,15 @@ + + + + + + + + + From 5d78cbdbbda03c448e89957b5bf612ce3d6cbdb4 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 20 Apr 2020 11:04:24 -0700 Subject: [PATCH 23/74] Propagate nonInferrableType in &&, || and ?? operators (#38035) * Propagate nonInferrableType in &&, || and ?? operators * Add regression test * Simpler solution: getTypeFacts(neverType) should return TypeFacts.None --- src/compiler/checker.ts | 5 ++++- .../reference/propagateNonInferrableType.js | 10 ++++++++++ .../reference/propagateNonInferrableType.symbols | 14 ++++++++++++++ .../reference/propagateNonInferrableType.types | 16 ++++++++++++++++ .../cases/compiler/propagateNonInferrableType.ts | 6 ++++++ 5 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/propagateNonInferrableType.js create mode 100644 tests/baselines/reference/propagateNonInferrableType.symbols create mode 100644 tests/baselines/reference/propagateNonInferrableType.types create mode 100644 tests/cases/compiler/propagateNonInferrableType.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 087353fb9fd..5eb685cb61c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19390,6 +19390,9 @@ namespace ts { if (flags & TypeFlags.NonPrimitive) { return strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts; } + if (flags & TypeFlags.Never) { + return TypeFacts.None; + } if (flags & TypeFlags.Instantiable) { return getTypeFacts(getBaseConstraintOfType(type) || unknownType); } @@ -19626,7 +19629,7 @@ namespace ts { const filtered = filter(types, f); return filtered === types ? type : getUnionTypeFromSortedList(filtered, (type).objectFlags); } - return f(type) ? type : neverType; + return type.flags & TypeFlags.Never || f(type) ? type : neverType; } function countTypes(type: Type) { diff --git a/tests/baselines/reference/propagateNonInferrableType.js b/tests/baselines/reference/propagateNonInferrableType.js new file mode 100644 index 00000000000..b245899049d --- /dev/null +++ b/tests/baselines/reference/propagateNonInferrableType.js @@ -0,0 +1,10 @@ +//// [propagateNonInferrableType.ts] +declare function resolver(): () => void; +declare function wrapResolver(resolverFunction: () => void): void; + +wrapResolver(resolver() || []); + + +//// [propagateNonInferrableType.js] +"use strict"; +wrapResolver(resolver() || []); diff --git a/tests/baselines/reference/propagateNonInferrableType.symbols b/tests/baselines/reference/propagateNonInferrableType.symbols new file mode 100644 index 00000000000..628922c2366 --- /dev/null +++ b/tests/baselines/reference/propagateNonInferrableType.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/propagateNonInferrableType.ts === +declare function resolver(): () => void; +>resolver : Symbol(resolver, Decl(propagateNonInferrableType.ts, 0, 0)) +>T : Symbol(T, Decl(propagateNonInferrableType.ts, 0, 26)) + +declare function wrapResolver(resolverFunction: () => void): void; +>wrapResolver : Symbol(wrapResolver, Decl(propagateNonInferrableType.ts, 0, 43)) +>T : Symbol(T, Decl(propagateNonInferrableType.ts, 1, 30)) +>resolverFunction : Symbol(resolverFunction, Decl(propagateNonInferrableType.ts, 1, 33)) + +wrapResolver(resolver() || []); +>wrapResolver : Symbol(wrapResolver, Decl(propagateNonInferrableType.ts, 0, 43)) +>resolver : Symbol(resolver, Decl(propagateNonInferrableType.ts, 0, 0)) + diff --git a/tests/baselines/reference/propagateNonInferrableType.types b/tests/baselines/reference/propagateNonInferrableType.types new file mode 100644 index 00000000000..f4aa66d6ccf --- /dev/null +++ b/tests/baselines/reference/propagateNonInferrableType.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/propagateNonInferrableType.ts === +declare function resolver(): () => void; +>resolver : () => () => void + +declare function wrapResolver(resolverFunction: () => void): void; +>wrapResolver : (resolverFunction: () => void) => void +>resolverFunction : () => void + +wrapResolver(resolver() || []); +>wrapResolver(resolver() || []) : void +>wrapResolver : (resolverFunction: () => void) => void +>resolver() || [] : () => void +>resolver() : () => void +>resolver : () => () => void +>[] : never[] + diff --git a/tests/cases/compiler/propagateNonInferrableType.ts b/tests/cases/compiler/propagateNonInferrableType.ts new file mode 100644 index 00000000000..051eb7b083f --- /dev/null +++ b/tests/cases/compiler/propagateNonInferrableType.ts @@ -0,0 +1,6 @@ +// @strict: true + +declare function resolver(): () => void; +declare function wrapResolver(resolverFunction: () => void): void; + +wrapResolver(resolver() || []); From 547fd12c2fa4a15892d63798ea930c831bf1ce03 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 20 Apr 2020 10:15:12 -0800 Subject: [PATCH 24/74] Fix doc comment template on assignment expressions (#38032) --- src/services/jsDoc.ts | 2 ++ .../docCommentTemplateExportAssignmentJS.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 tests/cases/fourslash/docCommentTemplateExportAssignmentJS.ts diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 7118fe8b761..63297c7868d 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -363,6 +363,8 @@ namespace ts.JsDoc { // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. return commentOwner.parent.kind === SyntaxKind.ModuleDeclaration ? undefined : { commentOwner }; + case SyntaxKind.ExpressionStatement: + return getCommentOwnerInfoWorker((commentOwner as ExpressionStatement).expression); case SyntaxKind.BinaryExpression: { const be = commentOwner as BinaryExpression; if (getAssignmentDeclarationKind(be) === AssignmentDeclarationKind.None) { diff --git a/tests/cases/fourslash/docCommentTemplateExportAssignmentJS.ts b/tests/cases/fourslash/docCommentTemplateExportAssignmentJS.ts new file mode 100644 index 00000000000..849227ba74b --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateExportAssignmentJS.ts @@ -0,0 +1,15 @@ +/// + +// @allowJs: true +// @checkJs: true + +// @Filename: index.js +//// /** /**/ */ +//// exports.foo = (a) => {}; + + +verify.docCommentTemplateAt("", 8, +`/** + * + * @param {any} a + */`); From 0f3f37b30c85f3be6072c21c43409d3df38a34af Mon Sep 17 00:00:00 2001 From: Dan Dascalescu Date: Tue, 21 Apr 2020 07:14:26 +1200 Subject: [PATCH 25/74] Fix typo in issue template titles (#38042) --- .github/ISSUE_TEMPLATE/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index b5bf7ad4a26..69db3e0326a 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -14,6 +14,6 @@ contact_links: name: "TypeScript FAQ" url: "https://github.com/microsoft/TypeScript/wiki/FAQ" - - about: "Please raise issues about the site on it's own repo." + about: "Please raise issues about the site on its own repo." name: Website url: "https://github.com/microsoft/TypeScript-Website/issues/new" From e7774c61447d1cc0288c3e38caba2aa98bd0cc44 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 20 Apr 2020 12:58:38 -0700 Subject: [PATCH 26/74] Handle non literal computed name when trying to get the name for object literal property name in json object (#37988) Fixes #37984 --- src/compiler/checker.ts | 4 --- src/compiler/commandLineParser.ts | 2 +- src/compiler/utilities.ts | 4 +++ ...sonFileWithComputedPropertyName.errors.txt | 17 +++++++++++ ...quireOfJsonFileWithComputedPropertyName.js | 29 +++++++++++++++++++ ...OfJsonFileWithComputedPropertyName.symbols | 24 +++++++++++++++ ...reOfJsonFileWithComputedPropertyName.types | 29 +++++++++++++++++++ ...quireOfJsonFileWithComputedPropertyName.ts | 15 ++++++++++ 8 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.errors.txt create mode 100644 tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.js create mode 100644 tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.symbols create mode 100644 tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.types create mode 100644 tests/cases/compiler/requireOfJsonFileWithComputedPropertyName.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5eb685cb61c..30d4c5b7c2a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7192,10 +7192,6 @@ namespace ts { return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } - function isComputedNonLiteralName(name: PropertyName): boolean { - return name.kind === SyntaxKind.ComputedPropertyName && !isStringOrNumericLiteralLike(name.expression); - } - function getRestType(source: Type, properties: PropertyName[], symbol: Symbol | undefined): Type { source = filterType(source, t => !(t.flags & TypeFlags.Nullable)); if (source.flags & TypeFlags.Never) { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 35ef50db8ad..8d4f332032d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1721,7 +1721,7 @@ namespace ts { errors.push(createDiagnosticForNodeInSourceFile(sourceFile, element.name, Diagnostics.String_literal_with_double_quotes_expected)); } - const textOfKey = getTextOfPropertyName(element.name); + const textOfKey = isComputedNonLiteralName(element.name) ? undefined : getTextOfPropertyName(element.name); const keyText = textOfKey && unescapeLeadingUnderscores(textOfKey); const option = keyText && knownOptions ? knownOptions.get(keyText) : undefined; if (keyText && extraKeyDiagnostics && !option) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 02705662f1f..080f2ed932e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -876,6 +876,10 @@ namespace ts { return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined; } + export function isComputedNonLiteralName(name: PropertyName): boolean { + return name.kind === SyntaxKind.ComputedPropertyName && !isStringOrNumericLiteralLike(name.expression); + } + export function getTextOfPropertyName(name: PropertyName | NoSubstitutionTemplateLiteral): __String { switch (name.kind) { case SyntaxKind.Identifier: diff --git a/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.errors.txt b/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.errors.txt new file mode 100644 index 00000000000..83691479939 --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/b.json(2,5): error TS1327: String literal with double quotes expected. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + import b1 = require('./b.json'); + let x = b1; + import b2 = require('./b.json'); + if (x) { + x = b2; + } + +==== tests/cases/compiler/b.json (1 errors) ==== + { + [a]: 10 + ~~~ +!!! error TS1327: String literal with double quotes expected. + } \ No newline at end of file diff --git a/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.js b/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.js new file mode 100644 index 00000000000..da94ca6d0a3 --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/requireOfJsonFileWithComputedPropertyName.ts] //// + +//// [file1.ts] +import b1 = require('./b.json'); +let x = b1; +import b2 = require('./b.json'); +if (x) { + x = b2; +} + +//// [b.json] +{ + [a]: 10 +} + +//// [b.json] +var _a; +_a = {}, + _a[a] = 10, + _a; +//// [file1.js] +"use strict"; +exports.__esModule = true; +var b1 = require("./b.json"); +var x = b1; +var b2 = require("./b.json"); +if (x) { + x = b2; +} diff --git a/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.symbols b/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.symbols new file mode 100644 index 00000000000..4327461265e --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/file1.ts === +import b1 = require('./b.json'); +>b1 : Symbol(b1, Decl(file1.ts, 0, 0)) + +let x = b1; +>x : Symbol(x, Decl(file1.ts, 1, 3)) +>b1 : Symbol(b1, Decl(file1.ts, 0, 0)) + +import b2 = require('./b.json'); +>b2 : Symbol(b2, Decl(file1.ts, 1, 11)) + +if (x) { +>x : Symbol(x, Decl(file1.ts, 1, 3)) + + x = b2; +>x : Symbol(x, Decl(file1.ts, 1, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 1, 11)) +} + +=== tests/cases/compiler/b.json === +{ + [a]: 10 +>[a] : Symbol([a], Decl(b.json, 0, 1)) +} diff --git a/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.types b/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.types new file mode 100644 index 00000000000..3fc20bb2cce --- /dev/null +++ b/tests/baselines/reference/requireOfJsonFileWithComputedPropertyName.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/file1.ts === +import b1 = require('./b.json'); +>b1 : { [x: number]: number; } + +let x = b1; +>x : { [x: number]: number; } +>b1 : { [x: number]: number; } + +import b2 = require('./b.json'); +>b2 : { [x: number]: number; } + +if (x) { +>x : { [x: number]: number; } + + x = b2; +>x = b2 : { [x: number]: number; } +>x : { [x: number]: number; } +>b2 : { [x: number]: number; } +} + +=== tests/cases/compiler/b.json === +{ +>{ [a]: 10} : { [x: number]: number; } + + [a]: 10 +>[a] : number +>a : any +>10 : 10 +} diff --git a/tests/cases/compiler/requireOfJsonFileWithComputedPropertyName.ts b/tests/cases/compiler/requireOfJsonFileWithComputedPropertyName.ts new file mode 100644 index 00000000000..f5dc94ea251 --- /dev/null +++ b/tests/cases/compiler/requireOfJsonFileWithComputedPropertyName.ts @@ -0,0 +1,15 @@ +// @outdir: out/ +// @resolveJsonModule: true + +// @Filename: file1.ts +import b1 = require('./b.json'); +let x = b1; +import b2 = require('./b.json'); +if (x) { + x = b2; +} + +// @Filename: b.json +{ + [a]: 10 +} \ No newline at end of file From 6d81577ad42904434424c6eddce64757fe2d8eb5 Mon Sep 17 00:00:00 2001 From: csigs Date: Tue, 21 Apr 2020 04:10:31 +0000 Subject: [PATCH 27/74] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 9 +++++++++ .../diagnosticMessages.generated.json.lcl | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index f83a7972c05..ea21fdee665 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -7188,6 +7188,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1c9300f3102..ee5f3358f1b 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -7181,6 +7181,15 @@ + + + + + + + + + From 63ff6572ae92224a26012a58b847f2e845f492bc Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 21 Apr 2020 08:09:25 -0700 Subject: [PATCH 28/74] Fix use-before-def with methods on esnext+useDefineForClassFields (#38033) * Fix use-before-def with methods on esnext+useDefineForClassFields It was incorrectly flagging methods as used before their definition, but this is allowed under any emit. * Add instance function test case --- src/compiler/checker.ts | 7 +- ...ertyToPropertyDeclarationESNext.errors.txt | 19 ++- ...eterPropertyToPropertyDeclarationESNext.js | 6 + ...ropertyToPropertyDeclarationESNext.symbols | 113 ++++++++++-------- ...rPropertyToPropertyDeclarationESNext.types | 18 +++ ...eterPropertyToPropertyDeclarationESNext.ts | 3 + 6 files changed, 108 insertions(+), 58 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 30d4c5b7c2a..9b5013e3141 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1423,9 +1423,10 @@ namespace ts { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (compilerOptions.target === ScriptTarget.ESNext && !!compilerOptions.useDefineForClassFields && getContainingClass(declaration)) { - return (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent)) && - !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); + if (compilerOptions.target === ScriptTarget.ESNext && !!compilerOptions.useDefineForClassFields + && getContainingClass(declaration) + && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) { + return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); } else { return true; diff --git a/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.errors.txt b/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.errors.txt index 2010e92a2d8..b8d6ddc136c 100644 --- a/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.errors.txt +++ b/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.errors.txt @@ -1,10 +1,11 @@ tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(2,16): error TS2729: Property 'bar' is used before its initialization. tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(3,16): error TS2729: Property 'foo' is used before its initialization. -tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(9,17): error TS2729: Property 'baz' is used before its initialization. -tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(10,16): error TS2729: Property 'foo' is used before its initialization. +tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(6,19): error TS2729: Property 'm3' is used before its initialization. +tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(12,17): error TS2729: Property 'baz' is used before its initialization. +tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts(13,16): error TS2729: Property 'foo' is used before its initialization. -==== tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts (4 errors) ==== +==== tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts (5 errors) ==== class C { qux = this.bar // should error ~~~ @@ -13,20 +14,26 @@ tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterProper bar = this.foo // should error ~~~ !!! error TS2729: Property 'foo' is used before its initialization. -!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:8:17: 'foo' is declared here. +!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:11:17: 'foo' is declared here. quiz = this.bar // ok + quench = this.m1() // ok + quanch = this.m3() // should error + ~~ +!!! error TS2729: Property 'm3' is used before its initialization. +!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:10:5: 'm3' is declared here. m1() { this.foo // ok } + m3 = function() { } constructor(public foo: string) {} quim = this.baz // should error ~~~ !!! error TS2729: Property 'baz' is used before its initialization. -!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:10:5: 'baz' is declared here. +!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:13:5: 'baz' is declared here. baz = this.foo; // should error ~~~ !!! error TS2729: Property 'foo' is used before its initialization. -!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:8:17: 'foo' is declared here. +!!! related TS2728 tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts:11:17: 'foo' is declared here. quid = this.baz // ok m2() { this.foo // ok diff --git a/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.js b/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.js index f71361eb570..d4e0de0d8c5 100644 --- a/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.js +++ b/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.js @@ -3,9 +3,12 @@ class C { qux = this.bar // should error bar = this.foo // should error quiz = this.bar // ok + quench = this.m1() // ok + quanch = this.m3() // should error m1() { this.foo // ok } + m3 = function() { } constructor(public foo: string) {} quim = this.baz // should error baz = this.foo; // should error @@ -45,9 +48,12 @@ class C { qux = this.bar; // should error bar = this.foo; // should error quiz = this.bar; // ok + quench = this.m1(); // ok + quanch = this.m3(); // should error m1() { this.foo; // ok } + m3 = function () { }; constructor(foo) { this.foo = foo; } diff --git a/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.symbols b/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.symbols index 5fd56137bb8..27d3f243966 100644 --- a/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.symbols +++ b/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.symbols @@ -10,9 +10,9 @@ class C { bar = this.foo // should error >bar : Symbol(C.bar, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 1, 18)) ->this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16)) +>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16)) >this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0)) ->foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16)) +>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16)) quiz = this.bar // ok >quiz : Symbol(C.quiz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 2, 18)) @@ -20,105 +20,120 @@ class C { >this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0)) >bar : Symbol(C.bar, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 1, 18)) + quench = this.m1() // ok +>quench : Symbol(C.quench, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 3, 19)) +>this.m1 : Symbol(C.m1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 5, 22)) +>this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0)) +>m1 : Symbol(C.m1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 5, 22)) + + quanch = this.m3() // should error +>quanch : Symbol(C.quanch, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 4, 22)) +>this.m3 : Symbol(C.m3, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 5)) +>this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0)) +>m3 : Symbol(C.m3, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 5)) + m1() { ->m1 : Symbol(C.m1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 3, 19)) +>m1 : Symbol(C.m1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 5, 22)) this.foo // ok ->this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16)) +>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16)) >this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0)) ->foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16)) +>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16)) } + m3 = function() { } +>m3 : Symbol(C.m3, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 5)) + constructor(public foo: string) {} ->foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16)) +>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16)) quim = this.baz // should error ->quim : Symbol(C.quim, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 38)) ->this.baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 19)) +>quim : Symbol(C.quim, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 38)) +>this.baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 11, 19)) >this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0)) ->baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 19)) +>baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 11, 19)) baz = this.foo; // should error ->baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 19)) ->this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16)) +>baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 11, 19)) +>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16)) >this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0)) ->foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16)) +>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16)) quid = this.baz // ok ->quid : Symbol(C.quid, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 9, 19)) ->this.baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 19)) +>quid : Symbol(C.quid, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 12, 19)) +>this.baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 11, 19)) >this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0)) ->baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 8, 19)) +>baz : Symbol(C.baz, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 11, 19)) m2() { ->m2 : Symbol(C.m2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 19)) +>m2 : Symbol(C.m2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 13, 19)) this.foo // ok ->this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16)) +>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16)) >this : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0)) ->foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16)) +>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16)) } } class D extends C { ->D : Symbol(D, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 14, 1)) +>D : Symbol(D, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 17, 1)) >C : Symbol(C, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 0, 0)) quill = this.foo // ok ->quill : Symbol(D.quill, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 16, 19)) ->this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16)) ->this : Symbol(D, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 14, 1)) ->foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 7, 16)) +>quill : Symbol(D.quill, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 19, 19)) +>this.foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16)) +>this : Symbol(D, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 17, 1)) +>foo : Symbol(C.foo, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 10, 16)) } class E { ->E : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 18, 1)) +>E : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 1)) bar = () => this.foo1 + this.foo2; // both ok ->bar : Symbol(E.bar, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 20, 9)) ->this.foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 38)) ->this : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 18, 1)) ->foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 38)) ->this.foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 23, 16)) ->this : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 18, 1)) ->foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 23, 16)) +>bar : Symbol(E.bar, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 23, 9)) +>this.foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 24, 38)) +>this : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 1)) +>foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 24, 38)) +>this.foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 26, 16)) +>this : Symbol(E, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 1)) +>foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 26, 16)) foo1 = ''; ->foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 21, 38)) +>foo1 : Symbol(E.foo1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 24, 38)) constructor(public foo2: string) {} ->foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 23, 16)) +>foo2 : Symbol(E.foo2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 26, 16)) } class F { ->F : Symbol(F, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 24, 1)) +>F : Symbol(F, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 27, 1)) Inner = class extends F { ->Inner : Symbol(F.Inner, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 26, 9)) ->F : Symbol(F, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 24, 1)) +>Inner : Symbol(F.Inner, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 29, 9)) +>F : Symbol(F, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 27, 1)) p2 = this.p1 ->p2 : Symbol((Anonymous class).p2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 27, 29)) ->this.p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 29, 5)) ->this : Symbol((Anonymous class), Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 27, 11)) ->p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 29, 5)) +>p2 : Symbol((Anonymous class).p2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 30, 29)) +>this.p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 32, 5)) +>this : Symbol((Anonymous class), Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 30, 11)) +>p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 32, 5)) } p1 = 0 ->p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 29, 5)) +>p1 : Symbol(F.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 32, 5)) } class G { ->G : Symbol(G, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 31, 1)) +>G : Symbol(G, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 34, 1)) Inner = class extends G { ->Inner : Symbol(G.Inner, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 32, 9)) ->G : Symbol(G, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 31, 1)) +>Inner : Symbol(G.Inner, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 35, 9)) +>G : Symbol(G, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 34, 1)) p2 = this.p1 ->p2 : Symbol((Anonymous class).p2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 33, 29)) ->this.p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 36, 16)) ->this : Symbol((Anonymous class), Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 33, 11)) ->p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 36, 16)) +>p2 : Symbol((Anonymous class).p2, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 36, 29)) +>this.p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 39, 16)) +>this : Symbol((Anonymous class), Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 36, 11)) +>p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 39, 16)) } constructor(public p1: number) {} ->p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 36, 16)) +>p1 : Symbol(G.p1, Decl(assignParameterPropertyToPropertyDeclarationESNext.ts, 39, 16)) } diff --git a/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.types b/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.types index 631b0dba5a4..d4b3cd9d958 100644 --- a/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.types +++ b/tests/baselines/reference/assignParameterPropertyToPropertyDeclarationESNext.types @@ -20,6 +20,20 @@ class C { >this : this >bar : string + quench = this.m1() // ok +>quench : void +>this.m1() : void +>this.m1 : () => void +>this : this +>m1 : () => void + + quanch = this.m3() // should error +>quanch : void +>this.m3() : void +>this.m3 : () => void +>this : this +>m3 : () => void + m1() { >m1 : () => void @@ -28,6 +42,10 @@ class C { >this : this >foo : string } + m3 = function() { } +>m3 : () => void +>function() { } : () => void + constructor(public foo: string) {} >foo : string diff --git a/tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts b/tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts index f4475f09ddf..d778149c428 100644 --- a/tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts +++ b/tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts @@ -4,9 +4,12 @@ class C { qux = this.bar // should error bar = this.foo // should error quiz = this.bar // ok + quench = this.m1() // ok + quanch = this.m3() // should error m1() { this.foo // ok } + m3 = function() { } constructor(public foo: string) {} quim = this.baz // should error baz = this.foo; // should error From 1e48057b9e2290ac238f35d2474812b03efdd1b5 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Tue, 21 Apr 2020 21:02:56 +0300 Subject: [PATCH 29/74] fix(15398): skip adding line breaks when replacing JS checks directives (#38086) --- .../codefixes/disableJsDiagnostics.ts | 3 ++- .../codeFixDisableJsDiagnosticsInFile10.ts | 23 ++++++++++++++++++ .../codeFixDisableJsDiagnosticsInFile9.ts | 24 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile10.ts create mode 100644 tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile9.ts diff --git a/src/services/codefixes/disableJsDiagnostics.ts b/src/services/codefixes/disableJsDiagnostics.ts index a4feeaa2dbd..13b1fec32ee 100644 --- a/src/services/codefixes/disableJsDiagnostics.ts +++ b/src/services/codefixes/disableJsDiagnostics.ts @@ -16,6 +16,7 @@ namespace ts.codefix { return undefined; } + const newLineCharacter = sourceFile.checkJsDirective ? "" : getNewLineOrDefaultFromHost(host, formatContext.options); const fixes: CodeFixAction[] = [ // fixId unnecessary because adding `// @ts-nocheck` even once will ignore every error in the file. createCodeFixActionWithoutFixAll( @@ -23,7 +24,7 @@ namespace ts.codefix { [createFileTextChanges(sourceFile.fileName, [ createTextChange(sourceFile.checkJsDirective ? createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end) - : createTextSpan(0, 0), `// @ts-nocheck${getNewLineOrDefaultFromHost(host, formatContext.options)}`), + : createTextSpan(0, 0), `// @ts-nocheck${newLineCharacter}`), ])], Diagnostics.Disable_checking_for_this_file), ]; diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile10.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile10.ts new file mode 100644 index 00000000000..ff1ba5c75b5 --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile10.ts @@ -0,0 +1,23 @@ +/// + +// @allowjs: true +// @checkJs: true +// @noEmit: true + +// @filename: a.js +////let x = ""; +////[|x|] = 1; + +// verify.codeFixAvailable([ +// { description: ts.Diagnostics.Ignore_this_error_message.message }, +// { description: ts.Diagnostics.Disable_checking_for_this_file.message } +// ]); + +verify.codeFix({ + description: ts.Diagnostics.Disable_checking_for_this_file.message, + index: 1, + newFileContent: +`// @ts-nocheck +let x = ""; +x = 1;`, +}); diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile9.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile9.ts new file mode 100644 index 00000000000..e7401e683b7 --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile9.ts @@ -0,0 +1,24 @@ +/// + +// @allowjs: true +// @checkJs: true +// @noEmit: true + +// @filename: a.js +////// @ts-check +////let x = ""; +////[|x|] = 1; + +// verify.codeFixAvailable([ +// { description: ts.Diagnostics.Ignore_this_error_message.message }, +// { description: ts.Diagnostics.Disable_checking_for_this_file.message } +// ]); + +verify.codeFix({ + description: ts.Diagnostics.Disable_checking_for_this_file.message, + index: 1, + newFileContent: +`// @ts-nocheck +let x = ""; +x = 1;`, +}); From 6ea291a14267f8d3b12a01b4f950dfe66e975bf9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 21 Apr 2020 12:58:37 -0700 Subject: [PATCH 30/74] Remove superCallShouldBeFirst error (#37947) * Remove superCallShouldBeFirst error It seems redundant since TS gives an error on any use of `this` before super, and non-`this` uses before `super` should be fine. Fixes #37371 * Revert "Remove superCallShouldBeFirst error" This reverts commit 3c09153c8ad00d73d60e7000a0e6263a6028615a. * error except for target:"esnext" && useDefineForClassFields --- src/compiler/checker.ts | 5 +++-- ...vateNameBadSuperUseDefineForClassFields.js | 22 +++++++++++++++++++ ...ameBadSuperUseDefineForClassFields.symbols | 18 +++++++++++++++ ...eNameBadSuperUseDefineForClassFields.types | 22 +++++++++++++++++++ ...vateNameBadSuperUseDefineForClassFields.ts | 10 +++++++++ 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.js create mode 100644 tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.symbols create mode 100644 tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.types create mode 100644 tests/cases/conformance/classes/members/privateNames/privateNameBadSuperUseDefineForClassFields.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9b5013e3141..b65eca1f8a3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -29677,8 +29677,9 @@ namespace ts { // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. const superCallShouldBeFirst = - some((node.parent).members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - some(node.parameters, p => hasModifier(p, ModifierFlags.ParameterPropertyModifier)); + (compilerOptions.target !== ScriptTarget.ESNext || !compilerOptions.useDefineForClassFields) && + (some((node.parent).members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || + some(node.parameters, p => hasModifier(p, ModifierFlags.ParameterPropertyModifier))); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. diff --git a/tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.js b/tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.js new file mode 100644 index 00000000000..018c1eaaece --- /dev/null +++ b/tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.js @@ -0,0 +1,22 @@ +//// [privateNameBadSuperUseDefineForClassFields.ts] +class B {}; +class A extends B { + #x; + constructor() { + void 0; // Error: 'super' call must come first + super(); + } +} + + +//// [privateNameBadSuperUseDefineForClassFields.js] +class B { +} +; +class A extends B { + #x; + constructor() { + void 0; // Error: 'super' call must come first + super(); + } +} diff --git a/tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.symbols b/tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.symbols new file mode 100644 index 00000000000..5e5115d7417 --- /dev/null +++ b/tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/classes/members/privateNames/privateNameBadSuperUseDefineForClassFields.ts === +class B {}; +>B : Symbol(B, Decl(privateNameBadSuperUseDefineForClassFields.ts, 0, 0)) + +class A extends B { +>A : Symbol(A, Decl(privateNameBadSuperUseDefineForClassFields.ts, 0, 11)) +>B : Symbol(B, Decl(privateNameBadSuperUseDefineForClassFields.ts, 0, 0)) + + #x; +>#x : Symbol(A.#x, Decl(privateNameBadSuperUseDefineForClassFields.ts, 1, 19)) + + constructor() { + void 0; // Error: 'super' call must come first + super(); +>super : Symbol(B, Decl(privateNameBadSuperUseDefineForClassFields.ts, 0, 0)) + } +} + diff --git a/tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.types b/tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.types new file mode 100644 index 00000000000..55432691aec --- /dev/null +++ b/tests/baselines/reference/privateNameBadSuperUseDefineForClassFields.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/classes/members/privateNames/privateNameBadSuperUseDefineForClassFields.ts === +class B {}; +>B : B + +class A extends B { +>A : A +>B : B + + #x; +>#x : any + + constructor() { + void 0; // Error: 'super' call must come first +>void 0 : undefined +>0 : 0 + + super(); +>super() : void +>super : typeof B + } +} + diff --git a/tests/cases/conformance/classes/members/privateNames/privateNameBadSuperUseDefineForClassFields.ts b/tests/cases/conformance/classes/members/privateNames/privateNameBadSuperUseDefineForClassFields.ts new file mode 100644 index 00000000000..984b65a5695 --- /dev/null +++ b/tests/cases/conformance/classes/members/privateNames/privateNameBadSuperUseDefineForClassFields.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @useDefineForClassFields: true +class B {}; +class A extends B { + #x; + constructor() { + void 0; // Error: 'super' call must come first + super(); + } +} From 136f728bb011ecf1bbf0ff2aac6dacc5cb6568cb Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 21 Apr 2020 13:13:50 -0700 Subject: [PATCH 31/74] Fix js declaration emit for inherited and this-typed inherited fields (#37970) --- src/compiler/checker.ts | 24 +++++++- ...InternalTypesProduceUniqueTypeParams.types | 4 +- .../reference/jsDeclarationsInterfaces.js | 4 +- .../reference/jsDeclarationsThisTypes.js | 59 +++++++++++++++++++ .../reference/jsDeclarationsThisTypes.symbols | 20 +++++++ .../reference/jsDeclarationsThisTypes.types | 20 +++++++ .../declarations/jsDeclarationsThisTypes.ts | 17 ++++++ 7 files changed, 142 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/jsDeclarationsThisTypes.js create mode 100644 tests/baselines/reference/jsDeclarationsThisTypes.symbols create mode 100644 tests/baselines/reference/jsDeclarationsThisTypes.types create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsThisTypes.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b65eca1f8a3..8228f62fe0e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5459,7 +5459,7 @@ namespace ts { function serializeReturnTypeForSignature(context: NodeBuilderContext, type: Type, signature: Signature, includePrivateSymbol?: (s: Symbol) => void, bundled?: boolean) { if (type !== errorType && context.enclosingDeclaration) { const annotation = signature.declaration && getEffectiveReturnTypeNode(signature.declaration); - if (!!findAncestor(annotation, n => n === context.enclosingDeclaration) && annotation && getTypeFromTypeNode(annotation) === type) { + if (!!findAncestor(annotation, n => n === context.enclosingDeclaration) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { const result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -6211,7 +6211,7 @@ namespace ts { ...!length(baseTypes) ? [] : [createHeritageClause(SyntaxKind.ExtendsKeyword, map(baseTypes, b => serializeBaseType(b, staticBaseType, localName)))], ...!length(implementsTypes) ? [] : [createHeritageClause(SyntaxKind.ImplementsKeyword, map(implementsTypes, b => serializeBaseType(b, staticBaseType, localName)))] ]; - const symbolProps = getPropertiesOfType(classType); + const symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); const publicSymbolProps = filter(symbolProps, s => { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties @@ -33482,6 +33482,26 @@ namespace ts { } } + function getNonInterhitedProperties(type: InterfaceType, baseTypes: BaseType[], properties: Symbol[]) { + if (!length(baseTypes)) { + return properties; + } + const seen = createUnderscoreEscapedMap(); + forEach(properties, p => { seen.set(p.escapedName, p); }); + + for (const base of baseTypes) { + const properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); + for (const prop of properties) { + const existing = seen.get(prop.escapedName); + if (existing && !isPropertyIdenticalTo(existing, prop)) { + seen.delete(prop.escapedName); + } + } + } + + return arrayFrom(seen.values()); + } + function checkInheritedPropertiesAreIdentical(type: InterfaceType, typeNode: Node): boolean { const baseTypes = getBaseTypes(type); if (baseTypes.length < 2) { diff --git a/tests/baselines/reference/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.types b/tests/baselines/reference/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.types index 142dedb2041..836c6ba044e 100644 --- a/tests/baselines/reference/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.types +++ b/tests/baselines/reference/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.types @@ -38,13 +38,13 @@ export const updateIfChanged = (t: T) => { >newU : U return Object.assign( ->Object.assign( >(key: K) => reduce>(u[key as keyof U] as Value, (v: Value) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }), { map: (updater: (u: U) => U) => set(updater(u)), set }) : ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => any & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K]) => U[K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K]) => U[K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K]) => U[K][K][K][K]) => T; set: (newU: U[K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K]) => U[K][K][K]) => T; set: (newU: U[K][K][K]) => T; }) & { map: (updater: (u: U[K][K]) => U[K][K]) => T; set: (newU: U[K][K]) => T; }) & { map: (updater: (u: U[K]) => U[K]) => T; set: (newU: U[K]) => T; }) & { map: (updater: (u: U) => U) => T; set: (newU: U) => T; } +>Object.assign( >(key: K) => reduce>(u[key as keyof U] as Value, (v: Value) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }), { map: (updater: (u: U) => U) => set(updater(u)), set }) : ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => any & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K]) => U) => T; set: (newU: U[K][K][K]) => T; }) & { map: (updater: (u: U[K][K]) => U) => T; set: (newU: U[K][K]) => T; }) & { map: (updater: (u: U[K]) => U) => T; set: (newU: U[K]) => T; }) & { map: (updater: (u: U) => U) => T; set: (newU: U) => T; } >Object.assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >Object : ObjectConstructor >assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >(key: K) => ->>(key: K) => reduce>(u[key as keyof U] as Value, (v: Value) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }) : (key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => any & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K]) => U[K][K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K]) => U[K][K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K]) => U[K][K][K][K][K]) => T; set: (newU: U[K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K]) => U[K][K][K][K]) => T; set: (newU: U[K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K]) => U[K][K][K]) => T; set: (newU: U[K][K][K]) => T; }) & { map: (updater: (u: U[K][K]) => U[K][K]) => T; set: (newU: U[K][K]) => T; }) & { map: (updater: (u: U[K]) => U[K]) => T; set: (newU: U[K]) => T; } +>>(key: K) => reduce>(u[key as keyof U] as Value, (v: Value) => { return update(Object.assign(Array.isArray(u) ? [] : {}, u, { [key]: v })); }) : (key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => ((key: K) => any & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K][K]) => U) => T; set: (newU: U[K][K][K][K]) => T; }) & { map: (updater: (u: U[K][K][K]) => U) => T; set: (newU: U[K][K][K]) => T; }) & { map: (updater: (u: U[K][K]) => U) => T; set: (newU: U[K][K]) => T; }) & { map: (updater: (u: U[K]) => U) => T; set: (newU: U[K]) => T; } >key : K reduce>(u[key as keyof U] as Value, (v: Value) => { diff --git a/tests/baselines/reference/jsDeclarationsInterfaces.js b/tests/baselines/reference/jsDeclarationsInterfaces.js index 00e78c8286a..f7f68846d29 100644 --- a/tests/baselines/reference/jsDeclarationsInterfaces.js +++ b/tests/baselines/reference/jsDeclarationsInterfaces.js @@ -135,10 +135,10 @@ export interface B { export interface C { new (): string; new (x: T_1): U_1; - new (x: Q_4): T_1 & Q_4; + new (x: Q_6): T_1 & Q_6; (): number; (x: T_1): U_1; - (x: Q_3): T_1 & Q_3; + (x: Q_4): T_1 & Q_4; field: T_1 & U_1; optionalField?: T_1; readonly readonlyField: T_1 & U_1; diff --git a/tests/baselines/reference/jsDeclarationsThisTypes.js b/tests/baselines/reference/jsDeclarationsThisTypes.js new file mode 100644 index 00000000000..65858ab41dc --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsThisTypes.js @@ -0,0 +1,59 @@ +//// [index.js] +export class A { + /** @returns {this} */ + method() { + return this; + } +} +export default class Base extends A { + // This method is required to reproduce #35932 + verify() { } +} + +//// [index.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +exports.A = void 0; +var A = /** @class */ (function () { + function A() { + } + /** @returns {this} */ + A.prototype.method = function () { + return this; + }; + return A; +}()); +exports.A = A; +var Base = /** @class */ (function (_super) { + __extends(Base, _super); + function Base() { + return _super !== null && _super.apply(this, arguments) || this; + } + // This method is required to reproduce #35932 + Base.prototype.verify = function () { }; + return Base; +}(A)); +exports["default"] = Base; + + +//// [index.d.ts] +export class A { + /** @returns {this} */ + method(): this; +} +export default class Base extends A { + verify(): void; +} diff --git a/tests/baselines/reference/jsDeclarationsThisTypes.symbols b/tests/baselines/reference/jsDeclarationsThisTypes.symbols new file mode 100644 index 00000000000..931bdd24a97 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsThisTypes.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +export class A { +>A : Symbol(A, Decl(index.js, 0, 0)) + + /** @returns {this} */ + method() { +>method : Symbol(A.method, Decl(index.js, 0, 16)) + + return this; +>this : Symbol(A, Decl(index.js, 0, 0)) + } +} +export default class Base extends A { +>Base : Symbol(Base, Decl(index.js, 5, 1)) +>A : Symbol(A, Decl(index.js, 0, 0)) + + // This method is required to reproduce #35932 + verify() { } +>verify : Symbol(Base.verify, Decl(index.js, 6, 37)) +} diff --git a/tests/baselines/reference/jsDeclarationsThisTypes.types b/tests/baselines/reference/jsDeclarationsThisTypes.types new file mode 100644 index 00000000000..801f1792656 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsThisTypes.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +export class A { +>A : A + + /** @returns {this} */ + method() { +>method : () => this + + return this; +>this : this + } +} +export default class Base extends A { +>Base : Base +>A : A + + // This method is required to reproduce #35932 + verify() { } +>verify : () => void +} diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsThisTypes.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsThisTypes.ts new file mode 100644 index 00000000000..bc2eae7dac6 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsThisTypes.ts @@ -0,0 +1,17 @@ +// @allowJs: true +// @checkJs: true +// @outDir: /out +// @lib: es6 +// @declaration: true +// @filename: index.js + +export class A { + /** @returns {this} */ + method() { + return this; + } +} +export default class Base extends A { + // This method is required to reproduce #35932 + verify() { } +} \ No newline at end of file From a72e49e8750b7d56968db5fe577a6c5bec344d41 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 21 Apr 2020 13:29:45 -0700 Subject: [PATCH 32/74] Delay pulling on signature contextual type until absolutely needed (#37851) --- src/compiler/checker.ts | 16 +++---- ...edTypeContextualTypeNotCircular.errors.txt | 18 ++++++++ ...erseMappedTypeContextualTypeNotCircular.js | 18 ++++++++ ...appedTypeContextualTypeNotCircular.symbols | 42 +++++++++++++++++++ ...eMappedTypeContextualTypeNotCircular.types | 34 +++++++++++++++ ...erseMappedTypeContextualTypeNotCircular.ts | 11 +++++ 6 files changed, 131 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.errors.txt create mode 100644 tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.js create mode 100644 tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.symbols create mode 100644 tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.types create mode 100644 tests/cases/compiler/reverseMappedTypeContextualTypeNotCircular.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8228f62fe0e..ac02f917827 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -55,7 +55,9 @@ namespace ts { const enum WideningKind { Normal, - GeneratorYield + FunctionReturn, + GeneratorNext, + GeneratorYield, } const enum TypeFacts { @@ -18092,7 +18094,7 @@ namespace ts { } function reportErrorsFromWidening(declaration: Declaration, type: Type, wideningKind?: WideningKind) { - if (produceDiagnostics && noImplicitAny && getObjectFlags(type) & ObjectFlags.ContainsWideningType) { + if (produceDiagnostics && noImplicitAny && getObjectFlags(type) & ObjectFlags.ContainsWideningType && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration as FunctionLikeDeclaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -27047,15 +27049,13 @@ namespace ts { } if (returnType || yieldType || nextType) { - const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); - if (!contextualSignature) { - if (yieldType) reportErrorsFromWidening(func, yieldType, WideningKind.GeneratorYield); - if (returnType) reportErrorsFromWidening(func, returnType); - if (nextType) reportErrorsFromWidening(func, nextType); - } + if (yieldType) reportErrorsFromWidening(func, yieldType, WideningKind.GeneratorYield); + if (returnType) reportErrorsFromWidening(func, returnType, WideningKind.FunctionReturn); + if (nextType) reportErrorsFromWidening(func, nextType, WideningKind.GeneratorNext); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { + const contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); const contextualType = !contextualSignature ? undefined : contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); diff --git a/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.errors.txt b/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.errors.txt new file mode 100644 index 00000000000..d5462d0d0b7 --- /dev/null +++ b/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/reverseMappedTypeContextualTypeNotCircular.ts(10,3): error TS2322: Type '(state: any, props: any) => {}' is not assignable to type 'Selector'. + + +==== tests/cases/compiler/reverseMappedTypeContextualTypeNotCircular.ts (1 errors) ==== + type Selector = (state: S) => R; + + declare function createStructuredSelector( + selectors: {[K in keyof T]: Selector}, + ): Selector; + + const editable = () => ({}); + + const mapStateToProps = createStructuredSelector({ + editable: (state: any, props: any) => editable(), // expect "Type '(state: any, props: any) => {}' is not assignable to type 'Selector'", _not_ a circularity error + ~~~~~~~~ +!!! error TS2322: Type '(state: any, props: any) => {}' is not assignable to type 'Selector'. +!!! related TS6500 tests/cases/compiler/reverseMappedTypeContextualTypeNotCircular.ts:10:3: The expected type comes from property 'editable' which is declared here on type '{ editable: Selector; }' + }); \ No newline at end of file diff --git a/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.js b/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.js new file mode 100644 index 00000000000..66302e8e642 --- /dev/null +++ b/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.js @@ -0,0 +1,18 @@ +//// [reverseMappedTypeContextualTypeNotCircular.ts] +type Selector = (state: S) => R; + +declare function createStructuredSelector( + selectors: {[K in keyof T]: Selector}, +): Selector; + +const editable = () => ({}); + +const mapStateToProps = createStructuredSelector({ + editable: (state: any, props: any) => editable(), // expect "Type '(state: any, props: any) => {}' is not assignable to type 'Selector'", _not_ a circularity error +}); + +//// [reverseMappedTypeContextualTypeNotCircular.js] +var editable = function () { return ({}); }; +var mapStateToProps = createStructuredSelector({ + editable: function (state, props) { return editable(); } +}); diff --git a/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.symbols b/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.symbols new file mode 100644 index 00000000000..94dcef3f0a3 --- /dev/null +++ b/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/reverseMappedTypeContextualTypeNotCircular.ts === +type Selector = (state: S) => R; +>Selector : Symbol(Selector, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 0, 0)) +>S : Symbol(S, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 0, 14)) +>R : Symbol(R, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 0, 16)) +>state : Symbol(state, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 0, 23)) +>S : Symbol(S, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 0, 14)) +>R : Symbol(R, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 0, 16)) + +declare function createStructuredSelector( +>createStructuredSelector : Symbol(createStructuredSelector, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 0, 38)) +>S : Symbol(S, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 2, 42)) +>T : Symbol(T, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 2, 44)) + + selectors: {[K in keyof T]: Selector}, +>selectors : Symbol(selectors, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 2, 48)) +>K : Symbol(K, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 3, 15)) +>T : Symbol(T, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 2, 44)) +>Selector : Symbol(Selector, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 0, 0)) +>S : Symbol(S, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 2, 42)) +>T : Symbol(T, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 2, 44)) +>K : Symbol(K, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 3, 15)) + +): Selector; +>Selector : Symbol(Selector, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 0, 0)) +>S : Symbol(S, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 2, 42)) +>T : Symbol(T, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 2, 44)) + +const editable = () => ({}); +>editable : Symbol(editable, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 6, 5)) + +const mapStateToProps = createStructuredSelector({ +>mapStateToProps : Symbol(mapStateToProps, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 8, 5)) +>createStructuredSelector : Symbol(createStructuredSelector, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 0, 38)) + + editable: (state: any, props: any) => editable(), // expect "Type '(state: any, props: any) => {}' is not assignable to type 'Selector'", _not_ a circularity error +>editable : Symbol(editable, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 8, 50)) +>state : Symbol(state, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 9, 13)) +>props : Symbol(props, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 9, 24)) +>editable : Symbol(editable, Decl(reverseMappedTypeContextualTypeNotCircular.ts, 6, 5)) + +}); diff --git a/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.types b/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.types new file mode 100644 index 00000000000..8f5d92f3d7d --- /dev/null +++ b/tests/baselines/reference/reverseMappedTypeContextualTypeNotCircular.types @@ -0,0 +1,34 @@ +=== tests/cases/compiler/reverseMappedTypeContextualTypeNotCircular.ts === +type Selector = (state: S) => R; +>Selector : Selector +>state : S + +declare function createStructuredSelector( +>createStructuredSelector : (selectors: { [K in keyof T]: Selector; }) => Selector + + selectors: {[K in keyof T]: Selector}, +>selectors : { [K in keyof T]: Selector; } + +): Selector; + +const editable = () => ({}); +>editable : () => {} +>() => ({}) : () => {} +>({}) : {} +>{} : {} + +const mapStateToProps = createStructuredSelector({ +>mapStateToProps : Selector +>createStructuredSelector({ editable: (state: any, props: any) => editable(), // expect "Type '(state: any, props: any) => {}' is not assignable to type 'Selector'", _not_ a circularity error}) : Selector +>createStructuredSelector : (selectors: { [K in keyof T]: Selector; }) => Selector +>{ editable: (state: any, props: any) => editable(), // expect "Type '(state: any, props: any) => {}' is not assignable to type 'Selector'", _not_ a circularity error} : { editable: (state: any, props: any) => {}; } + + editable: (state: any, props: any) => editable(), // expect "Type '(state: any, props: any) => {}' is not assignable to type 'Selector'", _not_ a circularity error +>editable : (state: any, props: any) => {} +>(state: any, props: any) => editable() : (state: any, props: any) => {} +>state : any +>props : any +>editable() : {} +>editable : () => {} + +}); diff --git a/tests/cases/compiler/reverseMappedTypeContextualTypeNotCircular.ts b/tests/cases/compiler/reverseMappedTypeContextualTypeNotCircular.ts new file mode 100644 index 00000000000..e80b71610ac --- /dev/null +++ b/tests/cases/compiler/reverseMappedTypeContextualTypeNotCircular.ts @@ -0,0 +1,11 @@ +type Selector = (state: S) => R; + +declare function createStructuredSelector( + selectors: {[K in keyof T]: Selector}, +): Selector; + +const editable = () => ({}); + +const mapStateToProps = createStructuredSelector({ + editable: (state: any, props: any) => editable(), // expect "Type '(state: any, props: any) => {}' is not assignable to type 'Selector'", _not_ a circularity error +}); \ No newline at end of file From 9dd881ba6c4dccbf507cd062af1d8bbb73021e5f Mon Sep 17 00:00:00 2001 From: csigs Date: Tue, 21 Apr 2020 22:10:39 +0000 Subject: [PATCH 33/74] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 29 ++++++++++++------- .../diagnosticMessages.generated.json.lcl | 25 +++++++++++----- .../diagnosticMessages.generated.json.lcl | 9 ++++++ .../diagnosticMessages.generated.json.lcl | 21 ++++++++++---- .../diagnosticMessages.generated.json.lcl | 17 ++++++++--- .../diagnosticMessages.generated.json.lcl | 9 ++++++ .../diagnosticMessages.generated.json.lcl | 17 ++++++++--- .../diagnosticMessages.generated.json.lcl | 9 ++++++ .../diagnosticMessages.generated.json.lcl | 9 ++++++ 9 files changed, 113 insertions(+), 32 deletions(-) diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 13031a428dc..581fe36aa7f 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1180,7 +1180,7 @@ - + @@ -3193,7 +3193,7 @@ - + @@ -4996,7 +4996,7 @@ - + @@ -5641,7 +5641,7 @@ - + @@ -7188,6 +7188,15 @@ + + + + + + + + + @@ -7399,7 +7408,7 @@ - + @@ -10312,7 +10321,7 @@ - + @@ -10759,7 +10768,7 @@ - + @@ -10768,7 +10777,7 @@ - + @@ -11107,7 +11116,7 @@ - + @@ -11668,7 +11677,7 @@ - + diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index d41aca93740..4f39a5a9347 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1180,7 +1180,7 @@ - + @@ -3193,7 +3193,7 @@ - + @@ -7188,6 +7188,15 @@ + + + + + + + + + @@ -7399,7 +7408,7 @@ - + @@ -7822,7 +7831,7 @@ - + @@ -10312,7 +10321,7 @@ - + @@ -10759,7 +10768,7 @@ - + @@ -10768,7 +10777,7 @@ - + @@ -11107,7 +11116,7 @@ - + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 4dcd83c6c97..4a84ecc9ba8 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -7185,6 +7185,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 2a8fd334faf..81b11ca7e68 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -445,7 +445,7 @@ - + @@ -1189,7 +1189,7 @@ - + @@ -3205,7 +3205,7 @@ - + @@ -7200,6 +7200,15 @@ + + + + + + + + + @@ -10324,7 +10333,7 @@ - + @@ -11119,7 +11128,7 @@ - + @@ -11680,7 +11689,7 @@ - + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 5532d3dd2ad..0fed2ad218d 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -445,7 +445,7 @@ - + @@ -3205,7 +3205,7 @@ - + @@ -7200,6 +7200,15 @@ + + + + + + + + + @@ -7411,7 +7420,7 @@ - + @@ -11119,7 +11128,7 @@ - + diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 43e653f9110..6f55deb823f 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -7188,6 +7188,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 40d74176e06..163d872a609 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -436,7 +436,7 @@ - + @@ -7188,6 +7188,15 @@ + + + + + + + + + @@ -7399,7 +7408,7 @@ - + @@ -10768,7 +10777,7 @@ - + @@ -11107,7 +11116,7 @@ - + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index 50e3c9757c3..4861b65f463 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -7187,6 +7187,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 650602aae1a..0ad845dcd28 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -7181,6 +7181,15 @@ + + + + + + + + + From d571a09cf8b95dba36ef8ec85e56c3e8e9cb147c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 21 Apr 2020 15:20:36 -0700 Subject: [PATCH 34/74] Navto covers all projects (#38027) * Remove needless structure/destructuring Just pass multiple arguments! Sheesh! * Basic working prototype * Cleaned up version 1. Add test 2. Change protocol. navto-all only happens when filename is undefined or missing. 3. Change location to earlier code path. This change was largely type-guided and resulted in some duplicated code, but I think it's less fault-prone. * remove temp notes * Single-project hits if projectFileName is provided and file is not * use original code as fallback --- src/server/protocol.ts | 8 ++- src/server/session.ts | 67 ++++++++++-------- .../unittests/tsserver/declarationFileMaps.ts | 68 +++++++++++++++++-- .../reference/api/tsserverlibrary.d.ts | 8 ++- 4 files changed, 116 insertions(+), 35 deletions(-) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 4c1292f8de4..b6cc2e4d8fd 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2784,7 +2784,7 @@ namespace ts.server.protocol { /** * Arguments for navto request message. */ - export interface NavtoRequestArgs extends FileRequestArgs { + export interface NavtoRequestArgs { /** * Search term to navigate to from current location; term can * be '.*' or an identifier prefix. @@ -2794,6 +2794,10 @@ namespace ts.server.protocol { * Optional limit on the number of items to return. */ maxResultCount?: number; + /** + * The file for the request (absolute pathname required). + */ + file?: string; /** * Optional flag to indicate we want results for just the current file * or the entire project. @@ -2809,7 +2813,7 @@ namespace ts.server.protocol { * match the search term given in argument 'searchTerm'. The * context for the search is given by the named file. */ - export interface NavtoRequest extends FileRequest { + export interface NavtoRequest extends Request { command: CommandTypes.Navto; arguments: NavtoRequestArgs; } diff --git a/src/server/session.ts b/src/server/session.ts index 590f0bb2cbc..3f0321074a9 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -304,7 +304,7 @@ namespace ts.server { projects, defaultProject, /*initialLocation*/ undefined, - ({ project }, tryAddToTodo) => { + (project, _, tryAddToTodo) => { for (const output of action(project)) { if (!contains(outputs, output, resultsEqual) && !tryAddToTodo(project, getLocation(output))) { outputs.push(output); @@ -329,7 +329,7 @@ namespace ts.server { projects, defaultProject, initialLocation, - ({ project, location }, tryAddToTodo) => { + (project, location, tryAddToTodo) => { for (const output of project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments, hostPreferences.providePrefixAndSuffixTextForRename) || emptyArray) { if (!contains(outputs, output, documentSpansEqual) && !tryAddToTodo(project, documentSpanLocation(output))) { outputs.push(output); @@ -358,7 +358,7 @@ namespace ts.server { projects, defaultProject, initialLocation, - ({ project, location }, getMappedLocation) => { + (project, location, getMappedLocation) => { for (const outputReferencedSymbol of project.getLanguageService().findReferences(location.fileName, location.pos) || emptyArray) { const mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); const definition: ReferencedSymbolDefinitionInfo = mappedDefinitionFile === undefined ? @@ -408,7 +408,8 @@ namespace ts.server { } type CombineProjectOutputCallback = ( - where: ProjectAndLocation, + project: Project, + location: TLocation, getMappedLocation: (project: Project, location: DocumentPosition) => DocumentPosition | undefined, ) => void; @@ -422,9 +423,9 @@ namespace ts.server { let toDo: ProjectAndLocation[] | undefined; const seenProjects = createMap(); forEachProjectInProjects(projects, initialLocation && initialLocation.fileName, (project, path) => { - // TLocation shoud be either `DocumentPosition` or `undefined`. Since `initialLocation` is `TLocation` this cast should be valid. + // TLocation should be either `DocumentPosition` or `undefined`. Since `initialLocation` is `TLocation` this cast should be valid. const location = (initialLocation ? { fileName: path, pos: initialLocation.pos } : undefined) as TLocation; - toDo = callbackProjectAndLocation({ project, location }, projectService, toDo, seenProjects, cb); + toDo = callbackProjectAndLocation(project, location, projectService, toDo, seenProjects, cb); }); // After initial references are collected, go over every other project and see if it has a reference for the symbol definition. @@ -442,14 +443,16 @@ namespace ts.server { if (!addToSeen(seenProjects, project)) return; const definition = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition); if (definition) { - toDo = callbackProjectAndLocation({ project, location: definition as TLocation }, projectService, toDo, seenProjects, cb); + toDo = callbackProjectAndLocation(project, definition as TLocation, projectService, toDo, seenProjects, cb); } }); } } while (toDo && toDo.length) { - toDo = callbackProjectAndLocation(Debug.checkDefined(toDo.pop()), projectService, toDo, seenProjects, cb); + const next = toDo.pop(); + Debug.assertIsDefined(next); + toDo = callbackProjectAndLocation(next.project, next.location, projectService, toDo, seenProjects, cb); } } @@ -487,31 +490,33 @@ namespace ts.server { } function callbackProjectAndLocation( - projectAndLocation: ProjectAndLocation, + project: Project, + location: TLocation, projectService: ProjectService, toDo: ProjectAndLocation[] | undefined, seenProjects: Map, cb: CombineProjectOutputCallback, ): ProjectAndLocation[] | undefined { - const { project, location } = projectAndLocation; if (project.getCancellationToken().isCancellationRequested()) return undefined; // Skip rest of toDo if cancelled // If this is not the file we were actually looking, return rest of the toDo if (isLocationProjectReferenceRedirect(project, location)) return toDo; - cb(projectAndLocation, (project, location) => { - addToSeen(seenProjects, projectAndLocation.project); - const originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(project, location); + cb(project, location, (innerProject, location) => { + addToSeen(seenProjects, project); + const originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(innerProject, location); if (!originalLocation) return undefined; const originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName)!; toDo = toDo || []; for (const project of originalScriptInfo.containingProjects) { - addToTodo({ project, location: originalLocation as TLocation }, toDo, seenProjects); + addToTodo(project, originalLocation as TLocation, toDo, seenProjects); } const symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo); if (symlinkedProjectsMap) { symlinkedProjectsMap.forEach((symlinkedProjects, symlinkedPath) => { - for (const symlinkedProject of symlinkedProjects) addToTodo({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } as TLocation }, toDo!, seenProjects); + for (const symlinkedProject of symlinkedProjects) { + addToTodo(symlinkedProject, { fileName: symlinkedPath, pos: originalLocation.pos } as TLocation, toDo!, seenProjects); + } }); } return originalLocation === location ? undefined : originalLocation; @@ -519,8 +524,8 @@ namespace ts.server { return toDo; } - function addToTodo(projectAndLocation: ProjectAndLocation, toDo: Push>, seenProjects: Map): void { - if (addToSeen(seenProjects, projectAndLocation.project)) toDo.push(projectAndLocation); + function addToTodo(project: Project, location: TLocation, toDo: Push>, seenProjects: Map): void { + if (addToSeen(seenProjects, project)) toDo.push({ project, location }); } function addToSeen(seenProjects: Map, project: Project) { @@ -1323,7 +1328,7 @@ namespace ts.server { // filter handles case when 'projects' is undefined projects = filter(projects, p => p.languageServiceEnabled && !p.isOrphan()); if (!ignoreNoProjectError && (!projects || !projects.length) && !symLinkedProjects) { - this.projectService.logErrorForScriptInfoNotFound(args.file); + this.projectService.logErrorForScriptInfoNotFound(args.file ?? args.projectFileName); return Errors.ThrowNoProject(); } return symLinkedProjects ? { projects: projects!, symLinkedProjects } : projects!; // TODO: GH#18217 @@ -1335,6 +1340,9 @@ namespace ts.server { if (project) { return project; } + if (!args.file) { + return Errors.ThrowNoProject(); + } } const info = this.projectService.getScriptInfo(args.file)!; return info.getDefaultProject(); @@ -1894,20 +1902,25 @@ namespace ts.server { } private getFullNavigateToItems(args: protocol.NavtoRequestArgs): readonly NavigateToItem[] { - const { currentFileOnly, searchValue, maxResultCount } = args; + const { currentFileOnly, searchValue, maxResultCount, projectFileName } = args; if (currentFileOnly) { - const { file, project } = this.getFileAndProject(args); + Debug.assertDefined(args.file); + const { file, project } = this.getFileAndProject(args as protocol.FileRequestArgs); return project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file); } - else { - return combineProjectOutputWhileOpeningReferencedProjects( - this.getProjects(args), - this.getDefaultProject(args), - project => - project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject()), - documentSpanLocation, + else if (!args.file && !projectFileName) { + return combineProjectOutputFromEveryProject( + this.projectService, + project => project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*filename*/ undefined, /*excludeDts*/ project.isNonTsProject()), navigateToItemIsEqualTo); } + const fileArgs = args as protocol.FileRequestArgs; + return combineProjectOutputWhileOpeningReferencedProjects( + this.getProjects(fileArgs), + this.getDefaultProject(fileArgs), + project => project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject()), + documentSpanLocation, + navigateToItemIsEqualTo); function navigateToItemIsEqualTo(a: NavigateToItem, b: NavigateToItem): boolean { if (a === b) { diff --git a/src/testRunner/unittests/tsserver/declarationFileMaps.ts b/src/testRunner/unittests/tsserver/declarationFileMaps.ts index 0fb08aa051b..c52e2ad807a 100644 --- a/src/testRunner/unittests/tsserver/declarationFileMaps.ts +++ b/src/testRunner/unittests/tsserver/declarationFileMaps.ts @@ -63,7 +63,7 @@ namespace ts.projectSystem { }; const aDts: File = { path: "/a/bin/a.d.ts", - // Need to mangle the sourceMappingURL part or it breaks the build + // ${""} is needed to mangle the sourceMappingURL part or it breaks the build content: `export declare function fnA(): void;\nexport interface IfaceA {\n}\nexport declare const instanceA: IfaceA;\n//# source${""}MappingURL=a.d.ts.map`, }; @@ -86,7 +86,7 @@ namespace ts.projectSystem { content: JSON.stringify(bDtsMapContent), }; const bDts: File = { - // Need to mangle the sourceMappingURL part or it breaks the build + // ${""} is need to mangle the sourceMappingURL part so it doesn't break the build path: "/b/bin/b.d.ts", content: `export declare function fnB(): void;\n//# source${""}MappingURL=b.d.ts.map`, }; @@ -114,7 +114,7 @@ namespace ts.projectSystem { }) }; - function makeSampleProjects(addUserTsConfig?: boolean) { + function makeSampleProjects(addUserTsConfig?: boolean, keepAllFiles?: boolean) { const host = createServerHost([aTs, aTsconfig, aDtsMap, aDts, bTsconfig, bTs, bDtsMap, bDts, ...(addUserTsConfig ? [userTsForConfigProject, userTsconfig] : [userTs]), dummyFile]); const session = createSession(host); @@ -122,7 +122,9 @@ namespace ts.projectSystem { checkDeclarationFiles(bTs, session, [bDtsMap, bDts]); // Testing what happens if we delete the original sources. - host.deleteFile(bTs.path); + if (!keepAllFiles) { + host.deleteFile(bTs.path); + } openFilesForSession([userTs], session); const service = session.getProjectService(); @@ -322,6 +324,64 @@ namespace ts.projectSystem { verifyATsConfigOriginalProject(session); }); + it("navigateToAll -- when neither file nor project is specified", () => { + const session = makeSampleProjects(/*addUserTsConfig*/ true, /*keepAllFiles*/ true); + const response = executeSessionRequest(session, CommandNames.Navto, { file: undefined, searchValue: "fn" }); + assert.deepEqual(response, [ + { + ...protocolFileSpanFromSubstring({ + file: bTs, + text: "export function fnB() {}" + }), + name: "fnB", + matchKind: "prefix", + isCaseSensitive: true, + kind: ScriptElementKind.functionElement, + kindModifiers: "export", + }, + { + ...protocolFileSpanFromSubstring({ + file: aTs, + text: "export function fnA() {}" + }), + name: "fnA", + matchKind: "prefix", + isCaseSensitive: true, + kind: ScriptElementKind.functionElement, + kindModifiers: "export", + }, + { + ...protocolFileSpanFromSubstring({ + file: userTs, + text: "export function fnUser() { a.fnA(); b.fnB(); a.instanceA; }" + }), + name: "fnUser", + matchKind: "prefix", + isCaseSensitive: true, + kind: ScriptElementKind.functionElement, + kindModifiers: "export", + } + ]); + }); + + it("navigateToAll -- when file is not specified but project is", () => { + const session = makeSampleProjects(/*addUserTsConfig*/ true, /*keepAllFiles*/ true); + const response = executeSessionRequest(session, CommandNames.Navto, { projectFileName: bTsconfig.path, file: undefined, searchValue: "fn" }); + assert.deepEqual(response, [ + { + ...protocolFileSpanFromSubstring({ + file: bTs, + text: "export function fnB() {}" + }), + name: "fnB", + matchKind: "prefix", + isCaseSensitive: true, + kind: ScriptElementKind.functionElement, + kindModifiers: "export", + } + ]); + }); + const referenceATs = (aTs: File): protocol.ReferencesResponseItem => makeReferenceItem({ file: aTs, isDefinition: true, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5e322bae86f..db6b0bc4905 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -8319,7 +8319,7 @@ declare namespace ts.server.protocol { /** * Arguments for navto request message. */ - interface NavtoRequestArgs extends FileRequestArgs { + interface NavtoRequestArgs { /** * Search term to navigate to from current location; term can * be '.*' or an identifier prefix. @@ -8329,6 +8329,10 @@ declare namespace ts.server.protocol { * Optional limit on the number of items to return. */ maxResultCount?: number; + /** + * The file for the request (absolute pathname required). + */ + file?: string; /** * Optional flag to indicate we want results for just the current file * or the entire project. @@ -8342,7 +8346,7 @@ declare namespace ts.server.protocol { * match the search term given in argument 'searchTerm'. The * context for the search is given by the named file. */ - interface NavtoRequest extends FileRequest { + interface NavtoRequest extends Request { command: CommandTypes.Navto; arguments: NavtoRequestArgs; } From 7d4fc7333105ef426a5a6605a75b5febff2d40be Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 21 Apr 2020 15:34:30 -0700 Subject: [PATCH 35/74] Fix preserveNewlines printer option when a list child has the same start or end as its parent (#37846) * Fix preserveNewlines printer option when a list child has the same start or end as its parent * Fix leading line separator calculation and JSX bug --- src/compiler/emitter.ts | 32 +++++++++++++------ src/compiler/utilities.ts | 14 ++++---- .../fourslash/textChangesPreserveNewlines8.ts | 29 +++++++++++++++++ 3 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 tests/cases/fourslash/textChangesPreserveNewlines8.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 94b03cfcb36..dc4b9ad5f2f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2366,16 +2366,10 @@ namespace ts { function emitParenthesizedExpression(node: ParenthesizedExpression) { const openParenPos = emitTokenWithComment(SyntaxKind.OpenParenToken, node.pos, writePunctuation, node); - const leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(node, [node.expression], ListFormat.None); - if (leadingNewlines) { - writeLinesAndIndent(leadingNewlines, /*writeLinesIfNotIndenting*/ false); - } + const indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression); - const trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(node, [node.expression], ListFormat.None); - if (trailingNewlines) { - writeLine(trailingNewlines); - } - decreaseIndentIf(leadingNewlines); + writeLineSeparatorsAfter(node.expression, node); + decreaseIndentIf(indented); emitTokenWithComment(SyntaxKind.CloseParenToken, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } @@ -3293,12 +3287,15 @@ namespace ts { writePunctuation("<"); if (isJsxOpeningElement(node)) { + const indented = writeLineSeparatorsAndIndentBefore(node.tagName, node); emitJsxTagName(node.tagName); emitTypeArguments(node, node.typeArguments); if (node.attributes.properties && node.attributes.properties.length > 0) { writeSpace(); } emit(node.attributes); + writeLineSeparatorsAfter(node.attributes, node); + decreaseIndentIf(indented); } writePunctuation(">"); @@ -4302,6 +4299,7 @@ namespace ts { return getEffectiveLines( includeComments => getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter( firstChild.pos, + parentNode.pos, currentSourceFile!, includeComments)); } @@ -4359,6 +4357,7 @@ namespace ts { return getEffectiveLines( includeComments => getLinesBetweenPositionAndNextNonWhitespaceCharacter( lastChild.end, + parentNode.end, currentSourceFile!, includeComments)); } @@ -4398,6 +4397,21 @@ namespace ts { return lines; } + function writeLineSeparatorsAndIndentBefore(node: Node, parent: Node): boolean { + const leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], ListFormat.None); + if (leadingNewlines) { + writeLinesAndIndent(leadingNewlines, /*writeLinesIfNotIndenting*/ false); + } + return !!leadingNewlines; + } + + function writeLineSeparatorsAfter(node: Node, parent: Node) { + const trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], ListFormat.None); + if (trailingNewlines) { + writeLine(trailingNewlines); + } + } + function synthesizedNodeStartsOnNewLine(node: Node, format: ListFormat) { if (nodeIsSynthesized(node)) { const startsOnNewLine = getStartsOnNewLine(node); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 080f2ed932e..bab1fe7b02b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4780,19 +4780,19 @@ namespace ts { return positionIsSynthesized(range.pos) ? -1 : skipTrivia(sourceFile.text, range.pos, /*stopAfterLineBreak*/ false, includeComments); } - export function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos: number, sourceFile: SourceFile, includeComments?: boolean) { + export function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos: number, stopPos: number, sourceFile: SourceFile, includeComments?: boolean) { const startPos = skipTrivia(sourceFile.text, pos, /*stopAfterLineBreak*/ false, includeComments); - const prevPos = getPreviousNonWhitespacePosition(startPos, sourceFile); - return getLinesBetweenPositions(sourceFile, prevPos || 0, startPos); + const prevPos = getPreviousNonWhitespacePosition(startPos, stopPos, sourceFile); + return getLinesBetweenPositions(sourceFile, prevPos ?? stopPos, startPos); } - export function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos: number, sourceFile: SourceFile, includeComments?: boolean) { + export function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos: number, stopPos: number, sourceFile: SourceFile, includeComments?: boolean) { const nextPos = skipTrivia(sourceFile.text, pos, /*stopAfterLineBreak*/ false, includeComments); - return getLinesBetweenPositions(sourceFile, pos, nextPos); + return getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos)); } - function getPreviousNonWhitespacePosition(pos: number, sourceFile: SourceFile) { - while (pos-- > 0) { + function getPreviousNonWhitespacePosition(pos: number, stopPos = 0, sourceFile: SourceFile) { + while (pos-- > stopPos) { if (!isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) { return pos; } diff --git a/tests/cases/fourslash/textChangesPreserveNewlines8.ts b/tests/cases/fourslash/textChangesPreserveNewlines8.ts new file mode 100644 index 00000000000..e74aef6c9d0 --- /dev/null +++ b/tests/cases/fourslash/textChangesPreserveNewlines8.ts @@ -0,0 +1,29 @@ +// #37813 + +/// + +////function foo() { +//// /*1*/var x: number +//// +//// x = 10; +//// return x;/*2*/ +////} + +goTo.select("1", "2"); +edit.applyRefactor({ + refactorName: "Extract Symbol", + actionName: "function_scope_1", + actionDescription: "Extract to function in global scope", + newContent: +`function foo() { + return /*RENAME*/newFunction(); +} + +function newFunction() { + var x: number; + + x = 10; + return x; +} +` +}); From 3c3b7dc4c3306d007046ee2c62373c72b452639a Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Tue, 21 Apr 2020 16:30:09 -0700 Subject: [PATCH 36/74] Update user baselines (#37995) Co-authored-by: typescript-bot --- tests/baselines/reference/docker/vue-next.log | 24 +++++++++---------- tests/baselines/reference/user/discord.js.log | 8 +++---- tests/baselines/reference/user/puppeteer.log | 6 +++-- tests/baselines/reference/user/webpack.log | 1 - 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/baselines/reference/docker/vue-next.log b/tests/baselines/reference/docker/vue-next.log index 7e673ffe7c8..b9bf1004dfd 100644 --- a/tests/baselines/reference/docker/vue-next.log +++ b/tests/baselines/reference/docker/vue-next.log @@ -1,7 +1,7 @@ Exit Code: 0 Standard output: -> @X.X.X-alpha.13 build /vue-next +> @X.X.X-beta.3 build /vue-next > node scripts/build.js "--types" Rolling up type definitions for compiler-core... Writing: /vue-next/temp/compiler-core.api.json @@ -41,18 +41,18 @@ created packages/compiler-core/dist/compiler-core.cjs.js in ?s created packages/compiler-core/dist/compiler-core.cjs.prod.js in ?s /vue-next/packages/compiler-dom/src/index.ts → packages/compiler-dom/dist/compiler-dom.esm-bundler.js... created packages/compiler-dom/dist/compiler-dom.esm-bundler.js in ?s +/vue-next/packages/compiler-dom/src/index.ts → packages/compiler-dom/dist/compiler-dom.esm-browser.js... +created packages/compiler-dom/dist/compiler-dom.esm-browser.js in ?s /vue-next/packages/compiler-dom/src/index.ts → packages/compiler-dom/dist/compiler-dom.cjs.js... created packages/compiler-dom/dist/compiler-dom.cjs.js in ?s /vue-next/packages/compiler-dom/src/index.ts → packages/compiler-dom/dist/compiler-dom.global.js... created packages/compiler-dom/dist/compiler-dom.global.js in ?s -/vue-next/packages/compiler-dom/src/index.ts → packages/compiler-dom/dist/compiler-dom.esm.js... -created packages/compiler-dom/dist/compiler-dom.esm.js in ?s +/vue-next/packages/compiler-dom/src/index.ts → packages/compiler-dom/dist/compiler-dom.esm-browser.prod.js... +created packages/compiler-dom/dist/compiler-dom.esm-browser.prod.js in ?s /vue-next/packages/compiler-dom/src/index.ts → packages/compiler-dom/dist/compiler-dom.cjs.prod.js... created packages/compiler-dom/dist/compiler-dom.cjs.prod.js in ?s /vue-next/packages/compiler-dom/src/index.ts → packages/compiler-dom/dist/compiler-dom.global.prod.js... created packages/compiler-dom/dist/compiler-dom.global.prod.js in ?s -/vue-next/packages/compiler-dom/src/index.ts → packages/compiler-dom/dist/compiler-dom.esm.prod.js... -created packages/compiler-dom/dist/compiler-dom.esm.prod.js in ?s /vue-next/packages/compiler-sfc/src/index.ts → packages/compiler-sfc/dist/compiler-sfc.cjs.js... (!) Unresolved dependencies https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency @@ -62,23 +62,23 @@ created packages/compiler-sfc/dist/compiler-sfc.cjs.js in ?s created packages/compiler-ssr/dist/compiler-ssr.cjs.js in ?s /vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.esm-bundler.js... created packages/reactivity/dist/reactivity.esm-bundler.js in ?s +/vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.esm-browser.js... +created packages/reactivity/dist/reactivity.esm-browser.js in ?s /vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.cjs.js... created packages/reactivity/dist/reactivity.cjs.js in ?s /vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.global.js... created packages/reactivity/dist/reactivity.global.js in ?s -/vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.esm.js... -created packages/reactivity/dist/reactivity.esm.js in ?s +/vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.esm-browser.prod.js... +created packages/reactivity/dist/reactivity.esm-browser.prod.js in ?s /vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.cjs.prod.js... created packages/reactivity/dist/reactivity.cjs.prod.js in ?s /vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.global.prod.js... created packages/reactivity/dist/reactivity.global.prod.js in ?s -/vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.esm.prod.js... -created packages/reactivity/dist/reactivity.esm.prod.js in ?s /vue-next/packages/runtime-core/src/index.ts → packages/runtime-core/dist/runtime-core.esm-bundler.js... -[!] (plugin rpt2) Error: /vue-next/packages/runtime-core/src/componentOptions.ts(161,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. +[!] (plugin rpt2) Error: /vue-next/packages/runtime-core/src/componentOptions.ts(181,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. Type 'Function' provides no match for the signature '(...args: any): any'. packages/runtime-core/src/componentOptions.ts -Error: /vue-next/packages/runtime-core/src/componentOptions.ts(161,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. +Error: /vue-next/packages/runtime-core/src/componentOptions.ts(181,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. Type 'Function' provides no match for the signature '(...args: any): any'. at error (/vue-next/node_modules/rollup/dist/shared/rollup.js:10399:30) at throwPluginError (/vue-next/node_modules/rollup/dist/shared/rollup.js:16617:12) @@ -90,7 +90,7 @@ Error: /vue-next/packages/runtime-core/src/componentOptions.ts(161,18): semantic at forEach (/vue-next/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:9342:14) at _.each (/vue-next/node_modules/rollup-plugin-typescript2/src/print-diagnostics.ts:9:2) at Object.transform (/vue-next/node_modules/rollup-plugin-typescript2/src/index.ts:242:5) -(node:17) UnhandledPromiseRejectionWarning: Error: Command failed with exit code 1 (EPERM): rollup -c --environment COMMIT:11654a6,NODE_ENV:production,TARGET:runtime-core,TYPES:true +(node:17) UnhandledPromiseRejectionWarning: Error: Command failed with exit code 1 (EPERM): rollup -c --environment COMMIT:6fefeaf,NODE_ENV:production,TARGET:runtime-core,TYPES:true at makeError (/vue-next/node_modules/execa/lib/error.js:59:11) at handlePromise (/vue-next/node_modules/execa/index.js:112:26) at processTicksAndRejections (internal/process/task_queues.js:97:5) diff --git a/tests/baselines/reference/user/discord.js.log b/tests/baselines/reference/user/discord.js.log index a56bd598bfe..66c4ff73cf8 100644 --- a/tests/baselines/reference/user/discord.js.log +++ b/tests/baselines/reference/user/discord.js.log @@ -5,10 +5,10 @@ node_modules/discord.js/typings/index.d.ts(18,30): error TS7016: Could not find node_modules/discord.js/typings/index.d.ts(96,37): error TS2694: Namespace 'NodeJS' has no exported member 'Immediate'. node_modules/discord.js/typings/index.d.ts(103,43): error TS2694: Namespace 'NodeJS' has no exported member 'Immediate'. node_modules/discord.js/typings/index.d.ts(107,79): error TS2694: Namespace 'NodeJS' has no exported member 'Immediate'. -node_modules/discord.js/typings/index.d.ts(1742,103): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'. -node_modules/discord.js/typings/index.d.ts(1744,34): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'. -node_modules/discord.js/typings/index.d.ts(1747,34): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'. -node_modules/discord.js/typings/index.d.ts(2980,21): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'. +node_modules/discord.js/typings/index.d.ts(1749,103): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'. +node_modules/discord.js/typings/index.d.ts(1751,34): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'. +node_modules/discord.js/typings/index.d.ts(1754,34): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'. +node_modules/discord.js/typings/index.d.ts(2989,21): error TS2694: Namespace 'NodeJS' has no exported member 'Timeout'. diff --git a/tests/baselines/reference/user/puppeteer.log b/tests/baselines/reference/user/puppeteer.log index b0e6d8711bc..6135c34f414 100644 --- a/tests/baselines/reference/user/puppeteer.log +++ b/tests/baselines/reference/user/puppeteer.log @@ -1,9 +1,11 @@ Exit Code: 1 Standard output: +src/JSHandle.ts(440,5): error TS2322: Type 'unknown' is not assignable to type 'T'. + 'unknown' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'unknown'. +src/JSHandle.ts(454,5): error TS2322: Type 'unknown' is not assignable to type 'T'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'unknown'. src/Launcher.js(181,17): error TS1003: Identifier expected. src/Launcher.js(359,17): error TS1003: Identifier expected. -src/PipeTransport.js(19,17): error TS1003: Identifier expected. -src/WebSocketTransport.js(19,17): error TS1003: Identifier expected. diff --git a/tests/baselines/reference/user/webpack.log b/tests/baselines/reference/user/webpack.log index 224a05ae6be..4b4f3e5ad7e 100644 --- a/tests/baselines/reference/user/webpack.log +++ b/tests/baselines/reference/user/webpack.log @@ -9,7 +9,6 @@ lib/wasm-async/AsyncWebAssemblyModulesPlugin.js(37,15): error TS2304: Cannot fin lib/wasm-async/AsyncWebAssemblyModulesPlugin.js(38,15): error TS2304: Cannot find name 'RuntimeTemplate'. lib/wasm-async/AsyncWebAssemblyModulesPlugin.js(39,15): error TS2304: Cannot find name 'ModuleGraph'. lib/wasm-async/AsyncWebAssemblyModulesPlugin.js(40,15): error TS2304: Cannot find name 'ChunkGraph'. -tooling/format-file-header.js(151,34): error TS2556: Expected 1-2 arguments, but got 0 or more. From 2784e03d7e5fa8969d9f53dc2b3635b5896ccf8b Mon Sep 17 00:00:00 2001 From: csigs Date: Wed, 22 Apr 2020 04:10:37 +0000 Subject: [PATCH 37/74] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 6f55deb823f..563b2b5a06b 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -436,7 +436,7 @@ - + @@ -1180,7 +1180,7 @@ - + @@ -3193,7 +3193,7 @@ - + @@ -7408,7 +7408,7 @@ - + @@ -11116,7 +11116,7 @@ - + @@ -11677,7 +11677,7 @@ - + From 39beb1d011a6bc412a67e1dfa2ec1cb1de438b4f Mon Sep 17 00:00:00 2001 From: Wenlu Wang Date: Wed, 22 Apr 2020 18:12:01 +0800 Subject: [PATCH 38/74] Add check for delete expression must be optional (#37921) * Add check for delete expression must be optional * Add more tests --- src/compiler/checker.ts | 15 +- src/compiler/diagnosticMessages.json | 4 + .../controlFlowDeleteOperator.errors.txt | 5 +- .../reference/deleteChain.errors.txt | 66 +++++++++ ...ionMustBeOptional(strict=false).errors.txt | 46 ++++++ ...eExpressionMustBeOptional(strict=false).js | 57 ++++++++ ...essionMustBeOptional(strict=false).symbols | 118 +++++++++++++++ ...pressionMustBeOptional(strict=false).types | 137 ++++++++++++++++++ ...sionMustBeOptional(strict=true).errors.txt | 52 +++++++ ...teExpressionMustBeOptional(strict=true).js | 58 ++++++++ ...ressionMustBeOptional(strict=true).symbols | 118 +++++++++++++++ ...xpressionMustBeOptional(strict=true).types | 137 ++++++++++++++++++ .../reference/privateNamesNoDelete.errors.txt | 5 +- .../deleteExpressionMustBeOptional.ts | 42 ++++++ 14 files changed, 856 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/deleteChain.errors.txt create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types create mode 100644 tests/cases/compiler/deleteExpressionMustBeOptional.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac02f917827..89be1e0aa73 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -27583,12 +27583,23 @@ namespace ts { } const links = getNodeLinks(expr); const symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol && isReadonlySymbol(symbol)) { - error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + if (symbol) { + if (isReadonlySymbol(symbol)) { + error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } + + checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol)); } return booleanType; } + function checkDeleteExpressionMustBeOptional(expr: AccessExpression, type: Type) { + const AnyOrUnknownOrNeverFlags = TypeFlags.AnyOrUnknown | TypeFlags.Never; + if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & TypeFlags.Undefined)) { + error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional); + } + } + function checkTypeOfExpression(node: TypeOfExpression): Type { checkExpression(node.expression); return typeofType; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ab45cbe0cf4..4a7c6e8b461 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2963,6 +2963,10 @@ "category": "Error", "code": 2789 }, + "The operand of a 'delete' operator must be optional.": { + "category": "Error", + "code": 2790 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/controlFlowDeleteOperator.errors.txt b/tests/baselines/reference/controlFlowDeleteOperator.errors.txt index 91ec2aa0de8..f5a6823a778 100644 --- a/tests/baselines/reference/controlFlowDeleteOperator.errors.txt +++ b/tests/baselines/reference/controlFlowDeleteOperator.errors.txt @@ -1,7 +1,8 @@ +tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(10,12): error TS2790: The operand of a 'delete' operator must be optional. tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error TS2703: The operand of a 'delete' operator must be a property reference. -==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (1 errors) ==== +==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (2 errors) ==== function f() { let x: { a?: number | string, b: number | string } = { b: 1 }; x.a; @@ -12,6 +13,8 @@ tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error T x.b; delete x.a; delete x.b; + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. x.a; x.b; x; diff --git a/tests/baselines/reference/deleteChain.errors.txt b/tests/baselines/reference/deleteChain.errors.txt new file mode 100644 index 00000000000..dd716419573 --- /dev/null +++ b/tests/baselines/reference/deleteChain.errors.txt @@ -0,0 +1,66 @@ +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(2,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(3,9): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(6,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(7,9): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(10,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(11,9): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(14,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(15,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(16,9): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(19,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(20,9): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(23,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(24,9): error TS2790: The operand of a 'delete' operator must be optional. + + +==== tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts (13 errors) ==== + declare const o1: undefined | { b: string }; + delete o1?.b; + ~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o1?.b); + ~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + + declare const o2: undefined | { b: { c: string } }; + delete o2?.b.c; + ~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o2?.b.c); + ~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + + declare const o3: { b: undefined | { c: string } }; + delete o3.b?.c; + ~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o3.b?.c); + ~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + + declare const o4: { b?: { c: { d?: { e: string } } } }; + delete o4.b?.c.d?.e; + ~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o4.b?.c.d)?.e; + ~~~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o4.b?.c.d?.e); + ~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + + declare const o5: { b?(): { c: { d?: { e: string } } } }; + delete o5.b?.().c.d?.e; + ~~~~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o5.b?.().c.d?.e); + ~~~~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + + declare const o6: { b?: { c: { d?: { e: string } } } }; + delete o6.b?.['c'].d?.['e']; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o6.b?.['c'].d?.['e']); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. \ No newline at end of file diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt new file mode 100644 index 00000000000..8a876cb6350 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt @@ -0,0 +1,46 @@ +tests/cases/compiler/deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'. + + +==== tests/cases/compiler/deleteExpressionMustBeOptional.ts (1 errors) ==== + interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never + } + + interface AA { + [s: string]: number + } + + type BB = { + [P in keyof any]: number + } + + declare const f: Foo + declare const a: AA + declare const b: BB + + delete f.a + delete f.b + delete f.c + delete f.d + delete f.e + delete f.f + delete f.g + delete f.h + delete f.i + delete f.j + ~ +!!! error TS2339: Property 'j' does not exist on type 'Foo'. + + delete a.a + delete a.b + + delete b.a + delete b.b \ No newline at end of file diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js new file mode 100644 index 00000000000..268c76175bf --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js @@ -0,0 +1,57 @@ +//// [deleteExpressionMustBeOptional.ts] +interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never +} + +interface AA { + [s: string]: number +} + +type BB = { + [P in keyof any]: number +} + +declare const f: Foo +declare const a: AA +declare const b: BB + +delete f.a +delete f.b +delete f.c +delete f.d +delete f.e +delete f.f +delete f.g +delete f.h +delete f.i +delete f.j + +delete a.a +delete a.b + +delete b.a +delete b.b + +//// [deleteExpressionMustBeOptional.js] +delete f.a; +delete f.b; +delete f.c; +delete f.d; +delete f.e; +delete f.f; +delete f.g; +delete f.h; +delete f.i; +delete f.j; +delete a.a; +delete a.b; +delete b.a; +delete b.b; diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols new file mode 100644 index 00000000000..aad7423a133 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols @@ -0,0 +1,118 @@ +=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + + a: number +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + + b: number | undefined +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + + c: number | null +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + + d?: number +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + + e: number | undefined | null +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + + f?: number | undefined | null +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + + g: unknown +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + + h: any +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + + i: never +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +} + +interface AA { +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + + [s: string]: number +>s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5)) +} + +type BB = { +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + + [P in keyof any]: number +>P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5)) +} + +declare const f: Foo +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + +declare const a: AA +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + +declare const b: BB +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + +delete f.a +>f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + +delete f.b +>f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + +delete f.c +>f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + +delete f.d +>f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + +delete f.e +>f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + +delete f.f +>f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + +delete f.g +>f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + +delete f.h +>f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + +delete f.i +>f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) + +delete f.j +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) + +delete a.a +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) + +delete a.b +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) + +delete b.a +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + +delete b.b +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types new file mode 100644 index 00000000000..371bb25e96d --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types @@ -0,0 +1,137 @@ +=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === +interface Foo { + a: number +>a : number + + b: number | undefined +>b : number + + c: number | null +>c : number +>null : null + + d?: number +>d : number + + e: number | undefined | null +>e : number +>null : null + + f?: number | undefined | null +>f : number +>null : null + + g: unknown +>g : unknown + + h: any +>h : any + + i: never +>i : never +} + +interface AA { + [s: string]: number +>s : string +} + +type BB = { +>BB : BB + + [P in keyof any]: number +} + +declare const f: Foo +>f : Foo + +declare const a: AA +>a : AA + +declare const b: BB +>b : BB + +delete f.a +>delete f.a : boolean +>f.a : number +>f : Foo +>a : number + +delete f.b +>delete f.b : boolean +>f.b : number +>f : Foo +>b : number + +delete f.c +>delete f.c : boolean +>f.c : number +>f : Foo +>c : number + +delete f.d +>delete f.d : boolean +>f.d : number +>f : Foo +>d : number + +delete f.e +>delete f.e : boolean +>f.e : number +>f : Foo +>e : number + +delete f.f +>delete f.f : boolean +>f.f : number +>f : Foo +>f : number + +delete f.g +>delete f.g : boolean +>f.g : unknown +>f : Foo +>g : unknown + +delete f.h +>delete f.h : boolean +>f.h : any +>f : Foo +>h : any + +delete f.i +>delete f.i : boolean +>f.i : never +>f : Foo +>i : never + +delete f.j +>delete f.j : boolean +>f.j : any +>f : Foo +>j : any + +delete a.a +>delete a.a : boolean +>a.a : number +>a : AA +>a : number + +delete a.b +>delete a.b : boolean +>a.b : number +>a : AA +>b : number + +delete b.a +>delete b.a : boolean +>b.a : number +>b : BB +>a : number + +delete b.b +>delete b.b : boolean +>b.b : number +>b : BB +>b : number + diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt new file mode 100644 index 00000000000..b1cabc96009 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt @@ -0,0 +1,52 @@ +tests/cases/compiler/deleteExpressionMustBeOptional.ts(25,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/compiler/deleteExpressionMustBeOptional.ts(27,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/compiler/deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'. + + +==== tests/cases/compiler/deleteExpressionMustBeOptional.ts (3 errors) ==== + interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never + } + + interface AA { + [s: string]: number + } + + type BB = { + [P in keyof any]: number + } + + declare const f: Foo + declare const a: AA + declare const b: BB + + delete f.a + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete f.b + delete f.c + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete f.d + delete f.e + delete f.f + delete f.g + delete f.h + delete f.i + delete f.j + ~ +!!! error TS2339: Property 'j' does not exist on type 'Foo'. + + delete a.a + delete a.b + + delete b.a + delete b.b \ No newline at end of file diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js new file mode 100644 index 00000000000..ca81456b4f4 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js @@ -0,0 +1,58 @@ +//// [deleteExpressionMustBeOptional.ts] +interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never +} + +interface AA { + [s: string]: number +} + +type BB = { + [P in keyof any]: number +} + +declare const f: Foo +declare const a: AA +declare const b: BB + +delete f.a +delete f.b +delete f.c +delete f.d +delete f.e +delete f.f +delete f.g +delete f.h +delete f.i +delete f.j + +delete a.a +delete a.b + +delete b.a +delete b.b + +//// [deleteExpressionMustBeOptional.js] +"use strict"; +delete f.a; +delete f.b; +delete f.c; +delete f.d; +delete f.e; +delete f.f; +delete f.g; +delete f.h; +delete f.i; +delete f.j; +delete a.a; +delete a.b; +delete b.a; +delete b.b; diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols new file mode 100644 index 00000000000..aad7423a133 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols @@ -0,0 +1,118 @@ +=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + + a: number +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + + b: number | undefined +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + + c: number | null +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + + d?: number +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + + e: number | undefined | null +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + + f?: number | undefined | null +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + + g: unknown +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + + h: any +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + + i: never +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +} + +interface AA { +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + + [s: string]: number +>s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5)) +} + +type BB = { +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + + [P in keyof any]: number +>P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5)) +} + +declare const f: Foo +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + +declare const a: AA +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + +declare const b: BB +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + +delete f.a +>f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + +delete f.b +>f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + +delete f.c +>f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + +delete f.d +>f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + +delete f.e +>f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + +delete f.f +>f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + +delete f.g +>f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + +delete f.h +>f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + +delete f.i +>f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) + +delete f.j +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) + +delete a.a +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) + +delete a.b +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) + +delete b.a +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + +delete b.b +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types new file mode 100644 index 00000000000..a3d6f52b7c4 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types @@ -0,0 +1,137 @@ +=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === +interface Foo { + a: number +>a : number + + b: number | undefined +>b : number | undefined + + c: number | null +>c : number | null +>null : null + + d?: number +>d : number | undefined + + e: number | undefined | null +>e : number | null | undefined +>null : null + + f?: number | undefined | null +>f : number | null | undefined +>null : null + + g: unknown +>g : unknown + + h: any +>h : any + + i: never +>i : never +} + +interface AA { + [s: string]: number +>s : string +} + +type BB = { +>BB : BB + + [P in keyof any]: number +} + +declare const f: Foo +>f : Foo + +declare const a: AA +>a : AA + +declare const b: BB +>b : BB + +delete f.a +>delete f.a : boolean +>f.a : number +>f : Foo +>a : number + +delete f.b +>delete f.b : boolean +>f.b : number | undefined +>f : Foo +>b : number | undefined + +delete f.c +>delete f.c : boolean +>f.c : number | null +>f : Foo +>c : number | null + +delete f.d +>delete f.d : boolean +>f.d : number | undefined +>f : Foo +>d : number | undefined + +delete f.e +>delete f.e : boolean +>f.e : number | null | undefined +>f : Foo +>e : number | null | undefined + +delete f.f +>delete f.f : boolean +>f.f : number | null | undefined +>f : Foo +>f : number | null | undefined + +delete f.g +>delete f.g : boolean +>f.g : unknown +>f : Foo +>g : unknown + +delete f.h +>delete f.h : boolean +>f.h : any +>f : Foo +>h : any + +delete f.i +>delete f.i : boolean +>f.i : never +>f : Foo +>i : never + +delete f.j +>delete f.j : boolean +>f.j : any +>f : Foo +>j : any + +delete a.a +>delete a.a : boolean +>a.a : number +>a : AA +>a : number + +delete a.b +>delete a.b : boolean +>a.b : number +>a : AA +>b : number + +delete b.a +>delete b.a : boolean +>b.a : number +>b : BB +>a : number + +delete b.b +>delete b.b : boolean +>b.b : number +>b : BB +>b : number + diff --git a/tests/baselines/reference/privateNamesNoDelete.errors.txt b/tests/baselines/reference/privateNamesNoDelete.errors.txt index d593fe107a1..e2fc11cb4ac 100644 --- a/tests/baselines/reference/privateNamesNoDelete.errors.txt +++ b/tests/baselines/reference/privateNamesNoDelete.errors.txt @@ -1,12 +1,15 @@ +tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts(4,16): error TS2790: The operand of a 'delete' operator must be optional. tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts(4,16): error TS18011: The operand of a 'delete' operator cannot be a private identifier. -==== tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts (1 errors) ==== +==== tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts (2 errors) ==== class A { #v = 1; constructor() { delete this.#v; // Error: The operand of a delete operator cannot be a private name. ~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + ~~~~~~~ !!! error TS18011: The operand of a 'delete' operator cannot be a private identifier. } } diff --git a/tests/cases/compiler/deleteExpressionMustBeOptional.ts b/tests/cases/compiler/deleteExpressionMustBeOptional.ts new file mode 100644 index 00000000000..9f84d9ea2f1 --- /dev/null +++ b/tests/cases/compiler/deleteExpressionMustBeOptional.ts @@ -0,0 +1,42 @@ +// @strict: true, false + +interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never +} + +interface AA { + [s: string]: number +} + +type BB = { + [P in keyof any]: number +} + +declare const f: Foo +declare const a: AA +declare const b: BB + +delete f.a +delete f.b +delete f.c +delete f.d +delete f.e +delete f.f +delete f.g +delete f.h +delete f.i +delete f.j + +delete a.a +delete a.b + +delete b.a +delete b.b \ No newline at end of file From 92a63741a288ff34f47df5505dbbd7ab19490493 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Wed, 22 Apr 2020 18:51:36 +0300 Subject: [PATCH 39/74] fix(38080): add outlining spans for TypeLiteral (#38089) --- src/services/outliningElementsCollector.ts | 1 + .../fourslash/getOutliningForTypeLiteral.ts | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/cases/fourslash/getOutliningForTypeLiteral.ts diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index dd71b48c49c..7c9e89052ab 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -199,6 +199,7 @@ namespace ts.OutliningElementsCollector { case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.CaseBlock: + case SyntaxKind.TypeLiteral: return spanForNode(n); case SyntaxKind.CaseClause: case SyntaxKind.DefaultClause: diff --git a/tests/cases/fourslash/getOutliningForTypeLiteral.ts b/tests/cases/fourslash/getOutliningForTypeLiteral.ts new file mode 100644 index 00000000000..d0d6693ec39 --- /dev/null +++ b/tests/cases/fourslash/getOutliningForTypeLiteral.ts @@ -0,0 +1,24 @@ +/// + +////type A =[| { +//// a: number; +////}|] +//// +////type B =[| { +//// a:[| { +//// a1:[| { +//// a2:[| { +//// x: number; +//// y: number; +//// }|] +//// }|] +//// }|], +//// b:[| { +//// x: number; +//// }|], +//// c:[| { +//// x: number; +//// }|] +////}|] + +verify.outliningSpansInCurrentFile(test.ranges(), "code"); From d2016912b5f8778b25c8f7c2dc4e82dbd5e27843 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Wed, 22 Apr 2020 19:07:36 +0300 Subject: [PATCH 40/74] fix(37825): exclude private fields from completions in subclasses (#37906) --- src/services/completions.ts | 3 ++- .../completionListClassPrivateFields.ts | 15 +++++++++++++ .../completionListClassPrivateFields_JS.ts | 21 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/completionListClassPrivateFields.ts create mode 100644 tests/cases/fourslash/completionListClassPrivateFields_JS.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index 2066c485ac8..bb08fe7d549 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -2427,7 +2427,8 @@ namespace ts.Completions { return baseSymbols.filter(propertySymbol => !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && - !(getDeclarationModifierFlagsFromSymbol(propertySymbol) & ModifierFlags.Private)); + !(getDeclarationModifierFlagsFromSymbol(propertySymbol) & ModifierFlags.Private) && + !isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration)); } /** diff --git a/tests/cases/fourslash/completionListClassPrivateFields.ts b/tests/cases/fourslash/completionListClassPrivateFields.ts new file mode 100644 index 00000000000..f7638047a67 --- /dev/null +++ b/tests/cases/fourslash/completionListClassPrivateFields.ts @@ -0,0 +1,15 @@ +/// + +////class A { +//// #private = 1; +////} +//// +////class B extends A { +//// /**/ +////} + +verify.completions({ + marker: "", + exact: completion.classElementKeywords, + isNewIdentifierLocation: true +}); diff --git a/tests/cases/fourslash/completionListClassPrivateFields_JS.ts b/tests/cases/fourslash/completionListClassPrivateFields_JS.ts new file mode 100644 index 00000000000..49c8d05af6a --- /dev/null +++ b/tests/cases/fourslash/completionListClassPrivateFields_JS.ts @@ -0,0 +1,21 @@ +/// + +// @allowJs: true +// @Filename: a.js +////class A { +//// #private = 1; +////} +//// +////class B extends A { +//// /**/ +////} + +verify.completions({ + marker: "", + exact: [ + { name: "A", sortText: completion.SortText.JavascriptIdentifiers }, + { name: "B", sortText: completion.SortText.JavascriptIdentifiers }, + ...completion.classElementInJsKeywords + ], + isNewIdentifierLocation: true +}); From f248567dabd1b9cc11bb53d815e79c80becaee51 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 22 Apr 2020 09:56:32 -0700 Subject: [PATCH 41/74] Filter undefined only in binding patterns in params (#38116) initialiser. But this is only correct when the initialiser is for a parameter. For example: ```ts declare let x: { s: string } | undefined; const { s } = x; ``` This PR removes undefined from the type of a binding pattern only when the binding pattern's parent is a parameter. This fixes the regression from 3.8. However, it's still not the ideal fix; we should be able to use control flow to solve this problem. Consider: ```ts const { s }: { s: string } | undefined = { s: 'hi' } declare function f({ s }: { s: string } | undefined = { s: 'hi' }): void ``` Neither line should have an error, but the first does in 3.8 and after this change. --- src/compiler/checker.ts | 2 +- ...rInitalizedVariablesFiltersUndefined.errors.txt | 14 ++++++++++++++ ...alTypeForInitalizedVariablesFiltersUndefined.js | 7 ++++++- ...eForInitalizedVariablesFiltersUndefined.symbols | 8 ++++++++ ...ypeForInitalizedVariablesFiltersUndefined.types | 8 ++++++++ ...alTypeForInitalizedVariablesFiltersUndefined.ts | 5 ++++- 6 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 89be1e0aa73..9014e2f43f9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7306,7 +7306,7 @@ namespace ts { parentType = getNonNullableType(parentType); } // Filter `undefined` from the type we check against if the parent has an initializer (which handles the `undefined` case implicitly) - else if (strictNullChecks && pattern.parent.initializer) { + else if (strictNullChecks && pattern.parent.initializer && isParameter(pattern.parent)) { parentType = getTypeWithFacts(parentType, TypeFacts.NEUndefined); } diff --git a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.errors.txt b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.errors.txt new file mode 100644 index 00000000000..32ff831d2bd --- /dev/null +++ b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts(7,9): error TS2339: Property 's' does not exist on type '{ s: string; } | undefined'. + + +==== tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts (1 errors) ==== + const fInferred = ({ a = 0 } = {}) => a; + // const fInferred: ({ a }?: { a?: number; }) => number + + const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a; + + declare var t: { s: string } | undefined; + const { s } = t; + ~ +!!! error TS2339: Property 's' does not exist on type '{ s: string; } | undefined'. + \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.js b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.js index 9c2a6eaa780..8311b6ff481 100644 --- a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.js +++ b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.js @@ -2,7 +2,11 @@ const fInferred = ({ a = 0 } = {}) => a; // const fInferred: ({ a }?: { a?: number; }) => number -const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a; +const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a; + +declare var t: { s: string } | undefined; +const { s } = t; + //// [contextualTypeForInitalizedVariablesFiltersUndefined.js] "use strict"; @@ -15,3 +19,4 @@ var fAnnotated = function (_a) { var _b = (_a === void 0 ? {} : _a).a, a = _b === void 0 ? 0 : _b; return a; }; +var s = t.s; diff --git a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.symbols b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.symbols index 7b675719012..81ae53f9418 100644 --- a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.symbols +++ b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.symbols @@ -12,3 +12,11 @@ const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a; >a : Symbol(a, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 3, 39)) >a : Symbol(a, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 3, 39)) +declare var t: { s: string } | undefined; +>t : Symbol(t, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 5, 11)) +>s : Symbol(s, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 5, 16)) + +const { s } = t; +>s : Symbol(s, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 6, 7)) +>t : Symbol(t, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 5, 11)) + diff --git a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types index d8278124ff0..58580fdacce 100644 --- a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types +++ b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types @@ -18,3 +18,11 @@ const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a; >{} : {} >a : number +declare var t: { s: string } | undefined; +>t : { s: string; } | undefined +>s : string + +const { s } = t; +>s : any +>t : { s: string; } | undefined + diff --git a/tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts b/tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts index 268544f8192..cfa8d8d6824 100644 --- a/tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts +++ b/tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts @@ -2,4 +2,7 @@ const fInferred = ({ a = 0 } = {}) => a; // const fInferred: ({ a }?: { a?: number; }) => number -const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a; \ No newline at end of file +const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a; + +declare var t: { s: string } | undefined; +const { s } = t; From ef83109dbf122644bdba9a8cb97ea007c7668ea0 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 22 Apr 2020 14:28:11 -0400 Subject: [PATCH 42/74] Prefer a likely literal over anonymous type in --noImplicitAny codefixes (#36015) * Prefer a likely literal over anonymous type in --noImplicitAny codefixes Before trying to make an anonymous type for a type's usage, we'll first check if there is exactly one builtin primitive the usage is assignable to, and use it if so. Right now that's only `number` and `string` because `boolean` has no distinguishable members. A couple of implementation details: * `tryInsertTypeAnnotation` needed to know to insert a type _after_ a node's `exclamationToken` if it exists * This code area was written before `??` :wink: * Used unknown/any instead of void when applicable * Fix little whitespace change in tests/cases/fourslash/codeFixInferFromUsagePropertyAccessJS.ts * Undid some now-unnecessary unknown additions * Took advice on restricting void to just call expressions --- src/services/codefixes/inferFromUsage.ts | 11 ++++++----- src/services/textChanges.ts | 2 +- .../codeFixInferFromUsageParameterLiteral.ts | 10 ++++++++++ .../fourslash/codeFixInferFromUsagePropertyAccess.ts | 2 +- .../codeFixInferFromUsagePropertyAccessJS.ts | 2 +- .../fourslash/codeFixInferFromUsageVariableLiteral.ts | 9 +++++++++ 6 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 tests/cases/fourslash/codeFixInferFromUsageParameterLiteral.ts create mode 100644 tests/cases/fourslash/codeFixInferFromUsageVariableLiteral.ts diff --git a/src/services/codefixes/inferFromUsage.ts b/src/services/codefixes/inferFromUsage.ts index 0af71bbbb9c..7fa01819d22 100644 --- a/src/services/codefixes/inferFromUsage.ts +++ b/src/services/codefixes/inferFromUsage.ts @@ -603,7 +603,7 @@ namespace ts.codefix { switch (node.parent.kind) { case SyntaxKind.ExpressionStatement: - addCandidateType(usage, checker.getVoidType()); + inferTypeFromExpressionStatement(node, usage); break; case SyntaxKind.PostfixUnaryExpression: usage.isNumber = true; @@ -661,6 +661,10 @@ namespace ts.codefix { } } + function inferTypeFromExpressionStatement(node: Expression, usage: Usage): void { + addCandidateType(usage, isCallExpression(node) ? checker.getVoidType() : checker.getAnyType()); + } + function inferTypeFromPrefixUnaryExpression(node: PrefixUnaryExpression, usage: Usage): void { switch (node.operator) { case SyntaxKind.PlusPlusToken: @@ -960,10 +964,7 @@ namespace ts.codefix { if (usage.numberIndex) { types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); } - if (usage.properties && usage.properties.size - || usage.calls && usage.calls.length - || usage.constructs && usage.constructs.length - || usage.stringIndex) { + if (usage.properties?.size || usage.calls?.length || usage.constructs?.length || usage.stringIndex) { types.push(inferStructuralType(usage)); } diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index bf1dae65602..2b743f4d592 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -434,7 +434,7 @@ namespace ts.textChanges { } } else { - endNode = node.kind !== SyntaxKind.VariableDeclaration && node.questionToken ? node.questionToken : node.name; + endNode = (node.kind === SyntaxKind.VariableDeclaration ? node.exclamationToken : node.questionToken) ?? node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); diff --git a/tests/cases/fourslash/codeFixInferFromUsageParameterLiteral.ts b/tests/cases/fourslash/codeFixInferFromUsageParameterLiteral.ts new file mode 100644 index 00000000000..16610635982 --- /dev/null +++ b/tests/cases/fourslash/codeFixInferFromUsageParameterLiteral.ts @@ -0,0 +1,10 @@ +/// + +// @noImplicitAny: true +//// function foo([|text |]) { +//// text.length; +//// text.indexOf("z"); +//// text.charAt(0); +//// } + +verify.rangeAfterCodeFix("text: string", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, /*index*/0); diff --git a/tests/cases/fourslash/codeFixInferFromUsagePropertyAccess.ts b/tests/cases/fourslash/codeFixInferFromUsagePropertyAccess.ts index 44d2e2d7b1c..41112b2409e 100644 --- a/tests/cases/fourslash/codeFixInferFromUsagePropertyAccess.ts +++ b/tests/cases/fourslash/codeFixInferFromUsagePropertyAccess.ts @@ -12,4 +12,4 @@ //// return x.y.z ////} -verify.rangeAfterCodeFix("a: { b: { c: void; }; }, m: { n: () => number; }, x: { y: { z: number[]; }; }", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, /*index*/0); +verify.rangeAfterCodeFix("a: { b: { c: any; }; }, m: { n: () => number; }, x: { y: { z: number[]; }; }", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, /*index*/0); diff --git a/tests/cases/fourslash/codeFixInferFromUsagePropertyAccessJS.ts b/tests/cases/fourslash/codeFixInferFromUsagePropertyAccessJS.ts index 357b1a991ba..ed9d4b33b37 100644 --- a/tests/cases/fourslash/codeFixInferFromUsagePropertyAccessJS.ts +++ b/tests/cases/fourslash/codeFixInferFromUsagePropertyAccessJS.ts @@ -21,7 +21,7 @@ verify.codeFix({ index: 0, newFileContent: `/** - * @param {{ b: { c: void; }; }} a + * @param {{ b: { c: any; }; }} a * @param {{ n: () => number; }} m * @param {{ y: { z: number[]; }; }} x */ diff --git a/tests/cases/fourslash/codeFixInferFromUsageVariableLiteral.ts b/tests/cases/fourslash/codeFixInferFromUsageVariableLiteral.ts new file mode 100644 index 00000000000..2641b009636 --- /dev/null +++ b/tests/cases/fourslash/codeFixInferFromUsageVariableLiteral.ts @@ -0,0 +1,9 @@ +/// + +// @noImplicitAny: true +//// let [|text! |]; +//// text.length; +//// text.indexOf("z"); +//// text.charAt(0); + +verify.rangeAfterCodeFix("text!: string", /*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, /*index*/0); From 032aa90289e52d6e49ba4abdb098b3bf6d55fa67 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 22 Apr 2020 15:45:15 -0700 Subject: [PATCH 43/74] Filter undefined from binding elements with initialisers without undefined in the type (#38122) * Filter undefined from binding elts w/o undefined-containing inits * use getTypeOfInitializer instead * improve comment based on Wesleys suggestion --- src/compiler/checker.ts | 4 ++-- ...ualTypeForInitalizedVariablesFiltersUndefined.errors.txt | 6 +++++- .../contextualTypeForInitalizedVariablesFiltersUndefined.js | 4 ++++ ...extualTypeForInitalizedVariablesFiltersUndefined.symbols | 5 +++++ ...ntextualTypeForInitalizedVariablesFiltersUndefined.types | 5 +++++ .../contextualTypeForInitalizedVariablesFiltersUndefined.ts | 1 + 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9014e2f43f9..ac46ee7e163 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7305,8 +7305,8 @@ namespace ts { if (strictNullChecks && declaration.flags & NodeFlags.Ambient && isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } - // Filter `undefined` from the type we check against if the parent has an initializer (which handles the `undefined` case implicitly) - else if (strictNullChecks && pattern.parent.initializer && isParameter(pattern.parent)) { + // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & TypeFacts.EQUndefined)) { parentType = getTypeWithFacts(parentType, TypeFacts.NEUndefined); } diff --git a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.errors.txt b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.errors.txt index 32ff831d2bd..abab02a197c 100644 --- a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.errors.txt +++ b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.errors.txt @@ -1,7 +1,8 @@ tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts(7,9): error TS2339: Property 's' does not exist on type '{ s: string; } | undefined'. +tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts(8,16): error TS2339: Property 's' does not exist on type '{ s: string; } | undefined'. -==== tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts (1 errors) ==== +==== tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts (2 errors) ==== const fInferred = ({ a = 0 } = {}) => a; // const fInferred: ({ a }?: { a?: number; }) => number @@ -11,4 +12,7 @@ tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts(7,9 const { s } = t; ~ !!! error TS2339: Property 's' does not exist on type '{ s: string; } | undefined'. + function fst({ s } = t) { } + ~ +!!! error TS2339: Property 's' does not exist on type '{ s: string; } | undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.js b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.js index 8311b6ff481..3003e420e5f 100644 --- a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.js +++ b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.js @@ -6,6 +6,7 @@ const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a; declare var t: { s: string } | undefined; const { s } = t; +function fst({ s } = t) { } //// [contextualTypeForInitalizedVariablesFiltersUndefined.js] @@ -20,3 +21,6 @@ var fAnnotated = function (_a) { return a; }; var s = t.s; +function fst(_a) { + var s = (_a === void 0 ? t : _a).s; +} diff --git a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.symbols b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.symbols index 81ae53f9418..749fd47dd14 100644 --- a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.symbols +++ b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.symbols @@ -20,3 +20,8 @@ const { s } = t; >s : Symbol(s, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 6, 7)) >t : Symbol(t, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 5, 11)) +function fst({ s } = t) { } +>fst : Symbol(fst, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 6, 16)) +>s : Symbol(s, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 7, 14)) +>t : Symbol(t, Decl(contextualTypeForInitalizedVariablesFiltersUndefined.ts, 5, 11)) + diff --git a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types index 58580fdacce..f2c72b1708d 100644 --- a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types +++ b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types @@ -26,3 +26,8 @@ const { s } = t; >s : any >t : { s: string; } | undefined +function fst({ s } = t) { } +>fst : ({ s }?: { s: string; } | undefined) => void +>s : any +>t : { s: string; } | undefined + diff --git a/tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts b/tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts index cfa8d8d6824..d6d23ba85b0 100644 --- a/tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts +++ b/tests/cases/compiler/contextualTypeForInitalizedVariablesFiltersUndefined.ts @@ -6,3 +6,4 @@ const fAnnotated: typeof fInferred = ({ a = 0 } = {}) => a; declare var t: { s: string } | undefined; const { s } = t; +function fst({ s } = t) { } From ab0428c82e9ac16b825aa95d143ab02367c76b2e Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Wed, 22 Apr 2020 16:58:14 -0700 Subject: [PATCH 44/74] Update user baselines (#38109) Co-authored-by: typescript-bot --- tests/baselines/reference/docker/vue-next.log | 18 +++++++++--------- tests/baselines/reference/user/npm.log | 7 +++++++ tests/baselines/reference/user/puppeteer.log | 4 ---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/baselines/reference/docker/vue-next.log b/tests/baselines/reference/docker/vue-next.log index b9bf1004dfd..e8186149779 100644 --- a/tests/baselines/reference/docker/vue-next.log +++ b/tests/baselines/reference/docker/vue-next.log @@ -75,27 +75,27 @@ created packages/reactivity/dist/reactivity.cjs.prod.js in ?s /vue-next/packages/reactivity/src/index.ts → packages/reactivity/dist/reactivity.global.prod.js... created packages/reactivity/dist/reactivity.global.prod.js in ?s /vue-next/packages/runtime-core/src/index.ts → packages/runtime-core/dist/runtime-core.esm-bundler.js... -[!] (plugin rpt2) Error: /vue-next/packages/runtime-core/src/componentOptions.ts(181,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. +[!] (plugin rpt2) Error: /vue-next/packages/runtime-core/src/componentOptions.ts(182,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. Type 'Function' provides no match for the signature '(...args: any): any'. packages/runtime-core/src/componentOptions.ts -Error: /vue-next/packages/runtime-core/src/componentOptions.ts(181,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. +Error: /vue-next/packages/runtime-core/src/componentOptions.ts(182,18): semantic error TS2344: Type 'Function & T[key]["get"]' does not satisfy the constraint '(...args: any) => any'. Type 'Function' provides no match for the signature '(...args: any): any'. - at error (/vue-next/node_modules/rollup/dist/shared/rollup.js:10399:30) - at throwPluginError (/vue-next/node_modules/rollup/dist/shared/rollup.js:16617:12) - at Object.error (/vue-next/node_modules/rollup/dist/shared/rollup.js:17634:24) - at Object.error (/vue-next/node_modules/rollup/dist/shared/rollup.js:16790:38) + at error (/vue-next/node_modules/rollup/dist/shared/rollup.js:160:30) + at throwPluginError (/vue-next/node_modules/rollup/dist/shared/rollup.js:16838:12) + at Object.error (/vue-next/node_modules/rollup/dist/shared/rollup.js:17857:24) + at Object.error (/vue-next/node_modules/rollup/dist/shared/rollup.js:17011:38) at RollupContext.error (/vue-next/node_modules/rollup-plugin-typescript2/src/rollupcontext.ts:37:18) at /vue-next/node_modules/rollup-plugin-typescript2/src/print-diagnostics.ts:41:11 at arrayEach (/vue-next/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:516:11) at forEach (/vue-next/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:9342:14) at _.each (/vue-next/node_modules/rollup-plugin-typescript2/src/print-diagnostics.ts:9:2) at Object.transform (/vue-next/node_modules/rollup-plugin-typescript2/src/index.ts:242:5) -(node:17) UnhandledPromiseRejectionWarning: Error: Command failed with exit code 1 (EPERM): rollup -c --environment COMMIT:6fefeaf,NODE_ENV:production,TARGET:runtime-core,TYPES:true +(node:18) UnhandledPromiseRejectionWarning: Error: Command failed with exit code 1 (EPERM): rollup -c --environment COMMIT:2acf3e8,NODE_ENV:production,TARGET:runtime-core,TYPES:true at makeError (/vue-next/node_modules/execa/lib/error.js:59:11) at handlePromise (/vue-next/node_modules/execa/index.js:112:26) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async build (/vue-next/scripts/build.js:71:3) at async buildAll (/vue-next/scripts/build.js:50:5) at async run (/vue-next/scripts/build.js:40:5) -(node:17) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) -(node:17) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. +(node:18) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) +(node:18) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. diff --git a/tests/baselines/reference/user/npm.log b/tests/baselines/reference/user/npm.log index 0bc07705d00..4da97268ad2 100644 --- a/tests/baselines/reference/user/npm.log +++ b/tests/baselines/reference/user/npm.log @@ -208,6 +208,11 @@ node_modules/npm/lib/config/lifecycle.js(23,24): error TS2339: Property 'config' node_modules/npm/lib/config/lifecycle.js(24,35): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/config/lifecycle.js(25,23): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/config/lifecycle.js(26,17): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. +node_modules/npm/lib/config/nerf-dart.js(16,10): error TS2790: The operand of a 'delete' operator must be optional. +node_modules/npm/lib/config/nerf-dart.js(17,10): error TS2790: The operand of a 'delete' operator must be optional. +node_modules/npm/lib/config/nerf-dart.js(18,10): error TS2790: The operand of a 'delete' operator must be optional. +node_modules/npm/lib/config/nerf-dart.js(19,10): error TS2790: The operand of a 'delete' operator must be optional. +node_modules/npm/lib/config/nerf-dart.js(20,10): error TS2790: The operand of a 'delete' operator must be optional. node_modules/npm/lib/config/pacote.js(23,26): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/config/pacote.js(24,13): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/config/pacote.js(25,15): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. @@ -1227,6 +1232,8 @@ node_modules/npm/test/tap/correct-mkdir.js(114,16): error TS2532: Object is poss node_modules/npm/test/tap/correct-mkdir.js(115,16): error TS2532: Object is possibly 'undefined'. node_modules/npm/test/tap/correct-mkdir.js(131,3): error TS2322: Type '999' is not assignable to type 'string | undefined'. node_modules/npm/test/tap/correct-mkdir.js(132,3): error TS2322: Type '999' is not assignable to type 'string | undefined'. +node_modules/npm/test/tap/correct-mkdir.js(133,10): error TS2790: The operand of a 'delete' operator must be optional. +node_modules/npm/test/tap/correct-mkdir.js(134,10): error TS2790: The operand of a 'delete' operator must be optional. node_modules/npm/test/tap/cruft-test.js(6,20): error TS2307: Cannot find module 'tap' or its corresponding type declarations. node_modules/npm/test/tap/debug-logs.js(3,20): error TS2307: Cannot find module 'tap' or its corresponding type declarations. node_modules/npm/test/tap/debug-logs.js(4,21): error TS2307: Cannot find module 'tacks' or its corresponding type declarations. diff --git a/tests/baselines/reference/user/puppeteer.log b/tests/baselines/reference/user/puppeteer.log index 6135c34f414..bc838695979 100644 --- a/tests/baselines/reference/user/puppeteer.log +++ b/tests/baselines/reference/user/puppeteer.log @@ -1,9 +1,5 @@ Exit Code: 1 Standard output: -src/JSHandle.ts(440,5): error TS2322: Type 'unknown' is not assignable to type 'T'. - 'unknown' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'unknown'. -src/JSHandle.ts(454,5): error TS2322: Type 'unknown' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'unknown'. src/Launcher.js(181,17): error TS1003: Identifier expected. src/Launcher.js(359,17): error TS1003: Identifier expected. From ef5f0ef58df8d7de2e88263b604c2ff6adee8a51 Mon Sep 17 00:00:00 2001 From: csigs Date: Thu, 23 Apr 2020 04:10:34 +0000 Subject: [PATCH 45/74] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index ea21fdee665..88cd2ac3e74 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1180,7 +1180,7 @@ - + @@ -3193,7 +3193,7 @@ - + @@ -7831,7 +7831,7 @@ - + @@ -10321,7 +10321,7 @@ - + @@ -11116,7 +11116,7 @@ - + @@ -11677,7 +11677,7 @@ - + From 9569e8aaa4997447a8675d89a50e53656e29e4a5 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 23 Apr 2020 11:59:38 -0700 Subject: [PATCH 46/74] Fix newline issues when adding multiple imports (#38119) * Add new import declarations in a single TextChanges call * Refactor --- src/compiler/core.ts | 22 ++++++++++++ src/services/codefixes/importFixes.ts | 36 +++++++++++-------- src/services/refactors/moveToNewFile.ts | 2 +- src/services/textChanges.ts | 18 ++++++++-- src/services/utilities.ts | 17 ++++++--- .../cases/fourslash/importNameCodeFix_all2.ts | 23 ++++++++++++ .../importNameCodeFix_exportEquals.ts | 1 - 7 files changed, 96 insertions(+), 23 deletions(-) create mode 100644 tests/cases/fourslash/importNameCodeFix_all2.ts diff --git a/src/compiler/core.ts b/src/compiler/core.ts index a309eb97c1b..2841b80aedf 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -844,6 +844,28 @@ namespace ts { return to; } + /** + * Combines two arrays, values, or undefineds into the smallest container that can accommodate the resulting set: + * + * ``` + * undefined -> undefined -> undefined + * T -> undefined -> T + * T -> T -> T[] + * T[] -> undefined -> T[] (no-op) + * T[] -> T -> T[] (append) + * T[] -> T[] -> T[] (concatenate) + * ``` + */ + export function combine(xs: T | readonly T[] | undefined, ys: T | readonly T[] | undefined): T | readonly T[] | undefined; + export function combine(xs: T | T[] | undefined, ys: T | T[] | undefined): T | T[] | undefined; + export function combine(xs: T | T[] | undefined, ys: T | T[] | undefined) { + if (xs === undefined) return ys; + if (ys === undefined) return xs; + if (isArray(xs)) return isArray(ys) ? concatenate(xs, ys) : append(xs, ys); + if (isArray(ys)) return append(ys, xs); + return [xs, ys]; + } + /** * Gets the actual offset into an array for a relative offset. Negative offsets indicate a * position offset from the end of the array. diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 57fd8c1dc6a..060d409eaa9 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -45,7 +45,6 @@ namespace ts.codefix { // Keys are import clause node IDs. const addToExisting = createMap<{ readonly importClauseOrBindingPattern: ImportClause | ObjectBindingPattern, defaultImport: string | undefined; readonly namedImports: string[], canUseTypeOnlyImport: boolean }>(); const newImports = createMap>(); - let lastModuleSpecifier: string | undefined; return { addImportFromDiagnostic, addImportFromExportedSymbol, writeFixes }; function addImportFromDiagnostic(diagnostic: DiagnosticWithLocation, context: CodeFixContextBase) { @@ -97,7 +96,6 @@ namespace ts.codefix { let entry = newImports.get(moduleSpecifier); if (!entry) { newImports.set(moduleSpecifier, entry = { namedImports: [], namespaceLikeImport: undefined, typeOnly, useRequire }); - lastModuleSpecifier = moduleSpecifier; } else { // An import clause can only be type-only if every import fix contributing to it can be type-only. @@ -135,10 +133,15 @@ namespace ts.codefix { addToExisting.forEach(({ importClauseOrBindingPattern, defaultImport, namedImports, canUseTypeOnlyImport }) => { doAddExistingFix(changeTracker, sourceFile, importClauseOrBindingPattern, defaultImport, namedImports, canUseTypeOnlyImport); }); + + let newDeclarations: Statement | readonly Statement[] | undefined; newImports.forEach(({ useRequire, ...imports }, moduleSpecifier) => { - const addDeclarations = useRequire ? addNewRequires : addNewImports; - addDeclarations(changeTracker, sourceFile, moduleSpecifier, quotePreference, imports, /*blankLineBetween*/ lastModuleSpecifier === moduleSpecifier); + const getDeclarations = useRequire ? getNewRequires : getNewImports; + newDeclarations = combine(newDeclarations, getDeclarations(moduleSpecifier, quotePreference, imports)); }); + if (newDeclarations) { + insertImports(changeTracker, sourceFile, newDeclarations, /*blankLineBetween*/ true); + } } } @@ -631,11 +634,11 @@ namespace ts.codefix { } case ImportFixKind.AddNew: { const { importKind, moduleSpecifier, typeOnly, useRequire } = fix; - const addDeclarations = useRequire ? addNewRequires : addNewImports; + const getDeclarations = useRequire ? getNewRequires : getNewImports; const importsCollection = importKind === ImportKind.Default ? { defaultImport: symbolName, typeOnly } : importKind === ImportKind.Named ? { namedImports: [symbolName], typeOnly } : { namespaceLikeImport: { importKind, name: symbolName }, typeOnly }; - addDeclarations(changes, sourceFile, moduleSpecifier, quotePreference, importsCollection, /*blankLineBetween*/ true); + insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, importsCollection), /*blankLineBetween*/ true); return [importKind === ImportKind.Default ? Diagnostics.Import_default_0_from_module_1 : Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: @@ -717,13 +720,13 @@ namespace ts.codefix { readonly name: string; }; } - function addNewImports(changes: textChanges.ChangeTracker, sourceFile: SourceFile, moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection, blankLineBetween: boolean): void { + function getNewImports(moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection): Statement | readonly Statement[] { const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference); + let statements: Statement | readonly Statement[] | undefined; if (imports.defaultImport !== undefined || imports.namedImports?.length) { - insertImport(changes, sourceFile, - makeImport( - imports.defaultImport === undefined ? undefined : createIdentifier(imports.defaultImport), - imports.namedImports?.map(n => createImportSpecifier(/*propertyName*/ undefined, createIdentifier(n))), moduleSpecifier, quotePreference, imports.typeOnly), /*blankLineBetween*/ blankLineBetween); + statements = combine(statements, makeImport( + imports.defaultImport === undefined ? undefined : createIdentifier(imports.defaultImport), + imports.namedImports?.map(n => createImportSpecifier(/*propertyName*/ undefined, createIdentifier(n))), moduleSpecifier, quotePreference, imports.typeOnly)); } const { namespaceLikeImport, typeOnly } = imports; if (namespaceLikeImport) { @@ -741,12 +744,14 @@ namespace ts.codefix { createNamespaceImport(createIdentifier(namespaceLikeImport.name)), typeOnly), quotedModuleSpecifier); - insertImport(changes, sourceFile, declaration, /*blankLineBetween*/ blankLineBetween); + statements = combine(statements, declaration); } + return Debug.checkDefined(statements); } - function addNewRequires(changes: textChanges.ChangeTracker, sourceFile: SourceFile, moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection, blankLineBetween: boolean) { + function getNewRequires(moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection): Statement | readonly Statement[] { const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference); + let statements: Statement | readonly Statement[] | undefined; // const { default: foo, bar, etc } = require('./mod'); if (imports.defaultImport || imports.namedImports?.length) { const bindingElements = imports.namedImports?.map(name => createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, name)) || []; @@ -754,13 +759,14 @@ namespace ts.codefix { bindingElements.unshift(createBindingElement(/*dotDotDotToken*/ undefined, "default", imports.defaultImport)); } const declaration = createConstEqualsRequireDeclaration(createObjectBindingPattern(bindingElements), quotedModuleSpecifier); - insertImport(changes, sourceFile, declaration, blankLineBetween); + statements = combine(statements, declaration); } // const foo = require('./mod'); if (imports.namespaceLikeImport) { const declaration = createConstEqualsRequireDeclaration(imports.namespaceLikeImport.name, quotedModuleSpecifier); - insertImport(changes, sourceFile, declaration, blankLineBetween); + statements = combine(statements, declaration); } + return Debug.checkDefined(statements); } function createConstEqualsRequireDeclaration(name: string | ObjectBindingPattern, quotedModuleSpecifier: StringLiteral): VariableStatement { diff --git a/src/services/refactors/moveToNewFile.ts b/src/services/refactors/moveToNewFile.ts index a9b8171cbc9..6a9e8df6bd7 100644 --- a/src/services/refactors/moveToNewFile.ts +++ b/src/services/refactors/moveToNewFile.ts @@ -121,7 +121,7 @@ namespace ts.refactor { const quotePreference = getQuotePreference(oldFile, preferences); const importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, quotePreference); if (importsFromNewFile) { - insertImport(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true); + insertImports(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true); } deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 2b743f4d592..e5b34b8d508 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -349,11 +349,25 @@ namespace ts.textChanges { } public insertNodeAtTopOfFile(sourceFile: SourceFile, newNode: Statement, blankLineBetween: boolean): void { + this.insertAtTopOfFile(sourceFile, newNode, blankLineBetween); + } + + public insertNodesAtTopOfFile(sourceFile: SourceFile, newNodes: readonly Statement[], blankLineBetween: boolean): void { + this.insertAtTopOfFile(sourceFile, newNodes, blankLineBetween); + } + + private insertAtTopOfFile(sourceFile: SourceFile, insert: Statement | readonly Statement[], blankLineBetween: boolean): void { const pos = getInsertionPositionAtSourceFileTop(sourceFile); - this.insertNodeAt(sourceFile, pos, newNode, { + const options = { prefix: pos === 0 ? undefined : this.newLineCharacter, suffix: (isLineBreak(sourceFile.text.charCodeAt(pos)) ? "" : this.newLineCharacter) + (blankLineBetween ? this.newLineCharacter : ""), - }); + }; + if (isArray(insert)) { + this.insertNodesAt(sourceFile, pos, insert, options); + } + else { + this.insertNodeAt(sourceFile, pos, insert, options); + } } public insertFirstParameter(sourceFile: SourceFile, parameters: NodeArray, newParam: ParameterDeclaration): void { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index a621b10e838..4eb45265800 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1871,14 +1871,23 @@ namespace ts { return node.modifiers && find(node.modifiers, m => m.kind === kind); } - export function insertImport(changes: textChanges.ChangeTracker, sourceFile: SourceFile, importDecl: Statement, blankLineBetween: boolean): void { - const importKindPredicate = importDecl.kind === SyntaxKind.VariableStatement ? isRequireVariableDeclarationStatement : isAnyImportSyntax; + export function insertImports(changes: textChanges.ChangeTracker, sourceFile: SourceFile, imports: Statement | readonly Statement[], blankLineBetween: boolean): void { + const decl = isArray(imports) ? imports[0] : imports; + const importKindPredicate = decl.kind === SyntaxKind.VariableStatement ? isRequireVariableDeclarationStatement : isAnyImportSyntax; const lastImportDeclaration = findLast(sourceFile.statements, statement => importKindPredicate(statement)); if (lastImportDeclaration) { - changes.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl); + if (isArray(imports)) { + changes.insertNodesAfter(sourceFile, lastImportDeclaration, imports); + } + else { + changes.insertNodeAfter(sourceFile, lastImportDeclaration, imports); + } + } + else if (isArray(imports)) { + changes.insertNodesAtTopOfFile(sourceFile, imports, blankLineBetween); } else { - changes.insertNodeAtTopOfFile(sourceFile, importDecl, blankLineBetween); + changes.insertNodeAtTopOfFile(sourceFile, imports, blankLineBetween); } } diff --git a/tests/cases/fourslash/importNameCodeFix_all2.ts b/tests/cases/fourslash/importNameCodeFix_all2.ts new file mode 100644 index 00000000000..6f7a9b3403c --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFix_all2.ts @@ -0,0 +1,23 @@ +/// + +// @Filename: /path.ts +////export declare function join(): void; + +// @Filename: /os.ts +////export declare function homedir(): void; + +// @Filename: /index.ts +//// +////join(); +////homedir(); + +goTo.file("/index.ts"); +verify.codeFixAll({ + fixId: "fixMissingImport", + fixAllDescription: "Add all missing imports", + newFileContent: `import { join } from "./path"; +import { homedir } from "./os"; + +join(); +homedir();` +}); diff --git a/tests/cases/fourslash/importNameCodeFix_exportEquals.ts b/tests/cases/fourslash/importNameCodeFix_exportEquals.ts index 4ab87df7e76..e413c4d4e1d 100644 --- a/tests/cases/fourslash/importNameCodeFix_exportEquals.ts +++ b/tests/cases/fourslash/importNameCodeFix_exportEquals.ts @@ -17,7 +17,6 @@ verify.codeFixAll({ fixAllDescription: "Add all missing imports", newFileContent: `import { b } from "./a"; - import a = require("./a"); a; From d7e437a409847ec4467cbc153fe9deb70722b33b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 23 Apr 2020 12:54:49 -0700 Subject: [PATCH 47/74] Have the `ChangeTracker` filter out edits that are no-ops (#38123) * Filter out edits that are no-ops in 'organize imports'. * Updated tests for 'organize imports'. * Always remove no-op changes from the change tracker. * Add a new `stringContainsAt` helper function to avoid traversing the entire file contents. * Combine `map`/`filter` sequence into `mapDefined`. * Fix up documentation. --- src/services/textChanges.ts | 19 +++++-- src/services/utilities.ts | 29 ++++++++++ .../unittests/services/organizeImports.ts | 54 +++++++++++++++---- 3 files changed, 87 insertions(+), 15 deletions(-) diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index e5b34b8d508..245306ac109 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -887,7 +887,7 @@ namespace ts.textChanges { namespace changesToText { export function getTextChangesFromChanges(changes: readonly Change[], newLineCharacter: string, formatContext: formatting.FormatContext, validate: ValidateNonFormattedText | undefined): FileTextChanges[] { - return group(changes, c => c.sourceFile.path).map(changesInFile => { + return mapDefined(group(changes, c => c.sourceFile.path), changesInFile => { const sourceFile = changesInFile[0].sourceFile; // order changes by start position // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa. @@ -897,9 +897,20 @@ namespace ts.textChanges { Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", () => `${JSON.stringify(normalized[i].range)} and ${JSON.stringify(normalized[i + 1].range)}`); } - const textChanges = normalized.map(c => - createTextChange(createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate))); - return { fileName: sourceFile.fileName, textChanges }; + + const textChanges = mapDefined(normalized, c => { + const span = createTextSpanFromRange(c.range); + const newText = computeNewText(c, sourceFile, newLineCharacter, formatContext, validate); + + // Filter out redundant changes. + if (span.length === newText.length && stringContainsAt(sourceFile.text, newText, span.start)) { + return undefined; + } + + return createTextChange(span, newText); + }); + + return textChanges.length > 0 ? { fileName: sourceFile.fileName, textChanges } : undefined; }); } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 4eb45265800..58f53198f79 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -2827,6 +2827,35 @@ namespace ts { return symbol.name; } + /** + * Useful to check whether a string contains another string at a specific index + * without allocating another string or traversing the entire contents of the outer string. + * + * This function is useful in place of either of the following: + * + * ```ts + * // Allocates + * haystack.substr(startIndex, needle.length) === needle + * + * // Full traversal + * haystack.indexOf(needle, startIndex) === startIndex + * ``` + * + * @param haystack The string that potentially contains `needle`. + * @param needle The string whose content might sit within `haystack`. + * @param startIndex The index within `haystack` to start searching for `needle`. + */ + export function stringContainsAt(haystack: string, needle: string, startIndex: number) { + const needleLength = needle.length; + if (needleLength + startIndex > haystack.length) { + return false; + } + for (let i = 0; i < needleLength; i++) { + if (needle.charCodeAt(i) !== haystack.charCodeAt(i + startIndex)) return false; + } + return true; + } + export function startsWithUnderscore(name: string): boolean { return name.charCodeAt(0) === CharacterCodes._; } diff --git a/src/testRunner/unittests/services/organizeImports.ts b/src/testRunner/unittests/services/organizeImports.ts index 6627616a67d..627928c03e8 100644 --- a/src/testRunner/unittests/services/organizeImports.ts +++ b/src/testRunner/unittests/services/organizeImports.ts @@ -285,6 +285,7 @@ namespace ts { }); }); + describe("Baselines", () => { const libFile = { @@ -327,6 +328,16 @@ export const Other = 1; assert.isEmpty(changes); }); + it("doesn't return any changes when the text would be identical", () => { + const testFile = { + path: "/a.ts", + content: `import { f } from 'foo';\nf();` + }; + const languageService = makeLanguageService(testFile); + const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions); + assert.isEmpty(changes); + }); + testOrganizeImports("Renamed_used", { path: "/test.ts", @@ -366,6 +377,16 @@ D(); }, libFile); + it("doesn't return any changes when the text would be identical", () => { + const testFile = { + path: "/a.ts", + content: `import { f } from 'foo';\nf();` + }; + const languageService = makeLanguageService(testFile); + const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions); + assert.isEmpty(changes); + }); + testOrganizeImports("Unused_All", { path: "/test.ts", @@ -377,14 +398,17 @@ import D from "lib"; }, libFile); - testOrganizeImports("Unused_Empty", - { + it("Unused_Empty", () => { + const testFile = { path: "/test.ts", content: ` import { } from "lib"; `, - }, - libFile); + }; + const languageService = makeLanguageService(testFile); + const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions); + assert.isEmpty(changes); + }); testOrganizeImports("Unused_false_positive_module_augmentation", { @@ -414,25 +438,33 @@ declare module 'caseless' { test(name: KeyType): boolean; } }` - }); + }); - testOrganizeImports("Unused_false_positive_shorthand_assignment", - { + it("Unused_false_positive_shorthand_assignment", () => { + const testFile = { path: "/test.ts", content: ` import { x } from "a"; const o = { x }; ` - }); + }; + const languageService = makeLanguageService(testFile); + const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions); + assert.isEmpty(changes); + }); - testOrganizeImports("Unused_false_positive_export_shorthand", - { + it("Unused_false_positive_export_shorthand", () => { + const testFile = { path: "/test.ts", content: ` import { x } from "a"; export { x }; ` - }); + }; + const languageService = makeLanguageService(testFile); + const changes = languageService.organizeImports({ type: "file", fileName: testFile.path }, testFormatSettings, emptyOptions); + assert.isEmpty(changes); + }); testOrganizeImports("MoveToTop", { From 815dc90dc508b24a37b4b0c3fa7ece04f3596f84 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 23 Apr 2020 19:01:16 -0700 Subject: [PATCH 48/74] Issue an error on cross-file merges we cant emit (#38148) --- src/compiler/checker.ts | 7 +++- src/compiler/diagnosticMessages.json | 8 +++++ src/compiler/transformers/declarations.ts | 14 +++++++- src/compiler/types.ts | 1 + .../jsDeclarationsCrossfileMerge.errors.txt | 17 ++++++++++ .../reference/jsDeclarationsCrossfileMerge.js | 28 ++++++++++++++++ .../jsDeclarationsCrossfileMerge.symbols | 28 ++++++++++++++++ .../jsDeclarationsCrossfileMerge.types | 32 +++++++++++++++++++ .../jsDeclarationsCrossfileMerge.ts | 16 ++++++++++ 9 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/jsDeclarationsCrossfileMerge.errors.txt create mode 100644 tests/baselines/reference/jsDeclarationsCrossfileMerge.js create mode 100644 tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols create mode 100644 tests/baselines/reference/jsDeclarationsCrossfileMerge.types create mode 100644 tests/cases/conformance/jsdoc/declarations/jsDeclarationsCrossfileMerge.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac46ee7e163..6320ff7d128 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6029,14 +6029,19 @@ namespace ts { serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (SymbolFlags.Function | SymbolFlags.Assignment))); } if (length(mergedMembers)) { + const containingFile = getSourceFileOfNode(context.enclosingDeclaration); const localName = getInternalSymbolName(symbol, symbolName); const nsBody = createModuleBlock([createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - createNamedExports(map(filter(mergedMembers, n => n.escapedName !== InternalSymbolName.ExportEquals), s => { + createNamedExports(mapDefined(filter(mergedMembers, n => n.escapedName !== InternalSymbolName.ExportEquals), s => { const name = unescapeLeadingUnderscores(s.escapedName); const localName = getInternalSymbolName(s, name); const aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s); + if (containingFile && (aliasDecl ? containingFile !== getSourceFileOfNode(aliasDecl) : !some(s.declarations, d => getSourceFileOfNode(d) === containingFile))) { + context.tracker?.reportNonlocalAugmentation?.(containingFile, symbol, s); + return undefined; + } const target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); includePrivateSymbol(target || s); const targetName = target ? getInternalSymbolName(target, unescapeLeadingUnderscores(target.escapedName)) : localName; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4a7c6e8b461..17b3dd829bd 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4388,6 +4388,14 @@ "category": "Error", "code": 6231 }, + "Declaration augments declaration in another file. This cannot be serialized.": { + "category": "Error", + "code": 6232 + }, + "This is the declaration being augmented. Consider moving the augmenting declaration into the same file.": { + "category": "Error", + "code": 6233 + }, "Projects to reference": { "category": "Message", diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 70f70a98c3e..413ff8f8cd2 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -76,7 +76,8 @@ namespace ts { reportLikelyUnsafeImportRequiredError, moduleResolverHost: host, trackReferencedAmbientModule, - trackExternalModuleSymbolOfImportTypeNode + trackExternalModuleSymbolOfImportTypeNode, + reportNonlocalAugmentation }; let errorNameNode: DeclarationName | undefined; @@ -190,6 +191,17 @@ namespace ts { } } + function reportNonlocalAugmentation(containingFile: SourceFile, parentSymbol: Symbol, symbol: Symbol) { + const primaryDeclaration = find(parentSymbol.declarations, d => getSourceFileOfNode(d) === containingFile)!; + const augmentingDeclarations = filter(symbol.declarations, d => getSourceFileOfNode(d) !== containingFile); + for (const augmentations of augmentingDeclarations) { + context.addDiagnostic(addRelatedInfo( + createDiagnosticForNode(augmentations, Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), + createDiagnosticForNode(primaryDeclaration, Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file) + )); + } + } + function transformDeclarationsForJS(sourceFile: SourceFile, bundled?: boolean) { const oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = (s) => ({ diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8e781b23ee7..70bc9b01528 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6468,6 +6468,7 @@ namespace ts { moduleResolverHost?: ModuleSpecifierResolutionHost & { getCommonSourceDirectory(): string }; trackReferencedAmbientModule?(decl: ModuleDeclaration, symbol: Symbol): void; trackExternalModuleSymbolOfImportTypeNode?(symbol: Symbol): void; + reportNonlocalAugmentation?(containingFile: SourceFile, parentSymbol: Symbol, augmentingSymbol: Symbol): void; } export interface TextSpan { diff --git a/tests/baselines/reference/jsDeclarationsCrossfileMerge.errors.txt b/tests/baselines/reference/jsDeclarationsCrossfileMerge.errors.txt new file mode 100644 index 00000000000..cd0bc2e0a3d --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsCrossfileMerge.errors.txt @@ -0,0 +1,17 @@ +tests/cases/conformance/jsdoc/declarations/index.js(4,1): error TS6232: Declaration augments declaration in another file. This cannot be serialized. + + +==== tests/cases/conformance/jsdoc/declarations/index.js (1 errors) ==== + const m = require("./exporter"); + + module.exports = m.default; + module.exports.memberName = "thing"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS6232: Declaration augments declaration in another file. This cannot be serialized. +!!! related TS6233 /.src/tests/cases/conformance/jsdoc/declarations/exporter.js:1:10: This is the declaration being augmented. Consider moving the augmenting declaration into the same file. + +==== tests/cases/conformance/jsdoc/declarations/exporter.js (0 errors) ==== + function validate() {} + + export default validate; + \ No newline at end of file diff --git a/tests/baselines/reference/jsDeclarationsCrossfileMerge.js b/tests/baselines/reference/jsDeclarationsCrossfileMerge.js new file mode 100644 index 00000000000..9e99ba43fc5 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsCrossfileMerge.js @@ -0,0 +1,28 @@ +//// [tests/cases/conformance/jsdoc/declarations/jsDeclarationsCrossfileMerge.ts] //// + +//// [index.js] +const m = require("./exporter"); + +module.exports = m.default; +module.exports.memberName = "thing"; + +//// [exporter.js] +function validate() {} + +export default validate; + + +//// [exporter.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function validate() { } +exports.default = validate; +//// [index.js] +var m = require("./exporter"); +module.exports = m.default; +module.exports.memberName = "thing"; + + +//// [index.d.ts] +declare const _exports: typeof import("./exporter").default; +export = _exports; diff --git a/tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols b/tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols new file mode 100644 index 00000000000..99455853c4c --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const m = require("./exporter"); +>m : Symbol(m, Decl(index.js, 0, 5)) +>require : Symbol(require) +>"./exporter" : Symbol("tests/cases/conformance/jsdoc/declarations/exporter", Decl(exporter.js, 0, 0)) + +module.exports = m.default; +>module.exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>module : Symbol(export=, Decl(index.js, 0, 32)) +>exports : Symbol(export=, Decl(index.js, 0, 32)) +>m.default : Symbol(default, Decl(exporter.js, 0, 22)) +>m : Symbol(m, Decl(index.js, 0, 5)) +>default : Symbol(default, Decl(exporter.js, 0, 22)) + +module.exports.memberName = "thing"; +>module.exports.memberName : Symbol(memberName) +>module.exports : Symbol(memberName, Decl(index.js, 2, 27)) +>module : Symbol(module, Decl(index.js, 0, 32)) +>exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) +>memberName : Symbol(memberName, Decl(index.js, 2, 27)) + +=== tests/cases/conformance/jsdoc/declarations/exporter.js === +function validate() {} +>validate : Symbol(validate, Decl(exporter.js, 0, 0)) + +export default validate; +>validate : Symbol(validate, Decl(exporter.js, 0, 0)) + diff --git a/tests/baselines/reference/jsDeclarationsCrossfileMerge.types b/tests/baselines/reference/jsDeclarationsCrossfileMerge.types new file mode 100644 index 00000000000..8de95cf8567 --- /dev/null +++ b/tests/baselines/reference/jsDeclarationsCrossfileMerge.types @@ -0,0 +1,32 @@ +=== tests/cases/conformance/jsdoc/declarations/index.js === +const m = require("./exporter"); +>m : typeof import("tests/cases/conformance/jsdoc/declarations/exporter") +>require("./exporter") : typeof import("tests/cases/conformance/jsdoc/declarations/exporter") +>require : any +>"./exporter" : "./exporter" + +module.exports = m.default; +>module.exports = m.default : typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default +>module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default; } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default +>m.default : { (): void; memberName: string; } +>m : typeof import("tests/cases/conformance/jsdoc/declarations/exporter") +>default : { (): void; memberName: string; } + +module.exports.memberName = "thing"; +>module.exports.memberName = "thing" : "thing" +>module.exports.memberName : string +>module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default +>module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default; } +>exports : typeof import("tests/cases/conformance/jsdoc/declarations/exporter").default +>memberName : string +>"thing" : "thing" + +=== tests/cases/conformance/jsdoc/declarations/exporter.js === +function validate() {} +>validate : typeof validate + +export default validate; +>validate : typeof validate + diff --git a/tests/cases/conformance/jsdoc/declarations/jsDeclarationsCrossfileMerge.ts b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsCrossfileMerge.ts new file mode 100644 index 00000000000..7f1624e6d87 --- /dev/null +++ b/tests/cases/conformance/jsdoc/declarations/jsDeclarationsCrossfileMerge.ts @@ -0,0 +1,16 @@ +// @allowJs: true +// @checkJs: true +// @target: es5 +// @lib: es6 +// @outDir: ./out +// @declaration: true +// @filename: index.js +const m = require("./exporter"); + +module.exports = m.default; +module.exports.memberName = "thing"; + +// @filename: exporter.js +function validate() {} + +export default validate; From a7d6825e25b44414adefdac0156b5c9d92a0d18b Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 23 Apr 2020 20:45:39 -0700 Subject: [PATCH 49/74] Fix temp vars referenced in parameter (#38130) * Fix temp vars referenced in parameter * Update error message --- src/compiler/checker.ts | 91 ++++- src/compiler/diagnosticMessages.json | 4 +- src/compiler/factory.ts | 13 +- src/compiler/transformer.ts | 57 ++- src/compiler/transformers/classFields.ts | 2 +- src/compiler/transformers/es2015.ts | 2 + src/compiler/transformers/es2020.ts | 380 +++++++++--------- src/compiler/types.ts | 15 + src/compiler/utilities.ts | 20 + src/compiler/visitor.ts | 97 ++++- src/compiler/visitorPublic.ts | 113 +++++- .../FunctionDeclaration3_es6.errors.txt | 4 +- .../reference/api/tsserverlibrary.d.ts | 3 +- tests/baselines/reference/api/typescript.d.ts | 3 +- .../asyncArrowFunction3_es2017.errors.txt | 4 +- .../asyncArrowFunction3_es5.errors.txt | 4 +- .../asyncArrowFunction3_es6.errors.txt | 4 +- ...syncFunctionDeclaration3_es2017.errors.txt | 4 +- .../asyncFunctionDeclaration3_es5.errors.txt | 4 +- .../asyncFunctionDeclaration3_es6.errors.txt | 4 +- ...pturedParametersInInitializers1.errors.txt | 12 +- ...pturedParametersInInitializers2.errors.txt | 16 +- .../capturedParametersInInitializers2.js | 4 +- .../circularOptionalityRemoval.errors.txt | 12 +- ...nParameterBindingPattern(target=es2015).js | 10 + ...ldInParameterBindingPattern(target=es5).js | 16 + ...nParameterBindingPattern(target=esnext).js | 10 + ...BindingPattern.2(target=es2015).errors.txt | 16 + ...terBindingPattern.2(target=es5).errors.txt | 16 + ...BindingPattern.2(target=esnext).errors.txt | 16 + ...ldInParameterInitializer(target=es2015).js | 10 + ...FieldInParameterInitializer(target=es5).js | 16 + ...ldInParameterInitializer(target=esnext).js | 10 + ...terInitializer.2(target=es2015).errors.txt | 15 + ...ameterInitializer.2(target=es5).errors.txt | 15 + ...terInitializer.2(target=esnext).errors.txt | 15 + ...rayBindingPatternAndAssignment3.errors.txt | 8 +- .../functionImplementationErrors.errors.txt | 8 +- ...nParameterBindingPattern(target=es2015).js | 9 + ...orInParameterBindingPattern(target=es5).js | 12 + ...nParameterBindingPattern(target=esnext).js | 9 + ...BindingPattern.2(target=es2015).errors.txt | 15 + ...terBindingPattern.2(target=es5).errors.txt | 15 + ...orInParameterInitializer(target=es2015).js | 9 + ...ratorInParameterInitializer(target=es5).js | 12 + ...orInParameterInitializer(target=esnext).js | 9 + ...terInitializer.2(target=es2015).errors.txt | 15 + ...ameterInitializer.2(target=es5).errors.txt | 15 + ...nParameterBindingPattern(target=es2015).js | 9 + ...ngInParameterBindingPattern(target=es5).js | 12 + ...nParameterBindingPattern(target=esnext).js | 9 + ...BindingPattern.2(target=es2015).errors.txt | 15 + ...terBindingPattern.2(target=es5).errors.txt | 15 + ...ngInParameterInitializer(target=es2015).js | 9 + ...iningInParameterInitializer(target=es5).js | 12 + ...ngInParameterInitializer(target=esnext).js | 9 + ...terInitializer.2(target=es2015).errors.txt | 15 + ...ameterInitializer.2(target=es5).errors.txt | 15 + ...nalParamReferencingOtherParams2.errors.txt | 4 +- ...nalParamReferencingOtherParams3.errors.txt | 4 +- ...ardReferencing.2(target=es2015).errors.txt | 25 ++ ...orwardReferencing.2(target=es5).errors.txt | 25 ++ ...rInitializersForwardReferencing.errors.txt | 40 +- ...InitializersForwardReferencing1.errors.txt | 21 +- ...ializersForwardReferencing1_es6.errors.txt | 12 +- ...fReferencesInFunctionParameters.errors.txt | 16 +- tests/baselines/reference/witness.errors.txt | 4 +- ...hStaticFieldInParameterBindingPattern.2.ts | 10 + ...hStaticFieldInParameterBindingPattern.3.ts | 11 + ...ithStaticFieldInParameterBindingPattern.ts | 5 + ...WithStaticFieldInParameterInitializer.2.ts | 10 + ...WithStaticFieldInParameterInitializer.3.ts | 11 + ...ssWithStaticFieldInParameterInitializer.ts | 5 + ...cingOperatorInParameterBindingPattern.2.ts | 10 + ...escingOperatorInParameterBindingPattern.ts | 6 + ...lescingOperatorInParameterInitializer.2.ts | 10 + ...oalescingOperatorInParameterInitializer.ts | 6 + ...onalChainingInParameterBindingPattern.2.ts | 10 + ...tionalChainingInParameterBindingPattern.ts | 6 + ...ptionalChainingInParameterInitializer.2.ts | 10 + .../optionalChainingInParameterInitializer.ts | 6 + ...rameterInitializersForwardReferencing.2.ts | 17 + 82 files changed, 1265 insertions(+), 312 deletions(-) create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=es2015).js create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=es5).js create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=esnext).js create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=es2015).errors.txt create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=es5).errors.txt create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=esnext).errors.txt create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=es2015).js create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=es5).js create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=esnext).js create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=es2015).errors.txt create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=es5).errors.txt create mode 100644 tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=esnext).errors.txt create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=es2015).js create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=es5).js create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=esnext).js create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern.2(target=es2015).errors.txt create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern.2(target=es5).errors.txt create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=es2015).js create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=es5).js create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=esnext).js create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer.2(target=es2015).errors.txt create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer.2(target=es5).errors.txt create mode 100644 tests/baselines/reference/optionalChainingInParameterBindingPattern(target=es2015).js create mode 100644 tests/baselines/reference/optionalChainingInParameterBindingPattern(target=es5).js create mode 100644 tests/baselines/reference/optionalChainingInParameterBindingPattern(target=esnext).js create mode 100644 tests/baselines/reference/optionalChainingInParameterBindingPattern.2(target=es2015).errors.txt create mode 100644 tests/baselines/reference/optionalChainingInParameterBindingPattern.2(target=es5).errors.txt create mode 100644 tests/baselines/reference/optionalChainingInParameterInitializer(target=es2015).js create mode 100644 tests/baselines/reference/optionalChainingInParameterInitializer(target=es5).js create mode 100644 tests/baselines/reference/optionalChainingInParameterInitializer(target=esnext).js create mode 100644 tests/baselines/reference/optionalChainingInParameterInitializer.2(target=es2015).errors.txt create mode 100644 tests/baselines/reference/optionalChainingInParameterInitializer.2(target=es5).errors.txt create mode 100644 tests/baselines/reference/parameterInitializersForwardReferencing.2(target=es2015).errors.txt create mode 100644 tests/baselines/reference/parameterInitializersForwardReferencing.2(target=es5).errors.txt create mode 100644 tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts create mode 100644 tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3.ts create mode 100644 tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.ts create mode 100644 tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts create mode 100644 tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.3.ts create mode 100644 tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.ts create mode 100644 tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.2.ts create mode 100644 tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.ts create mode 100644 tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2.ts create mode 100644 tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.ts create mode 100644 tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2.ts create mode 100644 tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.ts create mode 100644 tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.2.ts create mode 100644 tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.ts create mode 100644 tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6320ff7d128..52a667a1451 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1529,6 +1529,63 @@ namespace ts { } } + function useOuterVariableScopeInParameter(result: Symbol, location: Node, lastLocation: Node) { + const target = getEmitScriptTarget(compilerOptions); + const functionLocation = location; + if (isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) { + // check for several cases where we introduce temporaries that require moving the name/initializer of the parameter to the body + // - static field in a class expression + // - optional chaining pre-es2020 + // - nullish coalesce pre-es2020 + // - spread assignment in binding pattern pre-es2017 + if (target >= ScriptTarget.ES2015) { + const links = getNodeLinks(functionLocation); + if (links.declarationRequiresScopeChange === undefined) { + links.declarationRequiresScopeChange = forEach(functionLocation.parameters, requiresScopeChange) || false; + } + return !links.declarationRequiresScopeChange; + } + } + return false; + + function requiresScopeChange(node: ParameterDeclaration): boolean { + return requiresScopeChangeWorker(node.name) + || !!node.initializer && requiresScopeChangeWorker(node.initializer); + } + + function requiresScopeChangeWorker(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.ArrowFunction: + case SyntaxKind.FunctionExpression: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.Constructor: + // do not descend into these + return false; + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.PropertyAssignment: + return requiresScopeChangeWorker((node as MethodDeclaration | AccessorDeclaration | PropertyAssignment).name); + case SyntaxKind.PropertyDeclaration: + // static properties in classes introduce temporary variables + if (hasStaticModifier(node)) { + return target < ScriptTarget.ESNext || !compilerOptions.useDefineForClassFields; + } + return requiresScopeChangeWorker((node as PropertyDeclaration).name); + default: + // null coalesce and optional chain pre-es2020 produce temporary variables + if (isNullishCoalesce(node) || isOptionalChain(node)) { + return target < ScriptTarget.ES2020; + } + if (isBindingElement(node) && node.dotDotDotToken && isObjectBindingPattern(node.parent)) { + return target < ScriptTarget.ES2017; + } + if (isTypeNode(node)) return false; + return forEachChild(node, requiresScopeChangeWorker) || false; + } + } + } + /** * Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and * the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with @@ -1563,7 +1620,7 @@ namespace ts { let lastLocation: Node | undefined; let lastSelfReferenceLocation: Node | undefined; let propertyWithInvalidInitializer: Node | undefined; - let associatedDeclarationForContainingInitializer: ParameterDeclaration | BindingElement | undefined; + let associatedDeclarationForContainingInitializerOrBindingName: ParameterDeclaration | BindingElement | undefined; let withinDeferredContext = false; const errorLocation = location; let grandparent: Node; @@ -1592,9 +1649,7 @@ namespace ts { } if (meaning & result.flags & SymbolFlags.Variable) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ - const functionLocation = location; - if (compilerOptions.target && compilerOptions.target >= ScriptTarget.ES2015 && isParameter(lastLocation) && - functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) { + if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } else if (result.flags & SymbolFlags.FunctionScopedVariable) { @@ -1822,15 +1877,21 @@ namespace ts { location = getJSDocHost(location); break; case SyntaxKind.Parameter: - if (lastLocation && lastLocation === (location as ParameterDeclaration).initializer) { - associatedDeclarationForContainingInitializer = location as ParameterDeclaration; + if (lastLocation && ( + lastLocation === (location as ParameterDeclaration).initializer || + lastLocation === (location as ParameterDeclaration).name && isBindingPattern(lastLocation))) { + if (!associatedDeclarationForContainingInitializerOrBindingName) { + associatedDeclarationForContainingInitializerOrBindingName = location as ParameterDeclaration; + } } break; case SyntaxKind.BindingElement: - if (lastLocation && lastLocation === (location as BindingElement).initializer) { + if (lastLocation && ( + lastLocation === (location as BindingElement).initializer || + lastLocation === (location as BindingElement).name && isBindingPattern(lastLocation))) { const root = getRootDeclaration(location); if (root.kind === SyntaxKind.Parameter) { - associatedDeclarationForContainingInitializer = location as BindingElement; + associatedDeclarationForContainingInitializerOrBindingName = location as BindingElement; } } break; @@ -1941,17 +2002,17 @@ namespace ts { } } - // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & SymbolFlags.Value) === SymbolFlags.Value) { + // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & SymbolFlags.Value) === SymbolFlags.Value) { const candidate = getMergedSymbol(getLateBoundSymbol(result)); - const root = (getRootDeclaration(associatedDeclarationForContainingInitializer) as ParameterDeclaration); + const root = (getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName) as ParameterDeclaration); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself - if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializer)) { - error(errorLocation, Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, declarationNameToString(associatedDeclarationForContainingInitializer.name)); + if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) { + error(errorLocation, Diagnostics.Parameter_0_cannot_reference_itself, declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name)); } // And it cannot refer to any declarations which come after it - else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializer.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) { - error(errorLocation, Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, declarationNameToString(associatedDeclarationForContainingInitializer.name), declarationNameToString(errorLocation)); + else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) { + error(errorLocation, Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), declarationNameToString(errorLocation)); } } if (result && errorLocation && meaning & SymbolFlags.Value && result.flags & SymbolFlags.Alias) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 17b3dd829bd..03f42608454 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1477,11 +1477,11 @@ "category": "Error", "code": 2371 }, - "Parameter '{0}' cannot be referenced in its initializer.": { + "Parameter '{0}' cannot reference itself.": { "category": "Error", "code": 2372 }, - "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it.": { + "Parameter '{0}' cannot reference identifier '{1}' declared after it.": { "category": "Error", "code": 2373 }, diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 2b6e19cd179..ed854342245 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -4,11 +4,14 @@ namespace ts { enableEmitNotification: noop, enableSubstitution: noop, endLexicalEnvironment: returnUndefined, - getCompilerOptions: notImplemented, + getCompilerOptions: () => ({}), getEmitHost: notImplemented, getEmitResolver: notImplemented, + setLexicalEnvironmentFlags: noop, + getLexicalEnvironmentFlags: () => 0, hoistFunctionDeclaration: noop, hoistVariableDeclaration: noop, + addInitializationStatement: noop, isEmitNotificationEnabled: notImplemented, isSubstitutionEnabled: notImplemented, onEmitNode: noop, @@ -852,13 +855,13 @@ namespace ts { * This function needs to be called whenever we transform the statement * list of a source file, namespace, or function-like body. */ - export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number, visitor?: (node: Node) => VisitResult): number; - export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult): number | undefined; - export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult): number | undefined { + export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number, visitor?: (node: Node) => VisitResult, filter?: (node: Node) => boolean): number; + export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult, filter?: (node: Node) => boolean): number | undefined; + export function addCustomPrologue(target: Statement[], source: readonly Statement[], statementOffset: number | undefined, visitor?: (node: Node) => VisitResult, filter: (node: Node) => boolean = returnTrue): number | undefined { const numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { const statement = source[statementOffset]; - if (getEmitFlags(statement) & EmitFlags.CustomPrologue) { + if (getEmitFlags(statement) & EmitFlags.CustomPrologue && filter(statement)) { append(target, visitor ? visitNode(statement, visitor, isStatement) : statement); } else { diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index a3784a62a82..bd794d88482 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -148,8 +148,12 @@ namespace ts { const enabledSyntaxKindFeatures = new Array(SyntaxKind.Count); let lexicalEnvironmentVariableDeclarations: VariableDeclaration[]; let lexicalEnvironmentFunctionDeclarations: FunctionDeclaration[]; + let lexicalEnvironmentStatements: Statement[]; + let lexicalEnvironmentFlags = LexicalEnvironmentFlags.None; let lexicalEnvironmentVariableDeclarationsStack: VariableDeclaration[][] = []; let lexicalEnvironmentFunctionDeclarationsStack: FunctionDeclaration[][] = []; + let lexicalEnvironmentStatementsStack: Statement[][] = []; + let lexicalEnvironmentFlagsStack: LexicalEnvironmentFlags[] = []; let lexicalEnvironmentStackOffset = 0; let lexicalEnvironmentSuspended = false; let emitHelpers: EmitHelper[] | undefined; @@ -168,8 +172,11 @@ namespace ts { suspendLexicalEnvironment, resumeLexicalEnvironment, endLexicalEnvironment, + setLexicalEnvironmentFlags, + getLexicalEnvironmentFlags, hoistVariableDeclaration, hoistFunctionDeclaration, + addInitializationStatement, requestEmitHelper, readEmitHelpers, enableSubstitution, @@ -313,6 +320,9 @@ namespace ts { else { lexicalEnvironmentVariableDeclarations.push(decl); } + if (lexicalEnvironmentFlags & LexicalEnvironmentFlags.InParameters) { + lexicalEnvironmentFlags |= LexicalEnvironmentFlags.VariablesHoistedInParameters; + } } /** @@ -321,6 +331,7 @@ namespace ts { function hoistFunctionDeclaration(func: FunctionDeclaration): void { Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); + setEmitFlags(func, EmitFlags.CustomPrologue); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -329,6 +340,21 @@ namespace ts { } } + /** + * Adds an initialization statement to the top of the lexical environment. + */ + function addInitializationStatement(node: Statement): void { + Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the lexical environment during initialization."); + Debug.assert(state < TransformationState.Completed, "Cannot modify the lexical environment after transformation has completed."); + setEmitFlags(node, EmitFlags.CustomPrologue); + if (!lexicalEnvironmentStatements) { + lexicalEnvironmentStatements = [node]; + } + else { + lexicalEnvironmentStatements.push(node); + } + } + /** * Starts a new lexical environment. Any existing hoisted variable or function declarations * are pushed onto a stack, and the related storage variables are reset. @@ -344,9 +370,13 @@ namespace ts { // transformation. lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations; lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations; + lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements; + lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags; lexicalEnvironmentStackOffset++; lexicalEnvironmentVariableDeclarations = undefined!; lexicalEnvironmentFunctionDeclarations = undefined!; + lexicalEnvironmentStatements = undefined!; + lexicalEnvironmentFlags = LexicalEnvironmentFlags.None; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ @@ -375,7 +405,9 @@ namespace ts { Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); let statements: Statement[] | undefined; - if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { + if (lexicalEnvironmentVariableDeclarations || + lexicalEnvironmentFunctionDeclarations || + lexicalEnvironmentStatements) { if (lexicalEnvironmentFunctionDeclarations) { statements = [...lexicalEnvironmentFunctionDeclarations]; } @@ -395,19 +427,42 @@ namespace ts { statements.push(statement); } } + + if (lexicalEnvironmentStatements) { + if (!statements) { + statements = [...lexicalEnvironmentStatements]; + } + else { + statements = [...statements, ...lexicalEnvironmentStatements]; + } + } } // Restore the previous lexical environment. lexicalEnvironmentStackOffset--; lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset]; lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset]; + lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset]; + lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset]; if (lexicalEnvironmentStackOffset === 0) { lexicalEnvironmentVariableDeclarationsStack = []; lexicalEnvironmentFunctionDeclarationsStack = []; + lexicalEnvironmentStatementsStack = []; + lexicalEnvironmentFlagsStack = []; } return statements; } + function setLexicalEnvironmentFlags(flags: LexicalEnvironmentFlags, value: boolean): void { + lexicalEnvironmentFlags = value ? + lexicalEnvironmentFlags | flags : + lexicalEnvironmentFlags & ~flags; + } + + function getLexicalEnvironmentFlags(): LexicalEnvironmentFlags { + return lexicalEnvironmentFlags; + } + function requestEmitHelper(helper: EmitHelper): void { Debug.assert(state > TransformationState.Uninitialized, "Cannot modify the transformation context during initialization."); Debug.assert(state < TransformationState.Completed, "Cannot modify the transformation context after transformation has completed."); diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts index 692f353b00e..05b7cda9efc 100644 --- a/src/compiler/transformers/classFields.ts +++ b/src/compiler/transformers/classFields.ts @@ -606,7 +606,7 @@ namespace ts { createConstructor( /*decorators*/ undefined, /*modifiers*/ undefined, - parameters, + parameters ?? [], body ), constructor || node diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 6bffbe3b299..3e2e88d15c2 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -1853,6 +1853,8 @@ namespace ts { // ensureUseStrict is false because no new prologue-directive should be added. // addStandardPrologue will put already-existing directives at the beginning of the target statement-array statementOffset = addStandardPrologue(prologue, body.statements, /*ensureUseStrict*/ false); + statementOffset = addCustomPrologue(statements, body.statements, statementOffset, visitor, isHoistedFunction); + statementOffset = addCustomPrologue(statements, body.statements, statementOffset, visitor, isHoistedVariableStatement); } multiLine = addDefaultValueAssignmentsIfNeeded(statements, node) || multiLine; diff --git a/src/compiler/transformers/es2020.ts b/src/compiler/transformers/es2020.ts index 453b3b405f4..8cf31697520 100644 --- a/src/compiler/transformers/es2020.ts +++ b/src/compiler/transformers/es2020.ts @@ -1,209 +1,213 @@ /*@internal*/ namespace ts { - export function transformES2020(context: TransformationContext) { - const { - hoistVariableDeclaration, - } = context; + export function transformES2020(context: TransformationContext) { + const { + hoistVariableDeclaration, + } = context; - return chainBundle(transformSourceFile); + return chainBundle(transformSourceFile); - function transformSourceFile(node: SourceFile) { - if (node.isDeclarationFile) { - return node; - } + function transformSourceFile(node: SourceFile) { + if (node.isDeclarationFile) { + return node; + } - return visitEachChild(node, visitor, context); - } + return visitEachChild(node, visitor, context); + } - function visitor(node: Node): VisitResult { - if ((node.transformFlags & TransformFlags.ContainsES2020) === 0) { - return node; - } - switch (node.kind) { - case SyntaxKind.PropertyAccessExpression: - case SyntaxKind.ElementAccessExpression: - case SyntaxKind.CallExpression: - if (node.flags & NodeFlags.OptionalChain) { - const updated = visitOptionalExpression(node as OptionalChain, /*captureThisArg*/ false, /*isDelete*/ false); - Debug.assertNotNode(updated, isSyntheticReference); - return updated; - } - return visitEachChild(node, visitor, context); - case SyntaxKind.BinaryExpression: - if ((node).operatorToken.kind === SyntaxKind.QuestionQuestionToken) { - return transformNullishCoalescingExpression(node); - } - return visitEachChild(node, visitor, context); - case SyntaxKind.DeleteExpression: - return visitDeleteExpression(node as DeleteExpression); - default: - return visitEachChild(node, visitor, context); - } - } + function visitor(node: Node): VisitResult { + if ((node.transformFlags & TransformFlags.ContainsES2020) === 0) { + return node; + } + switch (node.kind) { + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: + case SyntaxKind.CallExpression: + if (node.flags & NodeFlags.OptionalChain) { + const updated = visitOptionalExpression(node as OptionalChain, /*captureThisArg*/ false, /*isDelete*/ false); + Debug.assertNotNode(updated, isSyntheticReference); + return updated; + } + return visitEachChild(node, visitor, context); + case SyntaxKind.BinaryExpression: + if ((node).operatorToken.kind === SyntaxKind.QuestionQuestionToken) { + return transformNullishCoalescingExpression(node); + } + return visitEachChild(node, visitor, context); + case SyntaxKind.DeleteExpression: + return visitDeleteExpression(node as DeleteExpression); + default: + return visitEachChild(node, visitor, context); + } + } - function flattenChain(chain: OptionalChain) { - Debug.assertNotNode(chain, isNonNullChain); - const links: OptionalChain[] = [chain]; - while (!chain.questionDotToken && !isTaggedTemplateExpression(chain)) { - chain = cast(skipPartiallyEmittedExpressions(chain.expression), isOptionalChain); - Debug.assertNotNode(chain, isNonNullChain); - links.unshift(chain); - } - return { expression: chain.expression, chain: links }; - } + function flattenChain(chain: OptionalChain) { + Debug.assertNotNode(chain, isNonNullChain); + const links: OptionalChain[] = [chain]; + while (!chain.questionDotToken && !isTaggedTemplateExpression(chain)) { + chain = cast(skipPartiallyEmittedExpressions(chain.expression), isOptionalChain); + Debug.assertNotNode(chain, isNonNullChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } - function visitNonOptionalParenthesizedExpression(node: ParenthesizedExpression, captureThisArg: boolean, isDelete: boolean): Expression { - const expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete); - if (isSyntheticReference(expression)) { - // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } - // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } - return createSyntheticReferenceExpression(updateParen(node, expression.expression), expression.thisArg); - } - return updateParen(node, expression); - } + function visitNonOptionalParenthesizedExpression(node: ParenthesizedExpression, captureThisArg: boolean, isDelete: boolean): Expression { + const expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete); + if (isSyntheticReference(expression)) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + return createSyntheticReferenceExpression(updateParen(node, expression.expression), expression.thisArg); + } + return updateParen(node, expression); + } - function visitNonOptionalPropertyOrElementAccessExpression(node: AccessExpression, captureThisArg: boolean, isDelete: boolean): Expression { - if (isOptionalChain(node)) { - // If `node` is an optional chain, then it is the outermost chain of an optional expression. - return visitOptionalExpression(node, captureThisArg, isDelete); - } + function visitNonOptionalPropertyOrElementAccessExpression(node: AccessExpression, captureThisArg: boolean, isDelete: boolean): Expression { + if (isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg, isDelete); + } - let expression: Expression = visitNode(node.expression, visitor, isExpression); - Debug.assertNotNode(expression, isSyntheticReference); + let expression: Expression = visitNode(node.expression, visitor, isExpression); + Debug.assertNotNode(expression, isSyntheticReference); - let thisArg: Expression | undefined; - if (captureThisArg) { - if (shouldCaptureInTempVariable(expression)) { - thisArg = createTempVariable(hoistVariableDeclaration); - expression = createAssignment(thisArg, expression); - } - else { - thisArg = expression; - } - } + let thisArg: Expression | undefined; + if (captureThisArg) { + if (shouldCaptureInTempVariable(expression)) { + thisArg = createTempVariable(hoistVariableDeclaration); + expression = createAssignment(thisArg, expression); + // if (inParameterInitializer) tempVariableInParameter = true; + } + else { + thisArg = expression; + } + } - expression = node.kind === SyntaxKind.PropertyAccessExpression - ? updatePropertyAccess(node, expression, visitNode(node.name, visitor, isIdentifier)) - : updateElementAccess(node, expression, visitNode(node.argumentExpression, visitor, isExpression)); - return thisArg ? createSyntheticReferenceExpression(expression, thisArg) : expression; - } + expression = node.kind === SyntaxKind.PropertyAccessExpression + ? updatePropertyAccess(node, expression, visitNode(node.name, visitor, isIdentifier)) + : updateElementAccess(node, expression, visitNode(node.argumentExpression, visitor, isExpression)); + return thisArg ? createSyntheticReferenceExpression(expression, thisArg) : expression; + } - function visitNonOptionalCallExpression(node: CallExpression, captureThisArg: boolean): Expression { - if (isOptionalChain(node)) { - // If `node` is an optional chain, then it is the outermost chain of an optional expression. - return visitOptionalExpression(node, captureThisArg, /*isDelete*/ false); - } - return visitEachChild(node, visitor, context); - } + function visitNonOptionalCallExpression(node: CallExpression, captureThisArg: boolean): Expression { + if (isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg, /*isDelete*/ false); + } + return visitEachChild(node, visitor, context); + } - function visitNonOptionalExpression(node: Expression, captureThisArg: boolean, isDelete: boolean): Expression { - switch (node.kind) { - case SyntaxKind.ParenthesizedExpression: return visitNonOptionalParenthesizedExpression(node as ParenthesizedExpression, captureThisArg, isDelete); - case SyntaxKind.PropertyAccessExpression: - case SyntaxKind.ElementAccessExpression: return visitNonOptionalPropertyOrElementAccessExpression(node as AccessExpression, captureThisArg, isDelete); - case SyntaxKind.CallExpression: return visitNonOptionalCallExpression(node as CallExpression, captureThisArg); - default: return visitNode(node, visitor, isExpression); - } - } + function visitNonOptionalExpression(node: Expression, captureThisArg: boolean, isDelete: boolean): Expression { + switch (node.kind) { + case SyntaxKind.ParenthesizedExpression: return visitNonOptionalParenthesizedExpression(node as ParenthesizedExpression, captureThisArg, isDelete); + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: return visitNonOptionalPropertyOrElementAccessExpression(node as AccessExpression, captureThisArg, isDelete); + case SyntaxKind.CallExpression: return visitNonOptionalCallExpression(node as CallExpression, captureThisArg); + default: return visitNode(node, visitor, isExpression); + } + } - function visitOptionalExpression(node: OptionalChain, captureThisArg: boolean, isDelete: boolean): Expression { - const { expression, chain } = flattenChain(node); - const left = visitNonOptionalExpression(expression, isCallChain(chain[0]), /*isDelete*/ false); - const leftThisArg = isSyntheticReference(left) ? left.thisArg : undefined; - let leftExpression = isSyntheticReference(left) ? left.expression : left; - let capturedLeft: Expression = leftExpression; - if (shouldCaptureInTempVariable(leftExpression)) { - capturedLeft = createTempVariable(hoistVariableDeclaration); - leftExpression = createAssignment(capturedLeft, leftExpression); - } - let rightExpression = capturedLeft; - let thisArg: Expression | undefined; - for (let i = 0; i < chain.length; i++) { - const segment = chain[i]; - switch (segment.kind) { - case SyntaxKind.PropertyAccessExpression: - case SyntaxKind.ElementAccessExpression: - if (i === chain.length - 1 && captureThisArg) { - if (shouldCaptureInTempVariable(rightExpression)) { - thisArg = createTempVariable(hoistVariableDeclaration); - rightExpression = createAssignment(thisArg, rightExpression); - } - else { - thisArg = rightExpression; - } - } - rightExpression = segment.kind === SyntaxKind.PropertyAccessExpression - ? createPropertyAccess(rightExpression, visitNode(segment.name, visitor, isIdentifier)) - : createElementAccess(rightExpression, visitNode(segment.argumentExpression, visitor, isExpression)); - break; - case SyntaxKind.CallExpression: - if (i === 0 && leftThisArg) { - rightExpression = createFunctionCall( - rightExpression, - leftThisArg.kind === SyntaxKind.SuperKeyword ? createThis() : leftThisArg, - visitNodes(segment.arguments, visitor, isExpression) - ); - } - else { - rightExpression = createCall( - rightExpression, - /*typeArguments*/ undefined, - visitNodes(segment.arguments, visitor, isExpression) - ); - } - break; - } - setOriginalNode(rightExpression, segment); - } + function visitOptionalExpression(node: OptionalChain, captureThisArg: boolean, isDelete: boolean): Expression { + const { expression, chain } = flattenChain(node); + const left = visitNonOptionalExpression(expression, isCallChain(chain[0]), /*isDelete*/ false); + const leftThisArg = isSyntheticReference(left) ? left.thisArg : undefined; + let leftExpression = isSyntheticReference(left) ? left.expression : left; + let capturedLeft: Expression = leftExpression; + if (shouldCaptureInTempVariable(leftExpression)) { + capturedLeft = createTempVariable(hoistVariableDeclaration); + leftExpression = createAssignment(capturedLeft, leftExpression); + // if (inParameterInitializer) tempVariableInParameter = true; + } + let rightExpression = capturedLeft; + let thisArg: Expression | undefined; + for (let i = 0; i < chain.length; i++) { + const segment = chain[i]; + switch (segment.kind) { + case SyntaxKind.PropertyAccessExpression: + case SyntaxKind.ElementAccessExpression: + if (i === chain.length - 1 && captureThisArg) { + if (shouldCaptureInTempVariable(rightExpression)) { + thisArg = createTempVariable(hoistVariableDeclaration); + rightExpression = createAssignment(thisArg, rightExpression); + // if (inParameterInitializer) tempVariableInParameter = true; + } + else { + thisArg = rightExpression; + } + } + rightExpression = segment.kind === SyntaxKind.PropertyAccessExpression + ? createPropertyAccess(rightExpression, visitNode(segment.name, visitor, isIdentifier)) + : createElementAccess(rightExpression, visitNode(segment.argumentExpression, visitor, isExpression)); + break; + case SyntaxKind.CallExpression: + if (i === 0 && leftThisArg) { + rightExpression = createFunctionCall( + rightExpression, + leftThisArg.kind === SyntaxKind.SuperKeyword ? createThis() : leftThisArg, + visitNodes(segment.arguments, visitor, isExpression) + ); + } + else { + rightExpression = createCall( + rightExpression, + /*typeArguments*/ undefined, + visitNodes(segment.arguments, visitor, isExpression) + ); + } + break; + } + setOriginalNode(rightExpression, segment); + } - const target = isDelete - ? createConditional(createNotNullCondition(leftExpression, capturedLeft, /*invert*/ true), createTrue(), createDelete(rightExpression)) - : createConditional(createNotNullCondition(leftExpression, capturedLeft, /*invert*/ true), createVoidZero(), rightExpression); - return thisArg ? createSyntheticReferenceExpression(target, thisArg) : target; - } + const target = isDelete + ? createConditional(createNotNullCondition(leftExpression, capturedLeft, /*invert*/ true), createTrue(), createDelete(rightExpression)) + : createConditional(createNotNullCondition(leftExpression, capturedLeft, /*invert*/ true), createVoidZero(), rightExpression); + return thisArg ? createSyntheticReferenceExpression(target, thisArg) : target; + } - function createNotNullCondition(left: Expression, right: Expression, invert?: boolean) { - return createBinary( - createBinary( - left, - createToken(invert ? SyntaxKind.EqualsEqualsEqualsToken : SyntaxKind.ExclamationEqualsEqualsToken), - createNull() - ), - createToken(invert ? SyntaxKind.BarBarToken : SyntaxKind.AmpersandAmpersandToken), - createBinary( - right, - createToken(invert ? SyntaxKind.EqualsEqualsEqualsToken : SyntaxKind.ExclamationEqualsEqualsToken), - createVoidZero() - ) - ); - } + function createNotNullCondition(left: Expression, right: Expression, invert?: boolean) { + return createBinary( + createBinary( + left, + createToken(invert ? SyntaxKind.EqualsEqualsEqualsToken : SyntaxKind.ExclamationEqualsEqualsToken), + createNull() + ), + createToken(invert ? SyntaxKind.BarBarToken : SyntaxKind.AmpersandAmpersandToken), + createBinary( + right, + createToken(invert ? SyntaxKind.EqualsEqualsEqualsToken : SyntaxKind.ExclamationEqualsEqualsToken), + createVoidZero() + ) + ); + } - function transformNullishCoalescingExpression(node: BinaryExpression) { - let left = visitNode(node.left, visitor, isExpression); - let right = left; - if (shouldCaptureInTempVariable(left)) { - right = createTempVariable(hoistVariableDeclaration); - left = createAssignment(right, left); - } - return createConditional( - createNotNullCondition(left, right), - right, - visitNode(node.right, visitor, isExpression), - ); - } + function transformNullishCoalescingExpression(node: BinaryExpression) { + let left = visitNode(node.left, visitor, isExpression); + let right = left; + if (shouldCaptureInTempVariable(left)) { + right = createTempVariable(hoistVariableDeclaration); + left = createAssignment(right, left); + // if (inParameterInitializer) tempVariableInParameter = true; + } + return createConditional( + createNotNullCondition(left, right), + right, + visitNode(node.right, visitor, isExpression), + ); + } - function shouldCaptureInTempVariable(expression: Expression): boolean { - // don't capture identifiers and `this` in a temporary variable - // `super` cannot be captured as it's no real variable - return !isIdentifier(expression) && - expression.kind !== SyntaxKind.ThisKeyword && - expression.kind !== SyntaxKind.SuperKeyword; - } + function shouldCaptureInTempVariable(expression: Expression): boolean { + // don't capture identifiers and `this` in a temporary variable + // `super` cannot be captured as it's no real variable + return !isIdentifier(expression) && + expression.kind !== SyntaxKind.ThisKeyword && + expression.kind !== SyntaxKind.SuperKeyword; + } - function visitDeleteExpression(node: DeleteExpression) { - return isOptionalChain(skipParentheses(node.expression)) - ? setOriginalNode(visitNonOptionalExpression(node.expression, /*captureThisArg*/ false, /*isDelete*/ true), node) - : updateDelete(node, visitNode(node.expression, visitor, isExpression)); - } - } + function visitDeleteExpression(node: DeleteExpression) { + return isOptionalChain(skipParentheses(node.expression)) + ? setOriginalNode(visitNonOptionalExpression(node.expression, /*captureThisArg*/ false, /*isDelete*/ true), node) + : updateDelete(node, visitNode(node.expression, visitor, isExpression)); + } + } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 70bc9b01528..8cf06d4ab4e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4323,6 +4323,7 @@ namespace ts { instantiations?: Map; // Instantiations of generic type alias (undefined if non-generic) isExhaustive?: boolean; // Is node an exhaustive switch statement skipDirectInference?: true; // Flag set by the API `getContextualType` call on a node when `Completions` is passed to force the checker to skip making inferences to a node's type + declarationRequiresScopeChange?: boolean; // Set by `useOuterVariableScopeInParameter` in checker when downlevel emit would change the name resolution scope inside of a parameter. } export const enum TypeFlags { @@ -5994,6 +5995,13 @@ namespace ts { set?: Expression; } + /* @internal */ + export const enum LexicalEnvironmentFlags { + None = 0, + InParameters = 1 << 0, // currently visiting a parameter list + VariablesHoistedInParameters = 1 << 1 // a temp variable was hoisted while visiting a parameter list + } + export interface TransformationContext { /*@internal*/ getEmitResolver(): EmitResolver; /*@internal*/ getEmitHost(): EmitHost; @@ -6004,6 +6012,9 @@ namespace ts { /** Starts a new lexical environment. */ startLexicalEnvironment(): void; + /* @internal */ setLexicalEnvironmentFlags(flags: LexicalEnvironmentFlags, value: boolean): void; + /* @internal */ getLexicalEnvironmentFlags(): LexicalEnvironmentFlags; + /** Suspends the current lexical environment, usually after visiting a parameter list. */ suspendLexicalEnvironment(): void; @@ -6019,6 +6030,10 @@ namespace ts { /** Hoists a variable declaration to the containing scope. */ hoistVariableDeclaration(node: Identifier): void; + /** Adds an initialization statement to the top of the lexical environment. */ + /* @internal */ + addInitializationStatement(node: Statement): void; + /** Records a request for a non-scoped emit helper in the current context. */ requestEmitHelper(helper: EmitHelper): void; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index bab1fe7b02b..9e1d338d8d7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1092,6 +1092,26 @@ namespace ts { && (node).expression.kind === SyntaxKind.StringLiteral; } + export function isCustomPrologue(node: Statement) { + return !!(getEmitFlags(node) & EmitFlags.CustomPrologue); + } + + export function isHoistedFunction(node: Statement) { + return isCustomPrologue(node) + && isFunctionDeclaration(node); + } + + function isHoistedVariable(node: VariableDeclaration) { + return isIdentifier(node.name) + && !node.initializer; + } + + export function isHoistedVariableStatement(node: Statement) { + return isCustomPrologue(node) + && isVariableStatement(node) + && every(node.declarationList.declarations, isHoistedVariable); + } + export function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile) { return node.kind !== SyntaxKind.JsxText ? getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index a7a331d4bff..c119eff97de 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -520,11 +520,18 @@ namespace ts { return result; } + function findSpanEnd(array: readonly T[], test: (value: T) => boolean, start: number) { + let i = start; + while (i < array.length && test(array[i])) { + i++; + } + return i; + } + /** * Merges generated lexical declarations into a new statement list. */ export function mergeLexicalEnvironment(statements: NodeArray, declarations: readonly Statement[] | undefined): NodeArray; - /** * Appends generated lexical declarations to an array of statements. */ @@ -534,9 +541,91 @@ namespace ts { return statements; } - return isNodeArray(statements) - ? setTextRange(createNodeArray(insertStatementsAfterStandardPrologue(statements.slice(), declarations)), statements) - : insertStatementsAfterStandardPrologue(statements, declarations); + // When we merge new lexical statements into an existing statement list, we merge them in the following manner: + // + // Given: + // + // | Left | Right | + // |------------------------------------|-------------------------------------| + // | [standard prologues (left)] | [standard prologues (right)] | + // | [hoisted functions (left)] | [hoisted functions (right)] | + // | [hoisted variables (left)] | [hoisted variables (right)] | + // | [lexical init statements (left)] | [lexical init statements (right)] | + // | [other statements (left)] | | + // + // The resulting statement list will be: + // + // | Result | + // |-------------------------------------| + // | [standard prologues (right)] | + // | [standard prologues (left)] | + // | [hoisted functions (right)] | + // | [hoisted functions (left)] | + // | [hoisted variables (right)] | + // | [hoisted variables (left)] | + // | [lexical init statements (right)] | + // | [lexical init statements (left)] | + // | [other statements (left)] | + // + // NOTE: It is expected that new lexical init statements must be evaluated before existing lexical init statements, + // as the prior transformation may depend on the evaluation of the lexical init statements to be in the correct state. + + // find standard prologues on left in the following order: standard directives, hoisted functions, hoisted variables, other custom + const leftStandardPrologueEnd = findSpanEnd(statements, isPrologueDirective, 0); + const leftHoistedFunctionsEnd = findSpanEnd(statements, isHoistedFunction, leftStandardPrologueEnd); + const leftHoistedVariablesEnd = findSpanEnd(statements, isHoistedVariableStatement, leftHoistedFunctionsEnd); + + // find standard prologues on right in the following order: standard directives, hoisted functions, hoisted variables, other custom + const rightStandardPrologueEnd = findSpanEnd(declarations, isPrologueDirective, 0); + const rightHoistedFunctionsEnd = findSpanEnd(declarations, isHoistedFunction, rightStandardPrologueEnd); + const rightHoistedVariablesEnd = findSpanEnd(declarations, isHoistedVariableStatement, rightHoistedFunctionsEnd); + const rightCustomPrologueEnd = findSpanEnd(declarations, isCustomPrologue, rightHoistedVariablesEnd); + Debug.assert(rightCustomPrologueEnd === declarations.length, "Expected declarations to be valid standard or custom prologues"); + + // splice prologues from the right into the left. We do this in reverse order + // so that we don't need to recompute the index on the left when we insert items. + const left = isNodeArray(statements) ? statements.slice() : statements; + + // splice other custom prologues from right into left + if (rightCustomPrologueEnd > rightHoistedVariablesEnd) { + left.splice(leftHoistedVariablesEnd, 0, ...declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd)); + } + + // splice hoisted variables from right into left + if (rightHoistedVariablesEnd > rightHoistedFunctionsEnd) { + left.splice(leftHoistedFunctionsEnd, 0, ...declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd)); + } + + // splice hoisted functions from right into left + if (rightHoistedFunctionsEnd > rightStandardPrologueEnd) { + left.splice(leftStandardPrologueEnd, 0, ...declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd)); + } + + // splice standard prologues from right into left (that are not already in left) + if (rightStandardPrologueEnd > 0) { + if (leftStandardPrologueEnd === 0) { + left.splice(0, 0, ...declarations.slice(0, rightStandardPrologueEnd)); + } + else { + const leftPrologues = createMap(); + for (let i = 0; i < leftStandardPrologueEnd; i++) { + const leftPrologue = statements[i] as PrologueDirective; + leftPrologues.set(leftPrologue.expression.text, true); + } + for (let i = rightStandardPrologueEnd - 1; i >= 0; i--) { + const rightPrologue = declarations[i] as PrologueDirective; + if (!leftPrologues.has(rightPrologue.expression.text)) { + left.unshift(rightPrologue); + } + } + } + } + + if (isNodeArray(statements)) { + return setTextRange(createNodeArray(left, statements.hasTrailingComma), statements); + } + + return statements; } /** diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index fa611bc9bde..b21af6186db 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -149,13 +149,124 @@ namespace ts { * Starts a new lexical environment and visits a parameter list, suspending the lexical * environment upon completion. */ + export function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor?: (nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray): NodeArray; + export function visitParameterList(nodes: NodeArray | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: (nodes: NodeArray | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray | undefined): NodeArray | undefined; export function visitParameterList(nodes: NodeArray | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes) { + let updated: NodeArray | undefined; context.startLexicalEnvironment(); - const updated = nodesVisitor(nodes, visitor, isParameterDeclaration); + if (nodes) { + context.setLexicalEnvironmentFlags(LexicalEnvironmentFlags.InParameters, true); + updated = nodesVisitor(nodes, visitor, isParameterDeclaration); + + // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an + // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression + // that we might transform that introduces a temporary variable would fail as the temporary variable + // exists in a different lexical scope. To address this, we move any binding patterns and initializers + // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list + // when the emit target is greater than ES2015. + if (context.getLexicalEnvironmentFlags() & LexicalEnvironmentFlags.VariablesHoistedInParameters && + getEmitScriptTarget(context.getCompilerOptions()) >= ScriptTarget.ES2015) { + updated = addDefaultValueAssignmentsIfNeeded(updated, context); + } + context.setLexicalEnvironmentFlags(LexicalEnvironmentFlags.InParameters, false); + } context.suspendLexicalEnvironment(); return updated; } + function addDefaultValueAssignmentsIfNeeded(parameters: NodeArray, context: TransformationContext) { + let result: ParameterDeclaration[] | undefined; + for (let i = 0; i < parameters.length; i++) { + const parameter = parameters[i]; + const updated = addDefaultValueAssignmentIfNeeded(parameter, context); + if (result || updated !== parameter) { + if (!result) result = parameters.slice(0, i); + result[i] = updated; + } + } + if (result) { + return setTextRange(createNodeArray(result, parameters.hasTrailingComma), parameters); + } + return parameters; + } + + function addDefaultValueAssignmentIfNeeded(parameter: ParameterDeclaration, context: TransformationContext) { + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + return parameter.dotDotDotToken ? parameter : + isBindingPattern(parameter.name) ? addDefaultValueAssignmentForBindingPattern(parameter, context) : + parameter.initializer ? addDefaultValueAssignmentForInitializer(parameter, parameter.name, parameter.initializer, context) : + parameter; + } + + function addDefaultValueAssignmentForBindingPattern(parameter: ParameterDeclaration, context: TransformationContext) { + context.addInitializationStatement( + createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList([ + createVariableDeclaration( + parameter.name, + parameter.type, + parameter.initializer ? + createConditional( + createStrictEquality( + getGeneratedNameForNode(parameter), + createVoidZero() + ), + parameter.initializer, + getGeneratedNameForNode(parameter) + ) : + getGeneratedNameForNode(parameter) + ), + ]) + ) + ); + return updateParameter(parameter, + parameter.decorators, + parameter.modifiers, + parameter.dotDotDotToken, + getGeneratedNameForNode(parameter), + parameter.questionToken, + parameter.type, + /*initializer*/ undefined); + } + + function addDefaultValueAssignmentForInitializer(parameter: ParameterDeclaration, name: Identifier, initializer: Expression, context: TransformationContext) { + context.addInitializationStatement( + createIf( + createTypeCheck(getSynthesizedClone(name), "undefined"), + setEmitFlags( + setTextRange( + createBlock([ + createExpressionStatement( + setEmitFlags( + setTextRange( + createAssignment( + setEmitFlags(getMutableClone(name), EmitFlags.NoSourceMap), + setEmitFlags(initializer, EmitFlags.NoSourceMap | getEmitFlags(initializer) | EmitFlags.NoComments) + ), + parameter + ), + EmitFlags.NoComments + ) + ) + ]), + parameter + ), + EmitFlags.SingleLine | EmitFlags.NoTrailingSourceMap | EmitFlags.NoTokenSourceMaps | EmitFlags.NoComments + ) + ) + ); + return updateParameter(parameter, + parameter.decorators, + parameter.modifiers, + parameter.dotDotDotToken, + parameter.name, + parameter.questionToken, + parameter.type, + /*initializer*/ undefined); + } + /** * Resumes a suspended lexical environment and visits a function body, ending the lexical * environment and merging hoisted declarations upon completion. diff --git a/tests/baselines/reference/FunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration3_es6.errors.txt index 409baef3a50..cdc50037d65 100644 --- a/tests/baselines/reference/FunctionDeclaration3_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration3_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'yield' cannot be referenced in its initializer. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'yield' cannot reference itself. ==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts (1 errors) ==== function f(yield = yield) { ~~~~~ -!!! error TS2372: Parameter 'yield' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'yield' cannot reference itself. } \ No newline at end of file diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index db6b0bc4905..e45bd38e2de 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4460,7 +4460,8 @@ declare namespace ts { * Starts a new lexical environment and visits a parameter list, suspending the lexical * environment upon completion. */ - function visitParameterList(nodes: NodeArray | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray; + function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor?: (nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray): NodeArray; + function visitParameterList(nodes: NodeArray | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: (nodes: NodeArray | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray | undefined): NodeArray | undefined; /** * Resumes a suspended lexical environment and visits a function body, ending the lexical * environment and merging hoisted declarations upon completion. diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 3ec2b8046b9..62e8560ae48 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -4460,7 +4460,8 @@ declare namespace ts { * Starts a new lexical environment and visits a parameter list, suspending the lexical * environment upon completion. */ - function visitParameterList(nodes: NodeArray | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray; + function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor?: (nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray): NodeArray; + function visitParameterList(nodes: NodeArray | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: (nodes: NodeArray | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) => NodeArray | undefined): NodeArray | undefined; /** * Resumes a suspended lexical environment and visits a function body, ending the lexical * environment and merging hoisted declarations upon completion. diff --git a/tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt index 1c1fd711760..64b47bc6cd5 100644 --- a/tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction3_es2017.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot reference itself. ==== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts (1 errors) ==== function f(await = await) { ~~~~~ -!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'await' cannot reference itself. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction3_es5.errors.txt b/tests/baselines/reference/asyncArrowFunction3_es5.errors.txt index 01c74ab3620..8540c900559 100644 --- a/tests/baselines/reference/asyncArrowFunction3_es5.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction3_es5.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction3_es5.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction3_es5.ts(1,20): error TS2372: Parameter 'await' cannot reference itself. ==== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction3_es5.ts (1 errors) ==== function f(await = await) { ~~~~~ -!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'await' cannot reference itself. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt index d0f56df51da..cfa4edcca4a 100644 --- a/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction3_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts(1,20): error TS2372: Parameter 'await' cannot reference itself. ==== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts (1 errors) ==== function f(await = await) { ~~~~~ -!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'await' cannot reference itself. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt index 53a85074834..599d481f319 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts(1,20): error TS2372: Parameter 'await' cannot reference itself. ==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts (1 errors) ==== function f(await = await) { ~~~~~ -!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'await' cannot reference itself. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration3_es5.errors.txt index 1192e396a64..c5b84f0602d 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration3_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es5.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5.ts(1,20): error TS2372: Parameter 'await' cannot reference itself. ==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5.ts (1 errors) ==== function f(await = await) { ~~~~~ -!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'await' cannot reference itself. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt index a480bf3d2b8..76ccd1269c6 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'await' cannot be referenced in its initializer. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts(1,20): error TS2372: Parameter 'await' cannot reference itself. ==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts (1 errors) ==== function f(await = await) { ~~~~~ -!!! error TS2372: Parameter 'await' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'await' cannot reference itself. } \ No newline at end of file diff --git a/tests/baselines/reference/capturedParametersInInitializers1.errors.txt b/tests/baselines/reference/capturedParametersInInitializers1.errors.txt index fce7c6ee488..bbd19e7f64d 100644 --- a/tests/baselines/reference/capturedParametersInInitializers1.errors.txt +++ b/tests/baselines/reference/capturedParametersInInitializers1.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/capturedParametersInInitializers1.ts(18,20): error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it. -tests/cases/compiler/capturedParametersInInitializers1.ts(22,26): error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it. -tests/cases/compiler/capturedParametersInInitializers1.ts(38,21): error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it. +tests/cases/compiler/capturedParametersInInitializers1.ts(18,20): error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it. +tests/cases/compiler/capturedParametersInInitializers1.ts(22,26): error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it. +tests/cases/compiler/capturedParametersInInitializers1.ts(38,21): error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it. ==== tests/cases/compiler/capturedParametersInInitializers1.ts (3 errors) ==== @@ -23,13 +23,13 @@ tests/cases/compiler/capturedParametersInInitializers1.ts(38,21): error TS2373: // error - used before declaration function foo4(y = {z}, z = 1) { ~ -!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it. +!!! error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it. } // error - used before declaration, IIFEs are inlined function foo5(y = (() => z)(), z = 1) { ~ -!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it. +!!! error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it. } // ok - IIFE inside another function @@ -47,6 +47,6 @@ tests/cases/compiler/capturedParametersInInitializers1.ts(38,21): error TS2373: // error - used as computed name of method function foo9(y = {[z]() { return z; }}, z = 1) { ~ -!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it. +!!! error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it. } \ No newline at end of file diff --git a/tests/baselines/reference/capturedParametersInInitializers2.errors.txt b/tests/baselines/reference/capturedParametersInInitializers2.errors.txt index df6c71f544b..4647aea937c 100644 --- a/tests/baselines/reference/capturedParametersInInitializers2.errors.txt +++ b/tests/baselines/reference/capturedParametersInInitializers2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/capturedParametersInInitializers2.ts(3,20): error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it. -tests/cases/compiler/capturedParametersInInitializers2.ts(4,14): error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it. -tests/cases/compiler/capturedParametersInInitializers2.ts(6,10): error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it. +tests/cases/compiler/capturedParametersInInitializers2.ts(3,20): error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it. +tests/cases/compiler/capturedParametersInInitializers2.ts(4,14): error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it. +tests/cases/compiler/capturedParametersInInitializers2.ts(6,10): error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it. tests/cases/compiler/capturedParametersInInitializers2.ts(13,26): error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. -tests/cases/compiler/capturedParametersInInitializers2.ts(13,27): error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it. +tests/cases/compiler/capturedParametersInInitializers2.ts(13,27): error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it. ==== tests/cases/compiler/capturedParametersInInitializers2.ts (5 errors) ==== @@ -10,14 +10,14 @@ tests/cases/compiler/capturedParametersInInitializers2.ts(13,27): error TS2373: y = class { static c = x; ~ -!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it. +!!! error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it. get [x]() {return x;} ~ -!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it. +!!! error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it. constructor() { x; } [z]() { return z; } ~ -!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'z' declared after it. +!!! error TS2373: Parameter 'y' cannot reference identifier 'z' declared after it. }, x = 1, z = 2 @@ -28,5 +28,5 @@ tests/cases/compiler/capturedParametersInInitializers2.ts(13,27): error TS2373: ~~~ !!! error TS1166: A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type. ~ -!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'x' declared after it. +!!! error TS2373: Parameter 'y' cannot reference identifier 'x' declared after it. } \ No newline at end of file diff --git a/tests/baselines/reference/capturedParametersInInitializers2.js b/tests/baselines/reference/capturedParametersInInitializers2.js index 53d5da5d445..da1f63b58e6 100644 --- a/tests/baselines/reference/capturedParametersInInitializers2.js +++ b/tests/baselines/reference/capturedParametersInInitializers2.js @@ -16,6 +16,7 @@ function foo2(y = class {[x] = x}, x = 1) { //// [capturedParametersInInitializers2.js] function foo(y, x, z) { + var _a; if (y === void 0) { y = (_a = /** @class */ (function () { function class_1() { x; @@ -32,10 +33,10 @@ function foo(y, x, z) { _a); } if (x === void 0) { x = 1; } if (z === void 0) { z = 2; } - var _a; y.c; } function foo2(y, x) { + var _a, _b; if (y === void 0) { y = (_b = /** @class */ (function () { function class_2() { this[_a] = x; @@ -45,5 +46,4 @@ function foo2(y, x) { _a = x, _b); } if (x === void 0) { x = 1; } - var _a, _b; } diff --git a/tests/baselines/reference/circularOptionalityRemoval.errors.txt b/tests/baselines/reference/circularOptionalityRemoval.errors.txt index 2b60b5b6621..b1c55b70f04 100644 --- a/tests/baselines/reference/circularOptionalityRemoval.errors.txt +++ b/tests/baselines/reference/circularOptionalityRemoval.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/circularOptionalityRemoval.ts(2,14): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. -tests/cases/compiler/circularOptionalityRemoval.ts(2,38): error TS2372: Parameter 'x' cannot be referenced in its initializer. +tests/cases/compiler/circularOptionalityRemoval.ts(2,38): error TS2372: Parameter 'x' cannot reference itself. tests/cases/compiler/circularOptionalityRemoval.ts(2,38): error TS2532: Object is possibly 'undefined'. -tests/cases/compiler/circularOptionalityRemoval.ts(2,46): error TS2372: Parameter 'x' cannot be referenced in its initializer. +tests/cases/compiler/circularOptionalityRemoval.ts(2,46): error TS2372: Parameter 'x' cannot reference itself. tests/cases/compiler/circularOptionalityRemoval.ts(5,14): error TS1015: Parameter cannot have question mark and initializer. tests/cases/compiler/circularOptionalityRemoval.ts(5,14): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/compiler/circularOptionalityRemoval.ts(5,27): error TS2304: Cannot find name 'someCondition'. -tests/cases/compiler/circularOptionalityRemoval.ts(5,54): error TS2372: Parameter 'x' cannot be referenced in its initializer. +tests/cases/compiler/circularOptionalityRemoval.ts(5,54): error TS2372: Parameter 'x' cannot reference itself. ==== tests/cases/compiler/circularOptionalityRemoval.ts (8 errors) ==== @@ -14,11 +14,11 @@ tests/cases/compiler/circularOptionalityRemoval.ts(5,54): error TS2372: Paramete ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2502: 'x' is referenced directly or indirectly in its own type annotation. ~ -!!! error TS2372: Parameter 'x' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'x' cannot reference itself. ~ !!! error TS2532: Object is possibly 'undefined'. ~ -!!! error TS2372: Parameter 'x' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'x' cannot reference itself. // Report from user function fn2(x?: string = someCondition ? 'value1' : x) { } @@ -29,4 +29,4 @@ tests/cases/compiler/circularOptionalityRemoval.ts(5,54): error TS2372: Paramete ~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'someCondition'. ~ -!!! error TS2372: Parameter 'x' cannot be referenced in its initializer. \ No newline at end of file +!!! error TS2372: Parameter 'x' cannot reference itself. \ No newline at end of file diff --git a/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=es2015).js b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=es2015).js new file mode 100644 index 00000000000..707f001650a --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=es2015).js @@ -0,0 +1,10 @@ +//// [classWithStaticFieldInParameterBindingPattern.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +(({ [class { static x = 1 }.x]: b = "" }) => {})(); + +//// [classWithStaticFieldInParameterBindingPattern.js] +// https://github.com/microsoft/TypeScript/issues/36295 +((_a) => { var _b; var { [(_b = class { + }, + _b.x = 1, + _b).x]: b = "" } = _a; })(); diff --git a/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=es5).js b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=es5).js new file mode 100644 index 00000000000..32ac07f7cd1 --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=es5).js @@ -0,0 +1,16 @@ +//// [classWithStaticFieldInParameterBindingPattern.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +(({ [class { static x = 1 }.x]: b = "" }) => {})(); + +//// [classWithStaticFieldInParameterBindingPattern.js] +// https://github.com/microsoft/TypeScript/issues/36295 +(function (_a) { + var _b; + var _c = (_b = /** @class */ (function () { + function class_1() { + } + return class_1; + }()), + _b.x = 1, + _b).x, _d = _a[_c], b = _d === void 0 ? "" : _d; +})(); diff --git a/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=esnext).js b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=esnext).js new file mode 100644 index 00000000000..707f001650a --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern(target=esnext).js @@ -0,0 +1,10 @@ +//// [classWithStaticFieldInParameterBindingPattern.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +(({ [class { static x = 1 }.x]: b = "" }) => {})(); + +//// [classWithStaticFieldInParameterBindingPattern.js] +// https://github.com/microsoft/TypeScript/issues/36295 +((_a) => { var _b; var { [(_b = class { + }, + _b.x = 1, + _b).x]: b = "" } = _a; })(); diff --git a/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=es2015).errors.txt b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=es2015).errors.txt new file mode 100644 index 00000000000..b2ca477fe31 --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=es2015).errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(3,20): error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it. +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(6,57): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + class C {} + (({ [class extends C { static x = 1 }.x]: b = "" }) => { var C; })(); + ~ +!!! error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it. + + const x = ""; + (({ [class extends C { static x = 1 }.x]: b = "" }, d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + \ No newline at end of file diff --git a/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=es5).errors.txt b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=es5).errors.txt new file mode 100644 index 00000000000..b2ca477fe31 --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=es5).errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(3,20): error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it. +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(6,57): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + class C {} + (({ [class extends C { static x = 1 }.x]: b = "" }) => { var C; })(); + ~ +!!! error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it. + + const x = ""; + (({ [class extends C { static x = 1 }.x]: b = "" }, d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + \ No newline at end of file diff --git a/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=esnext).errors.txt b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=esnext).errors.txt new file mode 100644 index 00000000000..b2ca477fe31 --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterBindingPattern.2(target=esnext).errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(3,20): error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it. +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts(6,57): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + class C {} + (({ [class extends C { static x = 1 }.x]: b = "" }) => { var C; })(); + ~ +!!! error TS2373: Parameter '{ [class extends C { static x = 1 }.x]: b = "" }' cannot reference identifier 'C' declared after it. + + const x = ""; + (({ [class extends C { static x = 1 }.x]: b = "" }, d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + \ No newline at end of file diff --git a/tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=es2015).js b/tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=es2015).js new file mode 100644 index 00000000000..fd89bcefa8b --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=es2015).js @@ -0,0 +1,10 @@ +//// [classWithStaticFieldInParameterInitializer.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +((b = class { static x = 1 }) => {})(); + +//// [classWithStaticFieldInParameterInitializer.js] +// https://github.com/microsoft/TypeScript/issues/36295 +((b) => { var _a; if (b === void 0) { b = (_a = class { + }, + _a.x = 1, + _a); } })(); diff --git a/tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=es5).js b/tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=es5).js new file mode 100644 index 00000000000..30142396a8e --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=es5).js @@ -0,0 +1,16 @@ +//// [classWithStaticFieldInParameterInitializer.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +((b = class { static x = 1 }) => {})(); + +//// [classWithStaticFieldInParameterInitializer.js] +// https://github.com/microsoft/TypeScript/issues/36295 +(function (b) { + var _a; + if (b === void 0) { b = (_a = /** @class */ (function () { + function class_1() { + } + return class_1; + }()), + _a.x = 1, + _a); } +})(); diff --git a/tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=esnext).js b/tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=esnext).js new file mode 100644 index 00000000000..fd89bcefa8b --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=esnext).js @@ -0,0 +1,10 @@ +//// [classWithStaticFieldInParameterInitializer.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +((b = class { static x = 1 }) => {})(); + +//// [classWithStaticFieldInParameterInitializer.js] +// https://github.com/microsoft/TypeScript/issues/36295 +((b) => { var _a; if (b === void 0) { b = (_a = class { + }, + _a.x = 1, + _a); } })(); diff --git a/tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=es2015).errors.txt b/tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=es2015).errors.txt new file mode 100644 index 00000000000..56fefb8b502 --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=es2015).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(3,21): error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it. +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(6,45): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + class C {} + ((b = class extends C { static x = 1 }) => { var C; })(); + ~ +!!! error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it. + + const x = ""; + ((b = class extends C { static x = 1 }, d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. \ No newline at end of file diff --git a/tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=es5).errors.txt b/tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=es5).errors.txt new file mode 100644 index 00000000000..56fefb8b502 --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=es5).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(3,21): error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it. +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(6,45): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + class C {} + ((b = class extends C { static x = 1 }) => { var C; })(); + ~ +!!! error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it. + + const x = ""; + ((b = class extends C { static x = 1 }, d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. \ No newline at end of file diff --git a/tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=esnext).errors.txt b/tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=esnext).errors.txt new file mode 100644 index 00000000000..56fefb8b502 --- /dev/null +++ b/tests/baselines/reference/classWithStaticFieldInParameterInitializer.2(target=esnext).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(3,21): error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it. +tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts(6,45): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + class C {} + ((b = class extends C { static x = 1 }) => { var C; })(); + ~ +!!! error TS2373: Parameter 'b' cannot reference identifier 'C' declared after it. + + const x = ""; + ((b = class extends C { static x = 1 }, d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.errors.txt index eff1e1a6593..af2d5b6fbd6 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts(2,22): error TS2448: Block-scoped variable 'e' used before its declaration. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts(3,22): error TS2448: Block-scoped variable 'i' used before its declaration. -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts(7,27): error TS2372: Parameter 'e' cannot be referenced in its initializer. -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts(9,27): error TS2373: Initializer of parameter 'h' cannot reference identifier 'i' declared after it. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts(7,27): error TS2372: Parameter 'e' cannot reference itself. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts(9,27): error TS2373: Parameter 'h' cannot reference identifier 'i' declared after it. ==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts (4 errors) ==== @@ -19,10 +19,10 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss })([1]); (function ([c, d = c, e = e]) { // error for e = e ~ -!!! error TS2372: Parameter 'e' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'e' cannot reference itself. })([1]); (function ([f, g = f, h = i, i = f]) { // error for h = i ~ -!!! error TS2373: Initializer of parameter 'h' cannot reference identifier 'i' declared after it. +!!! error TS2373: Parameter 'h' cannot reference identifier 'i' declared after it. })([1]) \ No newline at end of file diff --git a/tests/baselines/reference/functionImplementationErrors.errors.txt b/tests/baselines/reference/functionImplementationErrors.errors.txt index 5ed54e044d2..5a9ebea09be 100644 --- a/tests/baselines/reference/functionImplementationErrors.errors.txt +++ b/tests/baselines/reference/functionImplementationErrors.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(25,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/conformance/functions/functionImplementationErrors.ts(30,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. -tests/cases/conformance/functions/functionImplementationErrors.ts(35,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. +tests/cases/conformance/functions/functionImplementationErrors.ts(30,17): error TS2373: Parameter 'n' cannot reference identifier 'm' declared after it. +tests/cases/conformance/functions/functionImplementationErrors.ts(35,17): error TS2373: Parameter 'n' cannot reference identifier 'm' declared after it. ==== tests/cases/conformance/functions/functionImplementationErrors.ts (3 errors) ==== @@ -37,14 +37,14 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(35,17): error // Function signature with parameter initializer referencing in scope local variable function f6(n = m) { ~ -!!! error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. +!!! error TS2373: Parameter 'n' cannot reference identifier 'm' declared after it. var m = 4; } // Function signature with initializer referencing other parameter to the right function f7(n = m, m?) { ~ -!!! error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. +!!! error TS2373: Parameter 'n' cannot reference identifier 'm' declared after it. } // FunctionExpression with non -void return type annotation with a throw, no return, and other code diff --git a/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=es2015).js b/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=es2015).js new file mode 100644 index 00000000000..c7736309aba --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=es2015).js @@ -0,0 +1,9 @@ +//// [nullishCoalescingOperatorInParameterBindingPattern.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): string | undefined => undefined; +(({ [a() ?? "d"]: c = "" }) => {})(); + +//// [nullishCoalescingOperatorInParameterBindingPattern.js] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = () => undefined; +((_a) => { var _b; var { [(_b = a()) !== null && _b !== void 0 ? _b : "d"]: c = "" } = _a; })(); diff --git a/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=es5).js b/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=es5).js new file mode 100644 index 00000000000..ea103f59da6 --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=es5).js @@ -0,0 +1,12 @@ +//// [nullishCoalescingOperatorInParameterBindingPattern.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): string | undefined => undefined; +(({ [a() ?? "d"]: c = "" }) => {})(); + +//// [nullishCoalescingOperatorInParameterBindingPattern.js] +// https://github.com/microsoft/TypeScript/issues/36295 +var a = function () { return undefined; }; +(function (_a) { + var _b; + var _c = (_b = a()) !== null && _b !== void 0 ? _b : "d", _d = _a[_c], c = _d === void 0 ? "" : _d; +})(); diff --git a/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=esnext).js b/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=esnext).js new file mode 100644 index 00000000000..07a1b1e9e73 --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern(target=esnext).js @@ -0,0 +1,9 @@ +//// [nullishCoalescingOperatorInParameterBindingPattern.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): string | undefined => undefined; +(({ [a() ?? "d"]: c = "" }) => {})(); + +//// [nullishCoalescingOperatorInParameterBindingPattern.js] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = () => undefined; +(({ [a() ?? "d"]: c = "" }) => { })(); diff --git a/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern.2(target=es2015).errors.txt b/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern.2(target=es2015).errors.txt new file mode 100644 index 00000000000..6319b92a19f --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern.2(target=es2015).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.2.ts(3,6): error TS2373: Parameter '{ [a() ?? "d"]: c = "" }' cannot reference identifier 'a' declared after it. +tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.2.ts(6,31): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + const a = (): string | undefined => undefined; + (({ [a() ?? "d"]: c = "" }) => { var a; })(); + ~ +!!! error TS2373: Parameter '{ [a() ?? "d"]: c = "" }' cannot reference identifier 'a' declared after it. + + const x = ""; + (({ [a() ?? "d"]: c = "", d = x }) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern.2(target=es5).errors.txt b/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern.2(target=es5).errors.txt new file mode 100644 index 00000000000..6319b92a19f --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInParameterBindingPattern.2(target=es5).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.2.ts(3,6): error TS2373: Parameter '{ [a() ?? "d"]: c = "" }' cannot reference identifier 'a' declared after it. +tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.2.ts(6,31): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + const a = (): string | undefined => undefined; + (({ [a() ?? "d"]: c = "" }) => { var a; })(); + ~ +!!! error TS2373: Parameter '{ [a() ?? "d"]: c = "" }' cannot reference identifier 'a' declared after it. + + const x = ""; + (({ [a() ?? "d"]: c = "", d = x }) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=es2015).js b/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=es2015).js new file mode 100644 index 00000000000..f7f2e83221d --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=es2015).js @@ -0,0 +1,9 @@ +//// [nullishCoalescingOperatorInParameterInitializer.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): string | undefined => undefined; +((b = a() ?? "d") => {})(); + +//// [nullishCoalescingOperatorInParameterInitializer.js] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = () => undefined; +((b) => { var _a; if (b === void 0) { b = (_a = a()) !== null && _a !== void 0 ? _a : "d"; } })(); diff --git a/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=es5).js b/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=es5).js new file mode 100644 index 00000000000..439a4d6ba43 --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=es5).js @@ -0,0 +1,12 @@ +//// [nullishCoalescingOperatorInParameterInitializer.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): string | undefined => undefined; +((b = a() ?? "d") => {})(); + +//// [nullishCoalescingOperatorInParameterInitializer.js] +// https://github.com/microsoft/TypeScript/issues/36295 +var a = function () { return undefined; }; +(function (b) { + var _a; + if (b === void 0) { b = (_a = a()) !== null && _a !== void 0 ? _a : "d"; } +})(); diff --git a/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=esnext).js b/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=esnext).js new file mode 100644 index 00000000000..e9ae41d6bde --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer(target=esnext).js @@ -0,0 +1,9 @@ +//// [nullishCoalescingOperatorInParameterInitializer.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): string | undefined => undefined; +((b = a() ?? "d") => {})(); + +//// [nullishCoalescingOperatorInParameterInitializer.js] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = () => undefined; +((b = a() ?? "d") => { })(); diff --git a/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer.2(target=es2015).errors.txt b/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer.2(target=es2015).errors.txt new file mode 100644 index 00000000000..3c00102f390 --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer.2(target=es2015).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2.ts(3,7): error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. +tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2.ts(6,23): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + const a = (): string | undefined => undefined; + ((b = a() ?? "d") => { var a; })(); + ~ +!!! error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. + + const x = ""; + ((b = a() ?? "d", d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer.2(target=es5).errors.txt b/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer.2(target=es5).errors.txt new file mode 100644 index 00000000000..3c00102f390 --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInParameterInitializer.2(target=es5).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2.ts(3,7): error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. +tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2.ts(6,23): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + const a = (): string | undefined => undefined; + ((b = a() ?? "d") => { var a; })(); + ~ +!!! error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. + + const x = ""; + ((b = a() ?? "d", d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. \ No newline at end of file diff --git a/tests/baselines/reference/optionalChainingInParameterBindingPattern(target=es2015).js b/tests/baselines/reference/optionalChainingInParameterBindingPattern(target=es2015).js new file mode 100644 index 00000000000..3870f17544e --- /dev/null +++ b/tests/baselines/reference/optionalChainingInParameterBindingPattern(target=es2015).js @@ -0,0 +1,9 @@ +//// [optionalChainingInParameterBindingPattern.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): { d: string } | undefined => undefined; +(({ [a()?.d]: c = "" }) => {})(); + +//// [optionalChainingInParameterBindingPattern.js] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = () => undefined; +((_a) => { var _b; var { [(_b = a()) === null || _b === void 0 ? void 0 : _b.d]: c = "" } = _a; })(); diff --git a/tests/baselines/reference/optionalChainingInParameterBindingPattern(target=es5).js b/tests/baselines/reference/optionalChainingInParameterBindingPattern(target=es5).js new file mode 100644 index 00000000000..9fde11940ce --- /dev/null +++ b/tests/baselines/reference/optionalChainingInParameterBindingPattern(target=es5).js @@ -0,0 +1,12 @@ +//// [optionalChainingInParameterBindingPattern.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): { d: string } | undefined => undefined; +(({ [a()?.d]: c = "" }) => {})(); + +//// [optionalChainingInParameterBindingPattern.js] +// https://github.com/microsoft/TypeScript/issues/36295 +var a = function () { return undefined; }; +(function (_a) { + var _b; + var _c = (_b = a()) === null || _b === void 0 ? void 0 : _b.d, _d = _a[_c], c = _d === void 0 ? "" : _d; +})(); diff --git a/tests/baselines/reference/optionalChainingInParameterBindingPattern(target=esnext).js b/tests/baselines/reference/optionalChainingInParameterBindingPattern(target=esnext).js new file mode 100644 index 00000000000..088bc3f7eae --- /dev/null +++ b/tests/baselines/reference/optionalChainingInParameterBindingPattern(target=esnext).js @@ -0,0 +1,9 @@ +//// [optionalChainingInParameterBindingPattern.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): { d: string } | undefined => undefined; +(({ [a()?.d]: c = "" }) => {})(); + +//// [optionalChainingInParameterBindingPattern.js] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = () => undefined; +(({ [a()?.d]: c = "" }) => { })(); diff --git a/tests/baselines/reference/optionalChainingInParameterBindingPattern.2(target=es2015).errors.txt b/tests/baselines/reference/optionalChainingInParameterBindingPattern.2(target=es2015).errors.txt new file mode 100644 index 00000000000..74568e69691 --- /dev/null +++ b/tests/baselines/reference/optionalChainingInParameterBindingPattern.2(target=es2015).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2.ts(3,6): error TS2373: Parameter '{ [a()?.d]: c = "" }' cannot reference identifier 'a' declared after it. +tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2.ts(6,24): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + const a = (): { d: string } | undefined => undefined; + (({ [a()?.d]: c = "" }) => { var a; })(); + ~ +!!! error TS2373: Parameter '{ [a()?.d]: c = "" }' cannot reference identifier 'a' declared after it. + + const x = ""; + (({ [a()?.d]: c }, d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. \ No newline at end of file diff --git a/tests/baselines/reference/optionalChainingInParameterBindingPattern.2(target=es5).errors.txt b/tests/baselines/reference/optionalChainingInParameterBindingPattern.2(target=es5).errors.txt new file mode 100644 index 00000000000..74568e69691 --- /dev/null +++ b/tests/baselines/reference/optionalChainingInParameterBindingPattern.2(target=es5).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2.ts(3,6): error TS2373: Parameter '{ [a()?.d]: c = "" }' cannot reference identifier 'a' declared after it. +tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2.ts(6,24): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + const a = (): { d: string } | undefined => undefined; + (({ [a()?.d]: c = "" }) => { var a; })(); + ~ +!!! error TS2373: Parameter '{ [a()?.d]: c = "" }' cannot reference identifier 'a' declared after it. + + const x = ""; + (({ [a()?.d]: c }, d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. \ No newline at end of file diff --git a/tests/baselines/reference/optionalChainingInParameterInitializer(target=es2015).js b/tests/baselines/reference/optionalChainingInParameterInitializer(target=es2015).js new file mode 100644 index 00000000000..5c8a8ec76ee --- /dev/null +++ b/tests/baselines/reference/optionalChainingInParameterInitializer(target=es2015).js @@ -0,0 +1,9 @@ +//// [optionalChainingInParameterInitializer.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): { d: string } | undefined => undefined; +((b = a()?.d) => {})(); + +//// [optionalChainingInParameterInitializer.js] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = () => undefined; +((b) => { var _a; if (b === void 0) { b = (_a = a()) === null || _a === void 0 ? void 0 : _a.d; } })(); diff --git a/tests/baselines/reference/optionalChainingInParameterInitializer(target=es5).js b/tests/baselines/reference/optionalChainingInParameterInitializer(target=es5).js new file mode 100644 index 00000000000..07554c92cb6 --- /dev/null +++ b/tests/baselines/reference/optionalChainingInParameterInitializer(target=es5).js @@ -0,0 +1,12 @@ +//// [optionalChainingInParameterInitializer.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): { d: string } | undefined => undefined; +((b = a()?.d) => {})(); + +//// [optionalChainingInParameterInitializer.js] +// https://github.com/microsoft/TypeScript/issues/36295 +var a = function () { return undefined; }; +(function (b) { + var _a; + if (b === void 0) { b = (_a = a()) === null || _a === void 0 ? void 0 : _a.d; } +})(); diff --git a/tests/baselines/reference/optionalChainingInParameterInitializer(target=esnext).js b/tests/baselines/reference/optionalChainingInParameterInitializer(target=esnext).js new file mode 100644 index 00000000000..cdda35727ba --- /dev/null +++ b/tests/baselines/reference/optionalChainingInParameterInitializer(target=esnext).js @@ -0,0 +1,9 @@ +//// [optionalChainingInParameterInitializer.ts] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): { d: string } | undefined => undefined; +((b = a()?.d) => {})(); + +//// [optionalChainingInParameterInitializer.js] +// https://github.com/microsoft/TypeScript/issues/36295 +const a = () => undefined; +((b = a()?.d) => { })(); diff --git a/tests/baselines/reference/optionalChainingInParameterInitializer.2(target=es2015).errors.txt b/tests/baselines/reference/optionalChainingInParameterInitializer.2(target=es2015).errors.txt new file mode 100644 index 00000000000..80a8657d5bf --- /dev/null +++ b/tests/baselines/reference/optionalChainingInParameterInitializer.2(target=es2015).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.2.ts(3,7): error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. +tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.2.ts(6,19): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + const a = (): { d: string } | undefined => undefined; + ((b = a()?.d) => { var a; })(); + ~ +!!! error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. + + const x = ""; + ((b = a()?.d, d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. \ No newline at end of file diff --git a/tests/baselines/reference/optionalChainingInParameterInitializer.2(target=es5).errors.txt b/tests/baselines/reference/optionalChainingInParameterInitializer.2(target=es5).errors.txt new file mode 100644 index 00000000000..80a8657d5bf --- /dev/null +++ b/tests/baselines/reference/optionalChainingInParameterInitializer.2(target=es5).errors.txt @@ -0,0 +1,15 @@ +tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.2.ts(3,7): error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. +tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.2.ts(6,19): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.2.ts (2 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + const a = (): { d: string } | undefined => undefined; + ((b = a()?.d) => { var a; })(); + ~ +!!! error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. + + const x = ""; + ((b = a()?.d, d = x) => { var x; })(); + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. \ No newline at end of file diff --git a/tests/baselines/reference/optionalParamReferencingOtherParams2.errors.txt b/tests/baselines/reference/optionalParamReferencingOtherParams2.errors.txt index fa89c3ed761..19eb916515a 100644 --- a/tests/baselines/reference/optionalParamReferencingOtherParams2.errors.txt +++ b/tests/baselines/reference/optionalParamReferencingOtherParams2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/optionalParamReferencingOtherParams2.ts(2,29): error TS2373: Initializer of parameter 'y' cannot reference identifier 'b' declared after it. +tests/cases/compiler/optionalParamReferencingOtherParams2.ts(2,29): error TS2373: Parameter 'y' cannot reference identifier 'b' declared after it. ==== tests/cases/compiler/optionalParamReferencingOtherParams2.ts (1 errors) ==== var a = 1; function strange(x = a, y = b) { ~ -!!! error TS2373: Initializer of parameter 'y' cannot reference identifier 'b' declared after it. +!!! error TS2373: Parameter 'y' cannot reference identifier 'b' declared after it. var b = ""; return y; } \ No newline at end of file diff --git a/tests/baselines/reference/optionalParamReferencingOtherParams3.errors.txt b/tests/baselines/reference/optionalParamReferencingOtherParams3.errors.txt index f2b8d3d9127..b278a97dee7 100644 --- a/tests/baselines/reference/optionalParamReferencingOtherParams3.errors.txt +++ b/tests/baselines/reference/optionalParamReferencingOtherParams3.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/optionalParamReferencingOtherParams3.ts(1,20): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. +tests/cases/compiler/optionalParamReferencingOtherParams3.ts(1,20): error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. ==== tests/cases/compiler/optionalParamReferencingOtherParams3.ts (1 errors) ==== function right(a = b, b = a) { ~ -!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. +!!! error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. a; b; } \ No newline at end of file diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing.2(target=es2015).errors.txt b/tests/baselines/reference/parameterInitializersForwardReferencing.2(target=es2015).errors.txt new file mode 100644 index 00000000000..dda50bbc2fd --- /dev/null +++ b/tests/baselines/reference/parameterInitializersForwardReferencing.2(target=es2015).errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts(5,18): error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts(5,32): error TS2373: Parameter '{ b = a(), ...x }' cannot reference identifier 'a' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts(11,35): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts (3 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + + function a(): any {} + + function b({ b = a(), ...x } = a()) { + ~ +!!! error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. + ~ +!!! error TS2373: Parameter '{ b = a(), ...x }' cannot reference identifier 'a' declared after it. + var a; + } + + const x = ""; + + function c({ b, ...c } = a(), d = x) { + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + var x; + } \ No newline at end of file diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing.2(target=es5).errors.txt b/tests/baselines/reference/parameterInitializersForwardReferencing.2(target=es5).errors.txt new file mode 100644 index 00000000000..dda50bbc2fd --- /dev/null +++ b/tests/baselines/reference/parameterInitializersForwardReferencing.2(target=es5).errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts(5,18): error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts(5,32): error TS2373: Parameter '{ b = a(), ...x }' cannot reference identifier 'a' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts(11,35): error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + + +==== tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts (3 errors) ==== + // https://github.com/microsoft/TypeScript/issues/36295 + + function a(): any {} + + function b({ b = a(), ...x } = a()) { + ~ +!!! error TS2373: Parameter 'b' cannot reference identifier 'a' declared after it. + ~ +!!! error TS2373: Parameter '{ b = a(), ...x }' cannot reference identifier 'a' declared after it. + var a; + } + + const x = ""; + + function c({ b, ...c } = a(), d = x) { + ~ +!!! error TS2373: Parameter 'd' cannot reference identifier 'x' declared after it. + var x; + } \ No newline at end of file diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing.errors.txt b/tests/baselines/reference/parameterInitializersForwardReferencing.errors.txt index 22fe5ce558d..1bc24be31f6 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing.errors.txt +++ b/tests/baselines/reference/parameterInitializersForwardReferencing.errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(6,20): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(11,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(11,28): error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(17,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(23,25): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(32,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(33,16): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,14): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,21): error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,28): error TS2373: Initializer of parameter 'c' cannot reference identifier 'd' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(6,20): error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(11,21): error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(11,28): error TS2373: Parameter 'b' cannot reference identifier 'c' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(17,21): error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(23,25): error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(32,21): error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(33,16): error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,14): error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,21): error TS2373: Parameter 'b' cannot reference identifier 'c' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,28): error TS2373: Parameter 'c' cannot reference identifier 'd' declared after it. ==== tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts (10 errors) ==== @@ -18,16 +18,16 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37, function right(a = b, b = a) { ~ -!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. +!!! error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. a; b; } function right2(a = b, b = c, c = a) { ~ -!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. +!!! error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. ~ -!!! error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it. +!!! error TS2373: Parameter 'b' cannot reference identifier 'c' declared after it. a; b; c; @@ -35,7 +35,7 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37, function inside(a = b) { ~ -!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. +!!! error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. var b; } @@ -43,7 +43,7 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37, var b; function inside(a = b) { // Still an error because b is declared inside the function ~ -!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. +!!! error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. var b; } } @@ -54,20 +54,20 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37, class C { constructor(a = b, b = 1) { } ~ -!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. +!!! error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. method(a = b, b = 1) { } ~ -!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. +!!! error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. } // Function expressions var x = (a = b, b = c, c = d) => { var d; }; ~ -!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it. +!!! error TS2373: Parameter 'a' cannot reference identifier 'b' declared after it. ~ -!!! error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it. +!!! error TS2373: Parameter 'b' cannot reference identifier 'c' declared after it. ~ -!!! error TS2373: Initializer of parameter 'c' cannot reference identifier 'd' declared after it. +!!! error TS2373: Parameter 'c' cannot reference identifier 'd' declared after it. // Should not produce errors - can reference later parameters if they occur within a function expression initializer. function f(a, b = function () { return c; }, c = b()) { diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt b/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt index 91d200adbcd..3c8b2fcdc48 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1.errors.txt @@ -1,16 +1,17 @@ -tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(3,20): error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(13,20): error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(21,18): error TS2372: Parameter 'a' cannot be referenced in its initializer. -tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(25,22): error TS2372: Parameter 'async' cannot be referenced in its initializer. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(3,20): error TS2373: Parameter 'bar' cannot reference identifier 'foo' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(13,20): error TS2373: Parameter 'bar' cannot reference identifier 'foo' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(21,18): error TS2372: Parameter 'a' cannot reference itself. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(25,22): error TS2372: Parameter 'async' cannot reference itself. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(29,15): error TS2373: Parameter '{[foo]: bar}' cannot reference identifier 'foo' declared after it. tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(29,15): error TS2448: Block-scoped variable 'foo' used before its declaration. -==== tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts (5 errors) ==== +==== tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts (6 errors) ==== let foo: string = ""; function f1 (bar = foo) { // unexpected compiler error; works at runtime ~~~ -!!! error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. +!!! error TS2373: Parameter 'bar' cannot reference identifier 'foo' declared after it. var foo: number = 2; return bar; // returns 1 } @@ -22,7 +23,7 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(29 function f3 (bar = foo, foo = 2) { // correct compiler error, error at runtime ~~~ -!!! error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. +!!! error TS2373: Parameter 'bar' cannot reference identifier 'foo' declared after it. return bar; } @@ -32,18 +33,20 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts(29 function f5 (a = a) { ~ -!!! error TS2372: Parameter 'a' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'a' cannot reference itself. return a } function f6 (async = async) { ~~~~~ -!!! error TS2372: Parameter 'async' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'async' cannot reference itself. return async } function f7({[foo]: bar}: any[]) { ~~~ +!!! error TS2373: Parameter '{[foo]: bar}' cannot reference identifier 'foo' declared after it. + ~~~ !!! error TS2448: Block-scoped variable 'foo' used before its declaration. !!! related TS2728 tests/cases/conformance/functions/parameterInitializersForwardReferencing1.ts:30:9: 'foo' is declared here. let foo: number = 2; diff --git a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt index c65f327161e..fee18ea4964 100644 --- a/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt +++ b/tests/baselines/reference/parameterInitializersForwardReferencing1_es6.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(13,20): error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. -tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(21,18): error TS2372: Parameter 'a' cannot be referenced in its initializer. -tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(25,22): error TS2372: Parameter 'async' cannot be referenced in its initializer. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(13,20): error TS2373: Parameter 'bar' cannot reference identifier 'foo' declared after it. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(21,18): error TS2372: Parameter 'a' cannot reference itself. +tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(25,22): error TS2372: Parameter 'async' cannot reference itself. tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.ts(29,15): error TS2537: Type 'any[]' has no matching index signature for type 'string'. @@ -19,7 +19,7 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.t function f3 (bar = foo, foo = 2) { // correct compiler error, error at runtime ~~~ -!!! error TS2373: Initializer of parameter 'bar' cannot reference identifier 'foo' declared after it. +!!! error TS2373: Parameter 'bar' cannot reference identifier 'foo' declared after it. return bar; } @@ -29,13 +29,13 @@ tests/cases/conformance/functions/parameterInitializersForwardReferencing1_es6.t function f5 (a = a) { ~ -!!! error TS2372: Parameter 'a' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'a' cannot reference itself. return a } function f6 (async = async) { ~~~~~ -!!! error TS2372: Parameter 'async' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'async' cannot reference itself. return async } diff --git a/tests/baselines/reference/selfReferencesInFunctionParameters.errors.txt b/tests/baselines/reference/selfReferencesInFunctionParameters.errors.txt index 32955b0bdc2..6642da1d4ee 100644 --- a/tests/baselines/reference/selfReferencesInFunctionParameters.errors.txt +++ b/tests/baselines/reference/selfReferencesInFunctionParameters.errors.txt @@ -1,28 +1,28 @@ -tests/cases/compiler/selfReferencesInFunctionParameters.ts(1,26): error TS2372: Parameter 'x' cannot be referenced in its initializer. -tests/cases/compiler/selfReferencesInFunctionParameters.ts(4,35): error TS2372: Parameter 'x' cannot be referenced in its initializer. -tests/cases/compiler/selfReferencesInFunctionParameters.ts(8,28): error TS2372: Parameter 'y' cannot be referenced in its initializer. -tests/cases/compiler/selfReferencesInFunctionParameters.ts(11,29): error TS2372: Parameter 'b' cannot be referenced in its initializer. +tests/cases/compiler/selfReferencesInFunctionParameters.ts(1,26): error TS2372: Parameter 'x' cannot reference itself. +tests/cases/compiler/selfReferencesInFunctionParameters.ts(4,35): error TS2372: Parameter 'x' cannot reference itself. +tests/cases/compiler/selfReferencesInFunctionParameters.ts(8,28): error TS2372: Parameter 'y' cannot reference itself. +tests/cases/compiler/selfReferencesInFunctionParameters.ts(11,29): error TS2372: Parameter 'b' cannot reference itself. ==== tests/cases/compiler/selfReferencesInFunctionParameters.ts (4 errors) ==== function foo(x: number = x) { ~ -!!! error TS2372: Parameter 'x' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'x' cannot reference itself. } function bar(x0 = "", x: number = x) { ~ -!!! error TS2372: Parameter 'x' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'x' cannot reference itself. } class C { constructor(x = 1, y = y) { ~ -!!! error TS2372: Parameter 'y' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'y' cannot reference itself. } bar(a = "", b: string = b.toString()) { ~ -!!! error TS2372: Parameter 'b' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'b' cannot reference itself. } } \ No newline at end of file diff --git a/tests/baselines/reference/witness.errors.txt b/tests/baselines/reference/witness.errors.txt index efaed3cc43c..c005239eb96 100644 --- a/tests/baselines/reference/witness.errors.txt +++ b/tests/baselines/reference/witness.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/witness/witness.ts(4,21): error TS2372: Parameter 'pInit' cannot be referenced in its initializer. +tests/cases/conformance/types/witness/witness.ts(4,21): error TS2372: Parameter 'pInit' cannot reference itself. tests/cases/conformance/types/witness/witness.ts(8,14): error TS2729: Property 'x' is used before its initialization. tests/cases/conformance/types/witness/witness.ts(28,12): error TS2695: Left side of comma operator is unused and has no side effects. tests/cases/conformance/types/witness/witness.ts(29,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'co1' must be of type 'any', but here has type 'number'. @@ -23,7 +23,7 @@ tests/cases/conformance/types/witness/witness.ts(128,19): error TS2729: Property var pInit: any; function fn(pInit = pInit) { ~~~~~ -!!! error TS2372: Parameter 'pInit' cannot be referenced in its initializer. +!!! error TS2372: Parameter 'pInit' cannot reference itself. var pInit: any; } class InitClass { diff --git a/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts new file mode 100644 index 00000000000..839eb3c87a9 --- /dev/null +++ b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.2.ts @@ -0,0 +1,10 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/36295 +class C {} +(({ [class extends C { static x = 1 }.x]: b = "" }) => { var C; })(); + +const x = ""; +(({ [class extends C { static x = 1 }.x]: b = "" }, d = x) => { var x; })(); diff --git a/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3.ts b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3.ts new file mode 100644 index 00000000000..7f55d82804f --- /dev/null +++ b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.3.ts @@ -0,0 +1,11 @@ +// @target: esnext +// @noTypesAndSymbols: true +// @noEmit: true +// @useDefineForClassFields: true + +// https://github.com/microsoft/TypeScript/issues/36295 +class C {} +(({ [class extends C { static x = 1 }.x]: b = "" }) => { var C; })(); + +const x = ""; +(({ [class extends C { static x = 1 }.x]: b = "" }, d = x) => { var x; })(); diff --git a/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.ts b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.ts new file mode 100644 index 00000000000..1d6c683dc74 --- /dev/null +++ b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterBindingPattern.ts @@ -0,0 +1,5 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true + +// https://github.com/microsoft/TypeScript/issues/36295 +(({ [class { static x = 1 }.x]: b = "" }) => {})(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts new file mode 100644 index 00000000000..e70f19006df --- /dev/null +++ b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.2.ts @@ -0,0 +1,10 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/36295 +class C {} +((b = class extends C { static x = 1 }) => { var C; })(); + +const x = ""; +((b = class extends C { static x = 1 }, d = x) => { var x; })(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.3.ts b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.3.ts new file mode 100644 index 00000000000..ba2b2db8e25 --- /dev/null +++ b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.3.ts @@ -0,0 +1,11 @@ +// @target: esnext +// @noTypesAndSymbols: true +// @noEmit: true +// @useDefineForClassFields: true + +// https://github.com/microsoft/TypeScript/issues/36295 +class C {} +((b = class extends C { static x = 1 }) => { var C; })(); + +const x = ""; +((b = class extends C { static x = 1 }, d = x) => { var x; })(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.ts b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.ts new file mode 100644 index 00000000000..8b32f84feb3 --- /dev/null +++ b/tests/cases/conformance/classes/classExpressions/classWithStaticFieldInParameterInitializer.ts @@ -0,0 +1,5 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true + +// https://github.com/microsoft/TypeScript/issues/36295 +((b = class { static x = 1 }) => {})(); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.2.ts b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.2.ts new file mode 100644 index 00000000000..5925fe4d863 --- /dev/null +++ b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.2.ts @@ -0,0 +1,10 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): string | undefined => undefined; +(({ [a() ?? "d"]: c = "" }) => { var a; })(); + +const x = ""; +(({ [a() ?? "d"]: c = "", d = x }) => { var x; })(); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.ts b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.ts new file mode 100644 index 00000000000..1231cb5d0fe --- /dev/null +++ b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterBindingPattern.ts @@ -0,0 +1,6 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true + +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): string | undefined => undefined; +(({ [a() ?? "d"]: c = "" }) => {})(); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2.ts b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2.ts new file mode 100644 index 00000000000..c3da31aa203 --- /dev/null +++ b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.2.ts @@ -0,0 +1,10 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): string | undefined => undefined; +((b = a() ?? "d") => { var a; })(); + +const x = ""; +((b = a() ?? "d", d = x) => { var x; })(); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.ts b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.ts new file mode 100644 index 00000000000..f8c5da30425 --- /dev/null +++ b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInParameterInitializer.ts @@ -0,0 +1,6 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true + +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): string | undefined => undefined; +((b = a() ?? "d") => {})(); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2.ts b/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2.ts new file mode 100644 index 00000000000..423e8a46513 --- /dev/null +++ b/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.2.ts @@ -0,0 +1,10 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): { d: string } | undefined => undefined; +(({ [a()?.d]: c = "" }) => { var a; })(); + +const x = ""; +(({ [a()?.d]: c }, d = x) => { var x; })(); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.ts b/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.ts new file mode 100644 index 00000000000..38cabea7aee --- /dev/null +++ b/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterBindingPattern.ts @@ -0,0 +1,6 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true + +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): { d: string } | undefined => undefined; +(({ [a()?.d]: c = "" }) => {})(); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.2.ts b/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.2.ts new file mode 100644 index 00000000000..707be27f114 --- /dev/null +++ b/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.2.ts @@ -0,0 +1,10 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): { d: string } | undefined => undefined; +((b = a()?.d) => { var a; })(); + +const x = ""; +((b = a()?.d, d = x) => { var x; })(); \ No newline at end of file diff --git a/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.ts b/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.ts new file mode 100644 index 00000000000..867887fc260 --- /dev/null +++ b/tests/cases/conformance/expressions/optionalChaining/optionalChainingInParameterInitializer.ts @@ -0,0 +1,6 @@ +// @target: esnext,es2015,es5 +// @noTypesAndSymbols: true + +// https://github.com/microsoft/TypeScript/issues/36295 +const a = (): { d: string } | undefined => undefined; +((b = a()?.d) => {})(); \ No newline at end of file diff --git a/tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts b/tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts new file mode 100644 index 00000000000..7aa08e2dbf0 --- /dev/null +++ b/tests/cases/conformance/functions/parameterInitializersForwardReferencing.2.ts @@ -0,0 +1,17 @@ +// @target: es5, es2015, esnext +// @noEmit: true +// @noTypesAndSymbols: true + +// https://github.com/microsoft/TypeScript/issues/36295 + +function a(): any {} + +function b({ b = a(), ...x } = a()) { + var a; +} + +const x = ""; + +function c({ b, ...c } = a(), d = x) { + var x; +} \ No newline at end of file From 689822c1838dd0462f9fb514bad5e94fc96fb68e Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 24 Apr 2020 09:52:18 -0700 Subject: [PATCH 50/74] convertToAsyncFunction: Disable for `.then` with both fulfillment and rejection handlers (#38152) * Disable convert to async for `.then` with both fulfillment and rejection handlers * Delete baselines * Also disable refactor for 3+ arguments --- src/services/suggestionDiagnostics.ts | 13 ++++++++- .../services/convertToAsyncFunction.ts | 13 ++++++--- .../convertToAsyncFunction_Rej.ts | 17 ----------- .../convertToAsyncFunction_RejNoBrackets.ts | 17 ----------- .../convertToAsyncFunction_RejRef.ts | 29 ------------------- ...onvertToAsyncFunction_ResRejNoArgsArrow.js | 17 ----------- ...onvertToAsyncFunction_ResRejNoArgsArrow.ts | 17 ----------- 7 files changed, 21 insertions(+), 102 deletions(-) delete mode 100644 tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_Rej.ts delete mode 100644 tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_RejNoBrackets.ts delete mode 100644 tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_RejRef.ts delete mode 100644 tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ResRejNoArgsArrow.js delete mode 100644 tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ResRejNoArgsArrow.ts diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts index a80bd58c6d7..09607d8ab8a 100644 --- a/src/services/suggestionDiagnostics.ts +++ b/src/services/suggestionDiagnostics.ts @@ -156,7 +156,18 @@ namespace ts { } function isPromiseHandler(node: Node): node is CallExpression { - return isCallExpression(node) && (hasPropertyAccessExpressionWithName(node, "then") || hasPropertyAccessExpressionWithName(node, "catch")); + return isCallExpression(node) && ( + hasPropertyAccessExpressionWithName(node, "then") && hasSupportedNumberOfArguments(node) || + hasPropertyAccessExpressionWithName(node, "catch")); + } + + function hasSupportedNumberOfArguments(node: CallExpression) { + if (node.arguments.length > 2) return false; + if (node.arguments.length < 2) return true; + return some(node.arguments, arg => { + return arg.kind === SyntaxKind.NullKeyword || + isIdentifier(arg) && arg.text === "undefined"; + }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts diff --git a/src/testRunner/unittests/services/convertToAsyncFunction.ts b/src/testRunner/unittests/services/convertToAsyncFunction.ts index 2a362316075..999e1580a98 100644 --- a/src/testRunner/unittests/services/convertToAsyncFunction.ts +++ b/src/testRunner/unittests/services/convertToAsyncFunction.ts @@ -558,13 +558,13 @@ function [#|f|]():void{ } ` ); - _testConvertToAsyncFunction("convertToAsyncFunction_Rej", ` + _testConvertToAsyncFunctionFailed("convertToAsyncFunction_Rej", ` function [#|f|]():Promise { return fetch('https://typescriptlang.org').then(result => { console.log(result); }, rejection => { console.log("rejected:", rejection); }); } ` ); - _testConvertToAsyncFunction("convertToAsyncFunction_RejRef", ` + _testConvertToAsyncFunctionFailed("convertToAsyncFunction_RejRef", ` function [#|f|]():Promise { return fetch('https://typescriptlang.org').then(res, rej); } @@ -576,7 +576,7 @@ function rej(err){ } ` ); - _testConvertToAsyncFunction("convertToAsyncFunction_RejNoBrackets", ` + _testConvertToAsyncFunctionFailed("convertToAsyncFunction_RejNoBrackets", ` function [#|f|]():Promise { return fetch('https://typescriptlang.org').then(result => console.log(result), rejection => console.log("rejected:", rejection)); } @@ -1238,7 +1238,7 @@ function [#|f|]() { } `); - _testConvertToAsyncFunction("convertToAsyncFunction_ResRejNoArgsArrow", ` + _testConvertToAsyncFunctionFailed("convertToAsyncFunction_ResRejNoArgsArrow", ` function [#|f|]() { return Promise.resolve().then(() => 1, () => "a"); } @@ -1436,5 +1436,10 @@ function [#|get|]() { .catch>(() => ({ success: false })); } `); + + _testConvertToAsyncFunctionFailed("convertToAsyncFunction_threeArguments", ` +function [#|f|]() { + return Promise.resolve().then(undefined, undefined, () => 1); +}`); }); } diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_Rej.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_Rej.ts deleted file mode 100644 index bf3ee9c420c..00000000000 --- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_Rej.ts +++ /dev/null @@ -1,17 +0,0 @@ -// ==ORIGINAL== - -function /*[#|*/f/*|]*/():Promise { - return fetch('https://typescriptlang.org').then(result => { console.log(result); }, rejection => { console.log("rejected:", rejection); }); -} - -// ==ASYNC FUNCTION::Convert to async function== - -async function f():Promise { - try { - const result = await fetch('https://typescriptlang.org'); - console.log(result); - } - catch (rejection) { - console.log("rejected:", rejection); - } -} diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_RejNoBrackets.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_RejNoBrackets.ts deleted file mode 100644 index 8169745f5bd..00000000000 --- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_RejNoBrackets.ts +++ /dev/null @@ -1,17 +0,0 @@ -// ==ORIGINAL== - -function /*[#|*/f/*|]*/():Promise { - return fetch('https://typescriptlang.org').then(result => console.log(result), rejection => console.log("rejected:", rejection)); -} - -// ==ASYNC FUNCTION::Convert to async function== - -async function f():Promise { - try { - const result = await fetch('https://typescriptlang.org'); - return console.log(result); - } - catch (rejection) { - return console.log("rejected:", rejection); - } -} diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_RejRef.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_RejRef.ts deleted file mode 100644 index 77fadff7ee9..00000000000 --- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_RejRef.ts +++ /dev/null @@ -1,29 +0,0 @@ -// ==ORIGINAL== - -function /*[#|*/f/*|]*/():Promise { - return fetch('https://typescriptlang.org').then(res, rej); -} -function res(result){ - console.log(result); -} -function rej(err){ - console.log(err); -} - -// ==ASYNC FUNCTION::Convert to async function== - -async function f():Promise { - try { - const result = await fetch('https://typescriptlang.org'); - return res(result); - } - catch (err) { - return rej(err); - } -} -function res(result){ - console.log(result); -} -function rej(err){ - console.log(err); -} diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ResRejNoArgsArrow.js b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ResRejNoArgsArrow.js deleted file mode 100644 index 0b4a430f505..00000000000 --- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ResRejNoArgsArrow.js +++ /dev/null @@ -1,17 +0,0 @@ -// ==ORIGINAL== - - function /*[#|*/f/*|]*/() { - return Promise.resolve().then(() => 1, () => "a"); - } - -// ==ASYNC FUNCTION::Convert to async function== - - async function f() { - try { - await Promise.resolve(); - return 1; - } - catch (e) { - return "a"; - } - } diff --git a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ResRejNoArgsArrow.ts b/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ResRejNoArgsArrow.ts deleted file mode 100644 index 0b4a430f505..00000000000 --- a/tests/baselines/reference/convertToAsyncFunction/convertToAsyncFunction_ResRejNoArgsArrow.ts +++ /dev/null @@ -1,17 +0,0 @@ -// ==ORIGINAL== - - function /*[#|*/f/*|]*/() { - return Promise.resolve().then(() => 1, () => "a"); - } - -// ==ASYNC FUNCTION::Convert to async function== - - async function f() { - try { - await Promise.resolve(); - return 1; - } - catch (e) { - return "a"; - } - } From 38ff7762ec3b9eccf63161ddb449ab9a86975401 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 24 Apr 2020 12:10:29 -0700 Subject: [PATCH 51/74] Fix temp variable scoping in async generators (#38121) --- src/compiler/transformers/es2018.ts | 2 +- ...OperatorInAsyncGenerator(target=es2015).js | 21 ++++++++++++ ...ingOperatorInAsyncGenerator(target=es5).js | 33 +++++++++++++++++++ ...OperatorInAsyncGenerator(target=esnext).js | 18 ++++++++++ ...llishCoalescingOperatorInAsyncGenerator.ts | 12 +++++++ 5 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=es2015).js create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=es5).js create mode 100644 tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=esnext).js create mode 100644 tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInAsyncGenerator.ts diff --git a/src/compiler/transformers/es2018.ts b/src/compiler/transformers/es2018.ts index 9050ebc601b..a3ae750f6e7 100644 --- a/src/compiler/transformers/es2018.ts +++ b/src/compiler/transformers/es2018.ts @@ -1115,7 +1115,7 @@ namespace ts { context.requestEmitHelper(asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {} as EmitNode)).flags |= EmitFlags.AsyncFunctionBody; + (generatorFunc.emitNode || (generatorFunc.emitNode = {} as EmitNode)).flags |= EmitFlags.AsyncFunctionBody | EmitFlags.ReuseTempVariableScope; return createCall( getUnscopedHelperName("__asyncGenerator"), diff --git a/tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=es2015).js b/tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=es2015).js new file mode 100644 index 00000000000..6cbc459a37f --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=es2015).js @@ -0,0 +1,21 @@ +//// [nullishCoalescingOperatorInAsyncGenerator.ts] +// https://github.com/microsoft/TypeScript/issues/37686 +async function* f(a: { b?: number }) { + let c = a.b ?? 10; + while (c) { + yield c--; + } +} + + +//// [nullishCoalescingOperatorInAsyncGenerator.js] +// https://github.com/microsoft/TypeScript/issues/37686 +function f(a) { + var _a; + return __asyncGenerator(this, arguments, function* f_1() { + let c = (_a = a.b) !== null && _a !== void 0 ? _a : 10; + while (c) { + yield yield __await(c--); + } + }); +} diff --git a/tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=es5).js b/tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=es5).js new file mode 100644 index 00000000000..972189a54d3 --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=es5).js @@ -0,0 +1,33 @@ +//// [nullishCoalescingOperatorInAsyncGenerator.ts] +// https://github.com/microsoft/TypeScript/issues/37686 +async function* f(a: { b?: number }) { + let c = a.b ?? 10; + while (c) { + yield c--; + } +} + + +//// [nullishCoalescingOperatorInAsyncGenerator.js] +// https://github.com/microsoft/TypeScript/issues/37686 +function f(a) { + var _a; + return __asyncGenerator(this, arguments, function f_1() { + var c; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + c = (_a = a.b) !== null && _a !== void 0 ? _a : 10; + _b.label = 1; + case 1: + if (!c) return [3 /*break*/, 4]; + return [4 /*yield*/, __await(c--)]; + case 2: return [4 /*yield*/, _b.sent()]; + case 3: + _b.sent(); + return [3 /*break*/, 1]; + case 4: return [2 /*return*/]; + } + }); + }); +} diff --git a/tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=esnext).js b/tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=esnext).js new file mode 100644 index 00000000000..430355c3d42 --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperatorInAsyncGenerator(target=esnext).js @@ -0,0 +1,18 @@ +//// [nullishCoalescingOperatorInAsyncGenerator.ts] +// https://github.com/microsoft/TypeScript/issues/37686 +async function* f(a: { b?: number }) { + let c = a.b ?? 10; + while (c) { + yield c--; + } +} + + +//// [nullishCoalescingOperatorInAsyncGenerator.js] +// https://github.com/microsoft/TypeScript/issues/37686 +async function* f(a) { + let c = a.b ?? 10; + while (c) { + yield c--; + } +} diff --git a/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInAsyncGenerator.ts b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInAsyncGenerator.ts new file mode 100644 index 00000000000..54f6923c3e6 --- /dev/null +++ b/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperatorInAsyncGenerator.ts @@ -0,0 +1,12 @@ +// @target: esnext,es2015,es5 +// @lib: esnext +// @noEmitHelpers: true +// @noTypesAndSymbols: true + +// https://github.com/microsoft/TypeScript/issues/37686 +async function* f(a: { b?: number }) { + let c = a.b ?? 10; + while (c) { + yield c--; + } +} From fe140acc09b9dbe98cdc4f5cbc100b3bbaab8bed Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 24 Apr 2020 13:02:17 -0700 Subject: [PATCH 52/74] Fix truthiness call check for this-property access (#38163) --- src/compiler/checker.ts | 4 +++- .../truthinessCallExpressionCoercion1.errors.txt | 5 +++++ .../reference/truthinessCallExpressionCoercion1.js | 9 +++++++++ .../truthinessCallExpressionCoercion1.symbols | 12 ++++++++++++ .../truthinessCallExpressionCoercion1.types | 13 +++++++++++++ .../compiler/truthinessCallExpressionCoercion1.ts | 5 +++++ 6 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 52a667a1451..e1cda181eee 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -31909,7 +31909,9 @@ namespace ts { let childExpression = childNode.parent; while (testedExpression && childExpression) { - if (isIdentifier(testedExpression) && isIdentifier(childExpression)) { + if (isIdentifier(testedExpression) && isIdentifier(childExpression) || + testedExpression.kind === SyntaxKind.ThisKeyword && childExpression.kind === SyntaxKind.ThisKeyword + ) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion1.errors.txt b/tests/baselines/reference/truthinessCallExpressionCoercion1.errors.txt index 6a32d1f050a..e30041e220a 100644 --- a/tests/baselines/reference/truthinessCallExpressionCoercion1.errors.txt +++ b/tests/baselines/reference/truthinessCallExpressionCoercion1.errors.txt @@ -80,6 +80,11 @@ tests/cases/compiler/truthinessCallExpressionCoercion1.ts(61,9): error TS2774: T // ok this.maybeIsUser ? console.log('this.maybeIsUser') : undefined; + + // ok + if (this.isUser) { + this.isUser(); + } } } \ No newline at end of file diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion1.js b/tests/baselines/reference/truthinessCallExpressionCoercion1.js index 4415cedf596..ecb76aadf89 100644 --- a/tests/baselines/reference/truthinessCallExpressionCoercion1.js +++ b/tests/baselines/reference/truthinessCallExpressionCoercion1.js @@ -63,6 +63,11 @@ class Foo { // ok this.maybeIsUser ? console.log('this.maybeIsUser') : undefined; + + // ok + if (this.isUser) { + this.isUser(); + } } } @@ -117,6 +122,10 @@ var Foo = /** @class */ (function () { this.isUser ? console.log('this.isUser') : undefined; // ok this.maybeIsUser ? console.log('this.maybeIsUser') : undefined; + // ok + if (this.isUser) { + this.isUser(); + } }; return Foo; }()); diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion1.symbols b/tests/baselines/reference/truthinessCallExpressionCoercion1.symbols index 1f729481ac6..aace0d3c556 100644 --- a/tests/baselines/reference/truthinessCallExpressionCoercion1.symbols +++ b/tests/baselines/reference/truthinessCallExpressionCoercion1.symbols @@ -170,6 +170,18 @@ class Foo { >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) >undefined : Symbol(undefined) + + // ok + if (this.isUser) { +>this.isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion1.ts, 52, 32)) +>this : Symbol(Foo, Decl(truthinessCallExpressionCoercion1.ts, 49, 1)) +>isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion1.ts, 52, 32)) + + this.isUser(); +>this.isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion1.ts, 52, 32)) +>this : Symbol(Foo, Decl(truthinessCallExpressionCoercion1.ts, 49, 1)) +>isUser : Symbol(Foo.isUser, Decl(truthinessCallExpressionCoercion1.ts, 52, 32)) + } } } diff --git a/tests/baselines/reference/truthinessCallExpressionCoercion1.types b/tests/baselines/reference/truthinessCallExpressionCoercion1.types index 8c53f481c42..bcbde0d35f6 100644 --- a/tests/baselines/reference/truthinessCallExpressionCoercion1.types +++ b/tests/baselines/reference/truthinessCallExpressionCoercion1.types @@ -223,6 +223,19 @@ class Foo { >log : (...data: any[]) => void >'this.maybeIsUser' : "this.maybeIsUser" >undefined : undefined + + // ok + if (this.isUser) { +>this.isUser : () => boolean +>this : this +>isUser : () => boolean + + this.isUser(); +>this.isUser() : boolean +>this.isUser : () => boolean +>this : this +>isUser : () => boolean + } } } diff --git a/tests/cases/compiler/truthinessCallExpressionCoercion1.ts b/tests/cases/compiler/truthinessCallExpressionCoercion1.ts index 04331cbeadd..6835a434aa4 100644 --- a/tests/cases/compiler/truthinessCallExpressionCoercion1.ts +++ b/tests/cases/compiler/truthinessCallExpressionCoercion1.ts @@ -64,5 +64,10 @@ class Foo { // ok this.maybeIsUser ? console.log('this.maybeIsUser') : undefined; + + // ok + if (this.isUser) { + this.isUser(); + } } } From 1785d6c707248ae1225f0e4797300f5f210f40f8 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 24 Apr 2020 13:10:34 -0700 Subject: [PATCH 53/74] Special-case export assigned namespaces in getSpecifierForModuleSymbol so they behave like their containing module symbol (#38151) --- src/compiler/checker.ts | 18 +++- ...nedNamespaceNoTripleSlashTypesReference.js | 82 +++++++++++++++++++ ...mespaceNoTripleSlashTypesReference.symbols | 71 ++++++++++++++++ ...NamespaceNoTripleSlashTypesReference.types | 61 ++++++++++++++ ...nedNamespaceNoTripleSlashTypesReference.ts | 36 ++++++++ 5 files changed, 264 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.js create mode 100644 tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.symbols create mode 100644 tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.types create mode 100644 tests/cases/compiler/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e1cda181eee..b69320f2e4f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3517,12 +3517,16 @@ namespace ts { return mapDefined(candidates, candidate => getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined); function fileSymbolIfFileSymbolExportEqualsContainer(d: Declaration) { - const fileSymbol = getExternalModuleContainer(d); - const exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get(InternalSymbolName.ExportEquals); - return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; + return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container); } } + function getFileSymbolIfFileSymbolExportEqualsContainer(d: Declaration, container: Symbol) { + const fileSymbol = getExternalModuleContainer(d); + const exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get(InternalSymbolName.ExportEquals); + return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; + } + function getAliasForSymbolInContainer(container: Symbol, symbol: Symbol) { if (container === getParentOfSymbol(symbol)) { // fast path, `symbol` is either already the alias or isn't aliased @@ -5138,7 +5142,13 @@ namespace ts { } function getSpecifierForModuleSymbol(symbol: Symbol, context: NodeBuilderContext) { - const file = getDeclarationOfKind(symbol, SyntaxKind.SourceFile); + let file = getDeclarationOfKind(symbol, SyntaxKind.SourceFile); + if (!file) { + const equivalentFileSymbol = firstDefined(symbol.declarations, d => getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol)); + if (equivalentFileSymbol) { + file = getDeclarationOfKind(equivalentFileSymbol, SyntaxKind.SourceFile); + } + } if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; diff --git a/tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.js b/tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.js new file mode 100644 index 00000000000..8f147063de0 --- /dev/null +++ b/tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.js @@ -0,0 +1,82 @@ +//// [tests/cases/compiler/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.ts] //// + +//// [index.d.ts] +export = React; + +declare namespace React { + export type Component = { x: T, y: U, z: V }; + export interface DOMAttributes { } +} +//// [index.d.ts] +import { + Component +} from 'react' +export {}; + +declare module 'react' { + interface DOMAttributes { + css?: any + } +} + +//// [get-comp.ts] +import {Component} from 'react'; + +export function getComp(): Component { + return {} as any as Component +} +//// [inferred-comp-export.ts] +import { getComp } from "./get-comp"; + +// this shouldn't need any triple-slash references - it should have a direct import to `react` and that's it +// This issue (#35343) _only_ reproduces in the test harness when the file in question is in a subfolder +export const obj = { + comp: getComp() +} +//// [some-other-file.ts] +export * from '@emotion/core'; + + +//// [get-comp.js] +"use strict"; +exports.__esModule = true; +exports.getComp = void 0; +function getComp() { + return {}; +} +exports.getComp = getComp; +//// [inferred-comp-export.js] +"use strict"; +exports.__esModule = true; +exports.obj = void 0; +var get_comp_1 = require("./get-comp"); +// this shouldn't need any triple-slash references - it should have a direct import to `react` and that's it +// This issue (#35343) _only_ reproduces in the test harness when the file in question is in a subfolder +exports.obj = { + comp: get_comp_1.getComp() +}; +//// [some-other-file.js] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); +} +exports.__esModule = true; +__exportStar(require("@emotion/core"), exports); + + +//// [get-comp.d.ts] +import { Component } from 'react'; +export declare function getComp(): Component; +//// [inferred-comp-export.d.ts] +export declare const obj: { + comp: import("react").Component; +}; +//// [some-other-file.d.ts] +export * from '@emotion/core'; diff --git a/tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.symbols b/tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.symbols new file mode 100644 index 00000000000..87304e8e84f --- /dev/null +++ b/tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.symbols @@ -0,0 +1,71 @@ +=== tests/cases/compiler/node_modules/@types/react/index.d.ts === +export = React; +>React : Symbol(React, Decl(index.d.ts, 0, 15), Decl(index.d.ts, 3, 10)) + +declare namespace React { +>React : Symbol(React, Decl(index.d.ts, 0, 15), Decl(index.d.ts, 3, 10)) + + export type Component = { x: T, y: U, z: V }; +>Component : Symbol(Component, Decl(index.d.ts, 2, 25)) +>T : Symbol(T, Decl(index.d.ts, 3, 26)) +>U : Symbol(U, Decl(index.d.ts, 3, 34)) +>V : Symbol(V, Decl(index.d.ts, 3, 42)) +>x : Symbol(x, Decl(index.d.ts, 3, 54)) +>T : Symbol(T, Decl(index.d.ts, 3, 26)) +>y : Symbol(y, Decl(index.d.ts, 3, 60)) +>U : Symbol(U, Decl(index.d.ts, 3, 34)) +>z : Symbol(z, Decl(index.d.ts, 3, 66)) +>V : Symbol(V, Decl(index.d.ts, 3, 42)) + + export interface DOMAttributes { } +>DOMAttributes : Symbol(DOMAttributes, Decl(index.d.ts, 3, 74), Decl(index.d.ts, 5, 24)) +>T : Symbol(T, Decl(index.d.ts, 4, 35), Decl(index.d.ts, 6, 28)) +} +=== tests/cases/compiler/node_modules/@emotion/core/index.d.ts === +import { + Component +>Component : Symbol(Component, Decl(index.d.ts, 0, 8)) + +} from 'react' +export {}; + +declare module 'react' { +>'react' : Symbol(React, Decl(index.d.ts, 0, 15), Decl(index.d.ts, 3, 10)) + + interface DOMAttributes { +>DOMAttributes : Symbol(DOMAttributes, Decl(index.d.ts, 3, 74), Decl(index.d.ts, 5, 24)) +>T : Symbol(T, Decl(index.d.ts, 4, 35), Decl(index.d.ts, 6, 28)) + + css?: any +>css : Symbol(DOMAttributes.css, Decl(index.d.ts, 6, 32)) + } +} + +=== tests/cases/compiler/src/get-comp.ts === +import {Component} from 'react'; +>Component : Symbol(Component, Decl(get-comp.ts, 0, 8)) + +export function getComp(): Component { +>getComp : Symbol(getComp, Decl(get-comp.ts, 0, 32)) +>Component : Symbol(Component, Decl(get-comp.ts, 0, 8)) + + return {} as any as Component +>Component : Symbol(Component, Decl(get-comp.ts, 0, 8)) +} +=== tests/cases/compiler/src/inferred-comp-export.ts === +import { getComp } from "./get-comp"; +>getComp : Symbol(getComp, Decl(inferred-comp-export.ts, 0, 8)) + +// this shouldn't need any triple-slash references - it should have a direct import to `react` and that's it +// This issue (#35343) _only_ reproduces in the test harness when the file in question is in a subfolder +export const obj = { +>obj : Symbol(obj, Decl(inferred-comp-export.ts, 4, 12)) + + comp: getComp() +>comp : Symbol(comp, Decl(inferred-comp-export.ts, 4, 20)) +>getComp : Symbol(getComp, Decl(inferred-comp-export.ts, 0, 8)) +} +=== tests/cases/compiler/src/some-other-file.ts === +export * from '@emotion/core'; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.types b/tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.types new file mode 100644 index 00000000000..c3232b4406e --- /dev/null +++ b/tests/baselines/reference/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.types @@ -0,0 +1,61 @@ +=== tests/cases/compiler/node_modules/@types/react/index.d.ts === +export = React; +>React : any + +declare namespace React { + export type Component = { x: T, y: U, z: V }; +>Component : Component +>x : T +>y : U +>z : V + + export interface DOMAttributes { } +} +=== tests/cases/compiler/node_modules/@emotion/core/index.d.ts === +import { + Component +>Component : any + +} from 'react' +export {}; + +declare module 'react' { +>'react' : error + + interface DOMAttributes { + css?: any +>css : any + } +} + +=== tests/cases/compiler/src/get-comp.ts === +import {Component} from 'react'; +>Component : any + +export function getComp(): Component { +>getComp : () => Component + + return {} as any as Component +>{} as any as Component : Component +>{} as any : any +>{} : {} +} +=== tests/cases/compiler/src/inferred-comp-export.ts === +import { getComp } from "./get-comp"; +>getComp : () => import("tests/cases/compiler/node_modules/@types/react/index").Component + +// this shouldn't need any triple-slash references - it should have a direct import to `react` and that's it +// This issue (#35343) _only_ reproduces in the test harness when the file in question is in a subfolder +export const obj = { +>obj : { comp: import("tests/cases/compiler/node_modules/@types/react/index").Component; } +>{ comp: getComp()} : { comp: import("tests/cases/compiler/node_modules/@types/react/index").Component; } + + comp: getComp() +>comp : import("tests/cases/compiler/node_modules/@types/react/index").Component +>getComp() : import("tests/cases/compiler/node_modules/@types/react/index").Component +>getComp : () => import("tests/cases/compiler/node_modules/@types/react/index").Component +} +=== tests/cases/compiler/src/some-other-file.ts === +export * from '@emotion/core'; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/cases/compiler/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.ts b/tests/cases/compiler/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.ts new file mode 100644 index 00000000000..a71625b77e4 --- /dev/null +++ b/tests/cases/compiler/declarationEmitExportAssignedNamespaceNoTripleSlashTypesReference.ts @@ -0,0 +1,36 @@ +// @declaration: true +// @filename: node_modules/@types/react/index.d.ts +export = React; + +declare namespace React { + export type Component = { x: T, y: U, z: V }; + export interface DOMAttributes { } +} +// @filename: node_modules/@emotion/core/index.d.ts +import { + Component +} from 'react' +export {}; + +declare module 'react' { + interface DOMAttributes { + css?: any + } +} + +// @filename: src/get-comp.ts +import {Component} from 'react'; + +export function getComp(): Component { + return {} as any as Component +} +// @filename: src/inferred-comp-export.ts +import { getComp } from "./get-comp"; + +// this shouldn't need any triple-slash references - it should have a direct import to `react` and that's it +// This issue (#35343) _only_ reproduces in the test harness when the file in question is in a subfolder +export const obj = { + comp: getComp() +} +// @filename: src/some-other-file.ts +export * from '@emotion/core'; From ce95d9ca6be1526ffea041150141f9de4ed4b4e6 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 24 Apr 2020 13:49:48 -0700 Subject: [PATCH 54/74] Fix values and types merging in JS module exports (#37896) * Fix values and types merging in JS module exports * Fix everything * Share `setValueDeclaration` between binder (local merge) and checker (cross-file merge) * Revert accidental changes to baselines * Update baseline from master merge --- src/compiler/binder.ts | 10 ---- src/compiler/checker.ts | 45 +++++++++++++----- src/compiler/utilities.ts | 11 +++++ ...DeclarationsClassExtendsVisibility.symbols | 2 +- .../jsDeclarationsClassStatic.symbols | 2 +- .../jsDeclarationsCrossfileMerge.symbols | 2 +- ...nedClassExpressionAnonymousWithSub.symbols | 2 +- ...rtAssignedClassExpressionShadowing.symbols | 2 +- ...jsDeclarationsExportSubAssignments.symbols | 2 +- ...MemberMergedWithModuleAugmentation.symbols | 43 +++++++++++++++++ ...rtMemberMergedWithModuleAugmentation.types | 46 +++++++++++++++++++ ...erMergedWithModuleAugmentation2.errors.txt | 27 +++++++++++ ...emberMergedWithModuleAugmentation2.symbols | 25 ++++++++++ ...tMemberMergedWithModuleAugmentation2.types | 31 +++++++++++++ .../reference/moduleExportAlias2.symbols | 2 +- .../reference/moduleExportAlias4.symbols | 2 +- .../moduleExportAliasImported.symbols | 2 +- ...uleExportPropertyAssignmentDefault.symbols | 2 +- ...xportWithExportPropertyAssignment3.symbols | 12 ++--- ...xportWithExportPropertyAssignment4.symbols | 6 +-- .../reference/typedefCrossModule2.types | 26 +++++------ .../reference/typedefCrossModule4.types | 8 ++-- ...xportMemberMergedWithModuleAugmentation.ts | 26 +++++++++++ ...portMemberMergedWithModuleAugmentation2.ts | 17 +++++++ ...mpletionsImportModuleAugmentationWithJS.ts | 41 +++++++++++++++++ 25 files changed, 337 insertions(+), 57 deletions(-) create mode 100644 tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation.symbols create mode 100644 tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation.types create mode 100644 tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.errors.txt create mode 100644 tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.symbols create mode 100644 tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.types create mode 100644 tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation.ts create mode 100644 tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation2.ts create mode 100644 tests/cases/fourslash/completionsImportModuleAugmentationWithJS.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 3cde8be7ea1..356b2fd18f6 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -320,16 +320,6 @@ namespace ts { } } - function setValueDeclaration(symbol: Symbol, node: Declaration): void { - const { valueDeclaration } = symbol; - if (!valueDeclaration || - (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || - (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { - // other kinds of value declarations take precedence over modules and assignment declarations - symbol.valueDeclaration = node; - } - } - // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node: Declaration): __String | undefined { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b69320f2e4f..f5754baff48 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1115,12 +1115,8 @@ namespace ts { target.constEnumOnlyModule = false; } target.flags |= source.flags; - if (source.valueDeclaration && - (!target.valueDeclaration || - isAssignmentDeclaration(target.valueDeclaration) && !isAssignmentDeclaration(source.valueDeclaration) || - isEffectiveModuleDeclaration(target.valueDeclaration) && !isEffectiveModuleDeclaration(source.valueDeclaration))) { - // other kinds of value declarations take precedence over modules and assignment declarations - target.valueDeclaration = source.valueDeclaration; + if (source.valueDeclaration) { + setValueDeclaration(target, source.valueDeclaration); } addRange(target.declarations, source.declarations); if (source.members) { @@ -7724,11 +7720,38 @@ namespace ts { resolvedSymbol.exports = createSymbolTable(); } (resolvedSymbol || symbol).exports!.forEach((s, name) => { - if (members.has(name)) { - const exportedMember = exportedType.members.get(name)!; - const union = createSymbol(s.flags | exportedMember.flags, name); - union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]); - members.set(name, union); + const exportedMember = members.get(name)!; + if (exportedMember && exportedMember !== s) { + if (s.flags & SymbolFlags.Value) { + // If the member has an additional value-like declaration, union the types from the two declarations, + // but issue an error if they occurred in two different files. The purpose is to support a JS file with + // a pattern like: + // + // module.exports = { a: true }; + // module.exports.a = 3; + // + // but we may have a JS file with `module.exports = { a: true }` along with a TypeScript module augmentation + // declaring an `export const a: number`. In that case, we issue a duplicate identifier error, because + // it's unclear what that's supposed to mean, so it's probably a mistake. + if (getSourceFileOfNode(s.valueDeclaration) !== getSourceFileOfNode(exportedMember.valueDeclaration)) { + const unescapedName = unescapeLeadingUnderscores(s.escapedName); + const exportedMemberName = tryCast(exportedMember.valueDeclaration, isNamedDeclaration)?.name || exportedMember.valueDeclaration; + addRelatedInfo( + error(s.valueDeclaration, Diagnostics.Duplicate_identifier_0, unescapedName), + createDiagnosticForNode(exportedMemberName, Diagnostics._0_was_also_declared_here, unescapedName)); + addRelatedInfo( + error(exportedMemberName, Diagnostics.Duplicate_identifier_0, unescapedName), + createDiagnosticForNode(s.valueDeclaration, Diagnostics._0_was_also_declared_here, unescapedName)); + } + const union = createSymbol(s.flags | exportedMember.flags, name); + union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]); + union.valueDeclaration = exportedMember.valueDeclaration; + union.declarations = concatenate(exportedMember.declarations, s.declarations); + members.set(name, union); + } + else { + members.set(name, mergeSymbol(s, exportedMember)); + } } else { members.set(name, s); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 9e1d338d8d7..97231acf60b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2314,6 +2314,17 @@ namespace ts { !!getJSDocTypeTag(expr.parent); } + export function setValueDeclaration(symbol: Symbol, node: Declaration): void { + const { valueDeclaration } = symbol; + if (!valueDeclaration || + !(node.flags & NodeFlags.Ambient && !(valueDeclaration.flags & NodeFlags.Ambient)) && + (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || + (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { + // other kinds of value declarations take precedence over modules and assignment declarations + symbol.valueDeclaration = node; + } + } + export function isFunctionSymbol(symbol: Symbol | undefined) { if (!symbol || !symbol.valueDeclaration) { return false; diff --git a/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.symbols b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.symbols index cbf083c36f8..a59d302e7f0 100644 --- a/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.symbols +++ b/tests/baselines/reference/jsDeclarationsClassExtendsVisibility.symbols @@ -25,7 +25,7 @@ module.exports = Foo; >Foo : Symbol(Foo, Decl(cls.js, 4, 2)) module.exports.Strings = Strings; ->module.exports.Strings : Symbol(Strings) +>module.exports.Strings : Symbol(Strings, Decl(cls.js, 6, 21)) >module.exports : Symbol(Strings, Decl(cls.js, 6, 21)) >module : Symbol(module, Decl(cls.js, 5, 24)) >exports : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) diff --git a/tests/baselines/reference/jsDeclarationsClassStatic.symbols b/tests/baselines/reference/jsDeclarationsClassStatic.symbols index d79d144e509..8687099bbe3 100644 --- a/tests/baselines/reference/jsDeclarationsClassStatic.symbols +++ b/tests/baselines/reference/jsDeclarationsClassStatic.symbols @@ -34,7 +34,7 @@ module.exports = Handler; >Handler : Symbol(Handler, Decl(source.js, 0, 0), Decl(source.js, 7, 1)) module.exports.Strings = Strings ->module.exports.Strings : Symbol(Strings) +>module.exports.Strings : Symbol(Strings, Decl(source.js, 14, 25)) >module.exports : Symbol(Strings, Decl(source.js, 14, 25)) >module : Symbol(module, Decl(source.js, 12, 1)) >exports : Symbol("tests/cases/conformance/jsdoc/declarations/source", Decl(source.js, 0, 0)) diff --git a/tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols b/tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols index 99455853c4c..64753e212be 100644 --- a/tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols +++ b/tests/baselines/reference/jsDeclarationsCrossfileMerge.symbols @@ -13,7 +13,7 @@ module.exports = m.default; >default : Symbol(default, Decl(exporter.js, 0, 22)) module.exports.memberName = "thing"; ->module.exports.memberName : Symbol(memberName) +>module.exports.memberName : Symbol(memberName, Decl(index.js, 2, 27)) >module.exports : Symbol(memberName, Decl(index.js, 2, 27)) >module : Symbol(module, Decl(index.js, 0, 32)) >exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols index 228bb10cccc..aa5df49712f 100644 --- a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.symbols @@ -18,7 +18,7 @@ module.exports = class { } } module.exports.Sub = class { ->module.exports.Sub : Symbol(Sub) +>module.exports.Sub : Symbol(Sub, Decl(index.js, 7, 1)) >module.exports : Symbol(Sub, Decl(index.js, 7, 1)) >module : Symbol(module, Decl(index.js, 0, 0), Decl(index.js, 10, 27)) >exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.symbols b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.symbols index 40a6fb56147..a911c06ee2e 100644 --- a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.symbols +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.symbols @@ -27,7 +27,7 @@ module.exports = class Q { } } module.exports.Another = Q; ->module.exports.Another : Symbol(Another) +>module.exports.Another : Symbol(Another, Decl(index.js, 10, 1)) >module.exports : Symbol(Another, Decl(index.js, 10, 1)) >module : Symbol(module, Decl(index.js, 5, 1)) >exports : Symbol("tests/cases/conformance/jsdoc/declarations/index", Decl(index.js, 0, 0)) diff --git a/tests/baselines/reference/jsDeclarationsExportSubAssignments.symbols b/tests/baselines/reference/jsDeclarationsExportSubAssignments.symbols index a764b8e99d7..5939221ce90 100644 --- a/tests/baselines/reference/jsDeclarationsExportSubAssignments.symbols +++ b/tests/baselines/reference/jsDeclarationsExportSubAssignments.symbols @@ -19,7 +19,7 @@ module.exports = Foo; >Foo : Symbol(Foo, Decl(cls.js, 3, 2)) module.exports.Strings = Strings; ->module.exports.Strings : Symbol(Strings) +>module.exports.Strings : Symbol(Strings, Decl(cls.js, 5, 21)) >module.exports : Symbol(Strings, Decl(cls.js, 5, 21)) >module : Symbol(module, Decl(cls.js, 4, 12)) >exports : Symbol("tests/cases/conformance/jsdoc/declarations/cls", Decl(cls.js, 0, 0)) diff --git a/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation.symbols b/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation.symbols new file mode 100644 index 00000000000..e11817cab0b --- /dev/null +++ b/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation.symbols @@ -0,0 +1,43 @@ +=== /test.js === +class Abcde { +>Abcde : Symbol(Abcde, Decl(test.js, 0, 0)) + + /** @type {string} */ + x; +>x : Symbol(Abcde.x, Decl(test.js, 0, 13)) +} + +module.exports = { +>module.exports : Symbol("/test", Decl(test.js, 0, 0)) +>module : Symbol("/test.js", Decl(test.js, 3, 1), Decl(index.ts, 0, 31)) +>exports : Symbol("/test.js", Decl(test.js, 3, 1), Decl(index.ts, 0, 31)) + + Abcde +>Abcde : Symbol(Abcde, Decl(test.js, 5, 18)) + +}; + +=== /index.ts === +import { Abcde } from "./test"; +>Abcde : Symbol(Abcde, Decl(index.ts, 0, 8)) + +declare module "./test" { +>"./test" : Symbol("/test.js", Decl(test.js, 3, 1), Decl(index.ts, 0, 31)) + + interface Abcde { b: string } +>Abcde : Symbol(Abcde, Decl(index.ts, 2, 25), Decl(test.js, 5, 18)) +>b : Symbol(Abcde.b, Decl(index.ts, 3, 19)) +} + +new Abcde().x; +>new Abcde().x : Symbol(Abcde.x, Decl(test.js, 0, 13)) +>Abcde : Symbol(Abcde, Decl(index.ts, 0, 8)) +>x : Symbol(Abcde.x, Decl(test.js, 0, 13)) + +// Bug: the type meaning from /test.js does not +// propagate through the object literal export. +const x: Abcde = { b: "" }; +>x : Symbol(x, Decl(index.ts, 10, 5)) +>Abcde : Symbol(Abcde, Decl(index.ts, 0, 8)) +>b : Symbol(b, Decl(index.ts, 10, 18)) + diff --git a/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation.types b/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation.types new file mode 100644 index 00000000000..e53d62ff173 --- /dev/null +++ b/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation.types @@ -0,0 +1,46 @@ +=== /test.js === +class Abcde { +>Abcde : Abcde + + /** @type {string} */ + x; +>x : string +} + +module.exports = { +>module.exports = { Abcde} : { Abcde: typeof Abcde; } +>module.exports : { Abcde: typeof Abcde; } +>module : { "\"/test\"": { Abcde: typeof Abcde; }; } +>exports : { Abcde: typeof Abcde; } +>{ Abcde} : { Abcde: typeof Abcde; } + + Abcde +>Abcde : typeof Abcde + +}; + +=== /index.ts === +import { Abcde } from "./test"; +>Abcde : typeof Abcde + +declare module "./test" { +>"./test" : { Abcde: typeof Abcde; } + + interface Abcde { b: string } +>b : string +} + +new Abcde().x; +>new Abcde().x : string +>new Abcde() : Abcde +>Abcde : typeof Abcde +>x : string + +// Bug: the type meaning from /test.js does not +// propagate through the object literal export. +const x: Abcde = { b: "" }; +>x : Abcde +>{ b: "" } : { b: string; } +>b : string +>"" : "" + diff --git a/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.errors.txt b/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.errors.txt new file mode 100644 index 00000000000..44a0efae0da --- /dev/null +++ b/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.errors.txt @@ -0,0 +1,27 @@ +/index.ts(4,16): error TS2300: Duplicate identifier 'a'. +/index.ts(7,3): error TS2339: Property 'toFixed' does not exist on type 'string'. +/test.js(2,3): error TS2300: Duplicate identifier 'a'. + + +==== /test.js (1 errors) ==== + module.exports = { + a: "ok" + ~ +!!! error TS2300: Duplicate identifier 'a'. +!!! related TS6203 /index.ts:4:16: 'a' was also declared here. + }; + +==== /index.ts (2 errors) ==== + import { a } from "./test"; + + declare module "./test" { + export const a: number; + ~ +!!! error TS2300: Duplicate identifier 'a'. +!!! related TS6203 /test.js:2:3: 'a' was also declared here. + } + + a.toFixed(); + ~~~~~~~ +!!! error TS2339: Property 'toFixed' does not exist on type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.symbols b/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.symbols new file mode 100644 index 00000000000..02da41d876c --- /dev/null +++ b/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.symbols @@ -0,0 +1,25 @@ +=== /test.js === +module.exports = { +>module.exports : Symbol("/test", Decl(test.js, 0, 0)) +>module : Symbol("/test.js", Decl(test.js, 0, 0), Decl(index.ts, 0, 27)) +>exports : Symbol("/test.js", Decl(test.js, 0, 0), Decl(index.ts, 0, 27)) + + a: "ok" +>a : Symbol(a, Decl(test.js, 0, 18)) + +}; + +=== /index.ts === +import { a } from "./test"; +>a : Symbol(a, Decl(index.ts, 0, 8)) + +declare module "./test" { +>"./test" : Symbol("/test.js", Decl(test.js, 0, 0), Decl(index.ts, 0, 27)) + + export const a: number; +>a : Symbol(a, Decl(index.ts, 3, 14)) +} + +a.toFixed(); +>a : Symbol(a, Decl(index.ts, 0, 8)) + diff --git a/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.types b/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.types new file mode 100644 index 00000000000..fa6e940f60b --- /dev/null +++ b/tests/baselines/reference/jsExportMemberMergedWithModuleAugmentation2.types @@ -0,0 +1,31 @@ +=== /test.js === +module.exports = { +>module.exports = { a: "ok"} : { a: string | number; } +>module.exports : { a: string | number; } +>module : { "\"/test\"": { a: string | number; }; } +>exports : { a: string | number; } +>{ a: "ok"} : { a: string; } + + a: "ok" +>a : string +>"ok" : "ok" + +}; + +=== /index.ts === +import { a } from "./test"; +>a : string + +declare module "./test" { +>"./test" : { a: string | number; } + + export const a: number; +>a : number +} + +a.toFixed(); +>a.toFixed() : any +>a.toFixed : any +>a : string +>toFixed : any + diff --git a/tests/baselines/reference/moduleExportAlias2.symbols b/tests/baselines/reference/moduleExportAlias2.symbols index f6ebc315313..6dc88d4d8c9 100644 --- a/tests/baselines/reference/moduleExportAlias2.symbols +++ b/tests/baselines/reference/moduleExportAlias2.symbols @@ -37,7 +37,7 @@ exports = module.exports = C >C : Symbol(C, Decl(semver.js, 2, 22)) exports.f = n => n + 1 ->exports.f : Symbol(f) +>exports.f : Symbol(f, Decl(semver.js, 1, 28)) >exports : Symbol(f, Decl(semver.js, 1, 28)) >f : Symbol(f, Decl(semver.js, 1, 28)) >n : Symbol(n, Decl(semver.js, 2, 11)) diff --git a/tests/baselines/reference/moduleExportAlias4.symbols b/tests/baselines/reference/moduleExportAlias4.symbols index a3e2e2d5938..fd149513b7b 100644 --- a/tests/baselines/reference/moduleExportAlias4.symbols +++ b/tests/baselines/reference/moduleExportAlias4.symbols @@ -12,7 +12,7 @@ module.exports = class C {} >C : Symbol(C, Decl(bug24024.js, 2, 16)) module.exports.D = class D { } ->module.exports.D : Symbol(D) +>module.exports.D : Symbol(D, Decl(bug24024.js, 2, 27)) >module.exports : Symbol(D, Decl(bug24024.js, 2, 27)) >module : Symbol(module, Decl(bug24024.js, 1, 31)) >exports : Symbol("tests/cases/conformance/salsa/bug24024", Decl(bug24024.js, 0, 0)) diff --git a/tests/baselines/reference/moduleExportAliasImported.symbols b/tests/baselines/reference/moduleExportAliasImported.symbols index 9649cc0a3b6..298e439a0d7 100644 --- a/tests/baselines/reference/moduleExportAliasImported.symbols +++ b/tests/baselines/reference/moduleExportAliasImported.symbols @@ -1,6 +1,6 @@ === tests/cases/conformance/salsa/bug28014.js === exports.version = 1 ->exports.version : Symbol(version) +>exports.version : Symbol(version, Decl(bug28014.js, 0, 0)) >exports : Symbol(version, Decl(bug28014.js, 0, 0)) >version : Symbol(version, Decl(bug28014.js, 0, 0)) diff --git a/tests/baselines/reference/moduleExportPropertyAssignmentDefault.symbols b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.symbols index 8e704e5fe0d..0645e00f000 100644 --- a/tests/baselines/reference/moduleExportPropertyAssignmentDefault.symbols +++ b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.symbols @@ -9,7 +9,7 @@ module.exports = axios // both assignments should be ok >axios : Symbol(axios, Decl(axios.js, 0, 3)) module.exports.default = axios ->module.exports.default : Symbol(default) +>module.exports.default : Symbol(default, Decl(axios.js, 1, 22)) >module.exports : Symbol(default, Decl(axios.js, 1, 22)) >module : Symbol(module, Decl(axios.js, 0, 14)) >exports : Symbol("tests/cases/conformance/salsa/axios", Decl(axios.js, 0, 0)) diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols b/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols index 3ee790d7680..1c4aa535f61 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.symbols @@ -13,14 +13,14 @@ mod1.justExport.toFixed() >toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --)) mod1.bothBefore.toFixed() // error, 'toFixed' not on 'string | number' ->mod1.bothBefore : Symbol(bothBefore) +>mod1.bothBefore : Symbol(bothBefore, Decl(mod1.js, 3, 18), Decl(mod1.js, 0, 0)) >mod1 : Symbol(mod1, Decl(a.js, 1, 3)) ->bothBefore : Symbol(bothBefore) +>bothBefore : Symbol(bothBefore, Decl(mod1.js, 3, 18), Decl(mod1.js, 0, 0)) mod1.bothAfter.toFixed() // error, 'toFixed' not on 'string | number' ->mod1.bothAfter : Symbol(bothAfter) +>mod1.bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18), Decl(mod1.js, 6, 1)) >mod1 : Symbol(mod1, Decl(a.js, 1, 3)) ->bothAfter : Symbol(bothAfter) +>bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18), Decl(mod1.js, 6, 1)) mod1.justProperty.length >mod1.justProperty.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) @@ -41,7 +41,7 @@ declare function require(name: string): any; === tests/cases/conformance/salsa/mod1.js === /// module.exports.bothBefore = 'string' ->module.exports.bothBefore : Symbol(bothBefore) +>module.exports.bothBefore : Symbol(bothBefore, Decl(mod1.js, 3, 18), Decl(mod1.js, 0, 0)) >module.exports : Symbol(bothBefore, Decl(mod1.js, 0, 0)) >module : Symbol(module, Decl(mod1.js, 0, 0)) >exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) @@ -62,7 +62,7 @@ module.exports = { >bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18)) } module.exports.bothAfter = 'string' ->module.exports.bothAfter : Symbol(bothAfter) +>module.exports.bothAfter : Symbol(bothAfter, Decl(mod1.js, 4, 18), Decl(mod1.js, 6, 1)) >module.exports : Symbol(bothAfter, Decl(mod1.js, 6, 1)) >module : Symbol(module, Decl(mod1.js, 0, 0)) >exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols index ad044856870..76fecbc0b2c 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment4.symbols @@ -41,7 +41,7 @@ declare function require(name: string): any; === tests/cases/conformance/salsa/mod1.js === /// module.exports.bothBefore = 'string' ->module.exports.bothBefore : Symbol(bothBefore) +>module.exports.bothBefore : Symbol(bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) >module.exports : Symbol(bothBefore, Decl(mod1.js, 2, 16), Decl(mod1.js, 0, 0)) >module : Symbol(module, Decl(mod1.js, 0, 0)) >exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) @@ -75,14 +75,14 @@ function A() { >p : Symbol(A.p, Decl(mod1.js, 6, 14)) } module.exports.bothAfter = 'string' ->module.exports.bothAfter : Symbol(bothAfter) +>module.exports.bothAfter : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) >module.exports : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) >module : Symbol(module, Decl(mod1.js, 0, 0)) >exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) >bothAfter : Symbol(bothAfter, Decl(mod1.js, 3, 16), Decl(mod1.js, 8, 1)) module.exports.justProperty = 'string' ->module.exports.justProperty : Symbol(justProperty) +>module.exports.justProperty : Symbol(justProperty, Decl(mod1.js, 9, 35)) >module.exports : Symbol(justProperty, Decl(mod1.js, 9, 35)) >module : Symbol(module, Decl(mod1.js, 0, 0)) >exports : Symbol("tests/cases/conformance/salsa/mod1", Decl(mod1.js, 0, 0)) diff --git a/tests/baselines/reference/typedefCrossModule2.types b/tests/baselines/reference/typedefCrossModule2.types index c1afae93d85..9a1b0922f9e 100644 --- a/tests/baselines/reference/typedefCrossModule2.types +++ b/tests/baselines/reference/typedefCrossModule2.types @@ -1,7 +1,7 @@ === tests/cases/conformance/jsdoc/use.js === var mod = require('./mod1.js'); ->mod : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } ->require('./mod1.js') : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>mod : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } +>require('./mod1.js') : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } >require : any >'./mod1.js' : "./mod1.js" @@ -17,7 +17,7 @@ var bbb = new mod.Baz(); >bbb : any >new mod.Baz() : any >mod.Baz : any ->mod : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>mod : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } >Baz : any === tests/cases/conformance/jsdoc/mod1.js === @@ -31,16 +31,16 @@ class Foo { } // should error exports.Bar = class { } >exports.Bar = class { } : typeof Bar >exports.Bar : typeof Bar ->exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } >Bar : typeof Bar >class { } : typeof Bar /** @typedef {number} Baz */ module.exports = { ->module.exports = { Baz: class { }} : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } ->module.exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } ->module : { "\"tests/cases/conformance/jsdoc/mod1\"": { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; }; } ->exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>module.exports = { Baz: class { }} : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } +>module.exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } +>module : { "\"tests/cases/conformance/jsdoc/mod1\"": { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }; } +>exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } >{ Baz: class { }} : { Baz: typeof Baz; } Baz: class { } @@ -59,16 +59,16 @@ var Qux = 2; exports.Quid = 2; >exports.Quid = 2 : 2 >exports.Quid : number ->exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } >Quid : number >2 : 2 /** @typedef {number} Quack */ module.exports = { ->module.exports = { Quack: 2} : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } ->module.exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } ->module : { "\"tests/cases/conformance/jsdoc/mod1\"": { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; }; } ->exports : { Baz: any; Bar: typeof Bar; Quid: number; } | { Quack: any; Bar: typeof Bar; Quid: number; } +>module.exports = { Quack: 2} : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } +>module.exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } +>module : { "\"tests/cases/conformance/jsdoc/mod1\"": { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; }; } +>exports : { Baz: typeof Baz; Bar: typeof Bar; Quid: number; } | { Quack: number; Bar: typeof Bar; Quid: number; } >{ Quack: 2} : { Quack: number; } Quack: 2 diff --git a/tests/baselines/reference/typedefCrossModule4.types b/tests/baselines/reference/typedefCrossModule4.types index 61c2dace77c..eb01fe95625 100644 --- a/tests/baselines/reference/typedefCrossModule4.types +++ b/tests/baselines/reference/typedefCrossModule4.types @@ -4,10 +4,10 @@ class Bar { } >Bar : Bar module.exports = { Foo: Bar }; ->module.exports = { Foo: Bar } : { Foo: any; } ->module.exports : { Foo: any; } ->module : { "\"tests/cases/conformance/jsdoc/mod3\"": { Foo: any; }; } ->exports : { Foo: any; } +>module.exports = { Foo: Bar } : { Foo: typeof Bar; } +>module.exports : { Foo: typeof Bar; } +>module : { "\"tests/cases/conformance/jsdoc/mod3\"": { Foo: typeof Bar; }; } +>exports : { Foo: typeof Bar; } >{ Foo: Bar } : { Foo: typeof Bar; } >Foo : typeof Bar >Bar : typeof Bar diff --git a/tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation.ts b/tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation.ts new file mode 100644 index 00000000000..1c129be3646 --- /dev/null +++ b/tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation.ts @@ -0,0 +1,26 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @Filename: /test.js +class Abcde { + /** @type {string} */ + x; +} + +module.exports = { + Abcde +}; + +// @Filename: /index.ts +import { Abcde } from "./test"; + +declare module "./test" { + interface Abcde { b: string } +} + +new Abcde().x; + +// Bug: the type meaning from /test.js does not +// propagate through the object literal export. +const x: Abcde = { b: "" }; diff --git a/tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation2.ts b/tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation2.ts new file mode 100644 index 00000000000..7ef22ee7ec9 --- /dev/null +++ b/tests/cases/compiler/jsExportMemberMergedWithModuleAugmentation2.ts @@ -0,0 +1,17 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @Filename: /test.js +module.exports = { + a: "ok" +}; + +// @Filename: /index.ts +import { a } from "./test"; + +declare module "./test" { + export const a: number; +} + +a.toFixed(); diff --git a/tests/cases/fourslash/completionsImportModuleAugmentationWithJS.ts b/tests/cases/fourslash/completionsImportModuleAugmentationWithJS.ts new file mode 100644 index 00000000000..8ea84247d84 --- /dev/null +++ b/tests/cases/fourslash/completionsImportModuleAugmentationWithJS.ts @@ -0,0 +1,41 @@ +// #37833 + +/// + +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @Filename: /test.js +////class Abcde { +//// x +////} +//// +////module.exports = { +//// Abcde +////}; + +// @Filename: /index.ts +////export {}; +////declare module "./test" { +//// interface Abcde { b: string } +////} +//// +////Abcde/**/ + +verify.applyCodeActionFromCompletion("", { + name: "Abcde", + source: "/test", + description: `Import 'Abcde' from module "./test"`, + newFileContent: `import { Abcde } from "./test"; + +export {}; +declare module "./test" { + interface Abcde { b: string } +} + +Abcde`, + preferences: { + includeCompletionsForModuleExports: true + } +}); From 31b81bafe734d800ad25239a62705b38a29367e0 Mon Sep 17 00:00:00 2001 From: Alexander T Date: Fri, 24 Apr 2020 23:50:34 +0300 Subject: [PATCH 55/74] fix(38138): show suggestions for identifier in class property initializer (#38157) --- src/services/completions.ts | 8 ++++- .../completionsClassPropertiesAssignment.ts | 31 ++++++++++--------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index bb08fe7d549..a1e98a03d87 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -2685,10 +2685,16 @@ namespace ts.Completions { return cls; } break; - case SyntaxKind.Identifier: // class c extends React.Component { a: () => 1\n compon| } + case SyntaxKind.Identifier: { + // class c { public prop = c| } + if (isPropertyDeclaration(location.parent) && location.parent.initializer === location) { + return undefined; + } + // class c extends React.Component { a: () => 1\n compon| } if (isFromObjectTypeDeclaration(location)) { return findAncestor(location, isObjectTypeDeclaration); } + } } if (!contextToken) return undefined; diff --git a/tests/cases/fourslash/completionsClassPropertiesAssignment.ts b/tests/cases/fourslash/completionsClassPropertiesAssignment.ts index a3be4038c36..cb9aa111df0 100644 --- a/tests/cases/fourslash/completionsClassPropertiesAssignment.ts +++ b/tests/cases/fourslash/completionsClassPropertiesAssignment.ts @@ -1,29 +1,32 @@ /// ////class Class1 { -//// protected a = /*1*/ -//// private b = /*2*/ -//// public c = /*3*/ -//// public d = this./*4*/ +//// public a = this./*0*/ +//// protected b = /*1*/ +//// private c = /*2*/ +//// public d = /*3*/ ////} //// ////class Class2 { -//// a = /*5*/ +//// a = /*4*/ ////} ////class Class3 { -//// a = /*6*/ +//// a = /*5*/ ////} //// ////const prop = 'prop'; ////class Class4 { -//// [prop] = /*7*/ +//// [prop] = /*6*/ ////} const exact = completion.globalsPlus(["Class1", "Class2", "Class3", "prop", "Class4"]); -verify.completions({ marker: ["1"], exact }); -verify.completions({ marker: ["2"], exact }); -verify.completions({ marker: ["3"], exact }); -verify.completions({ marker: ["4"], exact: ['a', 'b', 'c', 'd'], isGlobalCompletion: false }); -verify.completions({ marker: ["5"], exact }); -verify.completions({ marker: ["6"], exact }); -verify.completions({ marker: ["7"], exact }); +const markers = ["1", "2", "3", "4", "5", "6"]; + +verify.completions({ marker: "0", exact: ['a', 'b', 'c', 'd'], isGlobalCompletion: false }); +verify.completions({ marker: markers, exact }); + +for (let marker of markers) { + goTo.marker(marker); + edit.insert("c"); + verify.completions({ exact }); +} From d28e38f57306af063e1ee84432f8efa6e7c22093 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 24 Apr 2020 14:30:28 -0700 Subject: [PATCH 56/74] Revert "make splice `deleteCount` required in es5.d.ts (#32643)" (#38169) This reverts commit ddcf139668c3a0aeda1da6a0d44887735ad37cdf. --- src/lib/es2015.core.d.ts | 9 -------- src/lib/es5.d.ts | 2 +- tests/baselines/reference/arraySlice.types | 4 ++-- tests/baselines/reference/invalidSplice.types | 4 ++-- .../jsDeclarationsImportTypeBundled.types | 8 +++---- ...tionsTypeReassignmentFromDeclaration.types | 8 +++---- ...ionsTypeReassignmentFromDeclaration2.types | 8 +++---- tests/baselines/reference/parserharness.types | 4 ++-- .../reference/restInvalidArgumentType.types | 2 +- .../restParameterWithBindingPattern3.types | 2 +- .../restPropertyWithBindingPattern.types | 4 ++-- .../baselines/reference/spliceES5.errors.txt | 11 ---------- tests/baselines/reference/spliceES5.js | 10 --------- tests/baselines/reference/spliceES5.symbols | 12 ----------- tests/baselines/reference/spliceES5.types | 21 ------------------- tests/baselines/reference/spliceES6.js | 10 --------- tests/baselines/reference/spliceES6.symbols | 12 ----------- tests/baselines/reference/spliceES6.types | 21 ------------------- .../reference/spreadInvalidArgumentType.types | 4 ++-- ...ymousTypeNotReferencingTypeParameter.types | 20 +++++++++--------- ...ingsWithOverloadResolution3_ES6.errors.txt | 2 +- tests/cases/compiler/spliceES5.ts | 4 ---- tests/cases/compiler/spliceES6.ts | 4 ---- 23 files changed, 36 insertions(+), 150 deletions(-) delete mode 100644 tests/baselines/reference/spliceES5.errors.txt delete mode 100644 tests/baselines/reference/spliceES5.js delete mode 100644 tests/baselines/reference/spliceES5.symbols delete mode 100644 tests/baselines/reference/spliceES5.types delete mode 100644 tests/baselines/reference/spliceES6.js delete mode 100644 tests/baselines/reference/spliceES6.symbols delete mode 100644 tests/baselines/reference/spliceES6.types delete mode 100644 tests/cases/compiler/spliceES5.ts delete mode 100644 tests/cases/compiler/spliceES6.ts diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index ef7dd1f69f7..1487891d524 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -42,15 +42,6 @@ interface Array { * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): this; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. If deleteCount is omitted, or if its value is equal to or larger - * than array.length - start (that is, if it is equal to or greater than the number of elements left in the array, - * starting at start), then all the elements from start to the end of the array will be deleted. - */ - splice(start: number, deleteCount?: number): T[]; } interface ArrayConstructor { diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 9b981d69fc0..478f78f772a 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1254,7 +1254,7 @@ interface Array { * @param start The zero-based location in the array from which to start removing elements. * @param deleteCount The number of elements to remove. */ - splice(start: number, deleteCount: number): T[]; + splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. diff --git a/tests/baselines/reference/arraySlice.types b/tests/baselines/reference/arraySlice.types index bc65a26cebf..d1ee482ccaa 100644 --- a/tests/baselines/reference/arraySlice.types +++ b/tests/baselines/reference/arraySlice.types @@ -4,9 +4,9 @@ var arr: string[] | number[]; arr.splice(1, 1); >arr.splice(1, 1) : string[] | number[] ->arr.splice : { (start: number, deleteCount: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } | { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; } +>arr.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } | { (start: number, deleteCount?: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; } >arr : string[] | number[] ->splice : { (start: number, deleteCount: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } | { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; } +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } | { (start: number, deleteCount?: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; } >1 : 1 >1 : 1 diff --git a/tests/baselines/reference/invalidSplice.types b/tests/baselines/reference/invalidSplice.types index a3ba1dde360..9ff59021725 100644 --- a/tests/baselines/reference/invalidSplice.types +++ b/tests/baselines/reference/invalidSplice.types @@ -2,9 +2,9 @@ var arr = [].splice(0,3,4,5); >arr : any[] >[].splice(0,3,4,5) : any[] ->[].splice : { (start: number, deleteCount: number): any[]; (start: number, deleteCount: number, ...items: any[]): any[]; } +>[].splice : { (start: number, deleteCount?: number): any[]; (start: number, deleteCount: number, ...items: any[]): any[]; } >[] : undefined[] ->splice : { (start: number, deleteCount: number): any[]; (start: number, deleteCount: number, ...items: any[]): any[]; } +>splice : { (start: number, deleteCount?: number): any[]; (start: number, deleteCount: number, ...items: any[]): any[]; } >0 : 0 >3 : 3 >4 : 4 diff --git a/tests/baselines/reference/jsDeclarationsImportTypeBundled.types b/tests/baselines/reference/jsDeclarationsImportTypeBundled.types index 6bb9bb74f52..0fac842568c 100644 --- a/tests/baselines/reference/jsDeclarationsImportTypeBundled.types +++ b/tests/baselines/reference/jsDeclarationsImportTypeBundled.types @@ -28,9 +28,9 @@ const items = [{x: 12}]; >12 : 12 module.exports = items; ->module.exports = items : { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; } ->module.exports : { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; } ->module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; }; } ->exports : { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; } +>module.exports = items : { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount?: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; } +>module.exports : { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount?: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; } +>module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount?: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; }; } +>exports : { [n: number]: { x: number; }; length: number; toString(): string; toLocaleString(): string; pop(): { x: number; }; push(...items: { x: number; }[]): number; concat(...items: ConcatArray<{ x: number; }>[]): { x: number; }[]; concat(...items: ({ x: number; } | ConcatArray<{ x: number; }>)[]): { x: number; }[]; join(separator?: string): string; reverse(): { x: number; }[]; shift(): { x: number; }; slice(start?: number, end?: number): { x: number; }[]; sort(compareFn?: (a: { x: number; }, b: { x: number; }) => number): { x: number; }[]; splice(start: number, deleteCount?: number): { x: number; }[]; splice(start: number, deleteCount: number, ...items: { x: number; }[]): { x: number; }[]; unshift(...items: { x: number; }[]): number; indexOf(searchElement: { x: number; }, fromIndex?: number): number; lastIndexOf(searchElement: { x: number; }, fromIndex?: number): number; every(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => void, thisArg?: any): void; map(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => unknown, thisArg?: any): { x: number; }[]; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduce(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: { x: number; }, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => { x: number; }, initialValue: { x: number; }): { x: number; }; reduceRight(callbackfn: (previousValue: U, currentValue: { x: number; }, currentIndex: number, array: { x: number; }[]) => U, initialValue: U): U; } >items : { x: number; }[] diff --git a/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.types b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.types index 92279bc2347..f684be1a540 100644 --- a/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.types +++ b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration.types @@ -16,9 +16,9 @@ const items = []; >[] : undefined[] module.exports = items; ->module.exports = items : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; splice(start: number, deleteCount?: number): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } ->module.exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; splice(start: number, deleteCount?: number): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } ->module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; splice(start: number, deleteCount?: number): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; }; } ->exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; splice(start: number, deleteCount?: number): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>module.exports = items : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>module.exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; }; } +>exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } >items : Item[] diff --git a/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.types b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.types index e4a85bef283..525b934644b 100644 --- a/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.types +++ b/tests/baselines/reference/jsDeclarationsTypeReassignmentFromDeclaration2.types @@ -7,10 +7,10 @@ const items = require("./some-mod")(); >"./some-mod" : "./some-mod" module.exports = items; ->module.exports = items : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; splice(start: number, deleteCount?: number): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } ->module.exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; splice(start: number, deleteCount?: number): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } ->module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; splice(start: number, deleteCount?: number): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; }; } ->exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; splice(start: number, deleteCount?: number): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>module.exports = items : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>module.exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } +>module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; }; } +>exports : { [n: number]: Item; length: number; toString(): string; toLocaleString(): string; pop(): Item; push(...items: Item[]): number; concat(...items: ConcatArray[]): Item[]; concat(...items: (Item | ConcatArray)[]): Item[]; join(separator?: string): string; reverse(): Item[]; shift(): Item; slice(start?: number, end?: number): Item[]; sort(compareFn?: (a: Item, b: Item) => number): Item[]; splice(start: number, deleteCount?: number): Item[]; splice(start: number, deleteCount: number, ...items: Item[]): Item[]; unshift(...items: Item[]): number; indexOf(searchElement: Item, fromIndex?: number): number; lastIndexOf(searchElement: Item, fromIndex?: number): number; every(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: Item, index: number, array: Item[]) => void, thisArg?: any): void; map(callbackfn: (value: Item, index: number, array: Item[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: Item, index: number, array: Item[]) => unknown, thisArg?: any): Item[]; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduce(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduce(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item): Item; reduceRight(callbackfn: (previousValue: Item, currentValue: Item, currentIndex: number, array: Item[]) => Item, initialValue: Item): Item; reduceRight(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number, array: Item[]) => U, initialValue: U): U; find(predicate: (this: void, value: Item, index: number, obj: Item[]) => value is S, thisArg?: any): S; find(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): Item; findIndex(predicate: (value: Item, index: number, obj: Item[]) => unknown, thisArg?: any): number; fill(value: Item, start?: number, end?: number): Item[]; copyWithin(target: number, start: number, end?: number): Item[]; [Symbol.iterator](): IterableIterator; entries(): IterableIterator<[number, Item]>; keys(): IterableIterator; values(): IterableIterator; [Symbol.unscopables](): { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }; } >items : Item[] === tests/cases/conformance/jsdoc/declarations/some-mod.d.ts === diff --git a/tests/baselines/reference/parserharness.types b/tests/baselines/reference/parserharness.types index c9b501d8754..793efe35fd7 100644 --- a/tests/baselines/reference/parserharness.types +++ b/tests/baselines/reference/parserharness.types @@ -6383,11 +6383,11 @@ module Harness { this.editRanges.splice(0, this.maxScriptVersions - this.editRanges.length); >this.editRanges.splice(0, this.maxScriptVersions - this.editRanges.length) : { length: number; editRange: any; }[] ->this.editRanges.splice : { (start: number, deleteCount: number): { length: number; editRange: any; }[]; (start: number, deleteCount: number, ...items: { length: number; editRange: any; }[]): { length: number; editRange: any; }[]; } +>this.editRanges.splice : { (start: number, deleteCount?: number): { length: number; editRange: any; }[]; (start: number, deleteCount: number, ...items: { length: number; editRange: any; }[]): { length: number; editRange: any; }[]; } >this.editRanges : { length: number; editRange: any; }[] >this : this >editRanges : { length: number; editRange: any; }[] ->splice : { (start: number, deleteCount: number): { length: number; editRange: any; }[]; (start: number, deleteCount: number, ...items: { length: number; editRange: any; }[]): { length: number; editRange: any; }[]; } +>splice : { (start: number, deleteCount?: number): { length: number; editRange: any; }[]; (start: number, deleteCount: number, ...items: { length: number; editRange: any; }[]): { length: number; editRange: any; }[]; } >0 : 0 >this.maxScriptVersions - this.editRanges.length : number >this.maxScriptVersions : number diff --git a/tests/baselines/reference/restInvalidArgumentType.types b/tests/baselines/reference/restInvalidArgumentType.types index 0a3b66362f8..638634e8bea 100644 --- a/tests/baselines/reference/restInvalidArgumentType.types +++ b/tests/baselines/reference/restInvalidArgumentType.types @@ -71,7 +71,7 @@ function f(p1: T, p2: T[]) { >p1 : T var {...r2} = p2; // OK ->r2 : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } +>r2 : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } >p2 : T[] var {...r3} = t; // Error, generic type paramter diff --git a/tests/baselines/reference/restParameterWithBindingPattern3.types b/tests/baselines/reference/restParameterWithBindingPattern3.types index 6b5a195ae3d..b98f0cdd367 100644 --- a/tests/baselines/reference/restParameterWithBindingPattern3.types +++ b/tests/baselines/reference/restParameterWithBindingPattern3.types @@ -31,5 +31,5 @@ function e(...{0: a = 1, 1: b = true, ...rest: rest}: [boolean, string, number]) >b : string >true : true >rest : any ->rest : { [n: number]: string | number | boolean; 0: boolean; 1: string; 2: number; length: 3; toString(): string; toLocaleString(): string; pop(): string | number | boolean; push(...items: (string | number | boolean)[]): number; concat(...items: ConcatArray[]): (string | number | boolean)[]; concat(...items: (string | number | boolean | ConcatArray)[]): (string | number | boolean)[]; join(separator?: string): string; reverse(): (string | number | boolean)[]; shift(): string | number | boolean; slice(start?: number, end?: number): (string | number | boolean)[]; sort(compareFn?: (a: string | number | boolean, b: string | number | boolean) => number): [boolean, string, number]; splice(start: number, deleteCount: number): (string | number | boolean)[]; splice(start: number, deleteCount: number, ...items: (string | number | boolean)[]): (string | number | boolean)[]; unshift(...items: (string | number | boolean)[]): number; indexOf(searchElement: string | number | boolean, fromIndex?: number): number; lastIndexOf(searchElement: string | number | boolean, fromIndex?: number): number; every(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => void, thisArg?: any): void; map(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): (string | number | boolean)[]; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; } +>rest : { [n: number]: string | number | boolean; 0: boolean; 1: string; 2: number; length: 3; toString(): string; toLocaleString(): string; pop(): string | number | boolean; push(...items: (string | number | boolean)[]): number; concat(...items: ConcatArray[]): (string | number | boolean)[]; concat(...items: (string | number | boolean | ConcatArray)[]): (string | number | boolean)[]; join(separator?: string): string; reverse(): (string | number | boolean)[]; shift(): string | number | boolean; slice(start?: number, end?: number): (string | number | boolean)[]; sort(compareFn?: (a: string | number | boolean, b: string | number | boolean) => number): [boolean, string, number]; splice(start: number, deleteCount?: number): (string | number | boolean)[]; splice(start: number, deleteCount: number, ...items: (string | number | boolean)[]): (string | number | boolean)[]; unshift(...items: (string | number | boolean)[]): number; indexOf(searchElement: string | number | boolean, fromIndex?: number): number; lastIndexOf(searchElement: string | number | boolean, fromIndex?: number): number; every(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => void, thisArg?: any): void; map(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: string | number | boolean, index: number, array: (string | number | boolean)[]) => unknown, thisArg?: any): (string | number | boolean)[]; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduce(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: string | number | boolean, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => string | number | boolean, initialValue: string | number | boolean): string | number | boolean; reduceRight(callbackfn: (previousValue: U, currentValue: string | number | boolean, currentIndex: number, array: (string | number | boolean)[]) => U, initialValue: U): U; } diff --git a/tests/baselines/reference/restPropertyWithBindingPattern.types b/tests/baselines/reference/restPropertyWithBindingPattern.types index e079b7857ee..55bd7fd95f6 100644 --- a/tests/baselines/reference/restPropertyWithBindingPattern.types +++ b/tests/baselines/reference/restPropertyWithBindingPattern.types @@ -17,14 +17,14 @@ ({...[]} = {}); >({...[]} = {}) : {} >{...[]} = {} : {} ->{...[]} : { [n: number]: undefined; length: number; toString(): string; toLocaleString(): string; pop(): undefined; push(...items: undefined[]): number; concat(...items: ConcatArray[]): undefined[]; concat(...items: ConcatArray[]): undefined[]; join(separator?: string): string; reverse(): undefined[]; shift(): undefined; slice(start?: number, end?: number): undefined[]; sort(compareFn?: (a: undefined, b: undefined) => number): undefined[]; splice(start: number, deleteCount: number): undefined[]; splice(start: number, deleteCount: number, ...items: undefined[]): undefined[]; unshift(...items: undefined[]): number; indexOf(searchElement: undefined, fromIndex?: number): number; lastIndexOf(searchElement: undefined, fromIndex?: number): number; every(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: undefined, index: number, array: undefined[]) => void, thisArg?: any): void; map(callbackfn: (value: undefined, index: number, array: undefined[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: undefined, index: number, array: undefined[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): undefined[]; reduce(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined): undefined; reduce(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined, initialValue: undefined): undefined; reduce(callbackfn: (previousValue: U, currentValue: undefined, currentIndex: number, array: undefined[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined): undefined; reduceRight(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined, initialValue: undefined): undefined; reduceRight(callbackfn: (previousValue: U, currentValue: undefined, currentIndex: number, array: undefined[]) => U, initialValue: U): U; } +>{...[]} : { [n: number]: undefined; length: number; toString(): string; toLocaleString(): string; pop(): undefined; push(...items: undefined[]): number; concat(...items: ConcatArray[]): undefined[]; concat(...items: ConcatArray[]): undefined[]; join(separator?: string): string; reverse(): undefined[]; shift(): undefined; slice(start?: number, end?: number): undefined[]; sort(compareFn?: (a: undefined, b: undefined) => number): undefined[]; splice(start: number, deleteCount?: number): undefined[]; splice(start: number, deleteCount: number, ...items: undefined[]): undefined[]; unshift(...items: undefined[]): number; indexOf(searchElement: undefined, fromIndex?: number): number; lastIndexOf(searchElement: undefined, fromIndex?: number): number; every(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: undefined, index: number, array: undefined[]) => void, thisArg?: any): void; map(callbackfn: (value: undefined, index: number, array: undefined[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: undefined, index: number, array: undefined[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): undefined[]; reduce(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined): undefined; reduce(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined, initialValue: undefined): undefined; reduce(callbackfn: (previousValue: U, currentValue: undefined, currentIndex: number, array: undefined[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined): undefined; reduceRight(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined, initialValue: undefined): undefined; reduceRight(callbackfn: (previousValue: U, currentValue: undefined, currentIndex: number, array: undefined[]) => U, initialValue: U): U; } >[] : undefined[] >{} : {} ({...([])} = {}); >({...([])} = {}) : {} >{...([])} = {} : {} ->{...([])} : { [n: number]: undefined; length: number; toString(): string; toLocaleString(): string; pop(): undefined; push(...items: undefined[]): number; concat(...items: ConcatArray[]): undefined[]; concat(...items: ConcatArray[]): undefined[]; join(separator?: string): string; reverse(): undefined[]; shift(): undefined; slice(start?: number, end?: number): undefined[]; sort(compareFn?: (a: undefined, b: undefined) => number): undefined[]; splice(start: number, deleteCount: number): undefined[]; splice(start: number, deleteCount: number, ...items: undefined[]): undefined[]; unshift(...items: undefined[]): number; indexOf(searchElement: undefined, fromIndex?: number): number; lastIndexOf(searchElement: undefined, fromIndex?: number): number; every(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: undefined, index: number, array: undefined[]) => void, thisArg?: any): void; map(callbackfn: (value: undefined, index: number, array: undefined[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: undefined, index: number, array: undefined[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): undefined[]; reduce(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined): undefined; reduce(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined, initialValue: undefined): undefined; reduce(callbackfn: (previousValue: U, currentValue: undefined, currentIndex: number, array: undefined[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined): undefined; reduceRight(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined, initialValue: undefined): undefined; reduceRight(callbackfn: (previousValue: U, currentValue: undefined, currentIndex: number, array: undefined[]) => U, initialValue: U): U; } +>{...([])} : { [n: number]: undefined; length: number; toString(): string; toLocaleString(): string; pop(): undefined; push(...items: undefined[]): number; concat(...items: ConcatArray[]): undefined[]; concat(...items: ConcatArray[]): undefined[]; join(separator?: string): string; reverse(): undefined[]; shift(): undefined; slice(start?: number, end?: number): undefined[]; sort(compareFn?: (a: undefined, b: undefined) => number): undefined[]; splice(start: number, deleteCount?: number): undefined[]; splice(start: number, deleteCount: number, ...items: undefined[]): undefined[]; unshift(...items: undefined[]): number; indexOf(searchElement: undefined, fromIndex?: number): number; lastIndexOf(searchElement: undefined, fromIndex?: number): number; every(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: undefined, index: number, array: undefined[]) => void, thisArg?: any): void; map(callbackfn: (value: undefined, index: number, array: undefined[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: undefined, index: number, array: undefined[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: undefined, index: number, array: undefined[]) => unknown, thisArg?: any): undefined[]; reduce(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined): undefined; reduce(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined, initialValue: undefined): undefined; reduce(callbackfn: (previousValue: U, currentValue: undefined, currentIndex: number, array: undefined[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined): undefined; reduceRight(callbackfn: (previousValue: undefined, currentValue: undefined, currentIndex: number, array: undefined[]) => undefined, initialValue: undefined): undefined; reduceRight(callbackfn: (previousValue: U, currentValue: undefined, currentIndex: number, array: undefined[]) => U, initialValue: U): U; } >([]) : undefined[] >[] : undefined[] >{} : {} diff --git a/tests/baselines/reference/spliceES5.errors.txt b/tests/baselines/reference/spliceES5.errors.txt deleted file mode 100644 index 448bb37fd2e..00000000000 --- a/tests/baselines/reference/spliceES5.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/spliceES5.ts(2,16): error TS2555: Expected at least 2 arguments, but got 1. - - -==== tests/cases/compiler/spliceES5.ts (1 errors) ==== - // see #32638 - var arr1 = [0].splice(0) - ~~~~~~~~~ -!!! error TS2555: Expected at least 2 arguments, but got 1. -!!! related TS6210 /.ts/lib.es5.d.ts:1277:27: An argument for 'deleteCount' was not provided. - var arr2 = [0].splice(0, 1) - \ No newline at end of file diff --git a/tests/baselines/reference/spliceES5.js b/tests/baselines/reference/spliceES5.js deleted file mode 100644 index d0239c19cb8..00000000000 --- a/tests/baselines/reference/spliceES5.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [spliceES5.ts] -// see #32638 -var arr1 = [0].splice(0) -var arr2 = [0].splice(0, 1) - - -//// [spliceES5.js] -// see #32638 -var arr1 = [0].splice(0); -var arr2 = [0].splice(0, 1); diff --git a/tests/baselines/reference/spliceES5.symbols b/tests/baselines/reference/spliceES5.symbols deleted file mode 100644 index fa0b1a5566d..00000000000 --- a/tests/baselines/reference/spliceES5.symbols +++ /dev/null @@ -1,12 +0,0 @@ -=== tests/cases/compiler/spliceES5.ts === -// see #32638 -var arr1 = [0].splice(0) ->arr1 : Symbol(arr1, Decl(spliceES5.ts, 1, 3)) ->[0].splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - -var arr2 = [0].splice(0, 1) ->arr2 : Symbol(arr2, Decl(spliceES5.ts, 2, 3)) ->[0].splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) - diff --git a/tests/baselines/reference/spliceES5.types b/tests/baselines/reference/spliceES5.types deleted file mode 100644 index 42da61a080a..00000000000 --- a/tests/baselines/reference/spliceES5.types +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/compiler/spliceES5.ts === -// see #32638 -var arr1 = [0].splice(0) ->arr1 : number[] ->[0].splice(0) : number[] ->[0].splice : { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; } ->[0] : number[] ->0 : 0 ->splice : { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; } ->0 : 0 - -var arr2 = [0].splice(0, 1) ->arr2 : number[] ->[0].splice(0, 1) : number[] ->[0].splice : { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; } ->[0] : number[] ->0 : 0 ->splice : { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; } ->0 : 0 ->1 : 1 - diff --git a/tests/baselines/reference/spliceES6.js b/tests/baselines/reference/spliceES6.js deleted file mode 100644 index 3fe0519ede9..00000000000 --- a/tests/baselines/reference/spliceES6.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [spliceES6.ts] -// see #32638 -var arr1 = [0].splice(0) -var arr2 = [0].splice(0, 1) - - -//// [spliceES6.js] -// see #32638 -var arr1 = [0].splice(0); -var arr2 = [0].splice(0, 1); diff --git a/tests/baselines/reference/spliceES6.symbols b/tests/baselines/reference/spliceES6.symbols deleted file mode 100644 index cbfb2a7ef37..00000000000 --- a/tests/baselines/reference/spliceES6.symbols +++ /dev/null @@ -1,12 +0,0 @@ -=== tests/cases/compiler/spliceES6.ts === -// see #32638 -var arr1 = [0].splice(0) ->arr1 : Symbol(arr1, Decl(spliceES6.ts, 1, 3)) ->[0].splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) - -var arr2 = [0].splice(0, 1) ->arr2 : Symbol(arr2, Decl(spliceES6.ts, 2, 3)) ->[0].splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) - diff --git a/tests/baselines/reference/spliceES6.types b/tests/baselines/reference/spliceES6.types deleted file mode 100644 index fc73c584c44..00000000000 --- a/tests/baselines/reference/spliceES6.types +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/compiler/spliceES6.ts === -// see #32638 -var arr1 = [0].splice(0) ->arr1 : number[] ->[0].splice(0) : number[] ->[0].splice : { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; (start: number, deleteCount?: number): number[]; } ->[0] : number[] ->0 : 0 ->splice : { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; (start: number, deleteCount?: number): number[]; } ->0 : 0 - -var arr2 = [0].splice(0, 1) ->arr2 : number[] ->[0].splice(0, 1) : number[] ->[0].splice : { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; (start: number, deleteCount?: number): number[]; } ->[0] : number[] ->0 : 0 ->splice : { (start: number, deleteCount: number): number[]; (start: number, deleteCount: number, ...items: number[]): number[]; (start: number, deleteCount?: number): number[]; } ->0 : 0 ->1 : 1 - diff --git a/tests/baselines/reference/spreadInvalidArgumentType.types b/tests/baselines/reference/spreadInvalidArgumentType.types index 2dae3fe38ef..ec1b7faa9ec 100644 --- a/tests/baselines/reference/spreadInvalidArgumentType.types +++ b/tests/baselines/reference/spreadInvalidArgumentType.types @@ -73,8 +73,8 @@ function f(p1: T, p2: T[]) { >p1 : T var o2 = { ...p2 }; // OK ->o2 : { [x: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } ->{ ...p2 } : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } +>o2 : { [x: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } +>{ ...p2 } : { [n: number]: T; length: number; toString(): string; toLocaleString(): string; pop(): T; push(...items: T[]): number; concat(...items: ConcatArray[]): T[]; concat(...items: (T | ConcatArray)[]): T[]; join(separator?: string): string; reverse(): T[]; shift(): T; slice(start?: number, end?: number): T[]; sort(compareFn?: (a: T, b: T) => number): T[]; splice(start: number, deleteCount?: number): T[]; splice(start: number, deleteCount: number, ...items: T[]): T[]; unshift(...items: T[]): number; indexOf(searchElement: T, fromIndex?: number): number; lastIndexOf(searchElement: T, fromIndex?: number): number; every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; } >p2 : T[] var o3 = { ...t }; // OK, generic type paramter diff --git a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types index 35c7db17f2f..cd907c26ec8 100644 --- a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types +++ b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types @@ -319,9 +319,9 @@ class ListWrapper { >index : number >value : T >list.splice(index, 0, value) : T[] ->list.splice : { (start: number, deleteCount: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>list.splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >list : T[] ->splice : { (start: number, deleteCount: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number >0 : 0 >value : T @@ -341,9 +341,9 @@ class ListWrapper { list.splice(index, 1); >list.splice(index, 1) : T[] ->list.splice : { (start: number, deleteCount: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>list.splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >list : T[] ->splice : { (start: number, deleteCount: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number >1 : 1 @@ -380,9 +380,9 @@ class ListWrapper { list.splice(index, 1); >list.splice(index, 1) : T[] ->list.splice : { (start: number, deleteCount: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>list.splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >list : T[] ->splice : { (start: number, deleteCount: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number >1 : 1 } @@ -410,9 +410,9 @@ class ListWrapper { list.splice(index, 1); >list.splice(index, 1) : T[] ->list.splice : { (start: number, deleteCount: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>list.splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >list : T[] ->splice : { (start: number, deleteCount: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number >1 : 1 @@ -543,9 +543,9 @@ class ListWrapper { >from : number >length : number >l.splice(from, length) : T[] ->l.splice : { (start: number, deleteCount: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>l.splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >l : T[] ->splice : { (start: number, deleteCount: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } +>splice : { (start: number, deleteCount?: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >from : number >length : number diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt index 3d0389b8502..95eb021c88b 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt @@ -113,7 +113,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'. ~~~~~~~ !!! error TS2551: Property 'toFixed' does not exist on type 'string'. Did you mean 'fixed'? -!!! related TS2728 /.ts/lib.es2015.core.d.ts:481:5: 'fixed' is declared here. +!!! related TS2728 /.ts/lib.es2015.core.d.ts:472:5: 'fixed' is declared here. fn5 `${ (n) => n.substr(0) }`; \ No newline at end of file diff --git a/tests/cases/compiler/spliceES5.ts b/tests/cases/compiler/spliceES5.ts deleted file mode 100644 index 6955fa44c22..00000000000 --- a/tests/cases/compiler/spliceES5.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @target: es5 -// see #32638 -var arr1 = [0].splice(0) -var arr2 = [0].splice(0, 1) diff --git a/tests/cases/compiler/spliceES6.ts b/tests/cases/compiler/spliceES6.ts deleted file mode 100644 index 0f1aa8223fd..00000000000 --- a/tests/cases/compiler/spliceES6.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @target: es6 -// see #32638 -var arr1 = [0].splice(0) -var arr2 = [0].splice(0, 1) From 968943f355c54b0cf6cc4efde10b57ff2cfa5bcb Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 24 Apr 2020 14:59:41 -0700 Subject: [PATCH 57/74] Reset error variable in downlevel for-await-of loop (#38170) * Rename forAwait tests * Reset error var in for-await loop --- src/compiler/transformers/es2018.ts | 163 +++++++++++++++--- ....js => emitter.forAwait(target=es2015).js} | 52 +++++- ...> emitter.forAwait(target=es2015).symbols} | 27 ++- ... => emitter.forAwait(target=es2015).types} | 26 ++- ....js => emitter.forAwait(target=es2017).js} | 52 +++++- ...> emitter.forAwait(target=es2017).symbols} | 27 ++- ... => emitter.forAwait(target=es2017).types} | 27 ++- ....js => emitter.forAwait(target=es2018).js} | 23 ++- ...> emitter.forAwait(target=es2018).symbols} | 26 ++- ... => emitter.forAwait(target=es2018).types} | 27 ++- ...es5.js => emitter.forAwait(target=es5).js} | 98 ++++++++++- ...s => emitter.forAwait(target=es5).symbols} | 27 ++- ...pes => emitter.forAwait(target=es5).types} | 27 ++- .../forAwait/emitter.forAwait.es2015.ts | 42 ----- .../forAwait/emitter.forAwait.es2017.ts | 42 ----- .../es5/forAwait/emitter.forAwait.es5.ts | 42 ----- .../emitter.forAwait.ts} | 11 +- 17 files changed, 532 insertions(+), 207 deletions(-) rename tests/baselines/reference/{emitter.forAwait.es2015.js => emitter.forAwait(target=es2015).js} (81%) rename tests/baselines/reference/{emitter.forAwait.es2017.symbols => emitter.forAwait(target=es2015).symbols} (63%) rename tests/baselines/reference/{emitter.forAwait.es2018.types => emitter.forAwait(target=es2015).types} (56%) rename tests/baselines/reference/{emitter.forAwait.es2017.js => emitter.forAwait(target=es2017).js} (79%) rename tests/baselines/reference/{emitter.forAwait.es2015.symbols => emitter.forAwait(target=es2017).symbols} (63%) rename tests/baselines/reference/{emitter.forAwait.es2015.types => emitter.forAwait(target=es2017).types} (56%) rename tests/baselines/reference/{emitter.forAwait.es2018.js => emitter.forAwait(target=es2018).js} (73%) rename tests/baselines/reference/{emitter.forAwait.es2018.symbols => emitter.forAwait(target=es2018).symbols} (63%) rename tests/baselines/reference/{emitter.forAwait.es2017.types => emitter.forAwait(target=es2018).types} (56%) rename tests/baselines/reference/{emitter.forAwait.es5.js => emitter.forAwait(target=es5).js} (83%) rename tests/baselines/reference/{emitter.forAwait.es5.symbols => emitter.forAwait(target=es5).symbols} (63%) rename tests/baselines/reference/{emitter.forAwait.es5.types => emitter.forAwait(target=es5).types} (56%) delete mode 100644 tests/cases/conformance/emitter/es2015/forAwait/emitter.forAwait.es2015.ts delete mode 100644 tests/cases/conformance/emitter/es2017/forAwait/emitter.forAwait.es2017.ts delete mode 100644 tests/cases/conformance/emitter/es5/forAwait/emitter.forAwait.es5.ts rename tests/cases/conformance/{emitter/es2018/forAwait/emitter.forAwait.es2018.ts => statements/for-await-ofStatements/emitter.forAwait.ts} (74%) diff --git a/src/compiler/transformers/es2018.ts b/src/compiler/transformers/es2018.ts index a3ae750f6e7..16d67fcef38 100644 --- a/src/compiler/transformers/es2018.ts +++ b/src/compiler/transformers/es2018.ts @@ -5,6 +5,38 @@ namespace ts { AsyncMethodsWithSuper = 1 << 0 } + // Facts we track as we traverse the tree + const enum HierarchyFacts { + None = 0, + + // + // Ancestor facts + // + + HasLexicalThis = 1 << 0, + IterationContainer = 1 << 1, + // NOTE: do not add more ancestor flags without also updating AncestorFactsMask below. + + // + // Ancestor masks + // + + AncestorFactsMask = (IterationContainer << 1) - 1, + + SourceFileIncludes = HasLexicalThis, + SourceFileExcludes = IterationContainer, + StrictModeSourceFileIncludes = None, + + ClassOrFunctionIncludes = HasLexicalThis, + ClassOrFunctionExcludes = IterationContainer, + + ArrowFunctionIncludes = None, + ArrowFunctionExcludes = ClassOrFunctionExcludes, + + IterationStatementIncludes = IterationContainer, + IterationStatementExcludes = None, + } + export function transformES2018(context: TransformationContext) { const { resumeLexicalEnvironment, @@ -26,7 +58,7 @@ namespace ts { let enabledSubstitutions: ESNextSubstitutionFlags; let enclosingFunctionFlags: FunctionFlags; let enclosingSuperContainerFlags: NodeCheckFlags = 0; - let hasLexicalThis: boolean; + let hierarchyFacts: HierarchyFacts = 0; let currentSourceFile: SourceFile; let taggedTemplateStringDeclarations: VariableDeclaration[]; @@ -40,6 +72,30 @@ namespace ts { return chainBundle(transformSourceFile); + function affectsSubtree(excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts) { + return hierarchyFacts !== (hierarchyFacts & ~excludeFacts | includeFacts); + } + + /** + * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. + * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. + * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. + */ + function enterSubtree(excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts) { + const ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & HierarchyFacts.AncestorFactsMask; + return ancestorFacts; + } + + /** + * Restores the `HierarchyFacts` for this node's ancestor after visiting this node's + * subtree. + * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. + */ + function exitSubtree(ancestorFacts: HierarchyFacts) { + hierarchyFacts = ancestorFacts; + } + function recordTaggedTemplateString(temp: Identifier) { taggedTemplateStringDeclarations = append( taggedTemplateStringDeclarations, @@ -75,11 +131,11 @@ namespace ts { return node; } - function doWithLexicalThis(cb: (value: T) => U, value: T) { - if (!hasLexicalThis) { - hasLexicalThis = true; + function doWithHierarchyFacts(cb: (value: T) => U, value: T, excludeFacts: HierarchyFacts, includeFacts: HierarchyFacts) { + if (affectsSubtree(excludeFacts, includeFacts)) { + const ancestorFacts = enterSubtree(excludeFacts, includeFacts); const result = cb(value); - hasLexicalThis = false; + exitSubtree(ancestorFacts); return result; } return cb(value); @@ -112,26 +168,66 @@ namespace ts { return visitVariableStatement(node as VariableStatement); case SyntaxKind.VariableDeclaration: return visitVariableDeclaration(node as VariableDeclaration); + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + case SyntaxKind.ForInStatement: + return doWithHierarchyFacts( + visitDefault, + node, + HierarchyFacts.IterationStatementExcludes, + HierarchyFacts.IterationStatementIncludes); case SyntaxKind.ForOfStatement: return visitForOfStatement(node as ForOfStatement, /*outermostLabeledStatement*/ undefined); case SyntaxKind.ForStatement: - return visitForStatement(node as ForStatement); + return doWithHierarchyFacts( + visitForStatement, + node as ForStatement, + HierarchyFacts.IterationStatementExcludes, + HierarchyFacts.IterationStatementIncludes); case SyntaxKind.VoidExpression: return visitVoidExpression(node as VoidExpression); case SyntaxKind.Constructor: - return doWithLexicalThis(visitConstructorDeclaration, node as ConstructorDeclaration); + return doWithHierarchyFacts( + visitConstructorDeclaration, + node as ConstructorDeclaration, + HierarchyFacts.ClassOrFunctionExcludes, + HierarchyFacts.ClassOrFunctionIncludes); case SyntaxKind.MethodDeclaration: - return doWithLexicalThis(visitMethodDeclaration, node as MethodDeclaration); + return doWithHierarchyFacts( + visitMethodDeclaration, + node as MethodDeclaration, + HierarchyFacts.ClassOrFunctionExcludes, + HierarchyFacts.ClassOrFunctionIncludes); case SyntaxKind.GetAccessor: - return doWithLexicalThis(visitGetAccessorDeclaration, node as GetAccessorDeclaration); + return doWithHierarchyFacts( + visitGetAccessorDeclaration, + node as GetAccessorDeclaration, + HierarchyFacts.ClassOrFunctionExcludes, + HierarchyFacts.ClassOrFunctionIncludes); case SyntaxKind.SetAccessor: - return doWithLexicalThis(visitSetAccessorDeclaration, node as SetAccessorDeclaration); + return doWithHierarchyFacts( + visitSetAccessorDeclaration, + node as SetAccessorDeclaration, + HierarchyFacts.ClassOrFunctionExcludes, + HierarchyFacts.ClassOrFunctionIncludes); case SyntaxKind.FunctionDeclaration: - return doWithLexicalThis(visitFunctionDeclaration, node as FunctionDeclaration); + return doWithHierarchyFacts( + visitFunctionDeclaration, + node as FunctionDeclaration, + HierarchyFacts.ClassOrFunctionExcludes, + HierarchyFacts.ClassOrFunctionIncludes); case SyntaxKind.FunctionExpression: - return doWithLexicalThis(visitFunctionExpression, node as FunctionExpression); + return doWithHierarchyFacts( + visitFunctionExpression, + node as FunctionExpression, + HierarchyFacts.ClassOrFunctionExcludes, + HierarchyFacts.ClassOrFunctionIncludes); case SyntaxKind.ArrowFunction: - return visitArrowFunction(node as ArrowFunction); + return doWithHierarchyFacts( + visitArrowFunction, + node as ArrowFunction, + HierarchyFacts.ArrowFunctionExcludes, + HierarchyFacts.ArrowFunctionIncludes); case SyntaxKind.Parameter: return visitParameter(node as ParameterDeclaration); case SyntaxKind.ExpressionStatement: @@ -152,7 +248,11 @@ namespace ts { return visitEachChild(node, visitor, context); case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: - return doWithLexicalThis(visitDefault, node); + return doWithHierarchyFacts( + visitDefault, + node, + HierarchyFacts.ClassOrFunctionExcludes, + HierarchyFacts.ClassOrFunctionIncludes); default: return visitEachChild(node, visitor, context); } @@ -231,7 +331,7 @@ namespace ts { if (statement.kind === SyntaxKind.ForOfStatement && (statement).awaitModifier) { return visitForOfStatement(statement, node); } - return restoreEnclosingLabel(visitEachChild(statement, visitor, context), node); + return restoreEnclosingLabel(visitNode(statement, visitor, isStatement, liftToBlock), node); } return visitEachChild(node, visitor, context); } @@ -311,14 +411,20 @@ namespace ts { } function visitSourceFile(node: SourceFile): SourceFile { + const ancestorFacts = enterSubtree( + HierarchyFacts.SourceFileExcludes, + isEffectiveStrictModeSourceFile(node, compilerOptions) ? + HierarchyFacts.StrictModeSourceFileIncludes : + HierarchyFacts.SourceFileIncludes); exportedVariableStatement = false; - hasLexicalThis = !isEffectiveStrictModeSourceFile(node, compilerOptions); const visited = visitEachChild(node, visitor, context); const statement = concatenate(visited.statements, taggedTemplateStringDeclarations && [ createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList(taggedTemplateStringDeclarations)) ]); - return updateSourceFileNode(visited, setTextRange(createNodeArray(statement), node.statements)); + const result = updateSourceFileNode(visited, setTextRange(createNodeArray(statement), node.statements)); + exitSubtree(ancestorFacts); + return result; } function visitTaggedTemplateExpression(node: TaggedTemplateExpression) { @@ -441,15 +547,15 @@ namespace ts { * @param node A ForOfStatement. */ function visitForOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement | undefined): VisitResult { + const ancestorFacts = enterSubtree(HierarchyFacts.IterationStatementExcludes, HierarchyFacts.IterationStatementIncludes); if (node.initializer.transformFlags & TransformFlags.ContainsObjectRestOrSpread) { node = transformForOfStatementWithObjectRest(node); } - if (node.awaitModifier) { - return transformForAwaitOfStatement(node, outermostLabeledStatement); - } - else { - return restoreEnclosingLabel(visitEachChild(node, visitor, context), outermostLabeledStatement); - } + const result = node.awaitModifier ? + transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) : + restoreEnclosingLabel(visitEachChild(node, visitor, context), outermostLabeledStatement); + exitSubtree(ancestorFacts); + return result; } function transformForOfStatementWithObjectRest(node: ForOfStatement) { @@ -528,7 +634,7 @@ namespace ts { : createAwait(expression); } - function transformForAwaitOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement | undefined) { + function transformForAwaitOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement | undefined, ancestorFacts: HierarchyFacts) { const expression = visitNode(node.expression, visitor, isExpression); const iterator = isIdentifier(expression) ? getGeneratedNameForNode(expression) : createTempVariable(/*recordTempVariable*/ undefined); const result = isIdentifier(expression) ? getGeneratedNameForNode(iterator) : createTempVariable(/*recordTempVariable*/ undefined); @@ -544,13 +650,18 @@ namespace ts { hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); + // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration + const initializer = ancestorFacts & HierarchyFacts.IterationContainer ? + inlineExpressions([createAssignment(errorRecord, createVoidZero()), callValues]) : + callValues; + const forStatement = setEmitFlags( setTextRange( createFor( /*initializer*/ setEmitFlags( setTextRange( createVariableDeclarationList([ - setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, callValues), node.expression), + setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, initializer), node.expression), createVariableDeclaration(result) ]), node.expression @@ -809,7 +920,7 @@ namespace ts { visitLexicalEnvironment(node.body!.statements, visitor, context, statementOffset) ) ), - hasLexicalThis + !!(hierarchyFacts & HierarchyFacts.HasLexicalThis) ) ); diff --git a/tests/baselines/reference/emitter.forAwait.es2015.js b/tests/baselines/reference/emitter.forAwait(target=es2015).js similarity index 81% rename from tests/baselines/reference/emitter.forAwait.es2015.js rename to tests/baselines/reference/emitter.forAwait(target=es2015).js index 2b2cc3ce08d..a651bbbb92c 100644 --- a/tests/baselines/reference/emitter.forAwait.es2015.js +++ b/tests/baselines/reference/emitter.forAwait(target=es2015).js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/emitter/es2015/forAwait/emitter.forAwait.es2015.ts] //// +//// [tests/cases/conformance/statements/for-await-ofStatements/emitter.forAwait.ts] //// //// [file1.ts] async function f1() { @@ -40,6 +40,15 @@ async function* f6() { continue outer; } } +//// [file7.ts] +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { + let y: any; + for (;;) { + for await (const x of y) { + } + } +} //// [file1.js] var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -264,3 +273,44 @@ function f6() { } }); } +//// [file7.js] +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +}; +// https://github.com/microsoft/TypeScript/issues/36166 +function f7() { + return __asyncGenerator(this, arguments, function* f7_1() { + var e_1, _a; + let y; + for (;;) { + try { + for (var y_1 = (e_1 = void 0, __asyncValues(y)), y_1_1; y_1_1 = yield __await(y_1.next()), !y_1_1.done;) { + const x = y_1_1.value; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (y_1_1 && !y_1_1.done && (_a = y_1.return)) yield __await(_a.call(y_1)); + } + finally { if (e_1) throw e_1.error; } + } + } + }); +} diff --git a/tests/baselines/reference/emitter.forAwait.es2017.symbols b/tests/baselines/reference/emitter.forAwait(target=es2015).symbols similarity index 63% rename from tests/baselines/reference/emitter.forAwait.es2017.symbols rename to tests/baselines/reference/emitter.forAwait(target=es2015).symbols index 184d26c1266..f32170c889a 100644 --- a/tests/baselines/reference/emitter.forAwait.es2017.symbols +++ b/tests/baselines/reference/emitter.forAwait(target=es2015).symbols @@ -1,4 +1,4 @@ -=== tests/cases/conformance/emitter/es2017/forAwait/file1.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file1.ts === async function f1() { >f1 : Symbol(f1, Decl(file1.ts, 0, 0)) @@ -10,7 +10,7 @@ async function f1() { >y : Symbol(y, Decl(file1.ts, 1, 7)) } } -=== tests/cases/conformance/emitter/es2017/forAwait/file2.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file2.ts === async function f2() { >f2 : Symbol(f2, Decl(file2.ts, 0, 0)) @@ -23,7 +23,7 @@ async function f2() { >y : Symbol(y, Decl(file2.ts, 1, 15)) } } -=== tests/cases/conformance/emitter/es2017/forAwait/file3.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file3.ts === async function* f3() { >f3 : Symbol(f3, Decl(file3.ts, 0, 0)) @@ -35,7 +35,7 @@ async function* f3() { >y : Symbol(y, Decl(file3.ts, 1, 7)) } } -=== tests/cases/conformance/emitter/es2017/forAwait/file4.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file4.ts === async function* f4() { >f4 : Symbol(f4, Decl(file4.ts, 0, 0)) @@ -48,7 +48,7 @@ async function* f4() { >y : Symbol(y, Decl(file4.ts, 1, 15)) } } -=== tests/cases/conformance/emitter/es2017/forAwait/file5.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file5.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function f5() { >f5 : Symbol(f5, Decl(file5.ts, 0, 0)) @@ -63,7 +63,7 @@ async function f5() { continue outer; } } -=== tests/cases/conformance/emitter/es2017/forAwait/file6.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { >f6 : Symbol(f6, Decl(file6.ts, 0, 0)) @@ -78,3 +78,18 @@ async function* f6() { continue outer; } } +=== tests/cases/conformance/statements/for-await-ofStatements/file7.ts === +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { +>f7 : Symbol(f7, Decl(file7.ts, 0, 0)) + + let y: any; +>y : Symbol(y, Decl(file7.ts, 2, 7)) + + for (;;) { + for await (const x of y) { +>x : Symbol(x, Decl(file7.ts, 4, 24)) +>y : Symbol(y, Decl(file7.ts, 2, 7)) + } + } +} diff --git a/tests/baselines/reference/emitter.forAwait.es2018.types b/tests/baselines/reference/emitter.forAwait(target=es2015).types similarity index 56% rename from tests/baselines/reference/emitter.forAwait.es2018.types rename to tests/baselines/reference/emitter.forAwait(target=es2015).types index a9b3a94dead..406f669ab3a 100644 --- a/tests/baselines/reference/emitter.forAwait.es2018.types +++ b/tests/baselines/reference/emitter.forAwait(target=es2015).types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/emitter/es2018/forAwait/file1.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file1.ts === async function f1() { >f1 : () => Promise @@ -10,7 +10,7 @@ async function f1() { >y : any } } -=== tests/cases/conformance/emitter/es2018/forAwait/file2.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file2.ts === async function f2() { >f2 : () => Promise @@ -23,7 +23,7 @@ async function f2() { >y : any } } -=== tests/cases/conformance/emitter/es2018/forAwait/file3.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file3.ts === async function* f3() { >f3 : () => AsyncGenerator @@ -35,7 +35,7 @@ async function* f3() { >y : any } } -=== tests/cases/conformance/emitter/es2018/forAwait/file4.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file4.ts === async function* f4() { >f4 : () => AsyncGenerator @@ -48,7 +48,7 @@ async function* f4() { >y : any } } -=== tests/cases/conformance/emitter/es2018/forAwait/file5.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file5.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function f5() { >f5 : () => Promise @@ -65,7 +65,7 @@ async function f5() { >outer : any } } -=== tests/cases/conformance/emitter/es2018/forAwait/file6.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { >f6 : () => AsyncGenerator @@ -82,4 +82,18 @@ async function* f6() { >outer : any } } +=== tests/cases/conformance/statements/for-await-ofStatements/file7.ts === +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { +>f7 : () => AsyncGenerator + let y: any; +>y : any + + for (;;) { + for await (const x of y) { +>x : any +>y : any + } + } +} diff --git a/tests/baselines/reference/emitter.forAwait.es2017.js b/tests/baselines/reference/emitter.forAwait(target=es2017).js similarity index 79% rename from tests/baselines/reference/emitter.forAwait.es2017.js rename to tests/baselines/reference/emitter.forAwait(target=es2017).js index dd0e8aede2b..e7ab46bccc5 100644 --- a/tests/baselines/reference/emitter.forAwait.es2017.js +++ b/tests/baselines/reference/emitter.forAwait(target=es2017).js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/emitter/es2017/forAwait/emitter.forAwait.es2017.ts] //// +//// [tests/cases/conformance/statements/for-await-ofStatements/emitter.forAwait.ts] //// //// [file1.ts] async function f1() { @@ -40,6 +40,15 @@ async function* f6() { continue outer; } } +//// [file7.ts] +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { + let y: any; + for (;;) { + for await (const x of y) { + } + } +} //// [file1.js] var __asyncValues = (this && this.__asyncValues) || function (o) { @@ -231,3 +240,44 @@ function f6() { } }); } +//// [file7.js] +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +}; +// https://github.com/microsoft/TypeScript/issues/36166 +function f7() { + return __asyncGenerator(this, arguments, function* f7_1() { + var e_1, _a; + let y; + for (;;) { + try { + for (var y_1 = (e_1 = void 0, __asyncValues(y)), y_1_1; y_1_1 = yield __await(y_1.next()), !y_1_1.done;) { + const x = y_1_1.value; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (y_1_1 && !y_1_1.done && (_a = y_1.return)) yield __await(_a.call(y_1)); + } + finally { if (e_1) throw e_1.error; } + } + } + }); +} diff --git a/tests/baselines/reference/emitter.forAwait.es2015.symbols b/tests/baselines/reference/emitter.forAwait(target=es2017).symbols similarity index 63% rename from tests/baselines/reference/emitter.forAwait.es2015.symbols rename to tests/baselines/reference/emitter.forAwait(target=es2017).symbols index bc75908f601..f32170c889a 100644 --- a/tests/baselines/reference/emitter.forAwait.es2015.symbols +++ b/tests/baselines/reference/emitter.forAwait(target=es2017).symbols @@ -1,4 +1,4 @@ -=== tests/cases/conformance/emitter/es2015/forAwait/file1.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file1.ts === async function f1() { >f1 : Symbol(f1, Decl(file1.ts, 0, 0)) @@ -10,7 +10,7 @@ async function f1() { >y : Symbol(y, Decl(file1.ts, 1, 7)) } } -=== tests/cases/conformance/emitter/es2015/forAwait/file2.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file2.ts === async function f2() { >f2 : Symbol(f2, Decl(file2.ts, 0, 0)) @@ -23,7 +23,7 @@ async function f2() { >y : Symbol(y, Decl(file2.ts, 1, 15)) } } -=== tests/cases/conformance/emitter/es2015/forAwait/file3.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file3.ts === async function* f3() { >f3 : Symbol(f3, Decl(file3.ts, 0, 0)) @@ -35,7 +35,7 @@ async function* f3() { >y : Symbol(y, Decl(file3.ts, 1, 7)) } } -=== tests/cases/conformance/emitter/es2015/forAwait/file4.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file4.ts === async function* f4() { >f4 : Symbol(f4, Decl(file4.ts, 0, 0)) @@ -48,7 +48,7 @@ async function* f4() { >y : Symbol(y, Decl(file4.ts, 1, 15)) } } -=== tests/cases/conformance/emitter/es2015/forAwait/file5.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file5.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function f5() { >f5 : Symbol(f5, Decl(file5.ts, 0, 0)) @@ -63,7 +63,7 @@ async function f5() { continue outer; } } -=== tests/cases/conformance/emitter/es2015/forAwait/file6.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { >f6 : Symbol(f6, Decl(file6.ts, 0, 0)) @@ -78,3 +78,18 @@ async function* f6() { continue outer; } } +=== tests/cases/conformance/statements/for-await-ofStatements/file7.ts === +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { +>f7 : Symbol(f7, Decl(file7.ts, 0, 0)) + + let y: any; +>y : Symbol(y, Decl(file7.ts, 2, 7)) + + for (;;) { + for await (const x of y) { +>x : Symbol(x, Decl(file7.ts, 4, 24)) +>y : Symbol(y, Decl(file7.ts, 2, 7)) + } + } +} diff --git a/tests/baselines/reference/emitter.forAwait.es2015.types b/tests/baselines/reference/emitter.forAwait(target=es2017).types similarity index 56% rename from tests/baselines/reference/emitter.forAwait.es2015.types rename to tests/baselines/reference/emitter.forAwait(target=es2017).types index 3c345386c37..406f669ab3a 100644 --- a/tests/baselines/reference/emitter.forAwait.es2015.types +++ b/tests/baselines/reference/emitter.forAwait(target=es2017).types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/emitter/es2015/forAwait/file1.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file1.ts === async function f1() { >f1 : () => Promise @@ -10,7 +10,7 @@ async function f1() { >y : any } } -=== tests/cases/conformance/emitter/es2015/forAwait/file2.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file2.ts === async function f2() { >f2 : () => Promise @@ -23,7 +23,7 @@ async function f2() { >y : any } } -=== tests/cases/conformance/emitter/es2015/forAwait/file3.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file3.ts === async function* f3() { >f3 : () => AsyncGenerator @@ -35,7 +35,7 @@ async function* f3() { >y : any } } -=== tests/cases/conformance/emitter/es2015/forAwait/file4.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file4.ts === async function* f4() { >f4 : () => AsyncGenerator @@ -48,7 +48,7 @@ async function* f4() { >y : any } } -=== tests/cases/conformance/emitter/es2015/forAwait/file5.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file5.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function f5() { >f5 : () => Promise @@ -65,7 +65,7 @@ async function f5() { >outer : any } } -=== tests/cases/conformance/emitter/es2015/forAwait/file6.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { >f6 : () => AsyncGenerator @@ -82,3 +82,18 @@ async function* f6() { >outer : any } } +=== tests/cases/conformance/statements/for-await-ofStatements/file7.ts === +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { +>f7 : () => AsyncGenerator + + let y: any; +>y : any + + for (;;) { + for await (const x of y) { +>x : any +>y : any + } + } +} diff --git a/tests/baselines/reference/emitter.forAwait.es2018.js b/tests/baselines/reference/emitter.forAwait(target=es2018).js similarity index 73% rename from tests/baselines/reference/emitter.forAwait.es2018.js rename to tests/baselines/reference/emitter.forAwait(target=es2018).js index f9ae2b1bd95..f111d9d4bc1 100644 --- a/tests/baselines/reference/emitter.forAwait.es2018.js +++ b/tests/baselines/reference/emitter.forAwait(target=es2018).js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/emitter/es2018/forAwait/emitter.forAwait.es2018.ts] //// +//// [tests/cases/conformance/statements/for-await-ofStatements/emitter.forAwait.ts] //// //// [file1.ts] async function f1() { @@ -39,8 +39,16 @@ async function* f6() { outer: for await (const x of y) { continue outer; } -} - +} +//// [file7.ts] +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { + let y: any; + for (;;) { + for await (const x of y) { + } + } +} //// [file1.js] async function f1() { @@ -82,3 +90,12 @@ async function* f6() { continue outer; } } +//// [file7.js] +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { + let y; + for (;;) { + for await (const x of y) { + } + } +} diff --git a/tests/baselines/reference/emitter.forAwait.es2018.symbols b/tests/baselines/reference/emitter.forAwait(target=es2018).symbols similarity index 63% rename from tests/baselines/reference/emitter.forAwait.es2018.symbols rename to tests/baselines/reference/emitter.forAwait(target=es2018).symbols index c1beab7fb78..f32170c889a 100644 --- a/tests/baselines/reference/emitter.forAwait.es2018.symbols +++ b/tests/baselines/reference/emitter.forAwait(target=es2018).symbols @@ -1,4 +1,4 @@ -=== tests/cases/conformance/emitter/es2018/forAwait/file1.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file1.ts === async function f1() { >f1 : Symbol(f1, Decl(file1.ts, 0, 0)) @@ -10,7 +10,7 @@ async function f1() { >y : Symbol(y, Decl(file1.ts, 1, 7)) } } -=== tests/cases/conformance/emitter/es2018/forAwait/file2.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file2.ts === async function f2() { >f2 : Symbol(f2, Decl(file2.ts, 0, 0)) @@ -23,7 +23,7 @@ async function f2() { >y : Symbol(y, Decl(file2.ts, 1, 15)) } } -=== tests/cases/conformance/emitter/es2018/forAwait/file3.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file3.ts === async function* f3() { >f3 : Symbol(f3, Decl(file3.ts, 0, 0)) @@ -35,7 +35,7 @@ async function* f3() { >y : Symbol(y, Decl(file3.ts, 1, 7)) } } -=== tests/cases/conformance/emitter/es2018/forAwait/file4.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file4.ts === async function* f4() { >f4 : Symbol(f4, Decl(file4.ts, 0, 0)) @@ -48,7 +48,7 @@ async function* f4() { >y : Symbol(y, Decl(file4.ts, 1, 15)) } } -=== tests/cases/conformance/emitter/es2018/forAwait/file5.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file5.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function f5() { >f5 : Symbol(f5, Decl(file5.ts, 0, 0)) @@ -63,7 +63,7 @@ async function f5() { continue outer; } } -=== tests/cases/conformance/emitter/es2018/forAwait/file6.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { >f6 : Symbol(f6, Decl(file6.ts, 0, 0)) @@ -78,4 +78,18 @@ async function* f6() { continue outer; } } +=== tests/cases/conformance/statements/for-await-ofStatements/file7.ts === +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { +>f7 : Symbol(f7, Decl(file7.ts, 0, 0)) + let y: any; +>y : Symbol(y, Decl(file7.ts, 2, 7)) + + for (;;) { + for await (const x of y) { +>x : Symbol(x, Decl(file7.ts, 4, 24)) +>y : Symbol(y, Decl(file7.ts, 2, 7)) + } + } +} diff --git a/tests/baselines/reference/emitter.forAwait.es2017.types b/tests/baselines/reference/emitter.forAwait(target=es2018).types similarity index 56% rename from tests/baselines/reference/emitter.forAwait.es2017.types rename to tests/baselines/reference/emitter.forAwait(target=es2018).types index 19642ddd677..406f669ab3a 100644 --- a/tests/baselines/reference/emitter.forAwait.es2017.types +++ b/tests/baselines/reference/emitter.forAwait(target=es2018).types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/emitter/es2017/forAwait/file1.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file1.ts === async function f1() { >f1 : () => Promise @@ -10,7 +10,7 @@ async function f1() { >y : any } } -=== tests/cases/conformance/emitter/es2017/forAwait/file2.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file2.ts === async function f2() { >f2 : () => Promise @@ -23,7 +23,7 @@ async function f2() { >y : any } } -=== tests/cases/conformance/emitter/es2017/forAwait/file3.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file3.ts === async function* f3() { >f3 : () => AsyncGenerator @@ -35,7 +35,7 @@ async function* f3() { >y : any } } -=== tests/cases/conformance/emitter/es2017/forAwait/file4.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file4.ts === async function* f4() { >f4 : () => AsyncGenerator @@ -48,7 +48,7 @@ async function* f4() { >y : any } } -=== tests/cases/conformance/emitter/es2017/forAwait/file5.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file5.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function f5() { >f5 : () => Promise @@ -65,7 +65,7 @@ async function f5() { >outer : any } } -=== tests/cases/conformance/emitter/es2017/forAwait/file6.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { >f6 : () => AsyncGenerator @@ -82,3 +82,18 @@ async function* f6() { >outer : any } } +=== tests/cases/conformance/statements/for-await-ofStatements/file7.ts === +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { +>f7 : () => AsyncGenerator + + let y: any; +>y : any + + for (;;) { + for await (const x of y) { +>x : any +>y : any + } + } +} diff --git a/tests/baselines/reference/emitter.forAwait.es5.js b/tests/baselines/reference/emitter.forAwait(target=es5).js similarity index 83% rename from tests/baselines/reference/emitter.forAwait.es5.js rename to tests/baselines/reference/emitter.forAwait(target=es5).js index f33af25dcc1..5b182d16d5c 100644 --- a/tests/baselines/reference/emitter.forAwait.es5.js +++ b/tests/baselines/reference/emitter.forAwait(target=es5).js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/emitter/es5/forAwait/emitter.forAwait.es5.ts] //// +//// [tests/cases/conformance/statements/for-await-ofStatements/emitter.forAwait.ts] //// //// [file1.ts] async function f1() { @@ -40,6 +40,15 @@ async function* f6() { continue outer; } } +//// [file7.ts] +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { + let y: any; + for (;;) { + for await (const x of y) { + } + } +} //// [file1.js] var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -544,3 +553,90 @@ function f6() { }); }); } +//// [file7.js] +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +}; +// https://github.com/microsoft/TypeScript/issues/36166 +function f7() { + return __asyncGenerator(this, arguments, function f7_1() { + var y, y_1, y_1_1, x, e_1_1; + var e_1, _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _b.trys.push([0, 5, 6, 11]); + y_1 = (e_1 = void 0, __asyncValues(y)); + _b.label = 1; + case 1: return [4 /*yield*/, __await(y_1.next())]; + case 2: + if (!(y_1_1 = _b.sent(), !y_1_1.done)) return [3 /*break*/, 4]; + x = y_1_1.value; + _b.label = 3; + case 3: return [3 /*break*/, 1]; + case 4: return [3 /*break*/, 11]; + case 5: + e_1_1 = _b.sent(); + e_1 = { error: e_1_1 }; + return [3 /*break*/, 11]; + case 6: + _b.trys.push([6, , 9, 10]); + if (!(y_1_1 && !y_1_1.done && (_a = y_1.return))) return [3 /*break*/, 8]; + return [4 /*yield*/, __await(_a.call(y_1))]; + case 7: + _b.sent(); + _b.label = 8; + case 8: return [3 /*break*/, 10]; + case 9: + if (e_1) throw e_1.error; + return [7 /*endfinally*/]; + case 10: return [7 /*endfinally*/]; + case 11: return [3 /*break*/, 0]; + case 12: return [2 /*return*/]; + } + }); + }); +} diff --git a/tests/baselines/reference/emitter.forAwait.es5.symbols b/tests/baselines/reference/emitter.forAwait(target=es5).symbols similarity index 63% rename from tests/baselines/reference/emitter.forAwait.es5.symbols rename to tests/baselines/reference/emitter.forAwait(target=es5).symbols index 05fb915c0fc..f32170c889a 100644 --- a/tests/baselines/reference/emitter.forAwait.es5.symbols +++ b/tests/baselines/reference/emitter.forAwait(target=es5).symbols @@ -1,4 +1,4 @@ -=== tests/cases/conformance/emitter/es5/forAwait/file1.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file1.ts === async function f1() { >f1 : Symbol(f1, Decl(file1.ts, 0, 0)) @@ -10,7 +10,7 @@ async function f1() { >y : Symbol(y, Decl(file1.ts, 1, 7)) } } -=== tests/cases/conformance/emitter/es5/forAwait/file2.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file2.ts === async function f2() { >f2 : Symbol(f2, Decl(file2.ts, 0, 0)) @@ -23,7 +23,7 @@ async function f2() { >y : Symbol(y, Decl(file2.ts, 1, 15)) } } -=== tests/cases/conformance/emitter/es5/forAwait/file3.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file3.ts === async function* f3() { >f3 : Symbol(f3, Decl(file3.ts, 0, 0)) @@ -35,7 +35,7 @@ async function* f3() { >y : Symbol(y, Decl(file3.ts, 1, 7)) } } -=== tests/cases/conformance/emitter/es5/forAwait/file4.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file4.ts === async function* f4() { >f4 : Symbol(f4, Decl(file4.ts, 0, 0)) @@ -48,7 +48,7 @@ async function* f4() { >y : Symbol(y, Decl(file4.ts, 1, 15)) } } -=== tests/cases/conformance/emitter/es5/forAwait/file5.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file5.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function f5() { >f5 : Symbol(f5, Decl(file5.ts, 0, 0)) @@ -63,7 +63,7 @@ async function f5() { continue outer; } } -=== tests/cases/conformance/emitter/es5/forAwait/file6.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { >f6 : Symbol(f6, Decl(file6.ts, 0, 0)) @@ -78,3 +78,18 @@ async function* f6() { continue outer; } } +=== tests/cases/conformance/statements/for-await-ofStatements/file7.ts === +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { +>f7 : Symbol(f7, Decl(file7.ts, 0, 0)) + + let y: any; +>y : Symbol(y, Decl(file7.ts, 2, 7)) + + for (;;) { + for await (const x of y) { +>x : Symbol(x, Decl(file7.ts, 4, 24)) +>y : Symbol(y, Decl(file7.ts, 2, 7)) + } + } +} diff --git a/tests/baselines/reference/emitter.forAwait.es5.types b/tests/baselines/reference/emitter.forAwait(target=es5).types similarity index 56% rename from tests/baselines/reference/emitter.forAwait.es5.types rename to tests/baselines/reference/emitter.forAwait(target=es5).types index 1452be304b6..406f669ab3a 100644 --- a/tests/baselines/reference/emitter.forAwait.es5.types +++ b/tests/baselines/reference/emitter.forAwait(target=es5).types @@ -1,4 +1,4 @@ -=== tests/cases/conformance/emitter/es5/forAwait/file1.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file1.ts === async function f1() { >f1 : () => Promise @@ -10,7 +10,7 @@ async function f1() { >y : any } } -=== tests/cases/conformance/emitter/es5/forAwait/file2.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file2.ts === async function f2() { >f2 : () => Promise @@ -23,7 +23,7 @@ async function f2() { >y : any } } -=== tests/cases/conformance/emitter/es5/forAwait/file3.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file3.ts === async function* f3() { >f3 : () => AsyncGenerator @@ -35,7 +35,7 @@ async function* f3() { >y : any } } -=== tests/cases/conformance/emitter/es5/forAwait/file4.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file4.ts === async function* f4() { >f4 : () => AsyncGenerator @@ -48,7 +48,7 @@ async function* f4() { >y : any } } -=== tests/cases/conformance/emitter/es5/forAwait/file5.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file5.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function f5() { >f5 : () => Promise @@ -65,7 +65,7 @@ async function f5() { >outer : any } } -=== tests/cases/conformance/emitter/es5/forAwait/file6.ts === +=== tests/cases/conformance/statements/for-await-ofStatements/file6.ts === // https://github.com/Microsoft/TypeScript/issues/21363 async function* f6() { >f6 : () => AsyncGenerator @@ -82,3 +82,18 @@ async function* f6() { >outer : any } } +=== tests/cases/conformance/statements/for-await-ofStatements/file7.ts === +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { +>f7 : () => AsyncGenerator + + let y: any; +>y : any + + for (;;) { + for await (const x of y) { +>x : any +>y : any + } + } +} diff --git a/tests/cases/conformance/emitter/es2015/forAwait/emitter.forAwait.es2015.ts b/tests/cases/conformance/emitter/es2015/forAwait/emitter.forAwait.es2015.ts deleted file mode 100644 index 64b44e901e2..00000000000 --- a/tests/cases/conformance/emitter/es2015/forAwait/emitter.forAwait.es2015.ts +++ /dev/null @@ -1,42 +0,0 @@ -// @target: es2015 -// @lib: esnext -// @filename: file1.ts -async function f1() { - let y: any; - for await (const x of y) { - } -} -// @filename: file2.ts -async function f2() { - let x: any, y: any; - for await (x of y) { - } -} -// @filename: file3.ts -async function* f3() { - let y: any; - for await (const x of y) { - } -} -// @filename: file4.ts -async function* f4() { - let x: any, y: any; - for await (x of y) { - } -} -// @filename: file5.ts -// https://github.com/Microsoft/TypeScript/issues/21363 -async function f5() { - let y: any; - outer: for await (const x of y) { - continue outer; - } -} -// @filename: file6.ts -// https://github.com/Microsoft/TypeScript/issues/21363 -async function* f6() { - let y: any; - outer: for await (const x of y) { - continue outer; - } -} \ No newline at end of file diff --git a/tests/cases/conformance/emitter/es2017/forAwait/emitter.forAwait.es2017.ts b/tests/cases/conformance/emitter/es2017/forAwait/emitter.forAwait.es2017.ts deleted file mode 100644 index f9d9fc3d4d9..00000000000 --- a/tests/cases/conformance/emitter/es2017/forAwait/emitter.forAwait.es2017.ts +++ /dev/null @@ -1,42 +0,0 @@ -// @target: es2017 -// @lib: esnext -// @filename: file1.ts -async function f1() { - let y: any; - for await (const x of y) { - } -} -// @filename: file2.ts -async function f2() { - let x: any, y: any; - for await (x of y) { - } -} -// @filename: file3.ts -async function* f3() { - let y: any; - for await (const x of y) { - } -} -// @filename: file4.ts -async function* f4() { - let x: any, y: any; - for await (x of y) { - } -} -// @filename: file5.ts -// https://github.com/Microsoft/TypeScript/issues/21363 -async function f5() { - let y: any; - outer: for await (const x of y) { - continue outer; - } -} -// @filename: file6.ts -// https://github.com/Microsoft/TypeScript/issues/21363 -async function* f6() { - let y: any; - outer: for await (const x of y) { - continue outer; - } -} \ No newline at end of file diff --git a/tests/cases/conformance/emitter/es5/forAwait/emitter.forAwait.es5.ts b/tests/cases/conformance/emitter/es5/forAwait/emitter.forAwait.es5.ts deleted file mode 100644 index a441b0da2bd..00000000000 --- a/tests/cases/conformance/emitter/es5/forAwait/emitter.forAwait.es5.ts +++ /dev/null @@ -1,42 +0,0 @@ -// @target: es5 -// @lib: esnext -// @filename: file1.ts -async function f1() { - let y: any; - for await (const x of y) { - } -} -// @filename: file2.ts -async function f2() { - let x: any, y: any; - for await (x of y) { - } -} -// @filename: file3.ts -async function* f3() { - let y: any; - for await (const x of y) { - } -} -// @filename: file4.ts -async function* f4() { - let x: any, y: any; - for await (x of y) { - } -} -// @filename: file5.ts -// https://github.com/Microsoft/TypeScript/issues/21363 -async function f5() { - let y: any; - outer: for await (const x of y) { - continue outer; - } -} -// @filename: file6.ts -// https://github.com/Microsoft/TypeScript/issues/21363 -async function* f6() { - let y: any; - outer: for await (const x of y) { - continue outer; - } -} \ No newline at end of file diff --git a/tests/cases/conformance/emitter/es2018/forAwait/emitter.forAwait.es2018.ts b/tests/cases/conformance/statements/for-await-ofStatements/emitter.forAwait.ts similarity index 74% rename from tests/cases/conformance/emitter/es2018/forAwait/emitter.forAwait.es2018.ts rename to tests/cases/conformance/statements/for-await-ofStatements/emitter.forAwait.ts index 02e875fb7e4..f61bc343261 100644 --- a/tests/cases/conformance/emitter/es2018/forAwait/emitter.forAwait.es2018.ts +++ b/tests/cases/conformance/statements/for-await-ofStatements/emitter.forAwait.ts @@ -1,4 +1,4 @@ -// @target: es2018 +// @target: es2018,es2017,es2015,es5 // @lib: esnext // @filename: file1.ts async function f1() { @@ -40,3 +40,12 @@ async function* f6() { continue outer; } } +// @filename: file7.ts +// https://github.com/microsoft/TypeScript/issues/36166 +async function* f7() { + let y: any; + for (;;) { + for await (const x of y) { + } + } +} \ No newline at end of file From b0b677649af966efe0fd6ef0b67ef9d2dbf1ccf4 Mon Sep 17 00:00:00 2001 From: csigs Date: Fri, 24 Apr 2020 22:10:50 +0000 Subject: [PATCH 58/74] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 581fe36aa7f..d5e8c5cbdd1 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -10197,6 +10197,15 @@ + + + + + + + + + From 84c83da3a9cc2050997a7fd53d650d648fb128f3 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 24 Apr 2020 16:04:33 -0700 Subject: [PATCH 59/74] Revert #37106 (#38172) --- src/compiler/checker.ts | 2 +- tests/baselines/reference/inKeywordTypeguard.errors.txt | 5 ++++- tests/baselines/reference/inKeywordTypeguard.types | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f5754baff48..7cefe80e77e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20555,7 +20555,7 @@ namespace ts { } function narrowByInKeyword(type: Type, literal: LiteralExpression, assumeTrue: boolean) { - if (type.flags & (TypeFlags.Union | TypeFlags.Object | TypeFlags.Intersection) || isThisTypeParameter(type)) { + if (type.flags & (TypeFlags.Union | TypeFlags.Object) || isThisTypeParameter(type)) { const propName = escapeLeadingUnderscores(literal.text); return filterType(type, t => isTypePresencePossible(t, propName, assumeTrue)); } diff --git a/tests/baselines/reference/inKeywordTypeguard.errors.txt b/tests/baselines/reference/inKeywordTypeguard.errors.txt index f5885acfc88..5aa04b17042 100644 --- a/tests/baselines/reference/inKeywordTypeguard.errors.txt +++ b/tests/baselines/reference/inKeywordTypeguard.errors.txt @@ -19,9 +19,10 @@ tests/cases/compiler/inKeywordTypeguard.ts(74,32): error TS2339: Property 'a' do tests/cases/compiler/inKeywordTypeguard.ts(82,39): error TS2339: Property 'b' does not exist on type 'A'. tests/cases/compiler/inKeywordTypeguard.ts(84,39): error TS2339: Property 'a' does not exist on type 'B'. tests/cases/compiler/inKeywordTypeguard.ts(94,26): error TS2339: Property 'a' does not exist on type 'never'. +tests/cases/compiler/inKeywordTypeguard.ts(103,13): error TS2322: Type '{ a: string; } & { b: string; }' is not assignable to type 'never'. -==== tests/cases/compiler/inKeywordTypeguard.ts (17 errors) ==== +==== tests/cases/compiler/inKeywordTypeguard.ts (18 errors) ==== class A { a: string; } class B { b: string; } @@ -163,6 +164,8 @@ tests/cases/compiler/inKeywordTypeguard.ts(94,26): error TS2339: Property 'a' do let s: string = x.a; } else { let n: never = x; + ~ +!!! error TS2322: Type '{ a: string; } & { b: string; }' is not assignable to type 'never'. } } \ No newline at end of file diff --git a/tests/baselines/reference/inKeywordTypeguard.types b/tests/baselines/reference/inKeywordTypeguard.types index bd77a8da45e..b15ab47d454 100644 --- a/tests/baselines/reference/inKeywordTypeguard.types +++ b/tests/baselines/reference/inKeywordTypeguard.types @@ -318,7 +318,7 @@ function positiveIntersectionTest(x: { a: string } & { b: string }) { } else { let n: never = x; >n : never ->x : never +>x : { a: string; } & { b: string; } } } From 1b8c68d7463e22903978bcb4a8c7dc8e3f7b3beb Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 24 Apr 2020 16:05:18 -0700 Subject: [PATCH 60/74] Revert "Add check for delete expression must be optional (#37921)" (#38154) This reverts commit 39beb1d011a6bc412a67e1dfa2ec1cb1de438b4f. --- src/compiler/checker.ts | 15 +- src/compiler/diagnosticMessages.json | 4 - .../controlFlowDeleteOperator.errors.txt | 5 +- .../reference/deleteChain.errors.txt | 66 --------- ...ionMustBeOptional(strict=false).errors.txt | 46 ------ ...eExpressionMustBeOptional(strict=false).js | 57 -------- ...essionMustBeOptional(strict=false).symbols | 118 --------------- ...pressionMustBeOptional(strict=false).types | 137 ------------------ ...sionMustBeOptional(strict=true).errors.txt | 52 ------- ...teExpressionMustBeOptional(strict=true).js | 58 -------- ...ressionMustBeOptional(strict=true).symbols | 118 --------------- ...xpressionMustBeOptional(strict=true).types | 137 ------------------ .../reference/privateNamesNoDelete.errors.txt | 5 +- .../deleteExpressionMustBeOptional.ts | 42 ------ 14 files changed, 4 insertions(+), 856 deletions(-) delete mode 100644 tests/baselines/reference/deleteChain.errors.txt delete mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt delete mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js delete mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols delete mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types delete mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt delete mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js delete mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols delete mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types delete mode 100644 tests/cases/compiler/deleteExpressionMustBeOptional.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7cefe80e77e..0bf27e3f07b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -27682,23 +27682,12 @@ namespace ts { } const links = getNodeLinks(expr); const symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol) { - if (isReadonlySymbol(symbol)) { - error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); - } - - checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol)); + if (symbol && isReadonlySymbol(symbol)) { + error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); } return booleanType; } - function checkDeleteExpressionMustBeOptional(expr: AccessExpression, type: Type) { - const AnyOrUnknownOrNeverFlags = TypeFlags.AnyOrUnknown | TypeFlags.Never; - if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & TypeFlags.Undefined)) { - error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional); - } - } - function checkTypeOfExpression(node: TypeOfExpression): Type { checkExpression(node.expression); return typeofType; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 03f42608454..1df368c4286 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2963,10 +2963,6 @@ "category": "Error", "code": 2789 }, - "The operand of a 'delete' operator must be optional.": { - "category": "Error", - "code": 2790 - }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/controlFlowDeleteOperator.errors.txt b/tests/baselines/reference/controlFlowDeleteOperator.errors.txt index f5a6823a778..91ec2aa0de8 100644 --- a/tests/baselines/reference/controlFlowDeleteOperator.errors.txt +++ b/tests/baselines/reference/controlFlowDeleteOperator.errors.txt @@ -1,8 +1,7 @@ -tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(10,12): error TS2790: The operand of a 'delete' operator must be optional. tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error TS2703: The operand of a 'delete' operator must be a property reference. -==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (2 errors) ==== +==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (1 errors) ==== function f() { let x: { a?: number | string, b: number | string } = { b: 1 }; x.a; @@ -13,8 +12,6 @@ tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error T x.b; delete x.a; delete x.b; - ~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. x.a; x.b; x; diff --git a/tests/baselines/reference/deleteChain.errors.txt b/tests/baselines/reference/deleteChain.errors.txt deleted file mode 100644 index dd716419573..00000000000 --- a/tests/baselines/reference/deleteChain.errors.txt +++ /dev/null @@ -1,66 +0,0 @@ -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(2,8): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(3,9): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(6,8): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(7,9): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(10,8): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(11,9): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(14,8): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(15,8): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(16,9): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(19,8): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(20,9): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(23,8): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(24,9): error TS2790: The operand of a 'delete' operator must be optional. - - -==== tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts (13 errors) ==== - declare const o1: undefined | { b: string }; - delete o1?.b; - ~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - delete (o1?.b); - ~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - - declare const o2: undefined | { b: { c: string } }; - delete o2?.b.c; - ~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - delete (o2?.b.c); - ~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - - declare const o3: { b: undefined | { c: string } }; - delete o3.b?.c; - ~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - delete (o3.b?.c); - ~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - - declare const o4: { b?: { c: { d?: { e: string } } } }; - delete o4.b?.c.d?.e; - ~~~~~~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - delete (o4.b?.c.d)?.e; - ~~~~~~~~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - delete (o4.b?.c.d?.e); - ~~~~~~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - - declare const o5: { b?(): { c: { d?: { e: string } } } }; - delete o5.b?.().c.d?.e; - ~~~~~~~~~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - delete (o5.b?.().c.d?.e); - ~~~~~~~~~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - - declare const o6: { b?: { c: { d?: { e: string } } } }; - delete o6.b?.['c'].d?.['e']; - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - delete (o6.b?.['c'].d?.['e']); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. \ No newline at end of file diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt deleted file mode 100644 index 8a876cb6350..00000000000 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt +++ /dev/null @@ -1,46 +0,0 @@ -tests/cases/compiler/deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'. - - -==== tests/cases/compiler/deleteExpressionMustBeOptional.ts (1 errors) ==== - interface Foo { - a: number - b: number | undefined - c: number | null - d?: number - e: number | undefined | null - f?: number | undefined | null - g: unknown - h: any - i: never - } - - interface AA { - [s: string]: number - } - - type BB = { - [P in keyof any]: number - } - - declare const f: Foo - declare const a: AA - declare const b: BB - - delete f.a - delete f.b - delete f.c - delete f.d - delete f.e - delete f.f - delete f.g - delete f.h - delete f.i - delete f.j - ~ -!!! error TS2339: Property 'j' does not exist on type 'Foo'. - - delete a.a - delete a.b - - delete b.a - delete b.b \ No newline at end of file diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js deleted file mode 100644 index 268c76175bf..00000000000 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js +++ /dev/null @@ -1,57 +0,0 @@ -//// [deleteExpressionMustBeOptional.ts] -interface Foo { - a: number - b: number | undefined - c: number | null - d?: number - e: number | undefined | null - f?: number | undefined | null - g: unknown - h: any - i: never -} - -interface AA { - [s: string]: number -} - -type BB = { - [P in keyof any]: number -} - -declare const f: Foo -declare const a: AA -declare const b: BB - -delete f.a -delete f.b -delete f.c -delete f.d -delete f.e -delete f.f -delete f.g -delete f.h -delete f.i -delete f.j - -delete a.a -delete a.b - -delete b.a -delete b.b - -//// [deleteExpressionMustBeOptional.js] -delete f.a; -delete f.b; -delete f.c; -delete f.d; -delete f.e; -delete f.f; -delete f.g; -delete f.h; -delete f.i; -delete f.j; -delete a.a; -delete a.b; -delete b.a; -delete b.b; diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols deleted file mode 100644 index aad7423a133..00000000000 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols +++ /dev/null @@ -1,118 +0,0 @@ -=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === -interface Foo { ->Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) - - a: number ->a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) - - b: number | undefined ->b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) - - c: number | null ->c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) - - d?: number ->d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) - - e: number | undefined | null ->e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) - - f?: number | undefined | null ->f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) - - g: unknown ->g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) - - h: any ->h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) - - i: never ->i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) -} - -interface AA { ->AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) - - [s: string]: number ->s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5)) -} - -type BB = { ->BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) - - [P in keyof any]: number ->P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5)) -} - -declare const f: Foo ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) - -declare const a: AA ->a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) ->AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) - -declare const b: BB ->b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) ->BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) - -delete f.a ->f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) - -delete f.b ->f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) - -delete f.c ->f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) - -delete f.d ->f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) - -delete f.e ->f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) - -delete f.f ->f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) - -delete f.g ->f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) - -delete f.h ->f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) - -delete f.i ->f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) - -delete f.j ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) - -delete a.a ->a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) - -delete a.b ->a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) - -delete b.a ->b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) - -delete b.b ->b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) - diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types deleted file mode 100644 index 371bb25e96d..00000000000 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types +++ /dev/null @@ -1,137 +0,0 @@ -=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === -interface Foo { - a: number ->a : number - - b: number | undefined ->b : number - - c: number | null ->c : number ->null : null - - d?: number ->d : number - - e: number | undefined | null ->e : number ->null : null - - f?: number | undefined | null ->f : number ->null : null - - g: unknown ->g : unknown - - h: any ->h : any - - i: never ->i : never -} - -interface AA { - [s: string]: number ->s : string -} - -type BB = { ->BB : BB - - [P in keyof any]: number -} - -declare const f: Foo ->f : Foo - -declare const a: AA ->a : AA - -declare const b: BB ->b : BB - -delete f.a ->delete f.a : boolean ->f.a : number ->f : Foo ->a : number - -delete f.b ->delete f.b : boolean ->f.b : number ->f : Foo ->b : number - -delete f.c ->delete f.c : boolean ->f.c : number ->f : Foo ->c : number - -delete f.d ->delete f.d : boolean ->f.d : number ->f : Foo ->d : number - -delete f.e ->delete f.e : boolean ->f.e : number ->f : Foo ->e : number - -delete f.f ->delete f.f : boolean ->f.f : number ->f : Foo ->f : number - -delete f.g ->delete f.g : boolean ->f.g : unknown ->f : Foo ->g : unknown - -delete f.h ->delete f.h : boolean ->f.h : any ->f : Foo ->h : any - -delete f.i ->delete f.i : boolean ->f.i : never ->f : Foo ->i : never - -delete f.j ->delete f.j : boolean ->f.j : any ->f : Foo ->j : any - -delete a.a ->delete a.a : boolean ->a.a : number ->a : AA ->a : number - -delete a.b ->delete a.b : boolean ->a.b : number ->a : AA ->b : number - -delete b.a ->delete b.a : boolean ->b.a : number ->b : BB ->a : number - -delete b.b ->delete b.b : boolean ->b.b : number ->b : BB ->b : number - diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt deleted file mode 100644 index b1cabc96009..00000000000 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt +++ /dev/null @@ -1,52 +0,0 @@ -tests/cases/compiler/deleteExpressionMustBeOptional.ts(25,8): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/compiler/deleteExpressionMustBeOptional.ts(27,8): error TS2790: The operand of a 'delete' operator must be optional. -tests/cases/compiler/deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'. - - -==== tests/cases/compiler/deleteExpressionMustBeOptional.ts (3 errors) ==== - interface Foo { - a: number - b: number | undefined - c: number | null - d?: number - e: number | undefined | null - f?: number | undefined | null - g: unknown - h: any - i: never - } - - interface AA { - [s: string]: number - } - - type BB = { - [P in keyof any]: number - } - - declare const f: Foo - declare const a: AA - declare const b: BB - - delete f.a - ~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - delete f.b - delete f.c - ~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - delete f.d - delete f.e - delete f.f - delete f.g - delete f.h - delete f.i - delete f.j - ~ -!!! error TS2339: Property 'j' does not exist on type 'Foo'. - - delete a.a - delete a.b - - delete b.a - delete b.b \ No newline at end of file diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js deleted file mode 100644 index ca81456b4f4..00000000000 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js +++ /dev/null @@ -1,58 +0,0 @@ -//// [deleteExpressionMustBeOptional.ts] -interface Foo { - a: number - b: number | undefined - c: number | null - d?: number - e: number | undefined | null - f?: number | undefined | null - g: unknown - h: any - i: never -} - -interface AA { - [s: string]: number -} - -type BB = { - [P in keyof any]: number -} - -declare const f: Foo -declare const a: AA -declare const b: BB - -delete f.a -delete f.b -delete f.c -delete f.d -delete f.e -delete f.f -delete f.g -delete f.h -delete f.i -delete f.j - -delete a.a -delete a.b - -delete b.a -delete b.b - -//// [deleteExpressionMustBeOptional.js] -"use strict"; -delete f.a; -delete f.b; -delete f.c; -delete f.d; -delete f.e; -delete f.f; -delete f.g; -delete f.h; -delete f.i; -delete f.j; -delete a.a; -delete a.b; -delete b.a; -delete b.b; diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols deleted file mode 100644 index aad7423a133..00000000000 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols +++ /dev/null @@ -1,118 +0,0 @@ -=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === -interface Foo { ->Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) - - a: number ->a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) - - b: number | undefined ->b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) - - c: number | null ->c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) - - d?: number ->d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) - - e: number | undefined | null ->e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) - - f?: number | undefined | null ->f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) - - g: unknown ->g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) - - h: any ->h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) - - i: never ->i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) -} - -interface AA { ->AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) - - [s: string]: number ->s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5)) -} - -type BB = { ->BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) - - [P in keyof any]: number ->P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5)) -} - -declare const f: Foo ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) - -declare const a: AA ->a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) ->AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) - -declare const b: BB ->b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) ->BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) - -delete f.a ->f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) - -delete f.b ->f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) - -delete f.c ->f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) - -delete f.d ->f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) - -delete f.e ->f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) - -delete f.f ->f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) - -delete f.g ->f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) - -delete f.h ->f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) - -delete f.i ->f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) ->i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) - -delete f.j ->f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) - -delete a.a ->a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) - -delete a.b ->a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) - -delete b.a ->b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) - -delete b.b ->b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) - diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types deleted file mode 100644 index a3d6f52b7c4..00000000000 --- a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types +++ /dev/null @@ -1,137 +0,0 @@ -=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === -interface Foo { - a: number ->a : number - - b: number | undefined ->b : number | undefined - - c: number | null ->c : number | null ->null : null - - d?: number ->d : number | undefined - - e: number | undefined | null ->e : number | null | undefined ->null : null - - f?: number | undefined | null ->f : number | null | undefined ->null : null - - g: unknown ->g : unknown - - h: any ->h : any - - i: never ->i : never -} - -interface AA { - [s: string]: number ->s : string -} - -type BB = { ->BB : BB - - [P in keyof any]: number -} - -declare const f: Foo ->f : Foo - -declare const a: AA ->a : AA - -declare const b: BB ->b : BB - -delete f.a ->delete f.a : boolean ->f.a : number ->f : Foo ->a : number - -delete f.b ->delete f.b : boolean ->f.b : number | undefined ->f : Foo ->b : number | undefined - -delete f.c ->delete f.c : boolean ->f.c : number | null ->f : Foo ->c : number | null - -delete f.d ->delete f.d : boolean ->f.d : number | undefined ->f : Foo ->d : number | undefined - -delete f.e ->delete f.e : boolean ->f.e : number | null | undefined ->f : Foo ->e : number | null | undefined - -delete f.f ->delete f.f : boolean ->f.f : number | null | undefined ->f : Foo ->f : number | null | undefined - -delete f.g ->delete f.g : boolean ->f.g : unknown ->f : Foo ->g : unknown - -delete f.h ->delete f.h : boolean ->f.h : any ->f : Foo ->h : any - -delete f.i ->delete f.i : boolean ->f.i : never ->f : Foo ->i : never - -delete f.j ->delete f.j : boolean ->f.j : any ->f : Foo ->j : any - -delete a.a ->delete a.a : boolean ->a.a : number ->a : AA ->a : number - -delete a.b ->delete a.b : boolean ->a.b : number ->a : AA ->b : number - -delete b.a ->delete b.a : boolean ->b.a : number ->b : BB ->a : number - -delete b.b ->delete b.b : boolean ->b.b : number ->b : BB ->b : number - diff --git a/tests/baselines/reference/privateNamesNoDelete.errors.txt b/tests/baselines/reference/privateNamesNoDelete.errors.txt index e2fc11cb4ac..d593fe107a1 100644 --- a/tests/baselines/reference/privateNamesNoDelete.errors.txt +++ b/tests/baselines/reference/privateNamesNoDelete.errors.txt @@ -1,15 +1,12 @@ -tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts(4,16): error TS2790: The operand of a 'delete' operator must be optional. tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts(4,16): error TS18011: The operand of a 'delete' operator cannot be a private identifier. -==== tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts (2 errors) ==== +==== tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts (1 errors) ==== class A { #v = 1; constructor() { delete this.#v; // Error: The operand of a delete operator cannot be a private name. ~~~~~~~ -!!! error TS2790: The operand of a 'delete' operator must be optional. - ~~~~~~~ !!! error TS18011: The operand of a 'delete' operator cannot be a private identifier. } } diff --git a/tests/cases/compiler/deleteExpressionMustBeOptional.ts b/tests/cases/compiler/deleteExpressionMustBeOptional.ts deleted file mode 100644 index 9f84d9ea2f1..00000000000 --- a/tests/cases/compiler/deleteExpressionMustBeOptional.ts +++ /dev/null @@ -1,42 +0,0 @@ -// @strict: true, false - -interface Foo { - a: number - b: number | undefined - c: number | null - d?: number - e: number | undefined | null - f?: number | undefined | null - g: unknown - h: any - i: never -} - -interface AA { - [s: string]: number -} - -type BB = { - [P in keyof any]: number -} - -declare const f: Foo -declare const a: AA -declare const b: BB - -delete f.a -delete f.b -delete f.c -delete f.d -delete f.e -delete f.f -delete f.g -delete f.h -delete f.i -delete f.j - -delete a.a -delete a.b - -delete b.a -delete b.b \ No newline at end of file From 4a5eeb0bb21bbcc795bf8edb7d391bb3694c295a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 24 Apr 2020 18:33:30 -0700 Subject: [PATCH 61/74] Skip comparing optional property flag when comparing against discriminant properties (#38101) --- src/compiler/checker.ts | 8 ++++---- .../reference/unionRelationshipCheckPasses.js | 7 +++++++ .../reference/unionRelationshipCheckPasses.symbols | 7 +++++++ .../reference/unionRelationshipCheckPasses.types | 10 ++++++++++ tests/cases/compiler/unionRelationshipCheckPasses.ts | 2 ++ 5 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/unionRelationshipCheckPasses.js create mode 100644 tests/baselines/reference/unionRelationshipCheckPasses.symbols create mode 100644 tests/baselines/reference/unionRelationshipCheckPasses.types create mode 100644 tests/cases/compiler/unionRelationshipCheckPasses.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0bf27e3f07b..25e25e43757 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -16639,7 +16639,7 @@ namespace ts { if (!targetProperty) continue outer; if (sourceProperty === targetProperty) continue; // We compare the source property to the target in the context of a single discriminant type. - const related = propertyRelatedTo(source, target, sourceProperty, targetProperty, _ => combination[i], /*reportErrors*/ false, IntersectionState.None); + const related = propertyRelatedTo(source, target, sourceProperty, targetProperty, _ => combination[i], /*reportErrors*/ false, IntersectionState.None, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -16737,7 +16737,7 @@ namespace ts { } } - function propertyRelatedTo(source: Type, target: Type, sourceProp: Symbol, targetProp: Symbol, getTypeOfSourceProperty: (sym: Symbol) => Type, reportErrors: boolean, intersectionState: IntersectionState): Ternary { + function propertyRelatedTo(source: Type, target: Type, sourceProp: Symbol, targetProp: Symbol, getTypeOfSourceProperty: (sym: Symbol) => Type, reportErrors: boolean, intersectionState: IntersectionState, skipOptional: boolean): Ternary { const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & ModifierFlags.Private || targetPropFlags & ModifierFlags.Private) { @@ -16780,7 +16780,7 @@ namespace ts { return Ternary.False; } // When checking for comparability, be more lenient with optional properties. - if (relation !== comparableRelation && sourceProp.flags & SymbolFlags.Optional && !(targetProp.flags & SymbolFlags.Optional)) { + if (!skipOptional && sourceProp.flags & SymbolFlags.Optional && !(targetProp.flags & SymbolFlags.Optional)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -16910,7 +16910,7 @@ namespace ts { if (!(targetProp.flags & SymbolFlags.Prototype) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { const sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - const related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState); + const related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { return Ternary.False; } diff --git a/tests/baselines/reference/unionRelationshipCheckPasses.js b/tests/baselines/reference/unionRelationshipCheckPasses.js new file mode 100644 index 00000000000..65e90ed34e8 --- /dev/null +++ b/tests/baselines/reference/unionRelationshipCheckPasses.js @@ -0,0 +1,7 @@ +//// [unionRelationshipCheckPasses.ts] +const item: { foo?: undefined } | { foo: number } = null as any as { foo?: number | undefined }; + + +//// [unionRelationshipCheckPasses.js] +"use strict"; +var item = null; diff --git a/tests/baselines/reference/unionRelationshipCheckPasses.symbols b/tests/baselines/reference/unionRelationshipCheckPasses.symbols new file mode 100644 index 00000000000..3fda4578bdb --- /dev/null +++ b/tests/baselines/reference/unionRelationshipCheckPasses.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/unionRelationshipCheckPasses.ts === +const item: { foo?: undefined } | { foo: number } = null as any as { foo?: number | undefined }; +>item : Symbol(item, Decl(unionRelationshipCheckPasses.ts, 0, 5)) +>foo : Symbol(foo, Decl(unionRelationshipCheckPasses.ts, 0, 13)) +>foo : Symbol(foo, Decl(unionRelationshipCheckPasses.ts, 0, 35)) +>foo : Symbol(foo, Decl(unionRelationshipCheckPasses.ts, 0, 68)) + diff --git a/tests/baselines/reference/unionRelationshipCheckPasses.types b/tests/baselines/reference/unionRelationshipCheckPasses.types new file mode 100644 index 00000000000..e0e582916bb --- /dev/null +++ b/tests/baselines/reference/unionRelationshipCheckPasses.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/unionRelationshipCheckPasses.ts === +const item: { foo?: undefined } | { foo: number } = null as any as { foo?: number | undefined }; +>item : { foo?: undefined; } | { foo: number; } +>foo : undefined +>foo : number +>null as any as { foo?: number | undefined } : { foo?: number | undefined; } +>null as any : any +>null : null +>foo : number | undefined + diff --git a/tests/cases/compiler/unionRelationshipCheckPasses.ts b/tests/cases/compiler/unionRelationshipCheckPasses.ts new file mode 100644 index 00000000000..cec4cffbf08 --- /dev/null +++ b/tests/cases/compiler/unionRelationshipCheckPasses.ts @@ -0,0 +1,2 @@ +// @strict: true +const item: { foo?: undefined } | { foo: number } = null as any as { foo?: number | undefined }; From 730bec81d1a6f903c4ee6c020e23a411230ac855 Mon Sep 17 00:00:00 2001 From: csigs Date: Sat, 25 Apr 2020 04:11:05 +0000 Subject: [PATCH 62/74] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 19 ++++++++++++++----- .../diagnosticMessages.generated.json.lcl | 9 +++++++++ .../diagnosticMessages.generated.json.lcl | 17 +++++++++++++---- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 9202ae5f4c0..a9eebf3b5b4 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3202,7 +3202,7 @@ - + @@ -5650,7 +5650,7 @@ - + @@ -10206,6 +10206,15 @@ + + + + + + + + + @@ -10330,7 +10339,7 @@ - + @@ -11125,7 +11134,7 @@ - + @@ -11686,7 +11695,7 @@ - + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 81b11ca7e68..439b7e2aff7 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -10209,6 +10209,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index ee5f3358f1b..89a10086f4c 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3186,7 +3186,7 @@ - + @@ -7821,7 +7821,7 @@ - + @@ -10187,6 +10187,15 @@ + + + + + + + + + @@ -11106,7 +11115,7 @@ - + @@ -11667,7 +11676,7 @@ - + From 6a6c83cf9acec4a7932675dfed9181dea0ca0afe Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 27 Apr 2020 13:23:45 -0700 Subject: [PATCH 63/74] Revert "Revert "Add check for delete expression must be optional (#37921)" (#38154)" (#38173) This reverts commit 1b8c68d7463e22903978bcb4a8c7dc8e3f7b3beb. --- src/compiler/checker.ts | 15 +- src/compiler/diagnosticMessages.json | 4 + .../controlFlowDeleteOperator.errors.txt | 5 +- .../reference/deleteChain.errors.txt | 66 +++++++++ ...ionMustBeOptional(strict=false).errors.txt | 46 ++++++ ...eExpressionMustBeOptional(strict=false).js | 57 ++++++++ ...essionMustBeOptional(strict=false).symbols | 118 +++++++++++++++ ...pressionMustBeOptional(strict=false).types | 137 ++++++++++++++++++ ...sionMustBeOptional(strict=true).errors.txt | 52 +++++++ ...teExpressionMustBeOptional(strict=true).js | 58 ++++++++ ...ressionMustBeOptional(strict=true).symbols | 118 +++++++++++++++ ...xpressionMustBeOptional(strict=true).types | 137 ++++++++++++++++++ .../reference/privateNamesNoDelete.errors.txt | 5 +- .../deleteExpressionMustBeOptional.ts | 42 ++++++ 14 files changed, 856 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/deleteChain.errors.txt create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols create mode 100644 tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types create mode 100644 tests/cases/compiler/deleteExpressionMustBeOptional.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 25e25e43757..93276c42cb3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -27682,12 +27682,23 @@ namespace ts { } const links = getNodeLinks(expr); const symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol && isReadonlySymbol(symbol)) { - error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + if (symbol) { + if (isReadonlySymbol(symbol)) { + error(expr, Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } + + checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol)); } return booleanType; } + function checkDeleteExpressionMustBeOptional(expr: AccessExpression, type: Type) { + const AnyOrUnknownOrNeverFlags = TypeFlags.AnyOrUnknown | TypeFlags.Never; + if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & TypeFlags.Undefined)) { + error(expr, Diagnostics.The_operand_of_a_delete_operator_must_be_optional); + } + } + function checkTypeOfExpression(node: TypeOfExpression): Type { checkExpression(node.expression); return typeofType; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 1df368c4286..03f42608454 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2963,6 +2963,10 @@ "category": "Error", "code": 2789 }, + "The operand of a 'delete' operator must be optional.": { + "category": "Error", + "code": 2790 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/controlFlowDeleteOperator.errors.txt b/tests/baselines/reference/controlFlowDeleteOperator.errors.txt index 91ec2aa0de8..f5a6823a778 100644 --- a/tests/baselines/reference/controlFlowDeleteOperator.errors.txt +++ b/tests/baselines/reference/controlFlowDeleteOperator.errors.txt @@ -1,7 +1,8 @@ +tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(10,12): error TS2790: The operand of a 'delete' operator must be optional. tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error TS2703: The operand of a 'delete' operator must be a property reference. -==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (1 errors) ==== +==== tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts (2 errors) ==== function f() { let x: { a?: number | string, b: number | string } = { b: 1 }; x.a; @@ -12,6 +13,8 @@ tests/cases/conformance/controlFlow/controlFlowDeleteOperator.ts(14,12): error T x.b; delete x.a; delete x.b; + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. x.a; x.b; x; diff --git a/tests/baselines/reference/deleteChain.errors.txt b/tests/baselines/reference/deleteChain.errors.txt new file mode 100644 index 00000000000..dd716419573 --- /dev/null +++ b/tests/baselines/reference/deleteChain.errors.txt @@ -0,0 +1,66 @@ +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(2,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(3,9): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(6,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(7,9): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(10,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(11,9): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(14,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(15,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(16,9): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(19,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(20,9): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(23,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts(24,9): error TS2790: The operand of a 'delete' operator must be optional. + + +==== tests/cases/conformance/expressions/optionalChaining/delete/deleteChain.ts (13 errors) ==== + declare const o1: undefined | { b: string }; + delete o1?.b; + ~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o1?.b); + ~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + + declare const o2: undefined | { b: { c: string } }; + delete o2?.b.c; + ~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o2?.b.c); + ~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + + declare const o3: { b: undefined | { c: string } }; + delete o3.b?.c; + ~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o3.b?.c); + ~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + + declare const o4: { b?: { c: { d?: { e: string } } } }; + delete o4.b?.c.d?.e; + ~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o4.b?.c.d)?.e; + ~~~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o4.b?.c.d?.e); + ~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + + declare const o5: { b?(): { c: { d?: { e: string } } } }; + delete o5.b?.().c.d?.e; + ~~~~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o5.b?.().c.d?.e); + ~~~~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + + declare const o6: { b?: { c: { d?: { e: string } } } }; + delete o6.b?.['c'].d?.['e']; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete (o6.b?.['c'].d?.['e']); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. \ No newline at end of file diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt new file mode 100644 index 00000000000..8a876cb6350 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).errors.txt @@ -0,0 +1,46 @@ +tests/cases/compiler/deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'. + + +==== tests/cases/compiler/deleteExpressionMustBeOptional.ts (1 errors) ==== + interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never + } + + interface AA { + [s: string]: number + } + + type BB = { + [P in keyof any]: number + } + + declare const f: Foo + declare const a: AA + declare const b: BB + + delete f.a + delete f.b + delete f.c + delete f.d + delete f.e + delete f.f + delete f.g + delete f.h + delete f.i + delete f.j + ~ +!!! error TS2339: Property 'j' does not exist on type 'Foo'. + + delete a.a + delete a.b + + delete b.a + delete b.b \ No newline at end of file diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js new file mode 100644 index 00000000000..268c76175bf --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).js @@ -0,0 +1,57 @@ +//// [deleteExpressionMustBeOptional.ts] +interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never +} + +interface AA { + [s: string]: number +} + +type BB = { + [P in keyof any]: number +} + +declare const f: Foo +declare const a: AA +declare const b: BB + +delete f.a +delete f.b +delete f.c +delete f.d +delete f.e +delete f.f +delete f.g +delete f.h +delete f.i +delete f.j + +delete a.a +delete a.b + +delete b.a +delete b.b + +//// [deleteExpressionMustBeOptional.js] +delete f.a; +delete f.b; +delete f.c; +delete f.d; +delete f.e; +delete f.f; +delete f.g; +delete f.h; +delete f.i; +delete f.j; +delete a.a; +delete a.b; +delete b.a; +delete b.b; diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols new file mode 100644 index 00000000000..aad7423a133 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).symbols @@ -0,0 +1,118 @@ +=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + + a: number +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + + b: number | undefined +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + + c: number | null +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + + d?: number +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + + e: number | undefined | null +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + + f?: number | undefined | null +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + + g: unknown +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + + h: any +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + + i: never +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +} + +interface AA { +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + + [s: string]: number +>s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5)) +} + +type BB = { +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + + [P in keyof any]: number +>P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5)) +} + +declare const f: Foo +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + +declare const a: AA +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + +declare const b: BB +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + +delete f.a +>f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + +delete f.b +>f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + +delete f.c +>f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + +delete f.d +>f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + +delete f.e +>f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + +delete f.f +>f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + +delete f.g +>f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + +delete f.h +>f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + +delete f.i +>f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) + +delete f.j +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) + +delete a.a +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) + +delete a.b +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) + +delete b.a +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + +delete b.b +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types new file mode 100644 index 00000000000..371bb25e96d --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=false).types @@ -0,0 +1,137 @@ +=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === +interface Foo { + a: number +>a : number + + b: number | undefined +>b : number + + c: number | null +>c : number +>null : null + + d?: number +>d : number + + e: number | undefined | null +>e : number +>null : null + + f?: number | undefined | null +>f : number +>null : null + + g: unknown +>g : unknown + + h: any +>h : any + + i: never +>i : never +} + +interface AA { + [s: string]: number +>s : string +} + +type BB = { +>BB : BB + + [P in keyof any]: number +} + +declare const f: Foo +>f : Foo + +declare const a: AA +>a : AA + +declare const b: BB +>b : BB + +delete f.a +>delete f.a : boolean +>f.a : number +>f : Foo +>a : number + +delete f.b +>delete f.b : boolean +>f.b : number +>f : Foo +>b : number + +delete f.c +>delete f.c : boolean +>f.c : number +>f : Foo +>c : number + +delete f.d +>delete f.d : boolean +>f.d : number +>f : Foo +>d : number + +delete f.e +>delete f.e : boolean +>f.e : number +>f : Foo +>e : number + +delete f.f +>delete f.f : boolean +>f.f : number +>f : Foo +>f : number + +delete f.g +>delete f.g : boolean +>f.g : unknown +>f : Foo +>g : unknown + +delete f.h +>delete f.h : boolean +>f.h : any +>f : Foo +>h : any + +delete f.i +>delete f.i : boolean +>f.i : never +>f : Foo +>i : never + +delete f.j +>delete f.j : boolean +>f.j : any +>f : Foo +>j : any + +delete a.a +>delete a.a : boolean +>a.a : number +>a : AA +>a : number + +delete a.b +>delete a.b : boolean +>a.b : number +>a : AA +>b : number + +delete b.a +>delete b.a : boolean +>b.a : number +>b : BB +>a : number + +delete b.b +>delete b.b : boolean +>b.b : number +>b : BB +>b : number + diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt new file mode 100644 index 00000000000..b1cabc96009 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).errors.txt @@ -0,0 +1,52 @@ +tests/cases/compiler/deleteExpressionMustBeOptional.ts(25,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/compiler/deleteExpressionMustBeOptional.ts(27,8): error TS2790: The operand of a 'delete' operator must be optional. +tests/cases/compiler/deleteExpressionMustBeOptional.ts(34,10): error TS2339: Property 'j' does not exist on type 'Foo'. + + +==== tests/cases/compiler/deleteExpressionMustBeOptional.ts (3 errors) ==== + interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never + } + + interface AA { + [s: string]: number + } + + type BB = { + [P in keyof any]: number + } + + declare const f: Foo + declare const a: AA + declare const b: BB + + delete f.a + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete f.b + delete f.c + ~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + delete f.d + delete f.e + delete f.f + delete f.g + delete f.h + delete f.i + delete f.j + ~ +!!! error TS2339: Property 'j' does not exist on type 'Foo'. + + delete a.a + delete a.b + + delete b.a + delete b.b \ No newline at end of file diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js new file mode 100644 index 00000000000..ca81456b4f4 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).js @@ -0,0 +1,58 @@ +//// [deleteExpressionMustBeOptional.ts] +interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never +} + +interface AA { + [s: string]: number +} + +type BB = { + [P in keyof any]: number +} + +declare const f: Foo +declare const a: AA +declare const b: BB + +delete f.a +delete f.b +delete f.c +delete f.d +delete f.e +delete f.f +delete f.g +delete f.h +delete f.i +delete f.j + +delete a.a +delete a.b + +delete b.a +delete b.b + +//// [deleteExpressionMustBeOptional.js] +"use strict"; +delete f.a; +delete f.b; +delete f.c; +delete f.d; +delete f.e; +delete f.f; +delete f.g; +delete f.h; +delete f.i; +delete f.j; +delete a.a; +delete a.b; +delete b.a; +delete b.b; diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols new file mode 100644 index 00000000000..aad7423a133 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).symbols @@ -0,0 +1,118 @@ +=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + + a: number +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + + b: number | undefined +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + + c: number | null +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + + d?: number +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + + e: number | undefined | null +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + + f?: number | undefined | null +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + + g: unknown +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + + h: any +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + + i: never +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +} + +interface AA { +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + + [s: string]: number +>s : Symbol(s, Decl(deleteExpressionMustBeOptional.ts, 13, 5)) +} + +type BB = { +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + + [P in keyof any]: number +>P : Symbol(P, Decl(deleteExpressionMustBeOptional.ts, 17, 5)) +} + +declare const f: Foo +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>Foo : Symbol(Foo, Decl(deleteExpressionMustBeOptional.ts, 0, 0)) + +declare const a: AA +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) +>AA : Symbol(AA, Decl(deleteExpressionMustBeOptional.ts, 10, 1)) + +declare const b: BB +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) +>BB : Symbol(BB, Decl(deleteExpressionMustBeOptional.ts, 14, 1)) + +delete f.a +>f.a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>a : Symbol(Foo.a, Decl(deleteExpressionMustBeOptional.ts, 0, 15)) + +delete f.b +>f.b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>b : Symbol(Foo.b, Decl(deleteExpressionMustBeOptional.ts, 1, 13)) + +delete f.c +>f.c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>c : Symbol(Foo.c, Decl(deleteExpressionMustBeOptional.ts, 2, 25)) + +delete f.d +>f.d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>d : Symbol(Foo.d, Decl(deleteExpressionMustBeOptional.ts, 3, 20)) + +delete f.e +>f.e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>e : Symbol(Foo.e, Decl(deleteExpressionMustBeOptional.ts, 4, 14)) + +delete f.f +>f.f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>f : Symbol(Foo.f, Decl(deleteExpressionMustBeOptional.ts, 5, 32)) + +delete f.g +>f.g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>g : Symbol(Foo.g, Decl(deleteExpressionMustBeOptional.ts, 6, 33)) + +delete f.h +>f.h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>h : Symbol(Foo.h, Decl(deleteExpressionMustBeOptional.ts, 7, 14)) + +delete f.i +>f.i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) +>i : Symbol(Foo.i, Decl(deleteExpressionMustBeOptional.ts, 8, 10)) + +delete f.j +>f : Symbol(f, Decl(deleteExpressionMustBeOptional.ts, 20, 13)) + +delete a.a +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) + +delete a.b +>a : Symbol(a, Decl(deleteExpressionMustBeOptional.ts, 21, 13)) + +delete b.a +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + +delete b.b +>b : Symbol(b, Decl(deleteExpressionMustBeOptional.ts, 22, 13)) + diff --git a/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types new file mode 100644 index 00000000000..a3d6f52b7c4 --- /dev/null +++ b/tests/baselines/reference/deleteExpressionMustBeOptional(strict=true).types @@ -0,0 +1,137 @@ +=== tests/cases/compiler/deleteExpressionMustBeOptional.ts === +interface Foo { + a: number +>a : number + + b: number | undefined +>b : number | undefined + + c: number | null +>c : number | null +>null : null + + d?: number +>d : number | undefined + + e: number | undefined | null +>e : number | null | undefined +>null : null + + f?: number | undefined | null +>f : number | null | undefined +>null : null + + g: unknown +>g : unknown + + h: any +>h : any + + i: never +>i : never +} + +interface AA { + [s: string]: number +>s : string +} + +type BB = { +>BB : BB + + [P in keyof any]: number +} + +declare const f: Foo +>f : Foo + +declare const a: AA +>a : AA + +declare const b: BB +>b : BB + +delete f.a +>delete f.a : boolean +>f.a : number +>f : Foo +>a : number + +delete f.b +>delete f.b : boolean +>f.b : number | undefined +>f : Foo +>b : number | undefined + +delete f.c +>delete f.c : boolean +>f.c : number | null +>f : Foo +>c : number | null + +delete f.d +>delete f.d : boolean +>f.d : number | undefined +>f : Foo +>d : number | undefined + +delete f.e +>delete f.e : boolean +>f.e : number | null | undefined +>f : Foo +>e : number | null | undefined + +delete f.f +>delete f.f : boolean +>f.f : number | null | undefined +>f : Foo +>f : number | null | undefined + +delete f.g +>delete f.g : boolean +>f.g : unknown +>f : Foo +>g : unknown + +delete f.h +>delete f.h : boolean +>f.h : any +>f : Foo +>h : any + +delete f.i +>delete f.i : boolean +>f.i : never +>f : Foo +>i : never + +delete f.j +>delete f.j : boolean +>f.j : any +>f : Foo +>j : any + +delete a.a +>delete a.a : boolean +>a.a : number +>a : AA +>a : number + +delete a.b +>delete a.b : boolean +>a.b : number +>a : AA +>b : number + +delete b.a +>delete b.a : boolean +>b.a : number +>b : BB +>a : number + +delete b.b +>delete b.b : boolean +>b.b : number +>b : BB +>b : number + diff --git a/tests/baselines/reference/privateNamesNoDelete.errors.txt b/tests/baselines/reference/privateNamesNoDelete.errors.txt index d593fe107a1..e2fc11cb4ac 100644 --- a/tests/baselines/reference/privateNamesNoDelete.errors.txt +++ b/tests/baselines/reference/privateNamesNoDelete.errors.txt @@ -1,12 +1,15 @@ +tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts(4,16): error TS2790: The operand of a 'delete' operator must be optional. tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts(4,16): error TS18011: The operand of a 'delete' operator cannot be a private identifier. -==== tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts (1 errors) ==== +==== tests/cases/conformance/classes/members/privateNames/privateNamesNoDelete.ts (2 errors) ==== class A { #v = 1; constructor() { delete this.#v; // Error: The operand of a delete operator cannot be a private name. ~~~~~~~ +!!! error TS2790: The operand of a 'delete' operator must be optional. + ~~~~~~~ !!! error TS18011: The operand of a 'delete' operator cannot be a private identifier. } } diff --git a/tests/cases/compiler/deleteExpressionMustBeOptional.ts b/tests/cases/compiler/deleteExpressionMustBeOptional.ts new file mode 100644 index 00000000000..9f84d9ea2f1 --- /dev/null +++ b/tests/cases/compiler/deleteExpressionMustBeOptional.ts @@ -0,0 +1,42 @@ +// @strict: true, false + +interface Foo { + a: number + b: number | undefined + c: number | null + d?: number + e: number | undefined | null + f?: number | undefined | null + g: unknown + h: any + i: never +} + +interface AA { + [s: string]: number +} + +type BB = { + [P in keyof any]: number +} + +declare const f: Foo +declare const a: AA +declare const b: BB + +delete f.a +delete f.b +delete f.c +delete f.d +delete f.e +delete f.f +delete f.g +delete f.h +delete f.i +delete f.j + +delete a.a +delete a.b + +delete b.a +delete b.b \ No newline at end of file From 466d0c0ecb07dd8740483475b67d9e8adacf04aa Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 27 Apr 2020 14:09:58 -0700 Subject: [PATCH 64/74] Bump version number to 4.0 (#38215) --- package.json | 2 +- src/compiler/corePublic.ts | 2 +- tests/baselines/reference/api/tsserverlibrary.d.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 824e08f2f49..6fa73b0e28c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "3.9.0", + "version": "4.0.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index c3a258cd84e..835779639dc 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -1,7 +1,7 @@ namespace ts { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - export const versionMajorMinor = "3.9"; + export const versionMajorMinor = "4.0"; /** The version of the TypeScript compiler release */ export const version = `${versionMajorMinor}.0-dev`; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index e45bd38e2de..27bd23efaa3 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.9"; + const versionMajorMinor = "4.0"; /** The version of the TypeScript compiler release */ const version: string; /** diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 62e8560ae48..068380e2ad5 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.9"; + const versionMajorMinor = "4.0"; /** The version of the TypeScript compiler release */ const version: string; /** From 167f954ec7cf456238cad4f2006fb330c53bba8e Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Mon, 27 Apr 2020 16:18:39 -0700 Subject: [PATCH 65/74] Handle undefined in indent helper (#38217) * Handle undefined in indent helper Telemetry shows that it's called with undefined (probably `stderr` in an error scenario?). * Add undefined to parameter type --- src/typingsInstaller/nodeTypingsInstaller.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/typingsInstaller/nodeTypingsInstaller.ts b/src/typingsInstaller/nodeTypingsInstaller.ts index 56b490e709d..ab050fd60bf 100644 --- a/src/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/typingsInstaller/nodeTypingsInstaller.ts @@ -246,7 +246,9 @@ namespace ts.server.typingsInstaller { const installer = new NodeTypingsInstaller(globalTypingsCacheLocation!, typingSafeListLocation!, typesMapLocation!, npmLocation, validateDefaultNpmLocation, /*throttleLimit*/5, log); // TODO: GH#18217 installer.listen(); - function indent(newline: string, str: string): string { - return `${newline} ` + str.replace(/\r?\n/, `${newline} `); + function indent(newline: string, str: string | undefined): string { + return str && str.length + ? `${newline} ` + str.replace(/\r?\n/, `${newline} `) + : ""; } } From 12cd15c8677d2cb5cc9bf0ffdb7461ca1335d983 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 28 Apr 2020 10:42:24 -0700 Subject: [PATCH 66/74] this: undefined in modules (#37784) It's always supposed to have been this way, but I was worried about how breaky the change would be when adding globalThisType. This PR is experiment to see how much. Fixes #35882 maybe --- src/compiler/checker.ts | 4 ++ ...sxFactoryDeclarationsLocalTypes.errors.txt | 8 +++- ...neJsxFactoryDeclarationsLocalTypes.symbols | 1 - ...lineJsxFactoryDeclarationsLocalTypes.types | 2 +- ...InInvalidContextsExternalModule.errors.txt | 4 +- ...hisInInvalidContextsExternalModule.symbols | 1 - .../thisInInvalidContextsExternalModule.types | 2 +- .../reference/topLevelLambda4.errors.txt | 7 ++++ .../reference/topLevelLambda4.symbols | 3 -- .../baselines/reference/topLevelLambda4.types | 10 ++--- .../tsxAttributeResolution15.errors.txt | 6 +-- .../tsxAttributeResolution15.symbols | 1 - .../reference/tsxAttributeResolution15.types | 2 +- .../tsxSpreadAttributesResolution4.errors.txt | 40 +++++++++++++++++++ .../tsxSpreadAttributesResolution4.symbols | 1 - .../tsxSpreadAttributesResolution4.types | 2 +- 16 files changed, 72 insertions(+), 22 deletions(-) create mode 100644 tests/baselines/reference/topLevelLambda4.errors.txt create mode 100644 tests/baselines/reference/tsxSpreadAttributesResolution4.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 93276c42cb3..b0527ec70b2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21660,6 +21660,10 @@ namespace ts { const fileSymbol = getSymbolOfNode(container); return fileSymbol && getTypeOfSymbol(fileSymbol); } + else if (container.externalModuleIndicator) { + // TODO: Maybe issue a better error than 'object is possibly undefined' + return undefinedType; + } else if (includeGlobalThis) { return getTypeOfSymbol(globalThisSymbol); } diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.errors.txt b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.errors.txt index a2d542ffb69..caced97b3e8 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.errors.txt +++ b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.errors.txt @@ -1,3 +1,5 @@ +tests/cases/conformance/jsx/inline/component.tsx(4,136): error TS2609: JSX spread child must be an array type. +tests/cases/conformance/jsx/inline/component.tsx(4,140): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/jsx/inline/index.tsx(5,1): error TS2741: Property '__predomBrand' is missing in type 'import("tests/cases/conformance/jsx/inline/renderer").dom.JSX.Element' but required in type 'import("tests/cases/conformance/jsx/inline/renderer2").predom.JSX.Element'. tests/cases/conformance/jsx/inline/index.tsx(21,22): error TS2786: 'MySFC' cannot be used as a JSX component. Its return type 'import("tests/cases/conformance/jsx/inline/renderer2").predom.JSX.Element' is not a valid JSX element. @@ -53,11 +55,15 @@ tests/cases/conformance/jsx/inline/index.tsx(24,48): error TS2322: Type 'import( } } export function predom(): predom.JSX.Element; -==== tests/cases/conformance/jsx/inline/component.tsx (0 errors) ==== +==== tests/cases/conformance/jsx/inline/component.tsx (2 errors) ==== /** @jsx predom */ import { predom } from "./renderer2" export const MySFC = (props: {x: number, y: number, children?: predom.JSX.Element[]}) =>

{props.x} + {props.y} = {props.x + props.y}{...this.props.children}

; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2609: JSX spread child must be an array type. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. export class MyClass implements predom.JSX.Element { __predomBrand!: void; diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols index c53ac6b1948..25af733e40f 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols +++ b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.symbols @@ -127,7 +127,6 @@ export const MySFC = (props: {x: number, y: number, children?: predom.JSX.Elemen >props.y : Symbol(y, Decl(component.tsx, 3, 40)) >props : Symbol(props, Decl(component.tsx, 3, 22)) >y : Symbol(y, Decl(component.tsx, 3, 40)) ->this : Symbol(globalThis) >p : Symbol(predom.JSX.IntrinsicElements, Decl(renderer2.d.ts, 1, 19)) export class MyClass implements predom.JSX.Element { diff --git a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types index c9f7d4c2d8d..38bcc1898eb 100644 --- a/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types +++ b/tests/baselines/reference/inlineJsxFactoryDeclarationsLocalTypes.types @@ -99,7 +99,7 @@ export const MySFC = (props: {x: number, y: number, children?: predom.JSX.Elemen >y : number >this.props.children : any >this.props : any ->this : typeof globalThis +>this : undefined >props : any >children : any >p : any diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt index 4cfd109b00e..18f0e314a8a 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(22,15): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(28,13): error TS2331: 'this' cannot be referenced in a module or namespace body. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(36,13): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS2507: Type 'typeof globalThis' is not a constructor function type. +tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(38,25): error TS2507: Type 'undefined' is not a constructor function type. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(44,9): error TS2332: 'this' cannot be referenced in current location. tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalModule.ts(45,9): error TS2332: 'this' cannot be referenced in current location. @@ -58,7 +58,7 @@ tests/cases/conformance/expressions/thisKeyword/thisInInvalidContextsExternalMod class ErrClass3 extends this { ~~~~ -!!! error TS2507: Type 'typeof globalThis' is not a constructor function type. +!!! error TS2507: Type 'undefined' is not a constructor function type. } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols b/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols index ad52fbdabeb..9cf261fa672 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.symbols @@ -69,7 +69,6 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : Symbol(ErrClass3, Decl(thisInInvalidContextsExternalModule.ts, 35, 29)) ->this : Symbol(globalThis) } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.types b/tests/baselines/reference/thisInInvalidContextsExternalModule.types index e6ad34c9a20..cbd78a8bce4 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.types +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.types @@ -72,7 +72,7 @@ genericFunc(undefined); // Should be an error class ErrClass3 extends this { >ErrClass3 : ErrClass3 ->this : typeof globalThis +>this : undefined } diff --git a/tests/baselines/reference/topLevelLambda4.errors.txt b/tests/baselines/reference/topLevelLambda4.errors.txt new file mode 100644 index 00000000000..4d70a3ffdda --- /dev/null +++ b/tests/baselines/reference/topLevelLambda4.errors.txt @@ -0,0 +1,7 @@ +tests/cases/compiler/topLevelLambda4.ts(1,22): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/compiler/topLevelLambda4.ts (1 errors) ==== + export var x = () => this.window; + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/topLevelLambda4.symbols b/tests/baselines/reference/topLevelLambda4.symbols index 202d1bf90d5..a4f403a762f 100644 --- a/tests/baselines/reference/topLevelLambda4.symbols +++ b/tests/baselines/reference/topLevelLambda4.symbols @@ -1,7 +1,4 @@ === tests/cases/compiler/topLevelLambda4.ts === export var x = () => this.window; >x : Symbol(x, Decl(topLevelLambda4.ts, 0, 10)) ->this.window : Symbol(window, Decl(lib.dom.d.ts, --, --)) ->this : Symbol(globalThis) ->window : Symbol(window, Decl(lib.dom.d.ts, --, --)) diff --git a/tests/baselines/reference/topLevelLambda4.types b/tests/baselines/reference/topLevelLambda4.types index 78546a181d3..76f2da1e120 100644 --- a/tests/baselines/reference/topLevelLambda4.types +++ b/tests/baselines/reference/topLevelLambda4.types @@ -1,8 +1,8 @@ === tests/cases/compiler/topLevelLambda4.ts === export var x = () => this.window; ->x : () => Window & typeof globalThis ->() => this.window : () => Window & typeof globalThis ->this.window : Window & typeof globalThis ->this : typeof globalThis ->window : Window & typeof globalThis +>x : () => any +>() => this.window : () => any +>this.window : any +>this : undefined +>window : any diff --git a/tests/baselines/reference/tsxAttributeResolution15.errors.txt b/tests/baselines/reference/tsxAttributeResolution15.errors.txt index 7ec97ba4675..ad4cee701ec 100644 --- a/tests/baselines/reference/tsxAttributeResolution15.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution15.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/jsx/file.tsx(11,21): error TS2322: Type '{ prop1: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & { children?: ReactNode; }'. Property 'prop1' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & { children?: ReactNode; }'. -tests/cases/conformance/jsx/file.tsx(14,44): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. +tests/cases/conformance/jsx/file.tsx(14,39): error TS2532: Object is possibly 'undefined'. ==== tests/cases/conformance/jsx/file.tsx (2 errors) ==== @@ -21,6 +21,6 @@ tests/cases/conformance/jsx/file.tsx(14,44): error TS7017: Element implicitly ha // OK let b = { this.textInput = input; }} /> - ~~~~~~~~~ -!!! error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. let c = \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution15.symbols b/tests/baselines/reference/tsxAttributeResolution15.symbols index c366c93cef1..5c91d12a103 100644 --- a/tests/baselines/reference/tsxAttributeResolution15.symbols +++ b/tests/baselines/reference/tsxAttributeResolution15.symbols @@ -31,7 +31,6 @@ let b = { this.textInput = input; }} /> >BigGreeter : Symbol(BigGreeter, Decl(file.tsx, 0, 32)) >ref : Symbol(ref, Decl(file.tsx, 13, 19)) >input : Symbol(input, Decl(file.tsx, 13, 26)) ->this : Symbol(globalThis) >input : Symbol(input, Decl(file.tsx, 13, 26)) let c = diff --git a/tests/baselines/reference/tsxAttributeResolution15.types b/tests/baselines/reference/tsxAttributeResolution15.types index 469f146cc45..a80a613cf46 100644 --- a/tests/baselines/reference/tsxAttributeResolution15.types +++ b/tests/baselines/reference/tsxAttributeResolution15.types @@ -37,7 +37,7 @@ let b = { this.textInput = input; }} /> >input : BigGreeter >this.textInput = input : BigGreeter >this.textInput : any ->this : typeof globalThis +>this : undefined >textInput : any >input : BigGreeter diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.errors.txt b/tests/baselines/reference/tsxSpreadAttributesResolution4.errors.txt new file mode 100644 index 00000000000..d0540d88494 --- /dev/null +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.errors.txt @@ -0,0 +1,40 @@ +tests/cases/conformance/jsx/file.tsx(32,45): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== + import React = require('react'); + + interface PoisonedProp { + x: string; + y: 2; + } + + class Poisoned extends React.Component { + render() { + return
Hello
; + } + } + + const obj: PoisonedProp = { + x: "hello world", + y: 2 + }; + + // OK + let p = ; + + class EmptyProp extends React.Component<{}, {}> { + render() { + return
Default hi
; + } + } + + // OK + let j: any; + let e1 = ; + let e2 = + let e3 = { this.textInput = input; } }} /> + ~~~~ +!!! error TS2532: Object is possibly 'undefined'. + let e4 = + let e5 = \ No newline at end of file diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols index cb357c8a20d..e599665b156 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.symbols @@ -79,7 +79,6 @@ let e3 = { this.textInput = input; } }} /> >EmptyProp : Symbol(EmptyProp, Decl(file.tsx, 19, 30)) >ref : Symbol(ref, Decl(file.tsx, 31, 25)) >input : Symbol(input, Decl(file.tsx, 31, 32)) ->this : Symbol(globalThis) >input : Symbol(input, Decl(file.tsx, 31, 32)) let e4 = diff --git a/tests/baselines/reference/tsxSpreadAttributesResolution4.types b/tests/baselines/reference/tsxSpreadAttributesResolution4.types index 82173c0df83..cb0e4bc8186 100644 --- a/tests/baselines/reference/tsxSpreadAttributesResolution4.types +++ b/tests/baselines/reference/tsxSpreadAttributesResolution4.types @@ -89,7 +89,7 @@ let e3 = { this.textInput = input; } }} /> >input : EmptyProp >this.textInput = input : EmptyProp >this.textInput : any ->this : typeof globalThis +>this : undefined >textInput : any >input : EmptyProp From 9d8a70c809ad00c500f83046606561b19c627eb8 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 28 Apr 2020 11:12:38 -0700 Subject: [PATCH 67/74] Include a stack in InitializationFailedResponse (#38223) * Include a stack in InitializationFailedResponse * Update API baselines --- src/jsTyping/types.ts | 1 + src/typingsInstaller/nodeTypingsInstaller.ts | 3 ++- tests/baselines/reference/api/tsserverlibrary.d.ts | 1 + tests/baselines/reference/api/typescript.d.ts | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/jsTyping/types.ts b/src/jsTyping/types.ts index 6da6200c2c0..34f69d0d624 100644 --- a/src/jsTyping/types.ts +++ b/src/jsTyping/types.ts @@ -51,6 +51,7 @@ declare namespace ts.server { export interface InitializationFailedResponse extends TypingInstallerResponse { readonly kind: EventInitializationFailed; readonly message: string; + readonly stack?: string; } export interface ProjectResponse extends TypingInstallerResponse { diff --git a/src/typingsInstaller/nodeTypingsInstaller.ts b/src/typingsInstaller/nodeTypingsInstaller.ts index ab050fd60bf..a59e8ec4b9d 100644 --- a/src/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/typingsInstaller/nodeTypingsInstaller.ts @@ -122,7 +122,8 @@ namespace ts.server.typingsInstaller { // store error info to report it later when it is known that server is already listening to events from typings installer this.delayedInitializationError = { kind: "event::initializationFailed", - message: (e).message + message: (e).message, + stack: (e).stack, }; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 27bd23efaa3..22d6234d13d 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4960,6 +4960,7 @@ declare namespace ts.server { interface InitializationFailedResponse extends TypingInstallerResponse { readonly kind: EventInitializationFailed; readonly message: string; + readonly stack?: string; } interface ProjectResponse extends TypingInstallerResponse { readonly projectName: string; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 068380e2ad5..4e4746560ed 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -4960,6 +4960,7 @@ declare namespace ts.server { interface InitializationFailedResponse extends TypingInstallerResponse { readonly kind: EventInitializationFailed; readonly message: string; + readonly stack?: string; } interface ProjectResponse extends TypingInstallerResponse { readonly projectName: string; From 16d2eb70759f90ba476a17f20a6e6213c2b2c237 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 28 Apr 2020 12:52:14 -0700 Subject: [PATCH 68/74] Error on this.xxx access of previously declared but uninitialized property (#38030) * Error on this.xxx access of previously declared but uninitialized property * Add tests * Accept new baselines --- src/compiler/checker.ts | 2 +- .../abstractPropertyInConstructor.errors.txt | 6 +- ...itializerWithThisPropertyAccess.errors.txt | 44 +++++++ .../initializerWithThisPropertyAccess.js | 114 ++++++++++++++++++ .../initializerWithThisPropertyAccess.symbols | 90 ++++++++++++++ .../initializerWithThisPropertyAccess.types | 97 +++++++++++++++ .../scopeResolutionIdentifiers.errors.txt | 45 +++++++ .../initializerWithThisPropertyAccess.ts | 35 ++++++ 8 files changed, 431 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/initializerWithThisPropertyAccess.errors.txt create mode 100644 tests/baselines/reference/initializerWithThisPropertyAccess.js create mode 100644 tests/baselines/reference/initializerWithThisPropertyAccess.symbols create mode 100644 tests/baselines/reference/initializerWithThisPropertyAccess.types create mode 100644 tests/baselines/reference/scopeResolutionIdentifiers.errors.txt create mode 100644 tests/cases/compiler/initializerWithThisPropertyAccess.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b0527ec70b2..af3af161ffb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1364,7 +1364,7 @@ namespace ts { return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } - if (declaration.pos <= usage.pos) { + if (declaration.pos <= usage.pos && !(isPropertyDeclaration(declaration) && isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage if (declaration.kind === SyntaxKind.BindingElement) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) diff --git a/tests/baselines/reference/abstractPropertyInConstructor.errors.txt b/tests/baselines/reference/abstractPropertyInConstructor.errors.txt index 869ec3b1e65..030369d81ed 100644 --- a/tests/baselines/reference/abstractPropertyInConstructor.errors.txt +++ b/tests/baselines/reference/abstractPropertyInConstructor.errors.txt @@ -2,10 +2,11 @@ tests/cases/compiler/abstractPropertyInConstructor.ts(4,24): error TS2715: Abstr tests/cases/compiler/abstractPropertyInConstructor.ts(7,18): error TS2715: Abstract property 'prop' in class 'AbstractClass' cannot be accessed in the constructor. tests/cases/compiler/abstractPropertyInConstructor.ts(9,14): error TS2715: Abstract property 'cb' in class 'AbstractClass' cannot be accessed in the constructor. tests/cases/compiler/abstractPropertyInConstructor.ts(25,18): error TS2715: Abstract property 'prop' in class 'AbstractClass' cannot be accessed in the constructor. +tests/cases/compiler/abstractPropertyInConstructor.ts(25,18): error TS2729: Property 'prop' is used before its initialization. tests/cases/compiler/abstractPropertyInConstructor.ts(39,22): error TS2715: Abstract property 'prop' in class 'AbstractClass' cannot be accessed in the constructor. -==== tests/cases/compiler/abstractPropertyInConstructor.ts (5 errors) ==== +==== tests/cases/compiler/abstractPropertyInConstructor.ts (6 errors) ==== abstract class AbstractClass { constructor(str: string, other: AbstractClass) { this.method(parseInt(str)); @@ -39,6 +40,9 @@ tests/cases/compiler/abstractPropertyInConstructor.ts(39,22): error TS2715: Abst other = this.prop; ~~~~ !!! error TS2715: Abstract property 'prop' in class 'AbstractClass' cannot be accessed in the constructor. + ~~~~ +!!! error TS2729: Property 'prop' is used before its initialization. +!!! related TS2728 tests/cases/compiler/abstractPropertyInConstructor.ts:20:14: 'prop' is declared here. fn = () => this.prop; method2() { diff --git a/tests/baselines/reference/initializerWithThisPropertyAccess.errors.txt b/tests/baselines/reference/initializerWithThisPropertyAccess.errors.txt new file mode 100644 index 00000000000..0e9502e7cb6 --- /dev/null +++ b/tests/baselines/reference/initializerWithThisPropertyAccess.errors.txt @@ -0,0 +1,44 @@ +tests/cases/compiler/initializerWithThisPropertyAccess.ts(3,14): error TS2729: Property 'a' is used before its initialization. +tests/cases/compiler/initializerWithThisPropertyAccess.ts(24,29): error TS2729: Property 'bar' is used before its initialization. + + +==== tests/cases/compiler/initializerWithThisPropertyAccess.ts (2 errors) ==== + class A { + a: number; + b = this.a; // Error + ~ +!!! error TS2729: Property 'a' is used before its initialization. +!!! related TS2728 tests/cases/compiler/initializerWithThisPropertyAccess.ts:2:5: 'a' is declared here. + c = () => this.a; + d = (new A()).a; + constructor() { + this.a = 1; + } + } + + class B extends A { + x = this.a; + } + + class C { + a!: number; + b = this.a; + } + + // Repro from #37979 + + class Foo { + private bar: Bar; + readonly barProp = this.bar.prop; + ~~~ +!!! error TS2729: Property 'bar' is used before its initialization. +!!! related TS2728 tests/cases/compiler/initializerWithThisPropertyAccess.ts:23:13: 'bar' is declared here. + constructor() { + this.bar = new Bar(); + } + } + + class Bar { + readonly prop = false; + } + \ No newline at end of file diff --git a/tests/baselines/reference/initializerWithThisPropertyAccess.js b/tests/baselines/reference/initializerWithThisPropertyAccess.js new file mode 100644 index 00000000000..dee3469b39f --- /dev/null +++ b/tests/baselines/reference/initializerWithThisPropertyAccess.js @@ -0,0 +1,114 @@ +//// [initializerWithThisPropertyAccess.ts] +class A { + a: number; + b = this.a; // Error + c = () => this.a; + d = (new A()).a; + constructor() { + this.a = 1; + } +} + +class B extends A { + x = this.a; +} + +class C { + a!: number; + b = this.a; +} + +// Repro from #37979 + +class Foo { + private bar: Bar; + readonly barProp = this.bar.prop; + constructor() { + this.bar = new Bar(); + } +} + +class Bar { + readonly prop = false; +} + + +//// [initializerWithThisPropertyAccess.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var A = /** @class */ (function () { + function A() { + var _this = this; + this.b = this.a; // Error + this.c = function () { return _this.a; }; + this.d = (new A()).a; + this.a = 1; + } + return A; +}()); +var B = /** @class */ (function (_super) { + __extends(B, _super); + function B() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.x = _this.a; + return _this; + } + return B; +}(A)); +var C = /** @class */ (function () { + function C() { + this.b = this.a; + } + return C; +}()); +// Repro from #37979 +var Foo = /** @class */ (function () { + function Foo() { + this.barProp = this.bar.prop; + this.bar = new Bar(); + } + return Foo; +}()); +var Bar = /** @class */ (function () { + function Bar() { + this.prop = false; + } + return Bar; +}()); + + +//// [initializerWithThisPropertyAccess.d.ts] +declare class A { + a: number; + b: number; + c: () => number; + d: number; + constructor(); +} +declare class B extends A { + x: number; +} +declare class C { + a: number; + b: number; +} +declare class Foo { + private bar; + readonly barProp = false; + constructor(); +} +declare class Bar { + readonly prop = false; +} diff --git a/tests/baselines/reference/initializerWithThisPropertyAccess.symbols b/tests/baselines/reference/initializerWithThisPropertyAccess.symbols new file mode 100644 index 00000000000..566e61cb531 --- /dev/null +++ b/tests/baselines/reference/initializerWithThisPropertyAccess.symbols @@ -0,0 +1,90 @@ +=== tests/cases/compiler/initializerWithThisPropertyAccess.ts === +class A { +>A : Symbol(A, Decl(initializerWithThisPropertyAccess.ts, 0, 0)) + + a: number; +>a : Symbol(A.a, Decl(initializerWithThisPropertyAccess.ts, 0, 9)) + + b = this.a; // Error +>b : Symbol(A.b, Decl(initializerWithThisPropertyAccess.ts, 1, 14)) +>this.a : Symbol(A.a, Decl(initializerWithThisPropertyAccess.ts, 0, 9)) +>this : Symbol(A, Decl(initializerWithThisPropertyAccess.ts, 0, 0)) +>a : Symbol(A.a, Decl(initializerWithThisPropertyAccess.ts, 0, 9)) + + c = () => this.a; +>c : Symbol(A.c, Decl(initializerWithThisPropertyAccess.ts, 2, 15)) +>this.a : Symbol(A.a, Decl(initializerWithThisPropertyAccess.ts, 0, 9)) +>this : Symbol(A, Decl(initializerWithThisPropertyAccess.ts, 0, 0)) +>a : Symbol(A.a, Decl(initializerWithThisPropertyAccess.ts, 0, 9)) + + d = (new A()).a; +>d : Symbol(A.d, Decl(initializerWithThisPropertyAccess.ts, 3, 21)) +>(new A()).a : Symbol(A.a, Decl(initializerWithThisPropertyAccess.ts, 0, 9)) +>A : Symbol(A, Decl(initializerWithThisPropertyAccess.ts, 0, 0)) +>a : Symbol(A.a, Decl(initializerWithThisPropertyAccess.ts, 0, 9)) + + constructor() { + this.a = 1; +>this.a : Symbol(A.a, Decl(initializerWithThisPropertyAccess.ts, 0, 9)) +>this : Symbol(A, Decl(initializerWithThisPropertyAccess.ts, 0, 0)) +>a : Symbol(A.a, Decl(initializerWithThisPropertyAccess.ts, 0, 9)) + } +} + +class B extends A { +>B : Symbol(B, Decl(initializerWithThisPropertyAccess.ts, 8, 1)) +>A : Symbol(A, Decl(initializerWithThisPropertyAccess.ts, 0, 0)) + + x = this.a; +>x : Symbol(B.x, Decl(initializerWithThisPropertyAccess.ts, 10, 19)) +>this.a : Symbol(A.a, Decl(initializerWithThisPropertyAccess.ts, 0, 9)) +>this : Symbol(B, Decl(initializerWithThisPropertyAccess.ts, 8, 1)) +>a : Symbol(A.a, Decl(initializerWithThisPropertyAccess.ts, 0, 9)) +} + +class C { +>C : Symbol(C, Decl(initializerWithThisPropertyAccess.ts, 12, 1)) + + a!: number; +>a : Symbol(C.a, Decl(initializerWithThisPropertyAccess.ts, 14, 9)) + + b = this.a; +>b : Symbol(C.b, Decl(initializerWithThisPropertyAccess.ts, 15, 15)) +>this.a : Symbol(C.a, Decl(initializerWithThisPropertyAccess.ts, 14, 9)) +>this : Symbol(C, Decl(initializerWithThisPropertyAccess.ts, 12, 1)) +>a : Symbol(C.a, Decl(initializerWithThisPropertyAccess.ts, 14, 9)) +} + +// Repro from #37979 + +class Foo { +>Foo : Symbol(Foo, Decl(initializerWithThisPropertyAccess.ts, 17, 1)) + + private bar: Bar; +>bar : Symbol(Foo.bar, Decl(initializerWithThisPropertyAccess.ts, 21, 11)) +>Bar : Symbol(Bar, Decl(initializerWithThisPropertyAccess.ts, 27, 1)) + + readonly barProp = this.bar.prop; +>barProp : Symbol(Foo.barProp, Decl(initializerWithThisPropertyAccess.ts, 22, 21)) +>this.bar.prop : Symbol(Bar.prop, Decl(initializerWithThisPropertyAccess.ts, 29, 11)) +>this.bar : Symbol(Foo.bar, Decl(initializerWithThisPropertyAccess.ts, 21, 11)) +>this : Symbol(Foo, Decl(initializerWithThisPropertyAccess.ts, 17, 1)) +>bar : Symbol(Foo.bar, Decl(initializerWithThisPropertyAccess.ts, 21, 11)) +>prop : Symbol(Bar.prop, Decl(initializerWithThisPropertyAccess.ts, 29, 11)) + + constructor() { + this.bar = new Bar(); +>this.bar : Symbol(Foo.bar, Decl(initializerWithThisPropertyAccess.ts, 21, 11)) +>this : Symbol(Foo, Decl(initializerWithThisPropertyAccess.ts, 17, 1)) +>bar : Symbol(Foo.bar, Decl(initializerWithThisPropertyAccess.ts, 21, 11)) +>Bar : Symbol(Bar, Decl(initializerWithThisPropertyAccess.ts, 27, 1)) + } +} + +class Bar { +>Bar : Symbol(Bar, Decl(initializerWithThisPropertyAccess.ts, 27, 1)) + + readonly prop = false; +>prop : Symbol(Bar.prop, Decl(initializerWithThisPropertyAccess.ts, 29, 11)) +} + diff --git a/tests/baselines/reference/initializerWithThisPropertyAccess.types b/tests/baselines/reference/initializerWithThisPropertyAccess.types new file mode 100644 index 00000000000..1abfa0cfe02 --- /dev/null +++ b/tests/baselines/reference/initializerWithThisPropertyAccess.types @@ -0,0 +1,97 @@ +=== tests/cases/compiler/initializerWithThisPropertyAccess.ts === +class A { +>A : A + + a: number; +>a : number + + b = this.a; // Error +>b : number +>this.a : number +>this : this +>a : number + + c = () => this.a; +>c : () => number +>() => this.a : () => number +>this.a : number +>this : this +>a : number + + d = (new A()).a; +>d : number +>(new A()).a : number +>(new A()) : A +>new A() : A +>A : typeof A +>a : number + + constructor() { + this.a = 1; +>this.a = 1 : 1 +>this.a : number +>this : this +>a : number +>1 : 1 + } +} + +class B extends A { +>B : B +>A : A + + x = this.a; +>x : number +>this.a : number +>this : this +>a : number +} + +class C { +>C : C + + a!: number; +>a : number + + b = this.a; +>b : number +>this.a : number +>this : this +>a : number +} + +// Repro from #37979 + +class Foo { +>Foo : Foo + + private bar: Bar; +>bar : Bar + + readonly barProp = this.bar.prop; +>barProp : false +>this.bar.prop : false +>this.bar : Bar +>this : this +>bar : Bar +>prop : false + + constructor() { + this.bar = new Bar(); +>this.bar = new Bar() : Bar +>this.bar : Bar +>this : this +>bar : Bar +>new Bar() : Bar +>Bar : typeof Bar + } +} + +class Bar { +>Bar : Bar + + readonly prop = false; +>prop : false +>false : false +} + diff --git a/tests/baselines/reference/scopeResolutionIdentifiers.errors.txt b/tests/baselines/reference/scopeResolutionIdentifiers.errors.txt new file mode 100644 index 00000000000..f8d0caa00b3 --- /dev/null +++ b/tests/baselines/reference/scopeResolutionIdentifiers.errors.txt @@ -0,0 +1,45 @@ +tests/cases/conformance/expressions/identifiers/scopeResolutionIdentifiers.ts(24,14): error TS2729: Property 's' is used before its initialization. + + +==== tests/cases/conformance/expressions/identifiers/scopeResolutionIdentifiers.ts (1 errors) ==== + // EveryType used in a nested scope of a different EveryType with the same name, type of the identifier is the one defined in the inner scope + + var s: string; + module M1 { + export var s: number; + var n = s; + var n: number; + } + + module M2 { + var s: number; + var n = s; + var n: number; + } + + function fn() { + var s: boolean; + var n = s; + var n: boolean; + } + + class C { + s: Date; + n = this.s; + ~ +!!! error TS2729: Property 's' is used before its initialization. +!!! related TS2728 tests/cases/conformance/expressions/identifiers/scopeResolutionIdentifiers.ts:23:5: 's' is declared here. + x() { + var p = this.n; + var p: Date; + } + } + + module M3 { + var s: any; + module M4 { + var n = s; + var n: any; + } + } + \ No newline at end of file diff --git a/tests/cases/compiler/initializerWithThisPropertyAccess.ts b/tests/cases/compiler/initializerWithThisPropertyAccess.ts new file mode 100644 index 00000000000..f4a23ecaa99 --- /dev/null +++ b/tests/cases/compiler/initializerWithThisPropertyAccess.ts @@ -0,0 +1,35 @@ +// @strict: true +// @declaration: true + +class A { + a: number; + b = this.a; // Error + c = () => this.a; + d = (new A()).a; + constructor() { + this.a = 1; + } +} + +class B extends A { + x = this.a; +} + +class C { + a!: number; + b = this.a; +} + +// Repro from #37979 + +class Foo { + private bar: Bar; + readonly barProp = this.bar.prop; + constructor() { + this.bar = new Bar(); + } +} + +class Bar { + readonly prop = false; +} From a0ebd2c26e7179032eff02cafc5cc2a8c59ea663 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 28 Apr 2020 16:56:35 -0700 Subject: [PATCH 69/74] Guard against recursion in inferTypeForHomomorphicMappedType (#38224) * Guard against recursion in inferTypeForHomomorphicMappedType * Add regression test --- src/compiler/checker.ts | 7 ++- .../reference/recursiveReverseMappedType.js | 32 +++++++++++++ .../recursiveReverseMappedType.symbols | 47 +++++++++++++++++++ .../recursiveReverseMappedType.types | 31 ++++++++++++ .../compiler/recursiveReverseMappedType.ts | 15 ++++++ 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/recursiveReverseMappedType.js create mode 100644 tests/baselines/reference/recursiveReverseMappedType.symbols create mode 100644 tests/baselines/reference/recursiveReverseMappedType.types create mode 100644 tests/cases/compiler/recursiveReverseMappedType.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index af3af161ffb..c11e9b9dba7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -827,6 +827,7 @@ namespace ts { /** Key is "/path/to/a.ts|/path/to/b.ts". */ let amalgamatedDuplicates: Map | undefined; const reverseMappedCache = createMap(); + let inInferTypeForHomomorphicMappedType = false; let ambientModulesCache: Symbol[] | undefined; /** * List of every ambient module with a "*" wildcard. @@ -18366,12 +18367,16 @@ namespace ts { * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ function inferTypeForHomomorphicMappedType(source: Type, target: MappedType, constraint: IndexType): Type | undefined { + if (inInferTypeForHomomorphicMappedType) { + return undefined; + } const key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } - reverseMappedCache.set(key, undefined); + inInferTypeForHomomorphicMappedType = true; const type = createReverseMappedType(source, target, constraint); + inInferTypeForHomomorphicMappedType = false; reverseMappedCache.set(key, type); return type; } diff --git a/tests/baselines/reference/recursiveReverseMappedType.js b/tests/baselines/reference/recursiveReverseMappedType.js new file mode 100644 index 00000000000..1d500b9ee65 --- /dev/null +++ b/tests/baselines/reference/recursiveReverseMappedType.js @@ -0,0 +1,32 @@ +//// [recursiveReverseMappedType.ts] +// Repro from #38198 + +type Recur = ( + T extends (unknown[]) ? {} : { [K in keyof T]?: Recur } +) | ['marker', ...Recur[]]; + +function join(l: Recur[]): Recur { + return ['marker', ...l]; +} + +function a(l: Recur[]): void { + const x: Recur | undefined = join(l); +} + + +//// [recursiveReverseMappedType.js] +"use strict"; +// Repro from #38198 +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; +function join(l) { + return __spreadArrays(['marker'], l); +} +function a(l) { + var x = join(l); +} diff --git a/tests/baselines/reference/recursiveReverseMappedType.symbols b/tests/baselines/reference/recursiveReverseMappedType.symbols new file mode 100644 index 00000000000..6e4a9cb5b0c --- /dev/null +++ b/tests/baselines/reference/recursiveReverseMappedType.symbols @@ -0,0 +1,47 @@ +=== tests/cases/compiler/recursiveReverseMappedType.ts === +// Repro from #38198 + +type Recur = ( +>Recur : Symbol(Recur, Decl(recursiveReverseMappedType.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveReverseMappedType.ts, 2, 11)) + + T extends (unknown[]) ? {} : { [K in keyof T]?: Recur } +>T : Symbol(T, Decl(recursiveReverseMappedType.ts, 2, 11)) +>K : Symbol(K, Decl(recursiveReverseMappedType.ts, 3, 36)) +>T : Symbol(T, Decl(recursiveReverseMappedType.ts, 2, 11)) +>Recur : Symbol(Recur, Decl(recursiveReverseMappedType.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveReverseMappedType.ts, 2, 11)) +>K : Symbol(K, Decl(recursiveReverseMappedType.ts, 3, 36)) + +) | ['marker', ...Recur[]]; +>Recur : Symbol(Recur, Decl(recursiveReverseMappedType.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveReverseMappedType.ts, 2, 11)) + +function join(l: Recur[]): Recur { +>join : Symbol(join, Decl(recursiveReverseMappedType.ts, 4, 30)) +>T : Symbol(T, Decl(recursiveReverseMappedType.ts, 6, 14)) +>l : Symbol(l, Decl(recursiveReverseMappedType.ts, 6, 17)) +>Recur : Symbol(Recur, Decl(recursiveReverseMappedType.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveReverseMappedType.ts, 6, 14)) +>Recur : Symbol(Recur, Decl(recursiveReverseMappedType.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveReverseMappedType.ts, 6, 14)) + + return ['marker', ...l]; +>l : Symbol(l, Decl(recursiveReverseMappedType.ts, 6, 17)) +} + +function a(l: Recur[]): void { +>a : Symbol(a, Decl(recursiveReverseMappedType.ts, 8, 1)) +>T : Symbol(T, Decl(recursiveReverseMappedType.ts, 10, 11)) +>l : Symbol(l, Decl(recursiveReverseMappedType.ts, 10, 14)) +>Recur : Symbol(Recur, Decl(recursiveReverseMappedType.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveReverseMappedType.ts, 10, 11)) + + const x: Recur | undefined = join(l); +>x : Symbol(x, Decl(recursiveReverseMappedType.ts, 11, 9)) +>Recur : Symbol(Recur, Decl(recursiveReverseMappedType.ts, 0, 0)) +>T : Symbol(T, Decl(recursiveReverseMappedType.ts, 10, 11)) +>join : Symbol(join, Decl(recursiveReverseMappedType.ts, 4, 30)) +>l : Symbol(l, Decl(recursiveReverseMappedType.ts, 10, 14)) +} + diff --git a/tests/baselines/reference/recursiveReverseMappedType.types b/tests/baselines/reference/recursiveReverseMappedType.types new file mode 100644 index 00000000000..a39e242d90b --- /dev/null +++ b/tests/baselines/reference/recursiveReverseMappedType.types @@ -0,0 +1,31 @@ +=== tests/cases/compiler/recursiveReverseMappedType.ts === +// Repro from #38198 + +type Recur = ( +>Recur : Recur + + T extends (unknown[]) ? {} : { [K in keyof T]?: Recur } +) | ['marker', ...Recur[]]; + +function join(l: Recur[]): Recur { +>join : (l: Recur[]) => Recur +>l : Recur[] + + return ['marker', ...l]; +>['marker', ...l] : ["marker", ...Recur[]] +>'marker' : "marker" +>...l : Recur +>l : Recur[] +} + +function a(l: Recur[]): void { +>a : (l: Recur[]) => void +>l : Recur[] + + const x: Recur | undefined = join(l); +>x : (T extends unknown[] ? {} : { [K in keyof T]?: (T[K] extends unknown[] ? {} : { [K in keyof T[K]]?: (T[K][K] extends unknown[] ? {} : { [K in keyof T[K][K]]?: (T[K][K][K] extends unknown[] ? {} : { [K in keyof T[K][K][K]]?: (T[K][K][K][K] extends unknown[] ? {} : { [K in keyof T[K][K][K][K]]?: (T[K][K][K][K][K] extends unknown[] ? {} : { [K in keyof T[K][K][K][K][K]]?: (T[K][K][K][K][K][K] extends unknown[] ? {} : { [K in keyof T[K][K][K][K][K][K]]?: (T[K][K][K][K][K][K][K] extends unknown[] ? {} : { [K in keyof T[K][K][K][K][K][K][K]]?: (T[K][K][K][K][K][K][K][K] extends unknown[] ? {} : { [K in keyof T[K][K][K][K][K][K][K][K]]?: (T[K][K][K][K][K][K][K][K][K] extends unknown[] ? {} : { [K in keyof T[K][K][K][K][K][K][K][K][K]]?: (T[K][K][K][K][K][K][K][K][K][K] extends unknown[] ? {} : { [K in keyof T[K][K][K][K][K][K][K][K][K][K]]?: (T[K][K][K][K][K][K][K][K][K][K][K] extends unknown[] ? {} : any) | ["marker", ...Recur[]] | undefined; }) | ["marker", ...Recur[]] | undefined; }) | ["marker", ...Recur[]] | undefined; }) | ["marker", ...Recur[]] | undefined; }) | ["marker", ...Recur[]] | undefined; }) | ["marker", ...Recur[]] | undefined; }) | ["marker", ...Recur[]] | undefined; }) | ["marker", ...Recur[]] | undefined; }) | ["marker", ...Recur[]] | undefined; }) | ["marker", ...Recur[]] | undefined; }) | ["marker", ...Recur[]] | undefined; }) | ["marker", ...Recur[]] | undefined +>join(l) : Recur +>join : (l: Recur[]) => Recur +>l : Recur[] +} + diff --git a/tests/cases/compiler/recursiveReverseMappedType.ts b/tests/cases/compiler/recursiveReverseMappedType.ts new file mode 100644 index 00000000000..89c80095f79 --- /dev/null +++ b/tests/cases/compiler/recursiveReverseMappedType.ts @@ -0,0 +1,15 @@ +// @strict: true + +// Repro from #38198 + +type Recur = ( + T extends (unknown[]) ? {} : { [K in keyof T]?: Recur } +) | ['marker', ...Recur[]]; + +function join(l: Recur[]): Recur { + return ['marker', ...l]; +} + +function a(l: Recur[]): void { + const x: Recur | undefined = join(l); +} From 3919042c7f1051c9b6006bf906306f3323da15f6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 28 Apr 2020 16:59:03 -0700 Subject: [PATCH 70/74] Control flow for constructor initialized properties (#37920) * Use CFA to determine types of properties declared by this.xxx assignments * Accept new baselines * Also use CFA in constructor functions * Accept new baselines * Fix lint error * Only widen fresh literal types in CFA of assignment to auto-typed * Auto-typing for declared properties with no type annotation or initializer * Add optionality if declaration includes '?' modifier * Always use CFA for properties with no initializer in .js files * Small fix --- src/compiler/binder.ts | 6 +- src/compiler/checker.ts | 189 ++++++++++++------ src/compiler/types.ts | 3 +- ...ExportsObjectAssignPrototypeProperty.types | 4 +- ...onstraintOfJavascriptClassExpression.types | 4 +- .../checkJsFiles_noErrorLocation.types | 4 +- .../checkSuperCallBeforeThisAccessing9.types | 4 +- .../classCanExtendConstructorFunction.types | 8 +- .../reference/classExtendingAny.types | 4 +- .../reference/constructorFunctions.types | 4 +- .../constructorFunctionsStrict.types | 8 +- .../reference/exportNestedNamespaces.types | 4 +- ...inferringClassMembersFromAssignments.types | 12 +- ...nferringClassMembersFromAssignments3.types | 4 +- ...nferringClassMembersFromAssignments5.types | 4 +- .../reference/jsDeclarationsClasses.types | 20 +- ...rationsExportAssignedClassExpression.types | 4 +- ...portAssignedClassExpressionAnonymous.types | 4 +- ...ignedClassExpressionAnonymousWithSub.types | 8 +- ...portAssignedClassExpressionShadowing.types | 4 +- ...onsExportAssignedConstructorFunction.types | 4 +- ...DeclarationsExportAssignedVisibility.types | 8 +- .../jsDeclarationsTypedefAndImportTypes.types | 4 +- .../reference/jsFileClassPropertyType.types | 4 +- .../reference/jsFileClassPropertyType3.types | 8 +- .../jsFileClassSelfReferencedProperty.types | 10 +- .../jsObjectsMarkedAsOpenEnded.types | 4 +- .../reference/jsdocAccessibilityTags.types | 12 +- .../reference/jsdocAugmentsMissingType.types | 4 +- .../reference/jsdocAugments_noExtends.types | 4 +- .../reference/jsdocFunctionType.types | 12 +- .../jsdocImplements_missingType.types | 4 +- .../jsdocImplements_properties.types | 8 +- .../baselines/reference/jsdocImportType.types | 4 +- .../reference/jsdocImportType2.types | 4 +- tests/baselines/reference/jsdocReadonly.types | 4 +- .../reference/jsdocTemplateClass.types | 4 +- ...peReferenceToImportOfClassExpression.types | 4 +- ...eferenceToImportOfFunctionExpression.types | 4 +- .../reference/jsdocTypeTagCast.types | 12 +- .../reference/moduleExportAssignment6.types | 8 +- .../moduleExportNestedNamespaces.types | 4 +- ...pertiesOfGenericConstructorFunctions.types | 8 +- .../reference/returnTagTypeGuard.types | 8 +- .../reference/thisPropertyAssignment.types | 6 +- .../thisPropertyAssignmentCircular.symbols | 2 + .../thisPropertyAssignmentCircular.types | 14 +- .../thisPropertyOverridesAccessors.types | 4 +- .../thisTypeOfConstructorFunctions.types | 12 +- .../typeFromJSConstructor.errors.txt | 13 +- .../reference/typeFromJSConstructor.types | 16 +- .../typeFromParamTagForFunction.types | 12 +- .../typeFromPropertyAssignment15.types | 4 +- .../typeFromPropertyAssignment2.types | 4 +- .../typeFromPropertyAssignment23.types | 4 +- .../typeFromPropertyAssignment25.types | 8 +- .../typeFromPropertyAssignment26.types | 4 +- .../typeFromPropertyAssignment28.types | 4 +- .../typeFromPropertyAssignment3.types | 4 +- .../typeFromPropertyAssignment35.types | 4 +- .../typeFromPrototypeAssignment.types | 4 +- .../typeFromPrototypeAssignment2.types | 4 +- .../reference/varRequireFromJavascript.types | 4 +- 63 files changed, 329 insertions(+), 250 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 356b2fd18f6..7d3e4af6765 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -649,7 +649,7 @@ namespace ts { } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === SyntaxKind.Constructor ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === SyntaxKind.Constructor || (isInJSFile && (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -670,8 +670,8 @@ namespace ts { if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === SyntaxKind.Constructor) { - (node).returnFlowNode = currentFlow; + if (node.kind === SyntaxKind.Constructor || (isInJSFile && (node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.FunctionExpression))) { + (node).returnFlowNode = currentFlow; } } if (!isIIFE) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c11e9b9dba7..7723d2b7c25 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7556,6 +7556,16 @@ namespace ts { return addOptionality(type, isOptional); } + if (isPropertyDeclaration(declaration) && (noImplicitAny || isInJSFile(declaration))) { + // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. + // Use control flow analysis of this.xxx assignments the constructor to determine the type of the property. + const constructor = findConstructorDeclaration(declaration.parent); + const type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : + getModifierFlags(declaration) & ModifierFlags.Ambient ? getTypeOfPropertyInBaseClass(declaration.symbol) : + undefined; + return type && addOptionality(type, isOptional); + } + if (isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. // I.e is sugar for @@ -7572,6 +7582,59 @@ namespace ts { return undefined; } + function isConstructorDeclaredProperty(symbol: Symbol) { + // A propery is considered a constructor declared property when all declaration sites are this.xxx assignments, + // when no declaration sites have JSDoc type annotations, and when at least one declaration site is in the body of + // a class constructor. + if (symbol.valueDeclaration && isBinaryExpression(symbol.valueDeclaration)) { + const links = getSymbolLinks(symbol); + if (links.isConstructorDeclaredProperty === undefined) { + links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && every(symbol.declarations, declaration => + isBinaryExpression(declaration) && + getAssignmentDeclarationKind(declaration) === AssignmentDeclarationKind.ThisProperty && + (declaration.left.kind !== SyntaxKind.ElementAccessExpression || isStringOrNumericLiteralLike((declaration.left).argumentExpression)) && + !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration)); + } + return links.isConstructorDeclaredProperty; + } + return false; + } + + function isAutoTypedProperty(symbol: Symbol) { + // A property is auto-typed when its declaration has no type annotation or initializer and we're in + // noImplicitAny mode or a .js file. + const declaration = symbol.valueDeclaration; + return declaration && isPropertyDeclaration(declaration) && !getEffectiveTypeAnnotationNode(declaration) && + !declaration.initializer && (noImplicitAny || isInJSFile(declaration)); + } + + function getDeclaringConstructor(symbol: Symbol) { + for (const declaration of symbol.declarations) { + const container = getThisContainer(declaration, /*includeArrowFunctions*/ false); + if (container && (container.kind === SyntaxKind.Constructor || isJSConstructor(container))) { + return container; + } + } + } + + function getFlowTypeInConstructor(symbol: Symbol, constructor: ConstructorDeclaration) { + const reference = createPropertyAccess(createThis(), unescapeLeadingUnderscores(symbol.escapedName)); + reference.expression.parent = reference; + reference.parent = constructor; + reference.flowNode = constructor.returnFlowNode; + const flowType = getFlowTypeOfProperty(reference, symbol); + if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) { + error(symbol.valueDeclaration, Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); + } + // We don't infer a type if assignments are only null or undefined. + return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); + } + + function getFlowTypeOfProperty(reference: Node, prop: Symbol | undefined) { + const initialType = prop && (!isAutoTypedProperty(prop) || getModifierFlags(prop.valueDeclaration) & ModifierFlags.Ambient) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + return getFlowTypeOfReference(reference, autoType, initialType); + } + function getWidenedTypeForAssignmentDeclaration(symbol: Symbol, resolvedSymbol?: Symbol) { // function/class/{} initializers are themselves containers, so they won't merge in the same way as other initializers const container = getAssignedExpandoInitializer(symbol.valueDeclaration); @@ -7583,52 +7646,60 @@ namespace ts { const containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } + let type; let definedInConstructor = false; let definedInMethod = false; - let jsdocType: Type | undefined; - let types: Type[] | undefined; - for (const declaration of symbol.declarations) { - const expression = (isBinaryExpression(declaration) || isCallExpression(declaration)) ? declaration : - isAccessExpression(declaration) ? isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - - const kind = isAccessExpression(expression) - ? getAssignmentDeclarationPropertyAccessKind(expression) - : getAssignmentDeclarationKind(expression); - if (kind === AssignmentDeclarationKind.ThisProperty) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; - } - else { - definedInMethod = true; - } - } - if (!isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((isBinaryExpression(expression) || isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + // We use control flow analysis to determine the type of the property if the property qualifies as a constructor + // declared property and the resulting control flow type isn't just undefined or null. + if (isConstructorDeclaredProperty(symbol)) { + type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)!); } - let type = jsdocType; if (!type) { - if (!length(types)) { - return errorType; // No types from any declarations :( - } - let constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types!, symbol.declarations) : undefined; - // use only the constructor types unless they were only assigned null | undefined (including widening variants) - if (definedInMethod) { - const propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol); - if (propType) { - (constructorTypes || (constructorTypes = [])).push(propType); - definedInConstructor = true; + let jsdocType: Type | undefined; + let types: Type[] | undefined; + for (const declaration of symbol.declarations) { + const expression = (isBinaryExpression(declaration) || isCallExpression(declaration)) ? declaration : + isAccessExpression(declaration) ? isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere + } + + const kind = isAccessExpression(expression) + ? getAssignmentDeclarationPropertyAccessKind(expression) + : getAssignmentDeclarationKind(expression); + if (kind === AssignmentDeclarationKind.ThisProperty) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((isBinaryExpression(expression) || isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } - const sourceTypes = some(constructorTypes, t => !!(t.flags & ~TypeFlags.Nullable)) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes!, UnionReduction.Subtype); + type = jsdocType; + if (!type) { + if (!length(types)) { + return errorType; // No types from any declarations :( + } + let constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types!, symbol.declarations) : undefined; + // use only the constructor types unless they were only assigned null | undefined (including widening variants) + if (definedInMethod) { + const propType = getTypeOfPropertyInBaseClass(symbol); + if (propType) { + (constructorTypes || (constructorTypes = [])).push(propType); + definedInConstructor = true; + } + } + const sourceTypes = some(constructorTypes, t => !!(t.flags & ~TypeFlags.Nullable)) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes!, UnionReduction.Subtype); + } } const widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); if (filterType(widened, t => !!(t.flags & ~TypeFlags.Nullable)) === neverType) { @@ -7800,21 +7871,6 @@ namespace ts { }); } - /** check for definition in base class if any declaration is in a class */ - function getTypeOfAssignmentDeclarationPropertyOfBaseType(property: Symbol) { - const parentDeclaration = forEach(property.declarations, d => { - const parent = getThisContainer(d, /*includeArrowFunctions*/ false).parent; - return isClassLike(parent) && parent; - }); - if (parentDeclaration) { - const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(parentDeclaration)) as InterfaceType; - const baseClassType = classType && getBaseTypes(classType)[0]; - if (baseClassType) { - return getTypeOfPropertyOfType(baseClassType, property.escapedName); - } - } - } - // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. @@ -12803,6 +12859,9 @@ namespace ts { if (accessFlags & AccessFlags.CacheSymbol) { getNodeLinks(accessNode!).resolvedSymbol = prop; } + if (isThisPropertyAccessInConstructor(accessExpression, prop)) { + return autoType; + } } const propType = getTypeOfSymbol(prop); return accessExpression && getAssignmentTargetKind(accessExpression) !== AssignmentKind.Definite ? @@ -17398,7 +17457,14 @@ namespace ts { // Return the declaring class type of a property or undefined if property not declared in class function getDeclaringClass(prop: Symbol) { - return prop.parent && prop.parent.flags & SymbolFlags.Class ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)!) : undefined; + return prop.parent && prop.parent.flags & SymbolFlags.Class ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)!) : undefined; + } + + // Return the inherited type of the given property or undefined if property doesn't exist in a base class. + function getTypeOfPropertyInBaseClass(property: Symbol) { + const classType = getDeclaringClass(property); + const baseClassType = classType && getBaseTypes(classType)[0]; + return baseClassType && getTypeOfPropertyOfType(baseClassType, property.escapedName); } // Return true if some underlying source property is declared in a class that derives @@ -20218,7 +20284,7 @@ namespace ts { if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - const assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); + const assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & TypeFlags.Union) { @@ -24158,6 +24224,10 @@ namespace ts { return false; } + function isThisPropertyAccessInConstructor(node: ElementAccessExpression | PropertyAccessExpression | QualifiedName, prop: Symbol) { + return isThisProperty(node) && (isAutoTypedProperty(prop) || isConstructorDeclaredProperty(prop)) && getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); + } + function checkPropertyAccessExpressionOrQualifiedName(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, leftType: Type, right: Identifier | PrivateIdentifier) { const parentSymbol = getNodeLinks(left).resolvedSymbol; const assignmentKind = getAssignmentTargetKind(node); @@ -24232,7 +24302,7 @@ namespace ts { error(right, Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, idText(right)); return errorType; } - propType = getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); } return getFlowTypeOfAccessExpression(node, prop, propType, right); } @@ -24247,6 +24317,9 @@ namespace ts { prop && !(prop.flags & (SymbolFlags.Variable | SymbolFlags.Property | SymbolFlags.Accessor)) && !(prop.flags & SymbolFlags.Method && propType.flags & TypeFlags.Union)) { return propType; } + if (propType === autoType) { + return getFlowTypeOfProperty(node, prop); + } // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8cf06d4ab4e..e5e50df8406 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1107,6 +1107,7 @@ namespace ts { exclamationToken?: ExclamationToken; body?: Block | Expression; /* @internal */ endFlowNode?: FlowNode; + /* @internal */ returnFlowNode?: FlowNode; } export type FunctionLikeDeclaration = @@ -1152,7 +1153,6 @@ namespace ts { kind: SyntaxKind.Constructor; parent: ClassLikeDeclaration; body?: FunctionBody; - /* @internal */ returnFlowNode?: FlowNode; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ @@ -4157,6 +4157,7 @@ namespace ts { deferralParent?: Type; // Source union/intersection of a deferred type cjsExportMerged?: Symbol; // Version of the symbol with all non export= exports merged with the export= target typeOnlyDeclaration?: TypeOnlyCompatibleAliasDeclaration | false; // First resolved alias declaration that makes the symbol only usable in type constructs + isConstructorDeclaredProperty?: boolean; // Property declared through 'this.x = ...' assignment in constructor } /* @internal */ diff --git a/tests/baselines/reference/checkExportsObjectAssignPrototypeProperty.types b/tests/baselines/reference/checkExportsObjectAssignPrototypeProperty.types index a3bb9cd12ce..6634a1a45ed 100644 --- a/tests/baselines/reference/checkExportsObjectAssignPrototypeProperty.types +++ b/tests/baselines/reference/checkExportsObjectAssignPrototypeProperty.types @@ -105,9 +105,9 @@ function Person(name) { this.name = name; >this.name = name : string ->this.name : string +>this.name : any >this : this ->name : string +>name : any >name : string } Person.prototype.describe = function () { diff --git a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.types b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.types index 5d58047f6e4..465e3faea62 100644 --- a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.types +++ b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.types @@ -23,9 +23,9 @@ someFunction(function(BaseClass) { this.foo = "bar"; >this.foo = "bar" : "bar" ->this.foo : string +>this.foo : any >this : this ->foo : string +>foo : any >"bar" : "bar" } _render(error) { diff --git a/tests/baselines/reference/checkJsFiles_noErrorLocation.types b/tests/baselines/reference/checkJsFiles_noErrorLocation.types index d714782fed1..b0dceb2d33c 100644 --- a/tests/baselines/reference/checkJsFiles_noErrorLocation.types +++ b/tests/baselines/reference/checkJsFiles_noErrorLocation.types @@ -25,9 +25,9 @@ class B extends A { this.foo = () => 3; >this.foo = () => 3 : () => number ->this.foo : () => number +>this.foo : any >this : this ->foo : () => number +>foo : any >() => 3 : () => number >3 : 3 } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.types b/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.types index 577256400b2..c39389422f0 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.types +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing9.types @@ -12,9 +12,9 @@ class Derived { this.x = 10; >this.x = 10 : 10 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >10 : 10 var that = this; diff --git a/tests/baselines/reference/classCanExtendConstructorFunction.types b/tests/baselines/reference/classCanExtendConstructorFunction.types index c7a6770563a..f667ce4b150 100644 --- a/tests/baselines/reference/classCanExtendConstructorFunction.types +++ b/tests/baselines/reference/classCanExtendConstructorFunction.types @@ -9,9 +9,9 @@ function Wagon(numberOxen) { this.numberOxen = numberOxen >this.numberOxen = numberOxen : number ->this.numberOxen : number +>this.numberOxen : any >this : this ->numberOxen : number +>numberOxen : any >numberOxen : number } /** @param {Wagon[]=} wagons */ @@ -91,9 +91,9 @@ class Sql extends Wagon { this.foonly = 12 >this.foonly = 12 : 12 ->this.foonly : number +>this.foonly : any >this : this ->foonly : number +>foonly : any >12 : 12 } /** diff --git a/tests/baselines/reference/classExtendingAny.types b/tests/baselines/reference/classExtendingAny.types index fb585ed1de0..0916674963d 100644 --- a/tests/baselines/reference/classExtendingAny.types +++ b/tests/baselines/reference/classExtendingAny.types @@ -67,9 +67,9 @@ class B extends Err { this.wat = 12 >this.wat = 12 : 12 ->this.wat : number +>this.wat : any >this : this ->wat : number +>wat : any >12 : 12 } f() { diff --git a/tests/baselines/reference/constructorFunctions.types b/tests/baselines/reference/constructorFunctions.types index ba2fedb6643..84ad439394d 100644 --- a/tests/baselines/reference/constructorFunctions.types +++ b/tests/baselines/reference/constructorFunctions.types @@ -143,9 +143,9 @@ function C6() { this.functions = [x => x, x => x + 1, x => x - 1] >this.functions = [x => x, x => x + 1, x => x - 1] : ((x: any) => any)[] ->this.functions : ((x: any) => any)[] +>this.functions : any >this : this ->functions : ((x: any) => any)[] +>functions : any >[x => x, x => x + 1, x => x - 1] : ((x: any) => any)[] >x => x : (x: any) => any >x : any diff --git a/tests/baselines/reference/constructorFunctionsStrict.types b/tests/baselines/reference/constructorFunctionsStrict.types index daeffbdd7ff..a92024920b5 100644 --- a/tests/baselines/reference/constructorFunctionsStrict.types +++ b/tests/baselines/reference/constructorFunctionsStrict.types @@ -85,10 +85,10 @@ var j = new A(2) k.x === j.x >k.x === j.x : boolean ->k.x : number +>k.x : number | undefined >k : A ->x : number ->j.x : number +>x : number | undefined +>j.x : number | undefined >j : A ->x : number +>x : number | undefined diff --git a/tests/baselines/reference/exportNestedNamespaces.types b/tests/baselines/reference/exportNestedNamespaces.types index 97ce99af19a..4bc7568885e 100644 --- a/tests/baselines/reference/exportNestedNamespaces.types +++ b/tests/baselines/reference/exportNestedNamespaces.types @@ -32,9 +32,9 @@ exports.Classic = class { constructor() { this.p = 1 >this.p = 1 : 1 ->this.p : number +>this.p : any >this : this ->p : number +>p : any >1 : 1 } } diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.types b/tests/baselines/reference/inferringClassMembersFromAssignments.types index 3d168707fe6..c962aa841d8 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.types +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.types @@ -11,24 +11,24 @@ class C { this.inConstructor = 0; >this.inConstructor = 0 : 0 ->this.inConstructor : string | number +>this.inConstructor : any >this : this ->inConstructor : string | number +>inConstructor : any >0 : 0 } else { this.inConstructor = "string" >this.inConstructor = "string" : "string" ->this.inConstructor : string | number +>this.inConstructor : any >this : this ->inConstructor : string | number +>inConstructor : any >"string" : "string" } this.inMultiple = 0; >this.inMultiple = 0 : 0 ->this.inMultiple : number +>this.inMultiple : any >this : this ->inMultiple : number +>inMultiple : any >0 : 0 } method() { diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments3.types b/tests/baselines/reference/inferringClassMembersFromAssignments3.types index 60d545b2832..66394eb9ed1 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments3.types +++ b/tests/baselines/reference/inferringClassMembersFromAssignments3.types @@ -5,9 +5,9 @@ class Base { constructor() { this.p = 1 >this.p = 1 : 1 ->this.p : number +>this.p : any >this : this ->p : number +>p : any >1 : 1 } } diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments5.types b/tests/baselines/reference/inferringClassMembersFromAssignments5.types index fc95b82e5fd..6bc1f2482d8 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments5.types +++ b/tests/baselines/reference/inferringClassMembersFromAssignments5.types @@ -25,9 +25,9 @@ class Derived extends Base { // should be OK, and p should have type number from this assignment this.p = 1 >this.p = 1 : 1 ->this.p : number +>this.p : any >this : this ->p : number +>p : any >1 : 1 } test() { diff --git a/tests/baselines/reference/jsDeclarationsClasses.types b/tests/baselines/reference/jsDeclarationsClasses.types index bbcea688c26..853bb6b8996 100644 --- a/tests/baselines/reference/jsDeclarationsClasses.types +++ b/tests/baselines/reference/jsDeclarationsClasses.types @@ -209,16 +209,16 @@ export class K { constructor() { this.p1 = 12; >this.p1 = 12 : 12 ->this.p1 : number +>this.p1 : any >this : this ->p1 : number +>p1 : any >12 : 12 this.p2 = "ok"; >this.p2 = "ok" : "ok" ->this.p2 : string +>this.p2 : any >this : this ->p2 : string +>p2 : any >"ok" : "ok" } @@ -243,9 +243,9 @@ export class M extends null { constructor() { this.prop = 12; >this.prop = 12 : 12 ->this.prop : number +>this.prop : any >this : this ->prop : number +>prop : any >12 : 12 } } @@ -270,9 +270,9 @@ export class N extends L { this.another = param; >this.another = param : T ->this.another : T +>this.another : any >this : this ->another : T +>another : any >param : T } } @@ -298,9 +298,9 @@ export class O extends N { this.another2 = param; >this.another2 = param : U ->this.another2 : U +>this.another2 : any >this : this ->another2 : U +>another2 : any >param : U } } diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.types b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.types index b2c7f801eb7..301d4f4adc5 100644 --- a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.types +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpression.types @@ -15,9 +15,9 @@ module.exports = class Thing { this.t = 12 + p; >this.t = 12 + p : number ->this.t : number +>this.t : any >this : this ->t : number +>t : any >12 + p : number >12 : 12 >p : number diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.types b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.types index ce144f50ebc..dc75cbed876 100644 --- a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.types +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymous.types @@ -14,9 +14,9 @@ module.exports = class { this.t = 12 + p; >this.t = 12 + p : number ->this.t : number +>this.t : any >this : this ->t : number +>t : any >12 + p : number >12 : 12 >p : number diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types index ccf33572b98..904bbe06944 100644 --- a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionAnonymousWithSub.types @@ -14,9 +14,9 @@ module.exports = class { this.t = 12 + p; >this.t = 12 + p : number ->this.t : number +>this.t : any >this : this ->t : number +>t : any >12 + p : number >12 : 12 >p : number @@ -34,9 +34,9 @@ module.exports.Sub = class { constructor() { this.instance = new module.exports(10); >this.instance = new module.exports(10) : import("tests/cases/conformance/jsdoc/declarations/index") ->this.instance : import("tests/cases/conformance/jsdoc/declarations/index") +>this.instance : any >this : this ->instance : import("tests/cases/conformance/jsdoc/declarations/index") +>instance : any >new module.exports(10) : import("tests/cases/conformance/jsdoc/declarations/index") >module.exports : typeof import("tests/cases/conformance/jsdoc/declarations/index") >module : { "\"tests/cases/conformance/jsdoc/declarations/index\"": typeof import("tests/cases/conformance/jsdoc/declarations/index"); } diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.types b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.types index b7c41fe7fbb..36fdb5bfdc4 100644 --- a/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.types +++ b/tests/baselines/reference/jsDeclarationsExportAssignedClassExpressionShadowing.types @@ -25,9 +25,9 @@ module.exports = class Q { constructor() { this.x = new A(); >this.x = new A() : A ->this.x : A +>this.x : any >this : this ->x : A +>x : any >new A() : A >A : typeof A } diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedConstructorFunction.types b/tests/baselines/reference/jsDeclarationsExportAssignedConstructorFunction.types index bbdaa717fb2..d7f0ad52721 100644 --- a/tests/baselines/reference/jsDeclarationsExportAssignedConstructorFunction.types +++ b/tests/baselines/reference/jsDeclarationsExportAssignedConstructorFunction.types @@ -11,9 +11,9 @@ module.exports.MyClass = function() { this.x = 1 >this.x = 1 : 1 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >1 : 1 } module.exports.MyClass.prototype = { diff --git a/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types index e54216161b9..a76835e3105 100644 --- a/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types +++ b/tests/baselines/reference/jsDeclarationsExportAssignedVisibility.types @@ -11,9 +11,9 @@ class Container { constructor() { this.usage = new Obj(); >this.usage = new Obj() : import("tests/cases/conformance/jsdoc/declarations/obj") ->this.usage : import("tests/cases/conformance/jsdoc/declarations/obj") +>this.usage : any >this : this ->usage : import("tests/cases/conformance/jsdoc/declarations/obj") +>usage : any >new Obj() : import("tests/cases/conformance/jsdoc/declarations/obj") >Obj : typeof import("tests/cases/conformance/jsdoc/declarations/obj") } @@ -38,9 +38,9 @@ module.exports = class Obj { constructor() { this.x = 12; >this.x = 12 : 12 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >12 : 12 } } diff --git a/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.types b/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.types index 6441a279a43..d4242cb21a7 100644 --- a/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.types +++ b/tests/baselines/reference/jsDeclarationsTypedefAndImportTypes.types @@ -38,9 +38,9 @@ class Wrap { this.connItem = c.item; >this.connItem = c.item : number ->this.connItem : number +>this.connItem : any >this : this ->connItem : number +>connItem : any >c.item : number >c : import("tests/cases/conformance/jsdoc/declarations/conn") >item : number diff --git a/tests/baselines/reference/jsFileClassPropertyType.types b/tests/baselines/reference/jsFileClassPropertyType.types index bf1605d5bc6..686560e3605 100644 --- a/tests/baselines/reference/jsFileClassPropertyType.types +++ b/tests/baselines/reference/jsFileClassPropertyType.types @@ -5,9 +5,9 @@ class C { constructor () { this.p = 0; >this.p = 0 : 0 ->this.p : number +>this.p : any >this : this ->p : number +>p : any >0 : 0 } } diff --git a/tests/baselines/reference/jsFileClassPropertyType3.types b/tests/baselines/reference/jsFileClassPropertyType3.types index eea855579ae..aee74b9787e 100644 --- a/tests/baselines/reference/jsFileClassPropertyType3.types +++ b/tests/baselines/reference/jsFileClassPropertyType3.types @@ -8,17 +8,17 @@ class C { this.p = null; >this.p = null : null ->this.p : number +>this.p : any >this : this ->p : number +>p : any >null : null } else { this.p = 0; >this.p = 0 : 0 ->this.p : number +>this.p : any >this : this ->p : number +>p : any >0 : 0 } } diff --git a/tests/baselines/reference/jsFileClassSelfReferencedProperty.types b/tests/baselines/reference/jsFileClassSelfReferencedProperty.types index 204eee67c97..9700c12ddd0 100644 --- a/tests/baselines/reference/jsFileClassSelfReferencedProperty.types +++ b/tests/baselines/reference/jsFileClassSelfReferencedProperty.types @@ -4,15 +4,15 @@ export class StackOverflowTest { constructor () { this.testStackOverflow = this.testStackOverflow.bind(this) ->this.testStackOverflow = this.testStackOverflow.bind(this) : any +>this.testStackOverflow = this.testStackOverflow.bind(this) : error >this.testStackOverflow : any >this : this >testStackOverflow : any ->this.testStackOverflow.bind(this) : any ->this.testStackOverflow.bind : any ->this.testStackOverflow : any +>this.testStackOverflow.bind(this) : error +>this.testStackOverflow.bind : error +>this.testStackOverflow : undefined >this : this ->testStackOverflow : any +>testStackOverflow : undefined >bind : any >this : this } diff --git a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types index 996165537bc..777f779e9c7 100644 --- a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types +++ b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types @@ -20,9 +20,9 @@ class C { constructor() { this.member = {}; >this.member = {} : {} ->this.member : {} +>this.member : any >this : this ->member : {} +>member : any >{} : {} this.member.a = 0; diff --git a/tests/baselines/reference/jsdocAccessibilityTags.types b/tests/baselines/reference/jsdocAccessibilityTags.types index 18a364c4da8..a16c3456f2e 100644 --- a/tests/baselines/reference/jsdocAccessibilityTags.types +++ b/tests/baselines/reference/jsdocAccessibilityTags.types @@ -52,9 +52,9 @@ class C { */ this.priv2 = 1; >this.priv2 = 1 : 1 ->this.priv2 : number +>this.priv2 : any >this : this ->priv2 : number +>priv2 : any >1 : 1 /** @@ -64,9 +64,9 @@ class C { */ this.prot2 = 2; >this.prot2 = 2 : 2 ->this.prot2 : number +>this.prot2 : any >this : this ->prot2 : number +>prot2 : any >2 : 2 /** @@ -76,9 +76,9 @@ class C { */ this.pub2 = 3; >this.pub2 = 3 : 3 ->this.pub2 : number +>this.pub2 : any >this : this ->pub2 : number +>pub2 : any >3 : 3 } h() { return this.priv2 } diff --git a/tests/baselines/reference/jsdocAugmentsMissingType.types b/tests/baselines/reference/jsdocAugmentsMissingType.types index de0ba42cdd2..430fae25480 100644 --- a/tests/baselines/reference/jsdocAugmentsMissingType.types +++ b/tests/baselines/reference/jsdocAugmentsMissingType.types @@ -2,9 +2,9 @@ class A { constructor() { this.x = 0; } } >A : A >this.x = 0 : 0 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >0 : 0 /** @augments */ diff --git a/tests/baselines/reference/jsdocAugments_noExtends.types b/tests/baselines/reference/jsdocAugments_noExtends.types index fab9c7b7c84..31c79acc60a 100644 --- a/tests/baselines/reference/jsdocAugments_noExtends.types +++ b/tests/baselines/reference/jsdocAugments_noExtends.types @@ -2,9 +2,9 @@ class A { constructor() { this.x = 0; } } >A : A >this.x = 0 : 0 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >0 : 0 /** @augments A */ diff --git a/tests/baselines/reference/jsdocFunctionType.types b/tests/baselines/reference/jsdocFunctionType.types index 6349dccb10a..f43ce2e84e2 100644 --- a/tests/baselines/reference/jsdocFunctionType.types +++ b/tests/baselines/reference/jsdocFunctionType.types @@ -44,9 +44,9 @@ class C { this.length = n; >this.length = n : number ->this.length : number +>this.length : any >this : this ->length : number +>length : any >n : number } } @@ -92,9 +92,9 @@ function D(n) { this.length = n; >this.length = n : number ->this.length : number +>this.length : any >this : this ->length : number +>length : any >n : number } @@ -151,9 +151,9 @@ var E = function(n) { this.not_length_on_purpose = n; >this.not_length_on_purpose = n : number ->this.not_length_on_purpose : number +>this.not_length_on_purpose : any >this : this ->not_length_on_purpose : number +>not_length_on_purpose : any >n : number }; diff --git a/tests/baselines/reference/jsdocImplements_missingType.types b/tests/baselines/reference/jsdocImplements_missingType.types index 7a63d6aa5f2..370d360db0a 100644 --- a/tests/baselines/reference/jsdocImplements_missingType.types +++ b/tests/baselines/reference/jsdocImplements_missingType.types @@ -2,9 +2,9 @@ class A { constructor() { this.x = 0; } } >A : A >this.x = 0 : 0 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >0 : 0 /** @implements */ diff --git a/tests/baselines/reference/jsdocImplements_properties.types b/tests/baselines/reference/jsdocImplements_properties.types index fb00977b860..79f7a3d5a0b 100644 --- a/tests/baselines/reference/jsdocImplements_properties.types +++ b/tests/baselines/reference/jsdocImplements_properties.types @@ -2,9 +2,9 @@ class A { constructor() { this.x = 0; } } >A : A >this.x = 0 : 0 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >0 : 0 /** @implements A*/ @@ -26,9 +26,9 @@ class B3 { constructor() { this.x = 10 } >this.x = 10 : 10 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >10 : 10 } diff --git a/tests/baselines/reference/jsdocImportType.types b/tests/baselines/reference/jsdocImportType.types index fd3157c19dc..b1d75424750 100644 --- a/tests/baselines/reference/jsdocImportType.types +++ b/tests/baselines/reference/jsdocImportType.types @@ -45,9 +45,9 @@ class Chunk { constructor() { this.chunk = 1; >this.chunk = 1 : 1 ->this.chunk : number +>this.chunk : any >this : this ->chunk : number +>chunk : any >1 : 1 } } diff --git a/tests/baselines/reference/jsdocImportType2.types b/tests/baselines/reference/jsdocImportType2.types index 635dfc1ff1e..f4386faf5a6 100644 --- a/tests/baselines/reference/jsdocImportType2.types +++ b/tests/baselines/reference/jsdocImportType2.types @@ -50,9 +50,9 @@ module.exports = class Chunk { constructor() { this.chunk = 1; >this.chunk = 1 : 1 ->this.chunk : number +>this.chunk : any >this : this ->chunk : number +>chunk : any >1 : 1 } } diff --git a/tests/baselines/reference/jsdocReadonly.types b/tests/baselines/reference/jsdocReadonly.types index 8a0f0806a24..806623749cd 100644 --- a/tests/baselines/reference/jsdocReadonly.types +++ b/tests/baselines/reference/jsdocReadonly.types @@ -35,9 +35,9 @@ class LOL { /** @readonly ok */ this.ka = 2 >this.ka = 2 : 2 ->this.ka : number +>this.ka : any >this : this ->ka : number +>ka : any >2 : 2 } } diff --git a/tests/baselines/reference/jsdocTemplateClass.types b/tests/baselines/reference/jsdocTemplateClass.types index 6e5695ca837..0479abccf3e 100644 --- a/tests/baselines/reference/jsdocTemplateClass.types +++ b/tests/baselines/reference/jsdocTemplateClass.types @@ -14,9 +14,9 @@ class Foo { this.a = x >this.a = x : T ->this.a : T +>this.a : any >this : this ->a : T +>a : any >x : T } /** diff --git a/tests/baselines/reference/jsdocTypeReferenceToImportOfClassExpression.types b/tests/baselines/reference/jsdocTypeReferenceToImportOfClassExpression.types index 98f18bc8fb0..0645f6adfda 100644 --- a/tests/baselines/reference/jsdocTypeReferenceToImportOfClassExpression.types +++ b/tests/baselines/reference/jsdocTypeReferenceToImportOfClassExpression.types @@ -39,9 +39,9 @@ class MW { this.compiler = compiler; >this.compiler = compiler : import("tests/cases/conformance/jsdoc/MC") ->this.compiler : import("tests/cases/conformance/jsdoc/MC") +>this.compiler : any >this : this ->compiler : import("tests/cases/conformance/jsdoc/MC") +>compiler : any >compiler : import("tests/cases/conformance/jsdoc/MC") } } diff --git a/tests/baselines/reference/jsdocTypeReferenceToImportOfFunctionExpression.types b/tests/baselines/reference/jsdocTypeReferenceToImportOfFunctionExpression.types index 1747fecbf6c..81422f0c76c 100644 --- a/tests/baselines/reference/jsdocTypeReferenceToImportOfFunctionExpression.types +++ b/tests/baselines/reference/jsdocTypeReferenceToImportOfFunctionExpression.types @@ -42,9 +42,9 @@ class MW { this.compiler = compiler; >this.compiler = compiler : typeof MC ->this.compiler : typeof MC +>this.compiler : any >this : this ->compiler : typeof MC +>compiler : any >compiler : typeof MC } } diff --git a/tests/baselines/reference/jsdocTypeTagCast.types b/tests/baselines/reference/jsdocTypeTagCast.types index dc40ea0d950..f7e9136ca34 100644 --- a/tests/baselines/reference/jsdocTypeTagCast.types +++ b/tests/baselines/reference/jsdocTypeTagCast.types @@ -43,9 +43,9 @@ class SomeBase { constructor() { this.p = 42; >this.p = 42 : 42 ->this.p : number +>this.p : any >this : this ->p : number +>p : any >42 : 42 } } @@ -60,9 +60,9 @@ class SomeDerived extends SomeBase { this.x = 42; >this.x = 42 : 42 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >42 : 42 } } @@ -72,9 +72,9 @@ class SomeOther { constructor() { this.q = 42; >this.q = 42 : 42 ->this.q : number +>this.q : any >this : this ->q : number +>q : any >42 : 42 } } diff --git a/tests/baselines/reference/moduleExportAssignment6.types b/tests/baselines/reference/moduleExportAssignment6.types index e1fd4a4dd12..ee4122873c0 100644 --- a/tests/baselines/reference/moduleExportAssignment6.types +++ b/tests/baselines/reference/moduleExportAssignment6.types @@ -8,16 +8,16 @@ class C { this.x = x >this.x = x : number ->this.x : number +>this.x : any >this : this ->x : number +>x : any >x : number this.exports = [x] >this.exports = [x] : number[] ->this.exports : number[] +>this.exports : any >this : this ->exports : number[] +>exports : any >[x] : number[] >x : number } diff --git a/tests/baselines/reference/moduleExportNestedNamespaces.types b/tests/baselines/reference/moduleExportNestedNamespaces.types index 249739a3beb..a1fc39b723c 100644 --- a/tests/baselines/reference/moduleExportNestedNamespaces.types +++ b/tests/baselines/reference/moduleExportNestedNamespaces.types @@ -39,9 +39,9 @@ module.exports.Classic = class { constructor() { this.p = 1 >this.p = 1 : 1 ->this.p : number +>this.p : any >this : this ->p : number +>p : any >1 : 1 } } diff --git a/tests/baselines/reference/propertiesOfGenericConstructorFunctions.types b/tests/baselines/reference/propertiesOfGenericConstructorFunctions.types index 71ef32425ab..42bf2ea2e94 100644 --- a/tests/baselines/reference/propertiesOfGenericConstructorFunctions.types +++ b/tests/baselines/reference/propertiesOfGenericConstructorFunctions.types @@ -94,16 +94,16 @@ function Cp(t) { this.x = 1 >this.x = 1 : 1 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >1 : 1 this.y = t >this.y = t : T ->this.y : T +>this.y : any >this : this ->y : T +>y : any >t : T } Cp.prototype = { diff --git a/tests/baselines/reference/returnTagTypeGuard.types b/tests/baselines/reference/returnTagTypeGuard.types index a8211118ea9..7056faa1336 100644 --- a/tests/baselines/reference/returnTagTypeGuard.types +++ b/tests/baselines/reference/returnTagTypeGuard.types @@ -5,9 +5,9 @@ class Entry { constructor() { this.c = 1 >this.c = 1 : 1 ->this.c : number +>this.c : any >this : this ->c : number +>c : any >1 : 1 } /** @@ -28,9 +28,9 @@ class Group { constructor() { this.d = 'no' >this.d = 'no' : "no" ->this.d : string +>this.d : any >this : this ->d : string +>d : any >'no' : "no" } /** diff --git a/tests/baselines/reference/thisPropertyAssignment.types b/tests/baselines/reference/thisPropertyAssignment.types index c919f47db1e..ad245977352 100644 --- a/tests/baselines/reference/thisPropertyAssignment.types +++ b/tests/baselines/reference/thisPropertyAssignment.types @@ -44,9 +44,9 @@ function F() { this.a = {}; >this.a = {} : {} ->this.a : {} +>this.a : any >this : this ->a : {} +>a : any >{} : {} this.a.b = {}; @@ -60,7 +60,7 @@ function F() { this["b"] = {}; >this["b"] = {} : {} ->this["b"] : {} +>this["b"] : any >this : this >"b" : "b" >{} : {} diff --git a/tests/baselines/reference/thisPropertyAssignmentCircular.symbols b/tests/baselines/reference/thisPropertyAssignmentCircular.symbols index 69bde885d52..efaf0a1235e 100644 --- a/tests/baselines/reference/thisPropertyAssignmentCircular.symbols +++ b/tests/baselines/reference/thisPropertyAssignmentCircular.symbols @@ -44,8 +44,10 @@ function C() { >this.x : Symbol(C.x, Decl(thisPropertyAssignmentCircular.js, 13, 14), Decl(thisPropertyAssignmentCircular.js, 14, 15)) >this : Symbol(C, Decl(thisPropertyAssignmentCircular.js, 10, 1)) >x : Symbol(C.x, Decl(thisPropertyAssignmentCircular.js, 13, 14), Decl(thisPropertyAssignmentCircular.js, 14, 15)) +>this.x.toString : Symbol(Function.toString, Decl(lib.es5.d.ts, --, --)) >this.x : Symbol(C.x, Decl(thisPropertyAssignmentCircular.js, 13, 14), Decl(thisPropertyAssignmentCircular.js, 14, 15)) >this : Symbol(C, Decl(thisPropertyAssignmentCircular.js, 10, 1)) >x : Symbol(C.x, Decl(thisPropertyAssignmentCircular.js, 13, 14), Decl(thisPropertyAssignmentCircular.js, 14, 15)) +>toString : Symbol(Function.toString, Decl(lib.es5.d.ts, --, --)) } diff --git a/tests/baselines/reference/thisPropertyAssignmentCircular.types b/tests/baselines/reference/thisPropertyAssignmentCircular.types index 1b5f8ae3dea..bdeba6dfeba 100644 --- a/tests/baselines/reference/thisPropertyAssignmentCircular.types +++ b/tests/baselines/reference/thisPropertyAssignmentCircular.types @@ -5,9 +5,9 @@ export class Foo { constructor() { this.foo = "Hello"; >this.foo = "Hello" : "Hello" ->this.foo : string +>this.foo : any >this : this ->foo : string +>foo : any >"Hello" : "Hello" } slicey() { @@ -52,11 +52,11 @@ function C() { >this : this >x : any >function() { this.x.toString(); } : () => void ->this.x.toString() : any ->this.x.toString : any ->this.x : any +>this.x.toString() : string +>this.x.toString : () => string +>this.x : () => void >this : this ->x : any ->toString : any +>x : () => void +>toString : () => string } diff --git a/tests/baselines/reference/thisPropertyOverridesAccessors.types b/tests/baselines/reference/thisPropertyOverridesAccessors.types index c242351dbd2..84da977ac12 100644 --- a/tests/baselines/reference/thisPropertyOverridesAccessors.types +++ b/tests/baselines/reference/thisPropertyOverridesAccessors.types @@ -23,9 +23,9 @@ class Bar extends Foo { this.p = 2 >this.p = 2 : 2 ->this.p : number +>this.p : any >this : this ->p : number +>p : any >2 : 2 } } diff --git a/tests/baselines/reference/thisTypeOfConstructorFunctions.types b/tests/baselines/reference/thisTypeOfConstructorFunctions.types index 126c0c9321a..2bd9ada0ac3 100644 --- a/tests/baselines/reference/thisTypeOfConstructorFunctions.types +++ b/tests/baselines/reference/thisTypeOfConstructorFunctions.types @@ -18,17 +18,17 @@ function Cp(t) { this.y = t >this.y = t : T ->this.y : T +>this.y : any >this : this ->y : T +>y : any >t : T /** @return {this} */ this.m3 = () => this >this.m3 = () => this : () => this ->this.m3 : () => this +>this.m3 : any >this : this ->m3 : () => this +>m3 : any >() => this : () => this >this : this } @@ -67,9 +67,9 @@ function Cpp(t) { this.y = t >this.y = t : T ->this.y : T +>this.y : any >this : this ->y : T +>y : any >t : T } /** @return {this} */ diff --git a/tests/baselines/reference/typeFromJSConstructor.errors.txt b/tests/baselines/reference/typeFromJSConstructor.errors.txt index ffcf5393f51..d77ca8ebd16 100644 --- a/tests/baselines/reference/typeFromJSConstructor.errors.txt +++ b/tests/baselines/reference/typeFromJSConstructor.errors.txt @@ -1,12 +1,13 @@ tests/cases/conformance/salsa/a.js(10,5): error TS7008: Member 'twices' implicitly has an 'any[]' type. tests/cases/conformance/salsa/a.js(14,5): error TS2322: Type '"hi"' is not assignable to type 'number'. +tests/cases/conformance/salsa/a.js(17,5): error TS2322: Type 'undefined' is not assignable to type 'string'. tests/cases/conformance/salsa/a.js(21,5): error TS2322: Type 'false' is not assignable to type 'number'. -tests/cases/conformance/salsa/a.js(24,5): error TS2322: Type 'null' is not assignable to type 'string | undefined'. -tests/cases/conformance/salsa/a.js(25,5): error TS2322: Type 'false' is not assignable to type 'string | undefined'. +tests/cases/conformance/salsa/a.js(24,5): error TS2322: Type 'null' is not assignable to type 'string'. +tests/cases/conformance/salsa/a.js(25,5): error TS2322: Type 'false' is not assignable to type 'string'. tests/cases/conformance/salsa/a.js(26,5): error TS2531: Object is possibly 'null'. -==== tests/cases/conformance/salsa/a.js (6 errors) ==== +==== tests/cases/conformance/salsa/a.js (7 errors) ==== function Installer () { // arg: number this.arg = 0 @@ -28,6 +29,8 @@ tests/cases/conformance/salsa/a.js(26,5): error TS2531: Object is possibly 'null this.unknown = 'hi' // ok this.newProperty = 1 // ok: number | boolean this.twice = undefined // ok + ~~~~~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. this.twice = 'hi' // ok } Installer.prototype.second = function () { @@ -38,10 +41,10 @@ tests/cases/conformance/salsa/a.js(26,5): error TS2531: Object is possibly 'null this.newProperty = false // ok this.twice = null // error ~~~~~~~~~~ -!!! error TS2322: Type 'null' is not assignable to type 'string | undefined'. +!!! error TS2322: Type 'null' is not assignable to type 'string'. this.twice = false // error ~~~~~~~~~~ -!!! error TS2322: Type 'false' is not assignable to type 'string | undefined'. +!!! error TS2322: Type 'false' is not assignable to type 'string'. this.twices.push(1) // error: Object is possibly null ~~~~~~~~~~~ !!! error TS2531: Object is possibly 'null'. diff --git a/tests/baselines/reference/typeFromJSConstructor.types b/tests/baselines/reference/typeFromJSConstructor.types index 38d736e5a68..68bd498f0f2 100644 --- a/tests/baselines/reference/typeFromJSConstructor.types +++ b/tests/baselines/reference/typeFromJSConstructor.types @@ -80,16 +80,16 @@ Installer.prototype.first = function () { this.twice = undefined // ok >this.twice = undefined : undefined ->this.twice : string | undefined +>this.twice : string >this : this ->twice : string | undefined +>twice : string >undefined : undefined this.twice = 'hi' // ok >this.twice = 'hi' : "hi" ->this.twice : string | undefined +>this.twice : string >this : this ->twice : string | undefined +>twice : string >'hi' : "hi" } Installer.prototype.second = function () { @@ -124,16 +124,16 @@ Installer.prototype.second = function () { this.twice = null // error >this.twice = null : null ->this.twice : string | undefined +>this.twice : string >this : this ->twice : string | undefined +>twice : string >null : null this.twice = false // error >this.twice = false : false ->this.twice : string | undefined +>this.twice : string >this : this ->twice : string | undefined +>twice : string >false : false this.twices.push(1) // error: Object is possibly null diff --git a/tests/baselines/reference/typeFromParamTagForFunction.types b/tests/baselines/reference/typeFromParamTagForFunction.types index 476c6c3c453..2c454f3e0da 100644 --- a/tests/baselines/reference/typeFromParamTagForFunction.types +++ b/tests/baselines/reference/typeFromParamTagForFunction.types @@ -50,9 +50,9 @@ exports.B = class { constructor() { this.x = 1; >this.x = 1 : 1 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >1 : 1 } }; @@ -135,9 +135,9 @@ export class E { constructor() { this.x = 1; >this.x = 1 : 1 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >1 : 1 } } @@ -206,9 +206,9 @@ class H { constructor() { this.x = 1; >this.x = 1 : 1 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >1 : 1 } } diff --git a/tests/baselines/reference/typeFromPropertyAssignment15.types b/tests/baselines/reference/typeFromPropertyAssignment15.types index e1573a21e75..c82b777396e 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment15.types +++ b/tests/baselines/reference/typeFromPropertyAssignment15.types @@ -13,9 +13,9 @@ Outer.Inner = class { constructor() { this.x = 1 >this.x = 1 : 1 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >1 : 1 } m() { } diff --git a/tests/baselines/reference/typeFromPropertyAssignment2.types b/tests/baselines/reference/typeFromPropertyAssignment2.types index c7f5619ab67..aa06b79f484 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment2.types +++ b/tests/baselines/reference/typeFromPropertyAssignment2.types @@ -20,9 +20,9 @@ Outer.Inner = class I { constructor() { this.x = 1 >this.x = 1 : 1 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >1 : 1 } } diff --git a/tests/baselines/reference/typeFromPropertyAssignment23.types b/tests/baselines/reference/typeFromPropertyAssignment23.types index 03bf1d91776..d100f718840 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment23.types +++ b/tests/baselines/reference/typeFromPropertyAssignment23.types @@ -5,9 +5,9 @@ class B { constructor () { this.n = 1 >this.n = 1 : 1 ->this.n : number +>this.n : any >this : this ->n : number +>n : any >1 : 1 } foo() { diff --git a/tests/baselines/reference/typeFromPropertyAssignment25.types b/tests/baselines/reference/typeFromPropertyAssignment25.types index d27b4a70165..e5ec6cf6f04 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment25.types +++ b/tests/baselines/reference/typeFromPropertyAssignment25.types @@ -13,9 +13,9 @@ Common.I = class { constructor() { this.i = 1 >this.i = 1 : 1 ->this.i : number +>this.i : any >this : this ->i : number +>i : any >1 : 1 } } @@ -36,9 +36,9 @@ Common.O = class extends Common.I { this.o = 2 >this.o = 2 : 2 ->this.o : number +>this.o : any >this : this ->o : number +>o : any >2 : 2 } } diff --git a/tests/baselines/reference/typeFromPropertyAssignment26.types b/tests/baselines/reference/typeFromPropertyAssignment26.types index a6bc4783488..dc01eed98d8 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment26.types +++ b/tests/baselines/reference/typeFromPropertyAssignment26.types @@ -13,9 +13,9 @@ UI.TreeElement = class { constructor() { this.treeOutline = 12 >this.treeOutline = 12 : 12 ->this.treeOutline : number +>this.treeOutline : any >this : this ->treeOutline : number +>treeOutline : any >12 : 12 } }; diff --git a/tests/baselines/reference/typeFromPropertyAssignment28.types b/tests/baselines/reference/typeFromPropertyAssignment28.types index dc25e6426be..a84ea102a87 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment28.types +++ b/tests/baselines/reference/typeFromPropertyAssignment28.types @@ -3,9 +3,9 @@ class C { constructor() { this.p = 1; } } >C : C >this.p = 1 : 1 ->this.p : number +>this.p : any >this : this ->p : number +>p : any >1 : 1 // Property assignment does nothing. diff --git a/tests/baselines/reference/typeFromPropertyAssignment3.types b/tests/baselines/reference/typeFromPropertyAssignment3.types index 3c3e34b518a..510296439c8 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment3.types +++ b/tests/baselines/reference/typeFromPropertyAssignment3.types @@ -22,9 +22,9 @@ Outer.Inner = class I { constructor() { this.x = 1 >this.x = 1 : 1 ->this.x : number +>this.x : any >this : this ->x : number +>x : any >1 : 1 } } diff --git a/tests/baselines/reference/typeFromPropertyAssignment35.types b/tests/baselines/reference/typeFromPropertyAssignment35.types index 4eebf48bbc1..78f1dfd6224 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment35.types +++ b/tests/baselines/reference/typeFromPropertyAssignment35.types @@ -34,9 +34,9 @@ Emu.D = class { constructor() { this._model = 1 >this._model = 1 : 1 ->this._model : number +>this._model : any >this : this ->_model : number +>_model : any >1 : 1 } } diff --git a/tests/baselines/reference/typeFromPrototypeAssignment.types b/tests/baselines/reference/typeFromPrototypeAssignment.types index 1e8aee1e1ba..b6d501697a5 100644 --- a/tests/baselines/reference/typeFromPrototypeAssignment.types +++ b/tests/baselines/reference/typeFromPrototypeAssignment.types @@ -8,9 +8,9 @@ var Multimap = function() { this._map = {}; >this._map = {} : {} ->this._map : {} +>this._map : any >this : this ->_map : {} +>_map : any >{} : {} this._map diff --git a/tests/baselines/reference/typeFromPrototypeAssignment2.types b/tests/baselines/reference/typeFromPrototypeAssignment2.types index 1a484ba8fc8..5f26d98200a 100644 --- a/tests/baselines/reference/typeFromPrototypeAssignment2.types +++ b/tests/baselines/reference/typeFromPrototypeAssignment2.types @@ -13,9 +13,9 @@ this._map = {}; >this._map = {} : {} ->this._map : {} +>this._map : any >this : this ->_map : {} +>_map : any >{} : {} this._map diff --git a/tests/baselines/reference/varRequireFromJavascript.types b/tests/baselines/reference/varRequireFromJavascript.types index 7537eecb639..f6ef20d1a15 100644 --- a/tests/baselines/reference/varRequireFromJavascript.types +++ b/tests/baselines/reference/varRequireFromJavascript.types @@ -44,9 +44,9 @@ export class Crunch { this.n = n >this.n = n : number ->this.n : number +>this.n : any >this : this ->n : number +>n : any >n : number } m() { From d9ad27f2dd17cc1413b7d442d2915b13e0347d3e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 28 Apr 2020 17:02:52 -0700 Subject: [PATCH 71/74] Early couldContainTypeVariables check in instantiateType (#37844) * Shared early couldContainTypeVariables check in instantiateType * Defer creation of map object in createUnionOrIntersectionProperty * Types with top-level non-generic type alias reference no type variables --- src/compiler/checker.ts | 81 ++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7723d2b7c25..f24f8b93d1a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10523,7 +10523,8 @@ namespace ts { } function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined { - const propSet = createMap(); + let singleProp: Symbol | undefined; + let propSet: Map | undefined; let indexTypes: Type[] | undefined; const isUnion = containingType.flags & TypeFlags.Union; const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0; @@ -10543,9 +10544,18 @@ namespace ts { else { optionalFlag &= prop.flags; } - const id = "" + getSymbolId(prop); - if (!propSet.has(id)) { - propSet.set(id, prop); + if (!singleProp) { + singleProp = prop; + } + else if (prop !== singleProp) { + if (!propSet) { + propSet = createMap(); + propSet.set("" + getSymbolId(singleProp), singleProp); + } + const id = "" + getSymbolId(prop); + if (!propSet.has(id)) { + propSet.set(id, prop); + } } checkFlags |= (isReadonlySymbol(prop) ? CheckFlags.Readonly : 0) | (!(modifiers & ModifierFlags.NonPublicAccessibilityModifier) ? CheckFlags.ContainsPublic : 0) | @@ -10572,13 +10582,13 @@ namespace ts { } } } - if (!propSet.size) { + if (!singleProp) { return undefined; } - const props = arrayFrom(propSet.values()); - if (props.length === 1 && !(checkFlags & CheckFlags.ReadPartial) && !indexTypes) { - return props[0]; + if (!propSet && !(checkFlags & CheckFlags.ReadPartial) && !indexTypes) { + return singleProp; } + const props = propSet ? arrayFrom(propSet.values()) : [singleProp]; let declarations: Declaration[] | undefined; let firstType: Type | undefined; let nameType: Type | undefined; @@ -14275,7 +14285,7 @@ namespace ts { function instantiateType(type: Type, mapper: TypeMapper | undefined): Type; function instantiateType(type: Type | undefined, mapper: TypeMapper | undefined): Type | undefined; function instantiateType(type: Type | undefined, mapper: TypeMapper | undefined): Type | undefined { - if (!type || !mapper) { + if (!(type && mapper && couldContainTypeVariables(type))) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { @@ -14311,37 +14321,23 @@ namespace ts { } if (flags & TypeFlags.Object) { const objectFlags = (type).objectFlags; - if (objectFlags & ObjectFlags.Anonymous) { - // If the anonymous type originates in a declaration of a function, method, class, or - // interface, in an object type literal, or in an object literal expression, we may need - // to instantiate the type because it might reference a type parameter. - return couldContainTypeVariables(type) ? - getObjectTypeInstantiation(type, mapper) : type; - } - if (objectFlags & ObjectFlags.Mapped) { - return getObjectTypeInstantiation(type, mapper); - } - if (objectFlags & ObjectFlags.Reference) { - if ((type).node) { - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & (ObjectFlags.Reference | ObjectFlags.Anonymous | ObjectFlags.Mapped)) { + if (objectFlags & ObjectFlags.Reference && !((type).node)) { + const resolvedTypeArguments = (type).resolvedTypeArguments; + const newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference((type).target, newTypeArguments) : type; } - const resolvedTypeArguments = (type).resolvedTypeArguments; - const newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); - return newTypeArguments !== resolvedTypeArguments ? createTypeReference((type).target, newTypeArguments) : type; + return getObjectTypeInstantiation(type, mapper); } return type; } - if ((flags & TypeFlags.Intersection) || (flags & TypeFlags.Union && !(flags & TypeFlags.Primitive))) { - if (!couldContainTypeVariables(type)) { - return type; - } + if (flags & TypeFlags.UnionOrIntersection) { const types = (type).types; const newTypes = instantiateTypes(types, mapper); - return newTypes === types - ? type - : (flags & TypeFlags.Intersection) - ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) - : getUnionType(newTypes, UnionReduction.Literal, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + return newTypes === types ? type : + flags & TypeFlags.Intersection ? + getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : + getUnionType(newTypes, UnionReduction.Literal, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (flags & TypeFlags.Index) { return getIndexType(instantiateType((type).type, mapper)); @@ -18388,16 +18384,25 @@ namespace ts { return !!(objectFlags & ObjectFlags.CouldContainTypeVariables); } const result = !!(type.flags & TypeFlags.Instantiable || - objectFlags & ObjectFlags.Reference && ((type).node || forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && type.symbol.declarations || - objectFlags & (ObjectFlags.Mapped | ObjectFlags.ObjectRestType) || - type.flags & TypeFlags.UnionOrIntersection && !(type.flags & TypeFlags.EnumLiteral) && some((type).types, couldContainTypeVariables)); + type.flags & TypeFlags.Object && !isNonGenericTopLevelType(type) && ( + objectFlags & ObjectFlags.Reference && ((type).node || forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && type.symbol.declarations || + objectFlags & (ObjectFlags.Mapped | ObjectFlags.ObjectRestType)) || + type.flags & TypeFlags.UnionOrIntersection && !(type.flags & TypeFlags.EnumLiteral) && !isNonGenericTopLevelType(type) && some((type).types, couldContainTypeVariables)); if (type.flags & TypeFlags.ObjectFlagsType) { (type).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed | (result ? ObjectFlags.CouldContainTypeVariables : 0); } return result; } + function isNonGenericTopLevelType(type: Type) { + if (type.aliasSymbol && !type.aliasTypeArguments) { + const declaration = getDeclarationOfKind(type.aliasSymbol, SyntaxKind.TypeAliasDeclaration); + return !!(declaration && findAncestor(declaration.parent, n => n.kind === SyntaxKind.SourceFile ? true : n.kind === SyntaxKind.ModuleDeclaration ? false : "quit")); + } + return false; + } + function isTypeParameterAtTopLevel(type: Type, typeParameter: TypeParameter): boolean { return !!(type === typeParameter || type.flags & TypeFlags.UnionOrIntersection && some((type).types, t => isTypeParameterAtTopLevel(t, typeParameter)) || From 0258db221068f096537540fa0e791a32861c3128 Mon Sep 17 00:00:00 2001 From: Orta Date: Wed, 29 Apr 2020 10:35:33 -0400 Subject: [PATCH 72/74] Adds support for looking up past Blocks in expando objects (#38031) * Adds support for looking up past Blocks in expando objects * Adds JS tests to validate the JS parsing also works * Get the top level block expando tests green --- src/compiler/binder.ts | 4 +- src/compiler/utilities.ts | 2 +- .../reference/topLevelBlockExpando.symbols | 100 ++++++++++++++ .../reference/topLevelBlockExpando.types | 123 ++++++++++++++++++ tests/cases/compiler/topLevelBlockExpando.ts | 49 +++++++ 5 files changed, 275 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/topLevelBlockExpando.symbols create mode 100644 tests/baselines/reference/topLevelBlockExpando.types create mode 100644 tests/cases/compiler/topLevelBlockExpando.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 7d3e4af6765..3ea8df0a839 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2964,7 +2964,7 @@ namespace ts { function bindSpecialPropertyAssignment(node: BindablePropertyAssignmentExpression) { // Class declarations in Typescript do not allow property declarations - const parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); + const parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer) ; if (!isInJSFile(node) && !isFunctionSymbol(parentSymbol)) { return; } @@ -3073,7 +3073,7 @@ namespace ts { } function bindPropertyAssignment(name: BindableStaticNameExpression, propertyAccess: BindableStaticAccessExpression, isPrototypeProperty: boolean, containerIsClass: boolean) { - let namespaceSymbol = lookupSymbolForPropertyAccess(name); + let namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); const isToplevel = isTopLevelNamespaceAssignment(propertyAccess); namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 97231acf60b..9452910feec 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2016,7 +2016,7 @@ namespace ts { /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). - * We treat the right hand side of assignments with container-like initalizers as declarations. + * We treat the right hand side of assignments with container-like initializers as declarations. */ export function getAssignedExpandoInitializer(node: Node | undefined): Expression | undefined { if (node && node.parent && isBinaryExpression(node.parent) && node.parent.operatorToken.kind === SyntaxKind.EqualsToken) { diff --git a/tests/baselines/reference/topLevelBlockExpando.symbols b/tests/baselines/reference/topLevelBlockExpando.symbols new file mode 100644 index 00000000000..f9f2944cc9b --- /dev/null +++ b/tests/baselines/reference/topLevelBlockExpando.symbols @@ -0,0 +1,100 @@ +=== tests/cases/compiler/check.ts === +// https://github.com/microsoft/TypeScript/issues/31972 + + + +// https://github.com/microsoft/TypeScript/issues/31972 +interface Person { +>Person : Symbol(Person, Decl(check.ts, 0, 0)) + + first: string; +>first : Symbol(Person.first, Decl(check.ts, 5, 18)) + + last: string; +>last : Symbol(Person.last, Decl(check.ts, 6, 16)) +} + +{ + const dice = () => Math.floor(Math.random() * 6); +>dice : Symbol(dice, Decl(check.ts, 11, 7)) +>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + dice.first = 'Rando'; +>dice.first : Symbol(dice.first, Decl(check.ts, 11, 51)) +>dice : Symbol(dice, Decl(check.ts, 11, 7)) +>first : Symbol(dice.first, Decl(check.ts, 11, 51)) + + dice.last = 'Calrissian'; +>dice.last : Symbol(dice.last, Decl(check.ts, 12, 23)) +>dice : Symbol(dice, Decl(check.ts, 11, 7)) +>last : Symbol(dice.last, Decl(check.ts, 12, 23)) + + const diceP: Person = dice; +>diceP : Symbol(diceP, Decl(check.ts, 14, 7)) +>Person : Symbol(Person, Decl(check.ts, 0, 0)) +>dice : Symbol(dice, Decl(check.ts, 11, 7)) +} + +=== tests/cases/compiler/check.js === +// Creates a type { first:string, last: string } +/** + * @typedef {Object} Human - creates a new type named 'SpecialType' + * @property {string} first - a string property of SpecialType + * @property {string} last - a number property of SpecialType + */ + +/** + * @param {Human} param used as a validation tool + */ +function doHumanThings(param) {} +>doHumanThings : Symbol(doHumanThings, Decl(check.js, 0, 0)) +>param : Symbol(param, Decl(check.js, 10, 23)) + +const dice1 = () => Math.floor(Math.random() * 6); +>dice1 : Symbol(dice1, Decl(check.js, 12, 5), Decl(check.js, 12, 50)) +>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + +// dice1.first = 'Rando'; +dice1.last = 'Calrissian'; +>dice1.last : Symbol(dice1.last, Decl(check.js, 12, 50)) +>dice1 : Symbol(dice1, Decl(check.js, 12, 5), Decl(check.js, 12, 50)) +>last : Symbol(dice1.last, Decl(check.js, 12, 50)) + +// doHumanThings(dice) + +// but inside a block... you can't call a human +{ + const dice2 = () => Math.floor(Math.random() * 6); +>dice2 : Symbol(dice2, Decl(check.js, 20, 7)) +>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) +>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) + + dice2.first = 'Rando'; +>dice2.first : Symbol(dice2.first, Decl(check.js, 20, 52)) +>dice2 : Symbol(dice2, Decl(check.js, 20, 7)) +>first : Symbol(dice2.first, Decl(check.js, 20, 52)) + + dice2.last = 'Calrissian'; +>dice2.last : Symbol(dice2.last, Decl(check.js, 21, 24)) +>dice2 : Symbol(dice2, Decl(check.js, 20, 7)) +>last : Symbol(dice2.last, Decl(check.js, 21, 24)) + + doHumanThings(dice2) +>doHumanThings : Symbol(doHumanThings, Decl(check.js, 0, 0)) +>dice2 : Symbol(dice2, Decl(check.js, 20, 7)) +} + diff --git a/tests/baselines/reference/topLevelBlockExpando.types b/tests/baselines/reference/topLevelBlockExpando.types new file mode 100644 index 00000000000..a8bd928ef29 --- /dev/null +++ b/tests/baselines/reference/topLevelBlockExpando.types @@ -0,0 +1,123 @@ +=== tests/cases/compiler/check.ts === +// https://github.com/microsoft/TypeScript/issues/31972 + + + +// https://github.com/microsoft/TypeScript/issues/31972 +interface Person { + first: string; +>first : string + + last: string; +>last : string +} + +{ + const dice = () => Math.floor(Math.random() * 6); +>dice : { (): number; first: string; last: string; } +>() => Math.floor(Math.random() * 6) : { (): number; first: string; last: string; } +>Math.floor(Math.random() * 6) : number +>Math.floor : (x: number) => number +>Math : Math +>floor : (x: number) => number +>Math.random() * 6 : number +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>6 : 6 + + dice.first = 'Rando'; +>dice.first = 'Rando' : "Rando" +>dice.first : string +>dice : { (): number; first: string; last: string; } +>first : string +>'Rando' : "Rando" + + dice.last = 'Calrissian'; +>dice.last = 'Calrissian' : "Calrissian" +>dice.last : string +>dice : { (): number; first: string; last: string; } +>last : string +>'Calrissian' : "Calrissian" + + const diceP: Person = dice; +>diceP : Person +>dice : { (): number; first: string; last: string; } +} + +=== tests/cases/compiler/check.js === +// Creates a type { first:string, last: string } +/** + * @typedef {Object} Human - creates a new type named 'SpecialType' + * @property {string} first - a string property of SpecialType + * @property {string} last - a number property of SpecialType + */ + +/** + * @param {Human} param used as a validation tool + */ +function doHumanThings(param) {} +>doHumanThings : (param: Human) => void +>param : Human + +const dice1 = () => Math.floor(Math.random() * 6); +>dice1 : { (): number; last: string; } +>() => Math.floor(Math.random() * 6) : { (): number; last: string; } +>Math.floor(Math.random() * 6) : number +>Math.floor : (x: number) => number +>Math : Math +>floor : (x: number) => number +>Math.random() * 6 : number +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>6 : 6 + +// dice1.first = 'Rando'; +dice1.last = 'Calrissian'; +>dice1.last = 'Calrissian' : "Calrissian" +>dice1.last : string +>dice1 : { (): number; last: string; } +>last : string +>'Calrissian' : "Calrissian" + +// doHumanThings(dice) + +// but inside a block... you can't call a human +{ + const dice2 = () => Math.floor(Math.random() * 6); +>dice2 : { (): number; first: string; last: string; } +>() => Math.floor(Math.random() * 6) : { (): number; first: string; last: string; } +>Math.floor(Math.random() * 6) : number +>Math.floor : (x: number) => number +>Math : Math +>floor : (x: number) => number +>Math.random() * 6 : number +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number +>6 : 6 + + dice2.first = 'Rando'; +>dice2.first = 'Rando' : "Rando" +>dice2.first : string +>dice2 : { (): number; first: string; last: string; } +>first : string +>'Rando' : "Rando" + + dice2.last = 'Calrissian'; +>dice2.last = 'Calrissian' : "Calrissian" +>dice2.last : string +>dice2 : { (): number; first: string; last: string; } +>last : string +>'Calrissian' : "Calrissian" + + doHumanThings(dice2) +>doHumanThings(dice2) : void +>doHumanThings : (param: Human) => void +>dice2 : { (): number; first: string; last: string; } +} + diff --git a/tests/cases/compiler/topLevelBlockExpando.ts b/tests/cases/compiler/topLevelBlockExpando.ts new file mode 100644 index 00000000000..35f758d0407 --- /dev/null +++ b/tests/cases/compiler/topLevelBlockExpando.ts @@ -0,0 +1,49 @@ +// https://github.com/microsoft/TypeScript/issues/31972 + +// @allowJs: true +// @noEmit: true +// @checkJs: true + +// @filename: check.ts + +// https://github.com/microsoft/TypeScript/issues/31972 +interface Person { + first: string; + last: string; +} + +{ + const dice = () => Math.floor(Math.random() * 6); + dice.first = 'Rando'; + dice.last = 'Calrissian'; + const diceP: Person = dice; +} + +// @filename: check.js + +// Creates a type { first:string, last: string } +/** + * @typedef {Object} Human - creates a new type named 'SpecialType' + * @property {string} first - a string property of SpecialType + * @property {string} last - a number property of SpecialType + */ + +/** + * @param {Human} param used as a validation tool + */ +function doHumanThings(param) {} + +const dice1 = () => Math.floor(Math.random() * 6); +// dice1.first = 'Rando'; +dice1.last = 'Calrissian'; + +// doHumanThings(dice) + +// but inside a block... you can't call a human +{ + const dice2 = () => Math.floor(Math.random() * 6); + dice2.first = 'Rando'; + dice2.last = 'Calrissian'; + + doHumanThings(dice2) +} From 6916387597705d228009fb604e367ac69309a71a Mon Sep 17 00:00:00 2001 From: csigs Date: Wed, 29 Apr 2020 16:10:44 +0000 Subject: [PATCH 73/74] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 42 +++++++++---- .../diagnosticMessages.generated.json.lcl | 51 ++++++++++++---- .../diagnosticMessages.generated.json.lcl | 42 +++++++++---- .../diagnosticMessages.generated.json.lcl | 53 ++++++++++------ .../diagnosticMessages.generated.json.lcl | 34 ++++++----- .../diagnosticMessages.generated.json.lcl | 40 +++++++----- .../diagnosticMessages.generated.json.lcl | 40 +++++++----- .../diagnosticMessages.generated.json.lcl | 48 +++++++++++---- .../diagnosticMessages.generated.json.lcl | 51 ++++++++++++---- .../diagnosticMessages.generated.json.lcl | 61 +++++++++++++------ .../diagnosticMessages.generated.json.lcl | 42 +++++++++---- .../diagnosticMessages.generated.json.lcl | 61 +++++++++++++------ .../diagnosticMessages.generated.json.lcl | 47 +++++++++----- 13 files changed, 429 insertions(+), 183 deletions(-) diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index d5e8c5cbdd1..e5a2a757fdb 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3642,6 +3642,15 @@
+ + + + + + + + + @@ -5832,15 +5841,6 @@ - - - - - - - - - @@ -7458,11 +7458,20 @@ - + - + - + + + + + + + + + + @@ -10554,6 +10563,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index 4f39a5a9347..d0ffb452051 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3642,6 +3642,15 @@ + + + + + + + + + @@ -5832,15 +5841,6 @@ - - - - - - - - - @@ -7458,11 +7458,20 @@ - + - + - + + + + + + + + + + @@ -10197,6 +10206,15 @@ + + + + + + + + + @@ -10545,6 +10563,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index a9eebf3b5b4..09404902518 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3651,6 +3651,15 @@ + + + + + + + + + @@ -5841,15 +5850,6 @@ - - - - - - - - - @@ -7467,11 +7467,20 @@ - + - + - + + + + + + + + + + @@ -10563,6 +10572,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 4a84ecc9ba8..b5e89f69064 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1177,7 +1177,7 @@ - + @@ -3190,7 +3190,7 @@ - + @@ -3639,6 +3639,12 @@ + + + + + + @@ -5638,7 +5644,7 @@ - + @@ -5829,15 +5835,6 @@ - - - - - - - - - @@ -7455,11 +7452,17 @@ - + - + + + + + + + - + @@ -10191,6 +10194,12 @@ + + + + + + @@ -10315,7 +10324,7 @@ - + @@ -10539,6 +10548,12 @@ + + + + + + @@ -10762,7 +10777,7 @@ - + @@ -10771,7 +10786,7 @@ - + @@ -11110,7 +11125,7 @@ - + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 439b7e2aff7..411ec179f3b 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3654,6 +3654,12 @@ + + + + + + @@ -5844,15 +5850,6 @@ - - - - - - - - - @@ -7470,12 +7467,15 @@ - + - - - - + + + + + + + @@ -10566,6 +10566,12 @@ + + + + + + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 0fed2ad218d..d00240f877a 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3654,6 +3654,12 @@ + + + + + + @@ -5844,15 +5850,6 @@ - - - - - - - - - @@ -7470,12 +7467,15 @@ - + - - - - + + + + + + + @@ -10209,6 +10209,12 @@ + + + + + + @@ -10557,6 +10563,12 @@ + + + + + + diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index 88cd2ac3e74..9c4d82045cb 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3642,6 +3642,12 @@ + + + + + + @@ -5832,15 +5838,6 @@ - - - - - - - - - @@ -7458,12 +7455,15 @@ - + - - - - + + + + + + + @@ -10197,6 +10197,12 @@ + + + + + + @@ -10545,6 +10551,12 @@ + + + + + + diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 563b2b5a06b..9f8615ab39c 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3642,6 +3642,15 @@ + + + + + + + + + @@ -5832,15 +5841,6 @@ - - - - - - - - - @@ -7458,11 +7458,20 @@ - + - + - + + + + + + + + + + @@ -10197,6 +10206,12 @@ + + + + + + @@ -10545,6 +10560,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 163d872a609..f4e76e9b75c 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3642,6 +3642,15 @@ + + + + + + + + + @@ -5832,15 +5841,6 @@ - - - - - - - - - @@ -7458,11 +7458,20 @@ - + - + - + + + + + + + + + + @@ -10197,6 +10206,15 @@ + + + + + + + + + @@ -10545,6 +10563,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index abb6254bdc0..6bb8f080d26 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -429,7 +429,7 @@ - + @@ -3183,7 +3183,7 @@ - + @@ -3632,6 +3632,15 @@ + + + + + + + + + @@ -5822,15 +5831,6 @@ - - - - - - - - - @@ -7398,7 +7398,7 @@ - + @@ -7448,11 +7448,20 @@ - + - + - + + + + + + + + + + @@ -10184,6 +10193,15 @@ + + + + + + + + + @@ -10532,6 +10550,15 @@ + + + + + + + + + @@ -10764,7 +10791,7 @@ - + @@ -11664,7 +11691,7 @@ - + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 89a10086f4c..79ab9ca04d7 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3635,6 +3635,15 @@ + + + + + + + + + @@ -5825,15 +5834,6 @@ - - - - - - - - - @@ -7451,11 +7451,20 @@ - + - + - + + + + + + + + + + @@ -10544,6 +10553,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index 4861b65f463..4b60684dca3 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1179,7 +1179,7 @@ - + @@ -3641,6 +3641,15 @@ + + + + + + + + + @@ -5640,7 +5649,7 @@ - + @@ -5831,15 +5840,6 @@ - - - - - - - - - @@ -7457,11 +7457,20 @@ - + - + - + + + + + + + + + + @@ -10196,6 +10205,15 @@ + + + + + + + + + @@ -10544,6 +10562,15 @@ + + + + + + + + + @@ -10767,7 +10794,7 @@ - + @@ -11115,7 +11142,7 @@ - + @@ -11676,7 +11703,7 @@ - + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 0ad845dcd28..e595742e66b 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3635,6 +3635,12 @@ + + + + + + @@ -5825,15 +5831,6 @@ - - - - - - - - - @@ -7401,7 +7398,7 @@ - + @@ -7451,12 +7448,15 @@ - + - - - - + + + + + + + @@ -10190,6 +10190,15 @@ + + + + + + + + + @@ -10538,6 +10547,12 @@ + + + + + + @@ -11109,7 +11124,7 @@ - + From 10fd1fa347fe51d040d586f2064bd1403d3c8dd9 Mon Sep 17 00:00:00 2001 From: csigs Date: Wed, 29 Apr 2020 22:10:59 +0000 Subject: [PATCH 74/74] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index b5e89f69064..2021e5c7201 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -3642,6 +3642,9 @@ + + + @@ -7455,6 +7458,9 @@ + + + @@ -10197,6 +10203,9 @@ + + + @@ -10551,6 +10560,9 @@ + + +