From a4faf75fb8189d268541017def51aa6be85da45b Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 25 Sep 2023 08:56:05 -0700 Subject: [PATCH 1/8] Add test --- .../declarationEmitBindingPatterns2.js | 16 ++++++++++++++ .../declarationEmitBindingPatterns2.symbols | 17 +++++++++++++++ .../declarationEmitBindingPatterns2.types | 21 +++++++++++++++++++ .../declarationEmitBindingPatterns2.ts | 11 ++++++++++ 4 files changed, 65 insertions(+) create mode 100644 tests/baselines/reference/declarationEmitBindingPatterns2.js create mode 100644 tests/baselines/reference/declarationEmitBindingPatterns2.symbols create mode 100644 tests/baselines/reference/declarationEmitBindingPatterns2.types create mode 100644 tests/cases/compiler/declarationEmitBindingPatterns2.ts diff --git a/tests/baselines/reference/declarationEmitBindingPatterns2.js b/tests/baselines/reference/declarationEmitBindingPatterns2.js new file mode 100644 index 0000000000000..8abcd2dd9a052 --- /dev/null +++ b/tests/baselines/reference/declarationEmitBindingPatterns2.js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/declarationEmitBindingPatterns2.ts] //// + +//// [declarationEmitBindingPatterns2.ts] +// https://github.com/microsoft/TypeScript/issues/55439 + +function foo(): { y: 1 } { + return { y: 1 }; +} + +export const { y = 0 } = foo(); + + + + +//// [declarationEmitBindingPatterns2.d.ts] +export declare const y: number; diff --git a/tests/baselines/reference/declarationEmitBindingPatterns2.symbols b/tests/baselines/reference/declarationEmitBindingPatterns2.symbols new file mode 100644 index 0000000000000..1e34957ac35cc --- /dev/null +++ b/tests/baselines/reference/declarationEmitBindingPatterns2.symbols @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/declarationEmitBindingPatterns2.ts] //// + +=== declarationEmitBindingPatterns2.ts === +// https://github.com/microsoft/TypeScript/issues/55439 + +function foo(): { y: 1 } { +>foo : Symbol(foo, Decl(declarationEmitBindingPatterns2.ts, 0, 0)) +>y : Symbol(y, Decl(declarationEmitBindingPatterns2.ts, 2, 17)) + + return { y: 1 }; +>y : Symbol(y, Decl(declarationEmitBindingPatterns2.ts, 3, 10)) +} + +export const { y = 0 } = foo(); +>y : Symbol(y, Decl(declarationEmitBindingPatterns2.ts, 6, 14)) +>foo : Symbol(foo, Decl(declarationEmitBindingPatterns2.ts, 0, 0)) + diff --git a/tests/baselines/reference/declarationEmitBindingPatterns2.types b/tests/baselines/reference/declarationEmitBindingPatterns2.types new file mode 100644 index 0000000000000..dbc15e51059c1 --- /dev/null +++ b/tests/baselines/reference/declarationEmitBindingPatterns2.types @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/declarationEmitBindingPatterns2.ts] //// + +=== declarationEmitBindingPatterns2.ts === +// https://github.com/microsoft/TypeScript/issues/55439 + +function foo(): { y: 1 } { +>foo : () => { y: 1;} +>y : 1 + + return { y: 1 }; +>{ y: 1 } : { y: 1; } +>y : 1 +>1 : 1 +} + +export const { y = 0 } = foo(); +>y : 1 | 0 +>0 : 0 +>foo() : { y: 1; } +>foo : () => { y: 1; } + diff --git a/tests/cases/compiler/declarationEmitBindingPatterns2.ts b/tests/cases/compiler/declarationEmitBindingPatterns2.ts new file mode 100644 index 0000000000000..1d43c3639cb0a --- /dev/null +++ b/tests/cases/compiler/declarationEmitBindingPatterns2.ts @@ -0,0 +1,11 @@ +// @strict: true +// @declaration: true +// @emitDeclarationOnly: true + +// https://github.com/microsoft/TypeScript/issues/55439 + +function foo(): { y: 1 } { + return { y: 1 }; +} + +export const { y = 0 } = foo(); From bf925fb2938bcfcc8d8ddb59d0c353b09d988da5 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:41:39 -0700 Subject: [PATCH 2/8] Add horrible probably wrong check --- src/compiler/checker.ts | 66 ++++++ src/compiler/diagnosticMessages.json | 4 + .../reference/ambientConstLiterals.errors.txt | 30 +++ ...ileExportAssignmentImportInternalModule.js | 14 -- ...ationEmitImportInExportAssignmentModule.js | 6 - tests/baselines/reference/es6ExportClause.js | 1 - .../reference/es6ExportClauseInEs5.js | 1 - .../importCallExpression5ES2020.errors.txt | 5 +- ...onalPropertiesToIndexSignatures.errors.txt | 31 +++ ...ortTypeReferenceToStringLiteral.errors.txt | 12 ++ .../reference/literalTypes2.errors.txt | 188 ++++++++++++++++ .../nullishCoalescingOperator2.errors.txt | 41 ++++ .../nullishCoalescingOperator3.errors.txt | 16 ++ .../nullishCoalescingOperator7.errors.txt | 21 ++ ...ullishCoalescingOperator_es2020.errors.txt | 59 +++++ ...shCoalescingOperator_not_strict.errors.txt | 41 ++++ .../privacyCheckTypeOfInvisibleModuleError.js | 19 +- ...rivacyCheckTypeOfInvisibleModuleNoError.js | 19 +- tests/baselines/reference/privacyGloImport.js | 102 ++++++++- .../reference/privacyGloImportParseErrors.js | 5 - tests/baselines/reference/privacyImport.js | 78 ++++++- ...yLocalInternalReferenceImportWithExport.js | 122 +++++++++-- ...calInternalReferenceImportWithoutExport.js | 91 ++++++-- ...pLevelInternalReferenceImportWithExport.js | 120 +++++++++-- ...velInternalReferenceImportWithoutExport.js | 89 ++++++-- .../baselines/reference/privacyVarDeclFile.js | 203 ++++++++++++++---- .../reference/strictFunctionTypes1.errors.txt | 56 +++++ .../stringLiteralTypesOverloads02.errors.txt | 65 ++++++ 28 files changed, 1348 insertions(+), 157 deletions(-) create mode 100644 tests/baselines/reference/ambientConstLiterals.errors.txt create mode 100644 tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.errors.txt create mode 100644 tests/baselines/reference/jsdocImportTypeReferenceToStringLiteral.errors.txt create mode 100644 tests/baselines/reference/literalTypes2.errors.txt create mode 100644 tests/baselines/reference/nullishCoalescingOperator2.errors.txt create mode 100644 tests/baselines/reference/nullishCoalescingOperator3.errors.txt create mode 100644 tests/baselines/reference/nullishCoalescingOperator7.errors.txt create mode 100644 tests/baselines/reference/nullishCoalescingOperator_es2020.errors.txt create mode 100644 tests/baselines/reference/nullishCoalescingOperator_not_strict.errors.txt create mode 100644 tests/baselines/reference/strictFunctionTypes1.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0991030bff6cc..2ee2548450da0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -875,6 +875,7 @@ import { ObjectLiteralElementLike, ObjectLiteralExpression, ObjectType, + OmittedExpression, OptionalChain, OptionalTypeNode, or, @@ -41954,6 +41955,71 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } checkCollisionsForDeclarationName(node, node.name); } + + // TODO(jakebailey): copy pasted from declaration.ts; improve + type CanHaveLiteralInitializer = VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration; + function canHaveLiteralInitializer(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + return !hasEffectiveModifier(node, ModifierFlags.Private); + case SyntaxKind.Parameter: + case SyntaxKind.VariableDeclaration: + return true; + } + return false; + } + + function shouldPrintWithInitializer(node: Node) { + return canHaveLiteralInitializer(node) && isLiteralConstDeclaration(node as CanHaveLiteralInitializer); // TODO: Make safe + } + + function getBindingNameVisible(elem: BindingElement | VariableDeclaration | OmittedExpression): boolean { + if (isOmittedExpression(elem)) { + return false; + } + if (isBindingPattern(elem.name)) { + // If any child binding pattern element has been marked visible (usually by collect linked aliases), then this is visible + return some(elem.name.elements, getBindingNameVisible); + } + else { + return isDeclarationVisible(elem); + } + } + + function isDeclarationAndNotVisible(node: NamedDeclaration) { + switch (node.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.EnumDeclaration: + return !isDeclarationVisible(node); + // The following should be doing their own visibility checks based on filtering their members + case SyntaxKind.VariableDeclaration: + return !getBindingNameVisible(node as VariableDeclaration); + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ExportDeclaration: + case SyntaxKind.ExportAssignment: + return false; + case SyntaxKind.ClassStaticBlockDeclaration: + return true; + } + return false; + } + + if ( + !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) + && !shouldPrintWithInitializer(node) + && !isDeclarationAndNotVisible(node) + ) { + const widenedLiteralType = getWidenedLiteralType(type); + if (!isTypeIdenticalTo(type, widenedLiteralType)) { + error(node.name, Diagnostics.The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1, typeToString(widenedLiteralType), typeToString(type)); + } + } } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration: Declaration | undefined, firstType: Type, nextDeclaration: Declaration, nextType: Type): void { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 68d87f7d28b57..7ddf9523d34fa 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3667,6 +3667,10 @@ "category": "Error", "code": 2855 }, + "The type of this declaration is ambiguous and may be observed as either '{0}' or '{1}'.": { + "category": "Error", + "code": 2856 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/ambientConstLiterals.errors.txt b/tests/baselines/reference/ambientConstLiterals.errors.txt new file mode 100644 index 0000000000000..40977191c9ef5 --- /dev/null +++ b/tests/baselines/reference/ambientConstLiterals.errors.txt @@ -0,0 +1,30 @@ +ambientConstLiterals.ts(20,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"abc" | "def"'. +ambientConstLiterals.ts(21,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '123 | 456'. + + +==== ambientConstLiterals.ts (2 errors) ==== + function f(x: T): T { + return x; + } + + enum E { A, B, C, "non identifier" } + + const c1 = "abc"; + const c2 = 123; + const c3 = c1; + const c4 = c2; + const c5 = f(123); + const c6 = f(-123); + const c7 = true; + const c8 = E.A; + const c8b = E["non identifier"]; + const c9 = { x: "abc" }; + const c10 = [123]; + const c11 = "abc" + "def"; + const c12 = 123 + 456; + const c13 = Math.random() > 0.5 ? "abc" : "def"; + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"abc" | "def"'. + const c14 = Math.random() > 0.5 ? 123 : 456; + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '123 | 456'. \ No newline at end of file diff --git a/tests/baselines/reference/declFileExportAssignmentImportInternalModule.js b/tests/baselines/reference/declFileExportAssignmentImportInternalModule.js index 10633bbae1e23..240ce9fe26655 100644 --- a/tests/baselines/reference/declFileExportAssignmentImportInternalModule.js +++ b/tests/baselines/reference/declFileExportAssignmentImportInternalModule.js @@ -34,20 +34,6 @@ module.exports = m; //// [declFileExportAssignmentImportInternalModule.d.ts] declare namespace m3 { - namespace m2 { - interface connectModule { - (res: any, req: any, next: any): void; - } - interface connectExport { - use: (mod: connectModule) => connectExport; - listen: (port: number) => void; - } - } - var server: { - (): m2.connectExport; - test1: m2.connectModule; - test2(): m2.connectModule; - }; } import m = m3; export = m; diff --git a/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js b/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js index 7f220e5ed5151..7466ba3b74bc1 100644 --- a/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js +++ b/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js @@ -30,11 +30,5 @@ module.exports = m; //// [declarationEmitImportInExportAssignmentModule.d.ts] declare namespace m { - namespace c { - class c { - } - } - import x = c; - var a: typeof x; } export = m; diff --git a/tests/baselines/reference/es6ExportClause.js b/tests/baselines/reference/es6ExportClause.js index eaf6536aafe4a..02ed12d099d94 100644 --- a/tests/baselines/reference/es6ExportClause.js +++ b/tests/baselines/reference/es6ExportClause.js @@ -37,7 +37,6 @@ declare class c { interface i { } declare namespace m { - var x: number; } declare var x: number; declare namespace uninstantiated { diff --git a/tests/baselines/reference/es6ExportClauseInEs5.js b/tests/baselines/reference/es6ExportClauseInEs5.js index b2d30fa7567a3..740bad51cc6b2 100644 --- a/tests/baselines/reference/es6ExportClauseInEs5.js +++ b/tests/baselines/reference/es6ExportClauseInEs5.js @@ -42,7 +42,6 @@ declare class c { interface i { } declare namespace m { - var x: number; } declare var x: number; declare namespace uninstantiated { diff --git a/tests/baselines/reference/importCallExpression5ES2020.errors.txt b/tests/baselines/reference/importCallExpression5ES2020.errors.txt index 703aceefef8fa..4768923043a6b 100644 --- a/tests/baselines/reference/importCallExpression5ES2020.errors.txt +++ b/tests/baselines/reference/importCallExpression5ES2020.errors.txt @@ -1,3 +1,4 @@ +2.ts(2,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | undefined' or '"./0" | undefined'. 2.ts(3,23): error TS7036: Dynamic import's specifier must be of type 'string', but here has type '"./0" | undefined'. 2.ts(4,24): error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'undefined'. 2.ts(5,24): error TS7036: Dynamic import's specifier must be of type 'string', but here has type '"./1" | null'. @@ -14,9 +15,11 @@ ==== 1.ts (0 errors) ==== export function backup() { return "backup"; } -==== 2.ts (4 errors) ==== +==== 2.ts (5 errors) ==== declare function bar(): boolean; const specify = bar() ? "./0" : undefined; + ~~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | undefined' or '"./0" | undefined'. let myModule = import(specify); ~~~~~~~ !!! error TS7036: Dynamic import's specifier must be of type 'string', but here has type '"./0" | undefined'. diff --git a/tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.errors.txt b/tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.errors.txt new file mode 100644 index 0000000000000..34598d58a5804 --- /dev/null +++ b/tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.errors.txt @@ -0,0 +1,31 @@ +inferenceOptionalPropertiesToIndexSignatures.ts(15,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | null' or '"value2" | null'. + + +==== inferenceOptionalPropertiesToIndexSignatures.ts (1 errors) ==== + declare function foo(obj: { [x: string]: T }): T; + + declare const x1: { a: string, b: number }; + declare const x2: { a: string, b: number | undefined }; + declare const x3: { a: string, b?: number }; + declare const x4: { a: string, b?: number | undefined }; + + let a1 = foo(x1); // string | number + let a2 = foo(x2); // string | number | undefined + let a3 = foo(x3); // string | number + let a4 = foo(x4); // string | number + + // Repro from #43045 + + const param2 = Math.random() < 0.5 ? 'value2' : null; + ~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | null' or '"value2" | null'. + + const obj = { + param1: 'value1', + ...(param2 ? {param2} : {}) + }; + + const query = Object.entries(obj).map( + ([k, v]) => `${k}=${encodeURIComponent(v)}` + ).join('&'); + \ No newline at end of file diff --git a/tests/baselines/reference/jsdocImportTypeReferenceToStringLiteral.errors.txt b/tests/baselines/reference/jsdocImportTypeReferenceToStringLiteral.errors.txt new file mode 100644 index 0000000000000..c365fa58510ee --- /dev/null +++ b/tests/baselines/reference/jsdocImportTypeReferenceToStringLiteral.errors.txt @@ -0,0 +1,12 @@ +a.js(2,5): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"foo"'. + + +==== b.js (0 errors) ==== + export const FOO = "foo"; + +==== a.js (1 errors) ==== + /** @type {import('./b').FOO} */ + let x; + ~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"foo"'. + \ No newline at end of file diff --git a/tests/baselines/reference/literalTypes2.errors.txt b/tests/baselines/reference/literalTypes2.errors.txt new file mode 100644 index 0000000000000..281b3b9c2e507 --- /dev/null +++ b/tests/baselines/reference/literalTypes2.errors.txt @@ -0,0 +1,188 @@ +literalTypes2.ts(155,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. +literalTypes2.ts(156,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or '1 | "two"'. + + +==== literalTypes2.ts (2 errors) ==== + enum E { + A, B, C + } + + let cond: boolean; + + function f1(p1 = 1, p2 = "abc", p3 = true, p4 = E.A) { + var v1 = 1; + var v2 = -123; + var v3 = 3 + 4; + var v4 = "abc"; + var v5 = ""; + var v6 = "abc" + "def"; + var v7 = true; + var v8 = E.A; + let x1 = 1; + let x2 = -123; + let x3 = 3 + 4; + let x4 = "abc"; + let x5 = ""; + let x6 = "abc" + "def"; + let x7 = true; + var x8 = E.A; + const c1 = 1; + const c2 = -123; + const c3 = 3 + 4; + const c4 = "abc"; + const c5 = ""; + const c6 = "abc" + "def"; + const c7 = true; + const c8 = E.A; + } + + function f2(p1: 1 = 1, p2: "abc" = "abc", p3: true = true, p4: E.A = E.A) { + var v1: 1 = 1; + var v2: -123 = -123; + var v3: "abc" = "abc"; + var v4: true = true; + var v5: E.A = E.A; + let x1: 1 = 1; + let x2: -123 = -123; + let x3: "abc" = "abc"; + let x4: true = true; + let x5: E.A = E.A; + } + + function f3() { + const c1 = cond ? 1 : 2; + const c2 = cond ? 1 : "two"; + const c3 = cond ? E.A : cond ? true : 123; + const c4 = cond ? "abc" : null; + const c5 = cond ? 456 : undefined; + const c6: { kind: 123 } = { kind: 123 }; + const c7: [1 | 2, "foo" | "bar"] = [1, "bar"]; + const c8 = cond ? c6 : cond ? c7 : "hello"; + let x1 = c1; + let x2 = c2; + let x3 = c3; + let x4 = c4; + let x5 = c5; + let x6 = c6; + let x7 = c7; + let x8 = c8; + } + + class C1 { + x1 = 1; + x2 = -123; + x3 = 3 + 4; + x4 = "abc"; + x5 = ""; + x6 = "abc" + "def"; + x7 = true; + x8 = E.A; + readonly c1 = 1; + readonly c2 = -123; + readonly c3 = 3 + 4; + readonly c4 = "abc"; + readonly c5 = ""; + readonly c6 = "abc" + "def"; + readonly c7 = true; + readonly c8 = E.A; + } + + function f4() { + const c1 = { a: 1, b: "foo" }; + const c2: { a : 0 | 1, b: "foo" | "bar" } = { a: 1, b: "foo" }; + let x1 = { a: 1, b: "foo" }; + let x2: { a : 0 | 1, b: "foo" | "bar" } = { a: 1, b: "foo" }; + } + + function f5() { + const c1 = [1, "foo"]; + const c2: (1 | "foo")[] = [1, "foo"]; + const c3: [1, "foo"] = [1, "foo"]; + let x1 = [1, "foo"]; + let x2: (1 | "foo")[] = [1, "foo"]; + let x3: [1, "foo"] = [1, "foo"]; + } + + function f6() { + const { c1 = true, c2 = 0, c3 = "foo" } = { c1: false, c2: 1, c3: "bar" }; + let { x1 = true, x2 = 0, x3 = "foo" } = { x1: false, x2: 1, x3: "bar" }; + } + + function f10() { + return "hello"; + } + + function f11() { + return cond ? 1 : "two"; + } + + function f12() { + if (cond) { + return 1; + } + else { + return "two"; + } + } + + class C2 { + foo() { + return 0; + } + bar() { + return cond ? 0 : 1; + } + } + + function f20() { + const f1 = () => 0; + const f2 = () => "hello"; + const f3 = () => true; + const f4 = () => E.C; + const f5 = (): "foo" => "foo"; + const f6: () => "foo" | "bar" = () => "bar"; + const f7: (() => "foo") | (() => "bar") = () => "bar"; + } + + declare function g1(x: T): T; + declare function g2(x: T, y: T): T; + declare function g3(x: T, y: U): T | U; + declare function g4(x: T): T[]; + declare function g5(x: T, y: T): T[]; + declare function g6(x: T[]): T; + declare function g7(x: T[]): T[]; + declare function g8(x: T, f: (p: T) => T): T; + + const a: (1 | 2)[] = [1, 2]; + + const x1 = g1(1); // Type 1 + const x2 = g2(1, 1); // Type 1 + const x3 = g2(1, 2); // Type 1 | 2 + ~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. + const x4 = g3(1, "two"); // Type 1 | "two" + ~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or '1 | "two"'. + const x5 = g4(1); // Type number[] + const x6 = g5(1, 2); // Type (1 | 2)[] + const x7 = g6([1, 2]); // Type number + const x8 = g6(a); // Type 1 | 2 + const x9 = g7(a); // Type (1 | 2)[] + const x10 = g8(1, x => x); // Type number + const x11 = g8(1, x => x + 1); // Type number + + function makeArray(x: T): T[] { + return [x]; + } + + function append(a: T[], x: T): T[] { + let result = a.slice(); + result.push(x); + return result; + } + + type Bit = 0 | 1; + + let aa = makeArray(0); + aa = append(aa, 1); + \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperator2.errors.txt b/tests/baselines/reference/nullishCoalescingOperator2.errors.txt new file mode 100644 index 0000000000000..1620173ec55b0 --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperator2.errors.txt @@ -0,0 +1,41 @@ +nullishCoalescingOperator2.ts(12,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. +nullishCoalescingOperator2.ts(13,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. +nullishCoalescingOperator2.ts(14,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. +nullishCoalescingOperator2.ts(15,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. +nullishCoalescingOperator2.ts(16,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. +nullishCoalescingOperator2.ts(17,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. + + +==== nullishCoalescingOperator2.ts (6 errors) ==== + declare const a1: 'literal' | undefined | null + declare const a2: '' | undefined | null + declare const a3: 1 | undefined | null + declare const a4: 0 | undefined | null + declare const a5: true | undefined | null + declare const a6: false | undefined | null + declare const a7: unknown | null + declare const a8: never | null + declare const a9: any | null + + + const aa1 = a1 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. + const aa2 = a2 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. + const aa3 = a3 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. + const aa4 = a4 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. + const aa5 = a5 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. + const aa6 = a6 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. + const aa7 = a7 ?? 'whatever' + const aa8 = a8 ?? 'whatever' + const aa9 = a9 ?? 'whatever' \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperator3.errors.txt b/tests/baselines/reference/nullishCoalescingOperator3.errors.txt new file mode 100644 index 0000000000000..59f28d152fbae --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperator3.errors.txt @@ -0,0 +1,16 @@ +nullishCoalescingOperator3.ts(9,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | boolean | 0 | 1' or 'boolean | "" | 0 | "literal" | 1 | "whatever"'. + + +==== nullishCoalescingOperator3.ts (1 errors) ==== + declare const a1: 'literal' | undefined | null + declare const a2: '' | undefined | null + declare const a3: 1 | undefined | null + declare const a4: 0 | undefined | null + declare const a5: true | undefined | null + declare const a6: false | undefined | null + + + const aa1 = a1 ?? a2 ?? a3 ?? a4 ?? a5 ?? a6 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | boolean | 0 | 1' or 'boolean | "" | 0 | "literal" | 1 | "whatever"'. + \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperator7.errors.txt b/tests/baselines/reference/nullishCoalescingOperator7.errors.txt new file mode 100644 index 0000000000000..53611a6bb76a9 --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperator7.errors.txt @@ -0,0 +1,21 @@ +nullishCoalescingOperator7.ts(5,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. +nullishCoalescingOperator7.ts(6,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. + + +==== nullishCoalescingOperator7.ts (2 errors) ==== + declare const a: string | undefined; + declare const b: string | undefined; + declare const c: string | undefined; + + const foo1 = a ? 1 : 2; + ~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. + const foo2 = a ?? 'foo' ? 1 : 2; + ~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. + const foo3 = a ?? 'foo' ? (b ?? 'bar') : (c ?? 'baz'); + + function f () { + const foo4 = a ?? 'foo' ? b ?? 'bar' : c ?? 'baz'; + } + \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperator_es2020.errors.txt b/tests/baselines/reference/nullishCoalescingOperator_es2020.errors.txt new file mode 100644 index 0000000000000..5e4a642d8d8c6 --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperator_es2020.errors.txt @@ -0,0 +1,59 @@ +nullishCoalescingOperator_es2020.ts(12,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. +nullishCoalescingOperator_es2020.ts(13,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. +nullishCoalescingOperator_es2020.ts(14,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. +nullishCoalescingOperator_es2020.ts(15,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. +nullishCoalescingOperator_es2020.ts(16,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. +nullishCoalescingOperator_es2020.ts(17,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. + + +==== nullishCoalescingOperator_es2020.ts (6 errors) ==== + declare const a1: 'literal' | undefined | null + declare const a2: '' | undefined | null + declare const a3: 1 | undefined | null + declare const a4: 0 | undefined | null + declare const a5: true | undefined | null + declare const a6: false | undefined | null + declare const a7: unknown | null + declare const a8: never | null + declare const a9: any | null + + + const aa1 = a1 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. + const aa2 = a2 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. + const aa3 = a3 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. + const aa4 = a4 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. + const aa5 = a5 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. + const aa6 = a6 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. + const aa7 = a7 ?? 'whatever' + const aa8 = a8 ?? 'whatever' + const aa9 = a9 ?? 'whatever' + + + declare let a: any, b: any, c: any; + + let x1 = (a ?? b as any) || c; + let x2 = c || (a ?? b as any); + let x3 = ((a ?? b) as any) || c; + let x4 = c || ((a ?? b) as any); + let x5 = (a ?? b) as any || c; + let x6 = c || (a ?? b) as any; + + let y1 = (a ?? b as any) && c; + let y2 = c && (a ?? b as any); + let y3 = ((a ?? b) as any) && c; + let y4 = c && ((a ?? b) as any); + let y5 = (a ?? b) as any && c; + let y6 = c && (a ?? b) as any; + \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperator_not_strict.errors.txt b/tests/baselines/reference/nullishCoalescingOperator_not_strict.errors.txt new file mode 100644 index 0000000000000..95478bcd8330a --- /dev/null +++ b/tests/baselines/reference/nullishCoalescingOperator_not_strict.errors.txt @@ -0,0 +1,41 @@ +nullishCoalescingOperator_not_strict.ts(12,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. +nullishCoalescingOperator_not_strict.ts(13,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. +nullishCoalescingOperator_not_strict.ts(14,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. +nullishCoalescingOperator_not_strict.ts(15,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. +nullishCoalescingOperator_not_strict.ts(16,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. +nullishCoalescingOperator_not_strict.ts(17,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. + + +==== nullishCoalescingOperator_not_strict.ts (6 errors) ==== + declare const a1: 'literal' | undefined | null + declare const a2: '' | undefined | null + declare const a3: 1 | undefined | null + declare const a4: 0 | undefined | null + declare const a5: true | undefined | null + declare const a6: false | undefined | null + declare const a7: unknown | null + declare const a8: never | null + declare const a9: any | null + + + const aa1 = a1 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. + const aa2 = a2 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. + const aa3 = a3 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. + const aa4 = a4 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. + const aa5 = a5 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. + const aa6 = a6 ?? 'whatever' + ~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. + const aa7 = a7 ?? 'whatever' + const aa8 = a8 ?? 'whatever' + const aa9 = a9 ?? 'whatever' \ No newline at end of file diff --git a/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleError.js b/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleError.js index ba5a1fad8140d..5e215408513b3 100644 --- a/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleError.js +++ b/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleError.js @@ -22,8 +22,25 @@ var Outer; //// [privacyCheckTypeOfInvisibleModuleError.d.ts] declare namespace Outer { namespace Inner { - var m: typeof Inner; } export var f: typeof Inner; export {}; } + + +//// [DtsFileErrors] + + +privacyCheckTypeOfInvisibleModuleError.d.ts(4,26): error TS2708: Cannot use namespace 'Inner' as a value. + + +==== privacyCheckTypeOfInvisibleModuleError.d.ts (1 errors) ==== + declare namespace Outer { + namespace Inner { + } + export var f: typeof Inner; + ~~~~~ +!!! error TS2708: Cannot use namespace 'Inner' as a value. + export {}; + } + \ No newline at end of file diff --git a/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleNoError.js b/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleNoError.js index 8d48438936da2..9dcf2490c729f 100644 --- a/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleNoError.js +++ b/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleNoError.js @@ -22,8 +22,25 @@ var Outer; //// [privacyCheckTypeOfInvisibleModuleNoError.d.ts] declare namespace Outer { namespace Inner { - var m: number; } export var f: typeof Inner; export {}; } + + +//// [DtsFileErrors] + + +privacyCheckTypeOfInvisibleModuleNoError.d.ts(4,26): error TS2708: Cannot use namespace 'Inner' as a value. + + +==== privacyCheckTypeOfInvisibleModuleNoError.d.ts (1 errors) ==== + declare namespace Outer { + namespace Inner { + } + export var f: typeof Inner; + ~~~~~ +!!! error TS2708: Cannot use namespace 'Inner' as a value. + export {}; + } + \ No newline at end of file diff --git a/tests/baselines/reference/privacyGloImport.js b/tests/baselines/reference/privacyGloImport.js index d99ccda06e2c3..e84acb0770421 100644 --- a/tests/baselines/reference/privacyGloImport.js +++ b/tests/baselines/reference/privacyGloImport.js @@ -275,11 +275,6 @@ declare namespace m1 { var v2: c1; } namespace m1_M2_private { - class c1 { - } - function f1(): c1; - var v1: typeof c1; - var v2: c1; } import m1_im1_private = m1_M1_public; export var m1_im1_private_v1_public: typeof m1_im1_private.c1; @@ -347,3 +342,100 @@ declare module "anotherParseError" { } declare namespace m2 { } + + +//// [DtsFileErrors] + + +privacyGloImport.d.ts(17,49): error TS2708: Cannot use namespace 'm1_im2_private' as a value. +privacyGloImport.d.ts(18,57): error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. +privacyGloImport.d.ts(19,49): error TS2708: Cannot use namespace 'm1_im2_private' as a value. +privacyGloImport.d.ts(20,57): error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. + + +==== privacyGloImport.d.ts (4 errors) ==== + declare namespace m1 { + export namespace m1_M1_public { + class c1 { + } + function f1(): c1; + var v1: typeof c1; + var v2: c1; + } + namespace m1_M2_private { + } + import m1_im1_private = m1_M1_public; + export var m1_im1_private_v1_public: typeof m1_im1_private.c1; + export var m1_im1_private_v2_public: m1_im1_private.c1; + export var m1_im1_private_v3_public: typeof m1_im1_private.f1; + export var m1_im1_private_v4_public: m1_im1_private.c1; + import m1_im2_private = m1_M2_private; + export var m1_im2_private_v1_public: typeof m1_im2_private.c1; + ~~~~~~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm1_im2_private' as a value. + export var m1_im2_private_v2_public: m1_im2_private.c1; + ~~ +!!! error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. + export var m1_im2_private_v3_public: typeof m1_im2_private.f1; + ~~~~~~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm1_im2_private' as a value. + export var m1_im2_private_v4_public: m1_im2_private.c1; + ~~ +!!! error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. + export import m1_im1_public = m1_M1_public; + export import m1_im2_public = m1_M2_private; + export {}; + } + declare namespace glo_M1_public { + class c1 { + } + function f1(): c1; + var v1: typeof c1; + var v2: c1; + } + declare module "glo_M2_public" { + function f1(): any; + class c1 { + } + var v1: { + new (): c1; + }; + var v2: c1; + } + declare module "use_glo_M1_public" { + import use_glo_M1_public = glo_M1_public; + var use_glo_M1_public_v1_public: { + new (): use_glo_M1_public.c1; + }; + var use_glo_M1_public_v2_public: typeof use_glo_M1_public; + var use_glo_M1_public_v3_public: () => use_glo_M1_public.c1; + var use_glo_M1_public_v1_private: { + new (): use_glo_M1_public.c1; + }; + var use_glo_M1_public_v2_private: typeof use_glo_M1_public; + var use_glo_M1_public_v3_private: () => use_glo_M1_public.c1; + import use_glo_M2_public = require("glo_M2_public"); + var use_glo_M2_public_v1_public: { + new (): use_glo_M2_public.c1; + }; + var use_glo_M2_public_v2_public: typeof use_glo_M2_public; + var use_glo_M2_public_v3_public: () => use_glo_M2_public.c1; + var use_glo_M2_public_v1_private: { + new (): use_glo_M2_public.c1; + }; + var use_glo_M2_public_v2_private: typeof use_glo_M2_public; + var use_glo_M2_public_v3_private: () => use_glo_M2_public.c1; + namespace m2 { + namespace m5 { + } + } + } + declare module "anotherParseError" { + namespace m2 { + } + namespace m2 { + } + } + declare namespace m2 { + } + \ No newline at end of file diff --git a/tests/baselines/reference/privacyGloImportParseErrors.js b/tests/baselines/reference/privacyGloImportParseErrors.js index 1a1252819e394..e19197080fe57 100644 --- a/tests/baselines/reference/privacyGloImportParseErrors.js +++ b/tests/baselines/reference/privacyGloImportParseErrors.js @@ -255,11 +255,6 @@ declare namespace m1 { var v2: c1; } namespace m1_M2_private { - class c1 { - } - function f1(): c1; - var v1: typeof c1; - var v2: c1; } export module "m1_M3_public" { function f1(): any; diff --git a/tests/baselines/reference/privacyImport.js b/tests/baselines/reference/privacyImport.js index 0681c429ff05f..6859532b14c6a 100644 --- a/tests/baselines/reference/privacyImport.js +++ b/tests/baselines/reference/privacyImport.js @@ -717,11 +717,6 @@ export declare namespace m1 { var v2: c1; } namespace m1_M2_private { - class c1 { - } - function f1(): c1; - var v1: typeof c1; - var v2: c1; } import m1_im1_private = m1_M1_public; export var m1_im1_private_v1_public: typeof m1_im1_private.c1; @@ -765,3 +760,76 @@ export import glo_im1_public = glo_M1_public; export import glo_im2_public = glo_M3_private; export declare namespace m3 { } + + +//// [DtsFileErrors] + + +privacyImport.d.ts(17,49): error TS2708: Cannot use namespace 'm1_im2_private' as a value. +privacyImport.d.ts(18,57): error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. +privacyImport.d.ts(19,49): error TS2708: Cannot use namespace 'm1_im2_private' as a value. +privacyImport.d.ts(20,57): error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. + + +==== privacyImport.d.ts (4 errors) ==== + export declare namespace m1 { + export namespace m1_M1_public { + class c1 { + } + function f1(): c1; + var v1: typeof c1; + var v2: c1; + } + namespace m1_M2_private { + } + import m1_im1_private = m1_M1_public; + export var m1_im1_private_v1_public: typeof m1_im1_private.c1; + export var m1_im1_private_v2_public: m1_im1_private.c1; + export var m1_im1_private_v3_public: typeof m1_im1_private.f1; + export var m1_im1_private_v4_public: m1_im1_private.c1; + import m1_im2_private = m1_M2_private; + export var m1_im2_private_v1_public: typeof m1_im2_private.c1; + ~~~~~~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm1_im2_private' as a value. + export var m1_im2_private_v2_public: m1_im2_private.c1; + ~~ +!!! error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. + export var m1_im2_private_v3_public: typeof m1_im2_private.f1; + ~~~~~~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm1_im2_private' as a value. + export var m1_im2_private_v4_public: m1_im2_private.c1; + ~~ +!!! error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. + export import m1_im1_public = m1_M1_public; + export import m1_im2_public = m1_M2_private; + export {}; + } + export declare namespace glo_M1_public { + class c1 { + } + function f1(): c1; + var v1: typeof c1; + var v2: c1; + } + export declare namespace glo_M3_private { + class c1 { + } + function f1(): c1; + var v1: typeof c1; + var v2: c1; + } + import glo_im1_private = glo_M1_public; + export declare var glo_im1_private_v1_public: typeof glo_im1_private.c1; + export declare var glo_im1_private_v2_public: glo_im1_private.c1; + export declare var glo_im1_private_v3_public: typeof glo_im1_private.f1; + export declare var glo_im1_private_v4_public: glo_im1_private.c1; + import glo_im3_private = glo_M3_private; + export declare var glo_im3_private_v1_public: typeof glo_im3_private.c1; + export declare var glo_im3_private_v2_public: glo_im3_private.c1; + export declare var glo_im3_private_v3_public: typeof glo_im3_private.f1; + export declare var glo_im3_private_v4_public: glo_im3_private.c1; + export import glo_im1_public = glo_M1_public; + export import glo_im2_public = glo_M3_private; + export declare namespace m3 { + } + \ No newline at end of file diff --git a/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js b/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js index 5ce9646b771d1..e10087d529837 100644 --- a/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js +++ b/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js @@ -302,24 +302,6 @@ var import_private; //// [privacyLocalInternalReferenceImportWithExport.d.ts] declare namespace m_private { - class c_private { - } - enum e_private { - Happy = 0, - Grumpy = 1 - } - function f_private(): c_private; - var v_private: c_private; - interface i_private { - } - namespace mi_private { - class c { - } - } - namespace mu_private { - interface i { - } - } } export declare namespace m_public { class c_public { @@ -372,3 +354,107 @@ export declare namespace import_public { var publicUse_im_public_mu_public: im_public_mu_public.i; } export {}; + + +//// [DtsFileErrors] + + +privacyLocalInternalReferenceImportWithExport.d.ts(24,41): error TS2708: Cannot use namespace 'm_private' as a value. +privacyLocalInternalReferenceImportWithExport.d.ts(24,51): error TS2694: Namespace 'm_private' has no exported member 'c_private'. +privacyLocalInternalReferenceImportWithExport.d.ts(25,41): error TS2708: Cannot use namespace 'm_private' as a value. +privacyLocalInternalReferenceImportWithExport.d.ts(25,51): error TS2694: Namespace 'm_private' has no exported member 'e_private'. +privacyLocalInternalReferenceImportWithExport.d.ts(26,41): error TS2708: Cannot use namespace 'm_private' as a value. +privacyLocalInternalReferenceImportWithExport.d.ts(26,51): error TS2694: Namespace 'm_private' has no exported member 'f_private'. +privacyLocalInternalReferenceImportWithExport.d.ts(27,41): error TS2708: Cannot use namespace 'm_private' as a value. +privacyLocalInternalReferenceImportWithExport.d.ts(27,51): error TS2694: Namespace 'm_private' has no exported member 'v_private'. +privacyLocalInternalReferenceImportWithExport.d.ts(28,41): error TS2708: Cannot use namespace 'm_private' as a value. +privacyLocalInternalReferenceImportWithExport.d.ts(28,51): error TS2694: Namespace 'm_private' has no exported member 'i_private'. +privacyLocalInternalReferenceImportWithExport.d.ts(29,42): error TS2708: Cannot use namespace 'm_private' as a value. +privacyLocalInternalReferenceImportWithExport.d.ts(29,52): error TS2694: Namespace 'm_private' has no exported member 'mi_private'. +privacyLocalInternalReferenceImportWithExport.d.ts(30,42): error TS2708: Cannot use namespace 'm_private' as a value. +privacyLocalInternalReferenceImportWithExport.d.ts(30,52): error TS2694: Namespace 'm_private' has no exported member 'mu_private'. + + +==== privacyLocalInternalReferenceImportWithExport.d.ts (14 errors) ==== + declare namespace m_private { + } + export declare namespace m_public { + class c_public { + } + enum e_public { + Happy = 0, + Grumpy = 1 + } + function f_public(): c_public; + var v_public: number; + interface i_public { + } + namespace mi_public { + class c { + } + } + namespace mu_public { + interface i { + } + } + } + export declare namespace import_public { + export import im_public_c_private = m_private.c_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'c_private'. + export import im_public_e_private = m_private.e_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'e_private'. + export import im_public_f_private = m_private.f_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'f_private'. + export import im_public_v_private = m_private.v_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'v_private'. + export import im_public_i_private = m_private.i_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'i_private'. + export import im_public_mi_private = m_private.mi_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'mi_private'. + export import im_public_mu_private = m_private.mu_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'mu_private'. + var publicUse_im_public_c_private: im_public_c_private; + var publicUse_im_public_e_private: im_public_e_private; + var publicUse_im_public_f_private: im_public_c_private; + var publicUse_im_public_v_private: im_public_c_private; + var publicUse_im_public_i_private: im_public_i_private; + var publicUse_im_public_mi_private: im_public_mi_private.c; + var publicUse_im_public_mu_private: im_public_mu_private.i; + export import im_public_c_public = m_public.c_public; + export import im_public_e_public = m_public.e_public; + export import im_public_f_public = m_public.f_public; + export import im_public_v_public = m_public.v_public; + export import im_public_i_public = m_public.i_public; + export import im_public_mi_public = m_public.mi_public; + export import im_public_mu_public = m_public.mu_public; + var publicUse_im_public_c_public: im_public_c_public; + var publicUse_im_public_e_public: im_public_e_public; + var publicUse_im_public_f_public: im_public_c_public; + var publicUse_im_public_v_public: number; + var publicUse_im_public_i_public: im_public_i_public; + var publicUse_im_public_mi_public: im_public_mi_public.c; + var publicUse_im_public_mu_public: im_public_mu_public.i; + } + export {}; + \ No newline at end of file diff --git a/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js b/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js index 9b88c75388c4f..72c0a020f77d2 100644 --- a/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js +++ b/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js @@ -304,24 +304,6 @@ define(["require", "exports"], function (require, exports) { //// [privacyLocalInternalReferenceImportWithoutExport.d.ts] declare namespace m_private { - class c_private { - } - enum e_private { - Happy = 0, - Grumpy = 1 - } - function f_private(): c_private; - var v_private: c_private; - interface i_private { - } - namespace mi_private { - class c { - } - } - namespace mu_private { - interface i { - } - } } export declare namespace m_public { class c_public { @@ -370,3 +352,76 @@ export declare namespace import_public { var publicUse_im_private_mu_public: im_private_mu_public.i; } export {}; + + +//// [DtsFileErrors] + + +privacyLocalInternalReferenceImportWithoutExport.d.ts(24,45): error TS2694: Namespace 'm_private' has no exported member 'c_private'. +privacyLocalInternalReferenceImportWithoutExport.d.ts(25,45): error TS2694: Namespace 'm_private' has no exported member 'e_private'. +privacyLocalInternalReferenceImportWithoutExport.d.ts(26,45): error TS2694: Namespace 'm_private' has no exported member 'i_private'. +privacyLocalInternalReferenceImportWithoutExport.d.ts(27,46): error TS2694: Namespace 'm_private' has no exported member 'mi_private'. +privacyLocalInternalReferenceImportWithoutExport.d.ts(28,46): error TS2694: Namespace 'm_private' has no exported member 'mu_private'. + + +==== privacyLocalInternalReferenceImportWithoutExport.d.ts (5 errors) ==== + declare namespace m_private { + } + export declare namespace m_public { + class c_public { + } + enum e_public { + Happy = 0, + Grumpy = 1 + } + function f_public(): c_public; + var v_public: number; + interface i_public { + } + namespace mi_public { + class c { + } + } + namespace mu_public { + interface i { + } + } + } + export declare namespace import_public { + import im_private_c_private = m_private.c_private; + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'c_private'. + import im_private_e_private = m_private.e_private; + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'e_private'. + import im_private_i_private = m_private.i_private; + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'i_private'. + import im_private_mi_private = m_private.mi_private; + ~~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'mi_private'. + import im_private_mu_private = m_private.mu_private; + ~~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'mu_private'. + var publicUse_im_private_c_private: im_private_c_private; + var publicUse_im_private_e_private: im_private_e_private; + var publicUse_im_private_f_private: im_private_c_private; + var publicUse_im_private_v_private: im_private_c_private; + var publicUse_im_private_i_private: im_private_i_private; + var publicUse_im_private_mi_private: im_private_mi_private.c; + var publicUse_im_private_mu_private: im_private_mu_private.i; + import im_private_c_public = m_public.c_public; + import im_private_e_public = m_public.e_public; + import im_private_i_public = m_public.i_public; + import im_private_mi_public = m_public.mi_public; + import im_private_mu_public = m_public.mu_public; + var publicUse_im_private_c_public: im_private_c_public; + var publicUse_im_private_e_public: im_private_e_public; + var publicUse_im_private_f_public: im_private_c_public; + var publicUse_im_private_v_public: number; + var publicUse_im_private_i_public: im_private_i_public; + var publicUse_im_private_mi_public: im_private_mi_public.c; + var publicUse_im_private_mu_public: im_private_mu_public.i; + } + export {}; + \ No newline at end of file diff --git a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js index 99397be4c408e..f72ef24a9c3e4 100644 --- a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js +++ b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js @@ -207,24 +207,6 @@ define(["require", "exports"], function (require, exports) { //// [privacyTopLevelInternalReferenceImportWithExport.d.ts] declare namespace m_private { - class c_private { - } - enum e_private { - Happy = 0, - Grumpy = 1 - } - function f_private(): c_private; - var v_private: c_private; - interface i_private { - } - namespace mi_private { - class c { - } - } - namespace mu_private { - interface i { - } - } } export declare namespace m_public { class c_public { @@ -275,3 +257,105 @@ export declare var publicUse_im_public_i_public: im_public_i_public; export declare var publicUse_im_public_mi_public: im_public_mi_public.c; export declare var publicUse_im_public_mu_public: im_public_mu_public.i; export {}; + + +//// [DtsFileErrors] + + +privacyTopLevelInternalReferenceImportWithExport.d.ts(23,37): error TS2708: Cannot use namespace 'm_private' as a value. +privacyTopLevelInternalReferenceImportWithExport.d.ts(23,47): error TS2694: Namespace 'm_private' has no exported member 'c_private'. +privacyTopLevelInternalReferenceImportWithExport.d.ts(24,37): error TS2708: Cannot use namespace 'm_private' as a value. +privacyTopLevelInternalReferenceImportWithExport.d.ts(24,47): error TS2694: Namespace 'm_private' has no exported member 'e_private'. +privacyTopLevelInternalReferenceImportWithExport.d.ts(25,37): error TS2708: Cannot use namespace 'm_private' as a value. +privacyTopLevelInternalReferenceImportWithExport.d.ts(25,47): error TS2694: Namespace 'm_private' has no exported member 'f_private'. +privacyTopLevelInternalReferenceImportWithExport.d.ts(26,37): error TS2708: Cannot use namespace 'm_private' as a value. +privacyTopLevelInternalReferenceImportWithExport.d.ts(26,47): error TS2694: Namespace 'm_private' has no exported member 'v_private'. +privacyTopLevelInternalReferenceImportWithExport.d.ts(27,37): error TS2708: Cannot use namespace 'm_private' as a value. +privacyTopLevelInternalReferenceImportWithExport.d.ts(27,47): error TS2694: Namespace 'm_private' has no exported member 'i_private'. +privacyTopLevelInternalReferenceImportWithExport.d.ts(28,38): error TS2708: Cannot use namespace 'm_private' as a value. +privacyTopLevelInternalReferenceImportWithExport.d.ts(28,48): error TS2694: Namespace 'm_private' has no exported member 'mi_private'. +privacyTopLevelInternalReferenceImportWithExport.d.ts(29,38): error TS2708: Cannot use namespace 'm_private' as a value. +privacyTopLevelInternalReferenceImportWithExport.d.ts(29,48): error TS2694: Namespace 'm_private' has no exported member 'mu_private'. + + +==== privacyTopLevelInternalReferenceImportWithExport.d.ts (14 errors) ==== + declare namespace m_private { + } + export declare namespace m_public { + class c_public { + } + enum e_public { + Happy = 0, + Grumpy = 1 + } + function f_public(): c_public; + var v_public: number; + interface i_public { + } + namespace mi_public { + class c { + } + } + namespace mu_public { + interface i { + } + } + } + export import im_public_c_private = m_private.c_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'c_private'. + export import im_public_e_private = m_private.e_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'e_private'. + export import im_public_f_private = m_private.f_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'f_private'. + export import im_public_v_private = m_private.v_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'v_private'. + export import im_public_i_private = m_private.i_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'i_private'. + export import im_public_mi_private = m_private.mi_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'mi_private'. + export import im_public_mu_private = m_private.mu_private; + ~~~~~~~~~ +!!! error TS2708: Cannot use namespace 'm_private' as a value. + ~~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'mu_private'. + export declare var publicUse_im_public_c_private: im_public_c_private; + export declare var publicUse_im_public_e_private: im_public_e_private; + export declare var publicUse_im_public_f_private: im_public_c_private; + export declare var publicUse_im_public_v_private: im_public_c_private; + export declare var publicUse_im_public_i_private: im_public_i_private; + export declare var publicUse_im_public_mi_private: im_public_mi_private.c; + export declare var publicUse_im_public_mu_private: im_public_mu_private.i; + export import im_public_c_public = m_public.c_public; + export import im_public_e_public = m_public.e_public; + export import im_public_f_public = m_public.f_public; + export import im_public_v_public = m_public.v_public; + export import im_public_i_public = m_public.i_public; + export import im_public_mi_public = m_public.mi_public; + export import im_public_mu_public = m_public.mu_public; + export declare var publicUse_im_public_c_public: im_public_c_public; + export declare var publicUse_im_public_e_public: im_public_e_public; + export declare var publicUse_im_public_f_public: im_public_c_public; + export declare var publicUse_im_public_v_public: number; + export declare var publicUse_im_public_i_public: im_public_i_public; + export declare var publicUse_im_public_mi_public: im_public_mi_public.c; + export declare var publicUse_im_public_mu_public: im_public_mu_public.i; + export {}; + \ No newline at end of file diff --git a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js index a7158320d678c..f4afec1707e92 100644 --- a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js +++ b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js @@ -207,24 +207,6 @@ define(["require", "exports"], function (require, exports) { //// [privacyTopLevelInternalReferenceImportWithoutExport.d.ts] declare namespace m_private { - class c_private { - } - enum e_private { - Happy = 0, - Grumpy = 1 - } - function f_private(): c_private; - var v_private: c_private; - interface i_private { - } - namespace mi_private { - class c { - } - } - namespace mu_private { - interface i { - } - } } export declare namespace m_public { class c_public { @@ -271,3 +253,74 @@ export declare var publicUse_im_private_i_public: im_private_i_public; export declare var publicUse_im_private_mi_public: im_private_mi_public.c; export declare var publicUse_im_private_mu_public: im_private_mu_public.i; export {}; + + +//// [DtsFileErrors] + + +privacyTopLevelInternalReferenceImportWithoutExport.d.ts(23,41): error TS2694: Namespace 'm_private' has no exported member 'c_private'. +privacyTopLevelInternalReferenceImportWithoutExport.d.ts(24,41): error TS2694: Namespace 'm_private' has no exported member 'e_private'. +privacyTopLevelInternalReferenceImportWithoutExport.d.ts(25,41): error TS2694: Namespace 'm_private' has no exported member 'i_private'. +privacyTopLevelInternalReferenceImportWithoutExport.d.ts(26,42): error TS2694: Namespace 'm_private' has no exported member 'mi_private'. +privacyTopLevelInternalReferenceImportWithoutExport.d.ts(27,42): error TS2694: Namespace 'm_private' has no exported member 'mu_private'. + + +==== privacyTopLevelInternalReferenceImportWithoutExport.d.ts (5 errors) ==== + declare namespace m_private { + } + export declare namespace m_public { + class c_public { + } + enum e_public { + Happy = 0, + Grumpy = 1 + } + function f_public(): c_public; + var v_public: number; + interface i_public { + } + namespace mi_public { + class c { + } + } + namespace mu_public { + interface i { + } + } + } + import im_private_c_private = m_private.c_private; + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'c_private'. + import im_private_e_private = m_private.e_private; + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'e_private'. + import im_private_i_private = m_private.i_private; + ~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'i_private'. + import im_private_mi_private = m_private.mi_private; + ~~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'mi_private'. + import im_private_mu_private = m_private.mu_private; + ~~~~~~~~~~ +!!! error TS2694: Namespace 'm_private' has no exported member 'mu_private'. + export declare var publicUse_im_private_c_private: im_private_c_private; + export declare var publicUse_im_private_e_private: im_private_e_private; + export declare var publicUse_im_private_f_private: im_private_c_private; + export declare var publicUse_im_private_v_private: im_private_c_private; + export declare var publicUse_im_private_i_private: im_private_i_private; + export declare var publicUse_im_private_mi_private: im_private_mi_private.c; + export declare var publicUse_im_private_mu_private: im_private_mu_private.i; + import im_private_c_public = m_public.c_public; + import im_private_e_public = m_public.e_public; + import im_private_i_public = m_public.i_public; + import im_private_mi_public = m_public.mi_public; + import im_private_mu_public = m_public.mu_public; + export declare var publicUse_im_private_c_public: im_private_c_public; + export declare var publicUse_im_private_e_public: im_private_e_public; + export declare var publicUse_im_private_f_public: im_private_c_public; + export declare var publicUse_im_private_v_public: number; + export declare var publicUse_im_private_i_public: im_private_i_public; + export declare var publicUse_im_private_mi_public: im_private_mi_public.c; + export declare var publicUse_im_private_mu_public: im_private_mu_public.i; + export {}; + \ No newline at end of file diff --git a/tests/baselines/reference/privacyVarDeclFile.js b/tests/baselines/reference/privacyVarDeclFile.js index 83f6ef53f1aea..3bd117870abde 100644 --- a/tests/baselines/reference/privacyVarDeclFile.js +++ b/tests/baselines/reference/privacyVarDeclFile.js @@ -764,10 +764,29 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { +} +export {}; +//// [privacyVarDeclFile_GlobalFile.d.ts] +declare class publicClassInGlobal { +} +interface publicInterfaceWithPublicPropertyTypesInGlobal { + myProperty: publicClassInGlobal; +} +declare class publicClassWithWithPublicPropertyTypesInGlobal { + static myPublicStaticProperty: publicClassInGlobal; + private static myPrivateStaticProperty; + myPublicProperty: publicClassInGlobal; + private myPrivateProperty; +} +declare var publicVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; +declare var publicAmbientVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; +declare namespace publicModuleInGlobal { class privateClass { } export class publicClass { } + namespace privateModule { + } export interface publicInterfaceWithPrivatePropertyTypes { myProperty: privateClass; } @@ -801,27 +820,75 @@ declare namespace privateModule { export var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; export {}; } -export {}; -//// [privacyVarDeclFile_GlobalFile.d.ts] -declare class publicClassInGlobal { -} -interface publicInterfaceWithPublicPropertyTypesInGlobal { - myProperty: publicClassInGlobal; -} -declare class publicClassWithWithPublicPropertyTypesInGlobal { - static myPublicStaticProperty: publicClassInGlobal; - private static myPrivateStaticProperty; - myPublicProperty: publicClassInGlobal; - private myPrivateProperty; -} -declare var publicVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; -declare var publicAmbientVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; -declare namespace publicModuleInGlobal { - class privateClass { + + +//// [DtsFileErrors] + + +privacyVarDeclFile_GlobalFile.d.ts(44,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_GlobalFile.d.ts(47,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_GlobalFile.d.ts(48,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_GlobalFile.d.ts(50,71): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_GlobalFile.d.ts(51,78): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_externalModule.d.ts(28,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_externalModule.d.ts(31,50): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_externalModule.d.ts(32,37): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_externalModule.d.ts(34,75): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_externalModule.d.ts(35,82): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_externalModule.d.ts(64,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_externalModule.d.ts(67,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_externalModule.d.ts(68,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_externalModule.d.ts(70,71): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyVarDeclFile_externalModule.d.ts(71,78): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + + +==== privacyVarDeclFile_externalModule.d.ts (10 errors) ==== + declare class privateClass { } - export class publicClass { + export declare class publicClass { } - namespace privateModule { + export interface publicInterfaceWithPrivatePropertyTypes { + myProperty: privateClass; + } + export interface publicInterfaceWithPublicPropertyTypes { + myProperty: publicClass; + } + export declare class publicClassWithWithPrivatePropertyTypes { + static myPublicStaticProperty: privateClass; + private static myPrivateStaticProperty; + myPublicProperty: privateClass; + private myPrivateProperty; + } + export declare class publicClassWithWithPublicPropertyTypes { + static myPublicStaticProperty: publicClass; + private static myPrivateStaticProperty; + myPublicProperty: publicClass; + private myPrivateProperty; + } + export declare var publicVarWithPrivatePropertyTypes: privateClass; + export declare var publicVarWithPublicPropertyTypes: publicClass; + export declare var publicAmbientVarWithPrivatePropertyTypes: privateClass; + export declare var publicAmbientVarWithPublicPropertyTypes: publicClass; + export interface publicInterfaceWithPrivateModulePropertyTypes { + myProperty: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export declare class publicClassWithPrivateModulePropertyTypes { + static myPublicStaticProperty: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myPublicProperty: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export declare var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export declare var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export declare namespace publicModule { class privateClass { } export class publicClass { @@ -850,45 +917,91 @@ declare namespace publicModuleInGlobal { export var publicAmbientVarWithPublicPropertyTypes: publicClass; export interface publicInterfaceWithPrivateModulePropertyTypes { myProperty: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export class publicClassWithPrivateModulePropertyTypes { static myPublicStaticProperty: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. myPublicProperty: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. export var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. export {}; } - export interface publicInterfaceWithPrivatePropertyTypes { - myProperty: privateClass; + declare namespace privateModule { } - export interface publicInterfaceWithPublicPropertyTypes { - myProperty: publicClass; + export {}; + +==== privacyVarDeclFile_GlobalFile.d.ts (5 errors) ==== + declare class publicClassInGlobal { } - export class publicClassWithWithPrivatePropertyTypes { - static myPublicStaticProperty: privateClass; - private static myPrivateStaticProperty; - myPublicProperty: privateClass; - private myPrivateProperty; + interface publicInterfaceWithPublicPropertyTypesInGlobal { + myProperty: publicClassInGlobal; } - export class publicClassWithWithPublicPropertyTypes { - static myPublicStaticProperty: publicClass; + declare class publicClassWithWithPublicPropertyTypesInGlobal { + static myPublicStaticProperty: publicClassInGlobal; private static myPrivateStaticProperty; - myPublicProperty: publicClass; + myPublicProperty: publicClassInGlobal; private myPrivateProperty; } - export var publicVarWithPrivatePropertyTypes: privateClass; - export var publicVarWithPublicPropertyTypes: publicClass; - export var publicAmbientVarWithPrivatePropertyTypes: privateClass; - export var publicAmbientVarWithPublicPropertyTypes: publicClass; - export interface publicInterfaceWithPrivateModulePropertyTypes { - myProperty: privateModule.publicClass; - } - export class publicClassWithPrivateModulePropertyTypes { - static myPublicStaticProperty: privateModule.publicClass; - myPublicProperty: privateModule.publicClass; + declare var publicVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; + declare var publicAmbientVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; + declare namespace publicModuleInGlobal { + class privateClass { + } + export class publicClass { + } + namespace privateModule { + } + export interface publicInterfaceWithPrivatePropertyTypes { + myProperty: privateClass; + } + export interface publicInterfaceWithPublicPropertyTypes { + myProperty: publicClass; + } + export class publicClassWithWithPrivatePropertyTypes { + static myPublicStaticProperty: privateClass; + private static myPrivateStaticProperty; + myPublicProperty: privateClass; + private myPrivateProperty; + } + export class publicClassWithWithPublicPropertyTypes { + static myPublicStaticProperty: publicClass; + private static myPrivateStaticProperty; + myPublicProperty: publicClass; + private myPrivateProperty; + } + export var publicVarWithPrivatePropertyTypes: privateClass; + export var publicVarWithPublicPropertyTypes: publicClass; + export var publicAmbientVarWithPrivatePropertyTypes: privateClass; + export var publicAmbientVarWithPublicPropertyTypes: publicClass; + export interface publicInterfaceWithPrivateModulePropertyTypes { + myProperty: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export class publicClassWithPrivateModulePropertyTypes { + static myPublicStaticProperty: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myPublicProperty: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export {}; } - export var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; - export var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; - export {}; -} + \ No newline at end of file diff --git a/tests/baselines/reference/strictFunctionTypes1.errors.txt b/tests/baselines/reference/strictFunctionTypes1.errors.txt new file mode 100644 index 0000000000000..fbe9de3681c50 --- /dev/null +++ b/tests/baselines/reference/strictFunctionTypes1.errors.txt @@ -0,0 +1,56 @@ +strictFunctionTypes1.ts(15,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"def" | "abc"'. + + +==== strictFunctionTypes1.ts (1 errors) ==== + declare function f1(f1: (x: T) => void, f2: (x: T) => void): (x: T) => void; + declare function f2(obj: T, f1: (x: T) => void, f2: (x: T) => void): T; + declare function f3(obj: T, f1: (x: T) => void, f2: (f: (x: T) => void) => void): T; + + interface Func { (x: T): void } + + declare function f4(f1: Func, f2: Func): Func; + + declare function fo(x: Object): void; + declare function fs(x: string): void; + declare function fx(f: (x: "def") => void): void; + + const x1 = f1(fo, fs); // (x: string) => void + const x2 = f2("abc", fo, fs); // "abc" + const x3 = f3("abc", fo, fx); // "abc" | "def" + ~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"def" | "abc"'. + const x4 = f4(fo, fs); // Func + + declare const never: never; + + const x10 = f2(never, fo, fs); // string + const x11 = f3(never, fo, fx); // "def" + + // Repro from #21112 + + declare function foo(a: ReadonlyArray): T; + let x = foo([]); // never + + // Modified repros from #26127 + + interface A { a: string } + interface B extends A { b: string } + + declare function acceptUnion(x: A | number): void; + declare function acceptA(x: A): void; + + declare let a: A; + declare let b: B; + + declare function coAndContra(value: T, func: (t: T) => void): T; + + const t1: A = coAndContra(a, acceptUnion); + const t2: B = coAndContra(b, acceptA); + const t3: A = coAndContra(never, acceptA); + + declare function coAndContraArray(value: T[], func: (t: T) => void): T[]; + + const t4: A[] = coAndContraArray([a], acceptUnion); + const t5: B[] = coAndContraArray([b], acceptA); + const t6: A[] = coAndContraArray([], acceptA); + \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt b/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt new file mode 100644 index 0000000000000..2d3a8c37567b0 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt @@ -0,0 +1,65 @@ +stringLiteralTypesOverloads02.ts(33,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"string" | "number"'. +stringLiteralTypesOverloads02.ts(34,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"string" | "boolean"'. +stringLiteralTypesOverloads02.ts(35,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"number" | "boolean"'. +stringLiteralTypesOverloads02.ts(36,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"string" | "number" | "boolean"'. + + +==== stringLiteralTypesOverloads02.ts (4 errors) ==== + function getFalsyPrimitive(x: "string"): string; + function getFalsyPrimitive(x: "number"): number; + function getFalsyPrimitive(x: "boolean"): boolean; + function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; + function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; + function getFalsyPrimitive(x: "number" | "string"): number | string; + function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; + function getFalsyPrimitive(x: string): string | number | boolean { + if (x === "string") { + return ""; + } + if (x === "number") { + return 0; + } + if (x === "boolean") { + return false; + } + + // Should be unreachable. + throw "Invalid value"; + } + + namespace Consts1 { + const EMPTY_STRING = getFalsyPrimitive("string"); + const ZERO = getFalsyPrimitive('number'); + const FALSE = getFalsyPrimitive("boolean"); + } + + const string = "string" + const number = "number" + const boolean = "boolean" + + const stringOrNumber = string || number; + ~~~~~~~~~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"string" | "number"'. + const stringOrBoolean = string || boolean; + ~~~~~~~~~~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"string" | "boolean"'. + const booleanOrNumber = number || boolean; + ~~~~~~~~~~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"number" | "boolean"'. + const stringOrBooleanOrNumber = stringOrBoolean || number; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"string" | "number" | "boolean"'. + + namespace Consts2 { + const EMPTY_STRING = getFalsyPrimitive(string); + const ZERO = getFalsyPrimitive(number); + const FALSE = getFalsyPrimitive(boolean); + + const a = getFalsyPrimitive(stringOrNumber); + const b = getFalsyPrimitive(stringOrBoolean); + const c = getFalsyPrimitive(booleanOrNumber); + const d = getFalsyPrimitive(stringOrBooleanOrNumber); + } + + + \ No newline at end of file From ead2d42437e67e1ef13411659e1495c28e8ae44f Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:00:13 -0700 Subject: [PATCH 3/8] Forgotten baselines --- ...lTypingWithFixedTypeParameters1.errors.txt | 5 +- ...declarationEmitBindingPatterns2.errors.txt | 14 ++++++ ...tionEmitPrivateReadonlyLiterals.errors.txt | 22 ++++++++ .../declarationEmitSpreadStringlyKeyedEnum.js | 50 +++++++++++++++++++ .../intraExpressionInferences.errors.txt | 8 ++- .../reference/literalTypes2.errors.txt | 8 ++- ...umentInferenceWithObjectLiteral.errors.txt | 5 +- ...eInferenceConflictingCandidates.errors.txt | 7 ++- 8 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitBindingPatterns2.errors.txt create mode 100644 tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.errors.txt diff --git a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt index 411a6b9079b81..64b31705b6fd6 100644 --- a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt +++ b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt @@ -1,14 +1,17 @@ contextualTypingWithFixedTypeParameters1.ts(2,22): error TS2339: Property 'foo' does not exist on type 'string'. +contextualTypingWithFixedTypeParameters1.ts(3,25): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '""'. contextualTypingWithFixedTypeParameters1.ts(3,32): error TS2339: Property 'foo' does not exist on type '""'. contextualTypingWithFixedTypeParameters1.ts(3,38): error TS2345: Argument of type '1' is not assignable to parameter of type '""'. -==== contextualTypingWithFixedTypeParameters1.ts (3 errors) ==== +==== contextualTypingWithFixedTypeParameters1.ts (4 errors) ==== var f10: (x: T, b: () => (a: T) => void, y: T) => T; f10('', () => a => a.foo, ''); // a is "" ~~~ !!! error TS2339: Property 'foo' does not exist on type 'string'. var r9 = f10('', () => (a => a.foo), 1); // error + ~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '""'. ~~~ !!! error TS2339: Property 'foo' does not exist on type '""'. ~ diff --git a/tests/baselines/reference/declarationEmitBindingPatterns2.errors.txt b/tests/baselines/reference/declarationEmitBindingPatterns2.errors.txt new file mode 100644 index 0000000000000..877f36a2808fe --- /dev/null +++ b/tests/baselines/reference/declarationEmitBindingPatterns2.errors.txt @@ -0,0 +1,14 @@ +declarationEmitBindingPatterns2.ts(7,16): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 0'. + + +==== declarationEmitBindingPatterns2.ts (1 errors) ==== + // https://github.com/microsoft/TypeScript/issues/55439 + + function foo(): { y: 1 } { + return { y: 1 }; + } + + export const { y = 0 } = foo(); + ~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 0'. + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.errors.txt b/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.errors.txt new file mode 100644 index 0000000000000..c3f7d845dc4e2 --- /dev/null +++ b/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.errors.txt @@ -0,0 +1,22 @@ +declarationEmitPrivateReadonlyLiterals.ts(2,29): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"a"'. +declarationEmitPrivateReadonlyLiterals.ts(3,22): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"b"'. +declarationEmitPrivateReadonlyLiterals.ts(4,29): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '42'. +declarationEmitPrivateReadonlyLiterals.ts(5,22): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '42'. + + +==== declarationEmitPrivateReadonlyLiterals.ts (4 errors) ==== + class Foo { + private static readonly A = "a"; + ~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"a"'. + private readonly B = "b"; + ~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"b"'. + private static readonly C = 42; + ~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '42'. + private readonly D = 42; + ~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '42'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitSpreadStringlyKeyedEnum.js b/tests/baselines/reference/declarationEmitSpreadStringlyKeyedEnum.js index ed33b7fe09199..96a23076a105b 100644 --- a/tests/baselines/reference/declarationEmitSpreadStringlyKeyedEnum.js +++ b/tests/baselines/reference/declarationEmitSpreadStringlyKeyedEnum.js @@ -53,3 +53,53 @@ export declare const SpotifyAgeGroupEnum: { "60-150": (typeof AgeGroups)["60-150"]; }; export {}; + + +//// [DtsFileErrors] + + +declarationEmitSpreadStringlyKeyedEnum.d.ts(12,5): error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["0-17"]'. +declarationEmitSpreadStringlyKeyedEnum.d.ts(13,5): error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["18-22"]'. +declarationEmitSpreadStringlyKeyedEnum.d.ts(14,5): error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["23-27"]'. +declarationEmitSpreadStringlyKeyedEnum.d.ts(15,5): error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["28-34"]'. +declarationEmitSpreadStringlyKeyedEnum.d.ts(16,5): error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["35-44"]'. +declarationEmitSpreadStringlyKeyedEnum.d.ts(17,5): error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["45-59"]'. +declarationEmitSpreadStringlyKeyedEnum.d.ts(18,5): error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["60-150"]'. + + +==== declarationEmitSpreadStringlyKeyedEnum.d.ts (7 errors) ==== + declare enum AgeGroups { + "0-17" = 0, + "18-22" = 1, + "23-27" = 2, + "28-34" = 3, + "35-44" = 4, + "45-59" = 5, + "60-150" = 6 + } + export declare const SpotifyAgeGroupEnum: { + [x: number]: string; + "0-17": (typeof AgeGroups)["0-17"]; + ~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["0-17"]'. + "18-22": (typeof AgeGroups)["18-22"]; + ~~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["18-22"]'. + "23-27": (typeof AgeGroups)["23-27"]; + ~~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["23-27"]'. + "28-34": (typeof AgeGroups)["28-34"]; + ~~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["28-34"]'. + "35-44": (typeof AgeGroups)["35-44"]; + ~~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["35-44"]'. + "45-59": (typeof AgeGroups)["45-59"]; + ~~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["45-59"]'. + "60-150": (typeof AgeGroups)["60-150"]; + ~~~~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'AgeGroups' or '(typeof AgeGroups)["60-150"]'. + }; + export {}; + \ No newline at end of file diff --git a/tests/baselines/reference/intraExpressionInferences.errors.txt b/tests/baselines/reference/intraExpressionInferences.errors.txt index 82da18c788e9b..74864b5494605 100644 --- a/tests/baselines/reference/intraExpressionInferences.errors.txt +++ b/tests/baselines/reference/intraExpressionInferences.errors.txt @@ -3,9 +3,11 @@ intraExpressionInferences.ts(131,5): error TS2322: Type '(inputs: Unwrap<{ num: The types of 'str' are incompatible between these types. Type 'number' is not assignable to type 'string'. intraExpressionInferences.ts(133,26): error TS2339: Property 'nonexistent' does not exist on type 'Unwrap<{ num: Wrapper; str: Wrapper; }>'. +intraExpressionInferences.ts(148,57): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '2 | 1'. +intraExpressionInferences.ts(149,34): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '2 | 1'. -==== intraExpressionInferences.ts (2 errors) ==== +==== intraExpressionInferences.ts (4 errors) ==== // Repros from #47599 declare function callIt(obj: { @@ -162,7 +164,11 @@ intraExpressionInferences.ts(133,26): error TS2339: Property 'nonexistent' does simplified({ generator: () => 123, receiver: (t) => console.log(t + 2) }) whatIWant({ generator: (bob) => bob ? 1 : 2, receiver: (t) => console.log(t + 2) }) + ~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '2 | 1'. nonObject((bob) => bob ? 1 : 2, (t) => console.log(t + 2)) + ~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '2 | 1'. // Repro from #48466 diff --git a/tests/baselines/reference/literalTypes2.errors.txt b/tests/baselines/reference/literalTypes2.errors.txt index 281b3b9c2e507..f20ffd3b3c7ec 100644 --- a/tests/baselines/reference/literalTypes2.errors.txt +++ b/tests/baselines/reference/literalTypes2.errors.txt @@ -1,8 +1,10 @@ +literalTypes2.ts(102,24): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 0'. +literalTypes2.ts(102,32): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"foo" | "bar"'. literalTypes2.ts(155,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. literalTypes2.ts(156,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or '1 | "two"'. -==== literalTypes2.ts (2 errors) ==== +==== literalTypes2.ts (4 errors) ==== enum E { A, B, C } @@ -105,6 +107,10 @@ literalTypes2.ts(156,7): error TS2856: The type of this declaration is ambiguous function f6() { const { c1 = true, c2 = 0, c3 = "foo" } = { c1: false, c2: 1, c3: "bar" }; + ~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 0'. + ~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"foo" | "bar"'. let { x1 = true, x2 = 0, x3 = "foo" } = { x1: false, x2: 1, x3: "bar" }; } diff --git a/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt index 4befe8603ae9c..5e8d24d28f969 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt @@ -1,7 +1,8 @@ +typeArgumentInferenceWithObjectLiteral.ts(30,18): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '0'. typeArgumentInferenceWithObjectLiteral.ts(35,43): error TS2345: Argument of type 'E2' is not assignable to parameter of type 'E1'. -==== typeArgumentInferenceWithObjectLiteral.ts (1 errors) ==== +==== typeArgumentInferenceWithObjectLiteral.ts (2 errors) ==== interface Computed { read(): T; write(value: T); @@ -32,6 +33,8 @@ typeArgumentInferenceWithObjectLiteral.ts(35,43): error TS2345: Argument of type var v1 = f1({ w: x => x, r: () => 0 }, 0); var v1 = f1({ w: x => x, r: () => 0 }, E1.X); var v1 = f1({ w: x => x, r: () => E1.X }, 0); + ~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '0'. var v2: E1; var v2 = f1({ w: x => x, r: () => E1.X }, E1.X); diff --git a/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt b/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt index 7d1beaf9615f0..c70badcb65ab7 100644 --- a/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt +++ b/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt @@ -1,9 +1,12 @@ typeInferenceConflictingCandidates.ts(3,7): error TS2345: Argument of type '3' is not assignable to parameter of type '""'. +typeInferenceConflictingCandidates.ts(3,10): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '""'. -==== typeInferenceConflictingCandidates.ts (1 errors) ==== +==== typeInferenceConflictingCandidates.ts (2 errors) ==== declare function g(a: T, b: T, c: (t: T) => T): T; g("", 3, a => a); ~ -!!! error TS2345: Argument of type '3' is not assignable to parameter of type '""'. \ No newline at end of file +!!! error TS2345: Argument of type '3' is not assignable to parameter of type '""'. + ~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '""'. \ No newline at end of file From 0ca3a1f099554cca95bf1e5dd8db8fb1f45d3df1 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 25 Sep 2023 13:40:25 -0700 Subject: [PATCH 4/8] Don't check private stuff --- src/compiler/checker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2ee2548450da0..6fce12c687e52 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -42013,6 +42013,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if ( !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) && !shouldPrintWithInitializer(node) + && !(hasEffectiveModifier(node, ModifierFlags.Private) || isPrivateIdentifierClassElementDeclaration(node)) && !isDeclarationAndNotVisible(node) ) { const widenedLiteralType = getWidenedLiteralType(type); From aa82b67f5c41bf5d6f628d06c060c033c7bf3155 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 25 Sep 2023 15:50:44 -0700 Subject: [PATCH 5/8] Add incorrect case caught in top100 --- .../ambiguousLiteralWideningEmit.errors.txt | 16 +++++++ .../reference/ambiguousLiteralWideningEmit.js | 23 +++++++++ .../ambiguousLiteralWideningEmit.symbols | 33 +++++++++++++ .../ambiguousLiteralWideningEmit.types | 48 +++++++++++++++++++ .../compiler/ambiguousLiteralWideningEmit.ts | 9 ++++ 5 files changed, 129 insertions(+) create mode 100644 tests/baselines/reference/ambiguousLiteralWideningEmit.errors.txt create mode 100644 tests/baselines/reference/ambiguousLiteralWideningEmit.js create mode 100644 tests/baselines/reference/ambiguousLiteralWideningEmit.symbols create mode 100644 tests/baselines/reference/ambiguousLiteralWideningEmit.types create mode 100644 tests/cases/compiler/ambiguousLiteralWideningEmit.ts diff --git a/tests/baselines/reference/ambiguousLiteralWideningEmit.errors.txt b/tests/baselines/reference/ambiguousLiteralWideningEmit.errors.txt new file mode 100644 index 0000000000000..aaee3185c7780 --- /dev/null +++ b/tests/baselines/reference/ambiguousLiteralWideningEmit.errors.txt @@ -0,0 +1,16 @@ +ambiguousLiteralWideningEmit.ts(4,18): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or 'string | 1'. +ambiguousLiteralWideningEmit.ts(4,29): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or 'string | 1'. + + +==== ambiguousLiteralWideningEmit.ts (2 errors) ==== + declare function pad(n: number | string): string; + + export default (dateString: string, type: 'date' | 'month' | 'year'): string => { + const [year, month = 1, date = 1] = dateString.split('-') + ~~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or 'string | 1'. + ~~~~ +!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or 'string | 1'. + return `${year}-${pad(month)}-${pad(date)}`.substr(0, { date: 10, month: 7, year: 4 }[type]) + } + \ No newline at end of file diff --git a/tests/baselines/reference/ambiguousLiteralWideningEmit.js b/tests/baselines/reference/ambiguousLiteralWideningEmit.js new file mode 100644 index 0000000000000..400623c80543d --- /dev/null +++ b/tests/baselines/reference/ambiguousLiteralWideningEmit.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/ambiguousLiteralWideningEmit.ts] //// + +//// [ambiguousLiteralWideningEmit.ts] +declare function pad(n: number | string): string; + +export default (dateString: string, type: 'date' | 'month' | 'year'): string => { + const [year, month = 1, date = 1] = dateString.split('-') + return `${year}-${pad(month)}-${pad(date)}`.substr(0, { date: 10, month: 7, year: 4 }[type]) +} + + +//// [ambiguousLiteralWideningEmit.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = (function (dateString, type) { + var _a = dateString.split('-'), year = _a[0], _b = _a[1], month = _b === void 0 ? 1 : _b, _c = _a[2], date = _c === void 0 ? 1 : _c; + return "".concat(year, "-").concat(pad(month), "-").concat(pad(date)).substr(0, { date: 10, month: 7, year: 4 }[type]); +}); + + +//// [ambiguousLiteralWideningEmit.d.ts] +declare const _default: (dateString: string, type: 'date' | 'month' | 'year') => string; +export default _default; diff --git a/tests/baselines/reference/ambiguousLiteralWideningEmit.symbols b/tests/baselines/reference/ambiguousLiteralWideningEmit.symbols new file mode 100644 index 0000000000000..c9c98bf17cf50 --- /dev/null +++ b/tests/baselines/reference/ambiguousLiteralWideningEmit.symbols @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/ambiguousLiteralWideningEmit.ts] //// + +=== ambiguousLiteralWideningEmit.ts === +declare function pad(n: number | string): string; +>pad : Symbol(pad, Decl(ambiguousLiteralWideningEmit.ts, 0, 0)) +>n : Symbol(n, Decl(ambiguousLiteralWideningEmit.ts, 0, 21)) + +export default (dateString: string, type: 'date' | 'month' | 'year'): string => { +>dateString : Symbol(dateString, Decl(ambiguousLiteralWideningEmit.ts, 2, 16)) +>type : Symbol(type, Decl(ambiguousLiteralWideningEmit.ts, 2, 35)) + + const [year, month = 1, date = 1] = dateString.split('-') +>year : Symbol(year, Decl(ambiguousLiteralWideningEmit.ts, 3, 11)) +>month : Symbol(month, Decl(ambiguousLiteralWideningEmit.ts, 3, 16)) +>date : Symbol(date, Decl(ambiguousLiteralWideningEmit.ts, 3, 27)) +>dateString.split : Symbol(String.split, Decl(lib.es5.d.ts, --, --)) +>dateString : Symbol(dateString, Decl(ambiguousLiteralWideningEmit.ts, 2, 16)) +>split : Symbol(String.split, Decl(lib.es5.d.ts, --, --)) + + return `${year}-${pad(month)}-${pad(date)}`.substr(0, { date: 10, month: 7, year: 4 }[type]) +>`${year}-${pad(month)}-${pad(date)}`.substr : Symbol(String.substr, Decl(lib.es5.d.ts, --, --)) +>year : Symbol(year, Decl(ambiguousLiteralWideningEmit.ts, 3, 11)) +>pad : Symbol(pad, Decl(ambiguousLiteralWideningEmit.ts, 0, 0)) +>month : Symbol(month, Decl(ambiguousLiteralWideningEmit.ts, 3, 16)) +>pad : Symbol(pad, Decl(ambiguousLiteralWideningEmit.ts, 0, 0)) +>date : Symbol(date, Decl(ambiguousLiteralWideningEmit.ts, 3, 27)) +>substr : Symbol(String.substr, Decl(lib.es5.d.ts, --, --)) +>date : Symbol(date, Decl(ambiguousLiteralWideningEmit.ts, 4, 59)) +>month : Symbol(month, Decl(ambiguousLiteralWideningEmit.ts, 4, 69)) +>year : Symbol(year, Decl(ambiguousLiteralWideningEmit.ts, 4, 79)) +>type : Symbol(type, Decl(ambiguousLiteralWideningEmit.ts, 2, 35)) +} + diff --git a/tests/baselines/reference/ambiguousLiteralWideningEmit.types b/tests/baselines/reference/ambiguousLiteralWideningEmit.types new file mode 100644 index 0000000000000..d2c6ad50a50b8 --- /dev/null +++ b/tests/baselines/reference/ambiguousLiteralWideningEmit.types @@ -0,0 +1,48 @@ +//// [tests/cases/compiler/ambiguousLiteralWideningEmit.ts] //// + +=== ambiguousLiteralWideningEmit.ts === +declare function pad(n: number | string): string; +>pad : (n: number | string) => string +>n : string | number + +export default (dateString: string, type: 'date' | 'month' | 'year'): string => { +>(dateString: string, type: 'date' | 'month' | 'year'): string => { const [year, month = 1, date = 1] = dateString.split('-') return `${year}-${pad(month)}-${pad(date)}`.substr(0, { date: 10, month: 7, year: 4 }[type])} : (dateString: string, type: 'date' | 'month' | 'year') => string +>dateString : string +>type : "date" | "month" | "year" + + const [year, month = 1, date = 1] = dateString.split('-') +>year : string +>month : string | 1 +>1 : 1 +>date : string | 1 +>1 : 1 +>dateString.split('-') : string[] +>dateString.split : (separator: string | RegExp, limit?: number | undefined) => string[] +>dateString : string +>split : (separator: string | RegExp, limit?: number | undefined) => string[] +>'-' : "-" + + return `${year}-${pad(month)}-${pad(date)}`.substr(0, { date: 10, month: 7, year: 4 }[type]) +>`${year}-${pad(month)}-${pad(date)}`.substr(0, { date: 10, month: 7, year: 4 }[type]) : string +>`${year}-${pad(month)}-${pad(date)}`.substr : (from: number, length?: number | undefined) => string +>`${year}-${pad(month)}-${pad(date)}` : string +>year : string +>pad(month) : string +>pad : (n: string | number) => string +>month : string | 1 +>pad(date) : string +>pad : (n: string | number) => string +>date : string | 1 +>substr : (from: number, length?: number | undefined) => string +>0 : 0 +>{ date: 10, month: 7, year: 4 }[type] : number +>{ date: 10, month: 7, year: 4 } : { date: number; month: number; year: number; } +>date : number +>10 : 10 +>month : number +>7 : 7 +>year : number +>4 : 4 +>type : "date" | "month" | "year" +} + diff --git a/tests/cases/compiler/ambiguousLiteralWideningEmit.ts b/tests/cases/compiler/ambiguousLiteralWideningEmit.ts new file mode 100644 index 0000000000000..65aa81d54f50a --- /dev/null +++ b/tests/cases/compiler/ambiguousLiteralWideningEmit.ts @@ -0,0 +1,9 @@ +// @declaration: true +// @strict: true + +declare function pad(n: number | string): string; + +export default (dateString: string, type: 'date' | 'month' | 'year'): string => { + const [year, month = 1, date = 1] = dateString.split('-') + return `${year}-${pad(month)}-${pad(date)}`.substr(0, { date: 10, month: 7, year: 4 }[type]) +} From 5560b8133a86d12b43bfbda0168445c2564c49fc Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 25 Sep 2023 16:02:24 -0700 Subject: [PATCH 6/8] Fix up visibility --- src/compiler/checker.ts | 36 +- .../ambiguousLiteralWideningEmit.errors.txt | 16 - ...lTypingWithFixedTypeParameters1.errors.txt | 5 +- ...eclFileImportModuleWithExportAssignment.js | 51 ++- ...tionEmitPrivateReadonlyLiterals.errors.txt | 22 -- tests/baselines/reference/declarationMaps.js | 34 +- .../reference/declarationMaps.js.map | 4 +- .../reference/declarationMaps.sourcemap.txt | 221 ++--------- .../reference/declareFileExportAssignment.js | 33 +- ...tAssignmentWithVarFromVariableStatement.js | 33 +- .../reference/importTypeGenericTypes.js | 60 ++- tests/baselines/reference/importTypeLocal.js | 52 ++- .../reference/importTypeLocalMissing.js | 4 - .../intraExpressionInferences.errors.txt | 8 +- .../reference/literalTypes2.errors.txt | 8 +- .../moduleAugmentationImportsAndExports2.js | 6 - .../moduleAugmentationImportsAndExports3.js | 6 - .../moduleAugmentationImportsAndExports5.js | 46 ++- .../reference/privacyAccessorDeclFile.js | 262 ++++++++++--- .../privacyFunctionParameterDeclFile.js | 315 +++++++++++---- .../privacyFunctionParameterDeclFile.types | 40 +- .../privacyFunctionReturnTypeDeclFile.js | 359 ++++++++++++++---- .../privacyFunctionReturnTypeDeclFile.types | 40 +- .../privacyTypeParametersOfClassDeclFile.js | 53 ++- ...rivacyTypeParametersOfInterfaceDeclFile.js | 90 ++++- ...umentInferenceWithObjectLiteral.errors.txt | 5 +- ...eInferenceConflictingCandidates.errors.txt | 7 +- 27 files changed, 1207 insertions(+), 609 deletions(-) delete mode 100644 tests/baselines/reference/ambiguousLiteralWideningEmit.errors.txt delete mode 100644 tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6fce12c687e52..1f3551294b38a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -41974,47 +41974,27 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return canHaveLiteralInitializer(node) && isLiteralConstDeclaration(node as CanHaveLiteralInitializer); // TODO: Make safe } - function getBindingNameVisible(elem: BindingElement | VariableDeclaration | OmittedExpression): boolean { + function isPrivateDeclaration(node: Node) { + return hasEffectiveModifier(node, ModifierFlags.Private) || isPrivateIdentifierClassElementDeclaration(node); + } + + function isVisibleExternally(elem: ParameterDeclaration | PropertyDeclaration | PropertySignature | VariableDeclaration | BindingElement | OmittedExpression): boolean { if (isOmittedExpression(elem)) { return false; } if (isBindingPattern(elem.name)) { - // If any child binding pattern element has been marked visible (usually by collect linked aliases), then this is visible - return some(elem.name.elements, getBindingNameVisible); + return some(elem.name.elements, isVisibleExternally); } else { return isDeclarationVisible(elem); } } - function isDeclarationAndNotVisible(node: NamedDeclaration) { - switch (node.kind) { - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ModuleDeclaration: - case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.ClassDeclaration: - case SyntaxKind.TypeAliasDeclaration: - case SyntaxKind.EnumDeclaration: - return !isDeclarationVisible(node); - // The following should be doing their own visibility checks based on filtering their members - case SyntaxKind.VariableDeclaration: - return !getBindingNameVisible(node as VariableDeclaration); - case SyntaxKind.ImportEqualsDeclaration: - case SyntaxKind.ImportDeclaration: - case SyntaxKind.ExportDeclaration: - case SyntaxKind.ExportAssignment: - return false; - case SyntaxKind.ClassStaticBlockDeclaration: - return true; - } - return false; - } - if ( !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) && !shouldPrintWithInitializer(node) - && !(hasEffectiveModifier(node, ModifierFlags.Private) || isPrivateIdentifierClassElementDeclaration(node)) - && !isDeclarationAndNotVisible(node) + && !isPrivateDeclaration(node) + && isVisibleExternally(node) ) { const widenedLiteralType = getWidenedLiteralType(type); if (!isTypeIdenticalTo(type, widenedLiteralType)) { diff --git a/tests/baselines/reference/ambiguousLiteralWideningEmit.errors.txt b/tests/baselines/reference/ambiguousLiteralWideningEmit.errors.txt deleted file mode 100644 index aaee3185c7780..0000000000000 --- a/tests/baselines/reference/ambiguousLiteralWideningEmit.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -ambiguousLiteralWideningEmit.ts(4,18): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or 'string | 1'. -ambiguousLiteralWideningEmit.ts(4,29): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or 'string | 1'. - - -==== ambiguousLiteralWideningEmit.ts (2 errors) ==== - declare function pad(n: number | string): string; - - export default (dateString: string, type: 'date' | 'month' | 'year'): string => { - const [year, month = 1, date = 1] = dateString.split('-') - ~~~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or 'string | 1'. - ~~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or 'string | 1'. - return `${year}-${pad(month)}-${pad(date)}`.substr(0, { date: 10, month: 7, year: 4 }[type]) - } - \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt index 64b31705b6fd6..411a6b9079b81 100644 --- a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt +++ b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt @@ -1,17 +1,14 @@ contextualTypingWithFixedTypeParameters1.ts(2,22): error TS2339: Property 'foo' does not exist on type 'string'. -contextualTypingWithFixedTypeParameters1.ts(3,25): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '""'. contextualTypingWithFixedTypeParameters1.ts(3,32): error TS2339: Property 'foo' does not exist on type '""'. contextualTypingWithFixedTypeParameters1.ts(3,38): error TS2345: Argument of type '1' is not assignable to parameter of type '""'. -==== contextualTypingWithFixedTypeParameters1.ts (4 errors) ==== +==== contextualTypingWithFixedTypeParameters1.ts (3 errors) ==== var f10: (x: T, b: () => (a: T) => void, y: T) => T; f10('', () => a => a.foo, ''); // a is "" ~~~ !!! error TS2339: Property 'foo' does not exist on type 'string'. var r9 = f10('', () => (a => a.foo), 1); // error - ~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '""'. ~~~ !!! error TS2339: Property 'foo' does not exist on type '""'. ~ diff --git a/tests/baselines/reference/declFileImportModuleWithExportAssignment.js b/tests/baselines/reference/declFileImportModuleWithExportAssignment.js index 65bac37e0e884..7fb4a35d7b153 100644 --- a/tests/baselines/reference/declFileImportModuleWithExportAssignment.js +++ b/tests/baselines/reference/declFileImportModuleWithExportAssignment.js @@ -41,13 +41,6 @@ exports.a.test1(null, null, null); //// [declFileImportModuleWithExportAssignment_0.d.ts] declare namespace m2 { - interface connectModule { - (res: any, req: any, next: any): void; - } - interface connectExport { - use: (mod: connectModule) => connectExport; - listen: (port: number) => void; - } } declare var m2: { (): m2.connectExport; @@ -63,3 +56,47 @@ export declare var a: { test1: a1.connectModule; test2(): a1.connectModule; }; + + +//// [DtsFileErrors] + + +declFileImportModuleWithExportAssignment_0.d.ts(4,12): error TS2694: Namespace 'm2' has no exported member 'connectExport'. +declFileImportModuleWithExportAssignment_0.d.ts(5,15): error TS2694: Namespace 'm2' has no exported member 'connectModule'. +declFileImportModuleWithExportAssignment_0.d.ts(6,17): error TS2694: Namespace 'm2' has no exported member 'connectModule'. +declFileImportModuleWithExportAssignment_1.d.ts(4,12): error TS2694: Namespace 'm2' has no exported member 'connectExport'. +declFileImportModuleWithExportAssignment_1.d.ts(5,15): error TS2694: Namespace 'm2' has no exported member 'connectModule'. +declFileImportModuleWithExportAssignment_1.d.ts(6,17): error TS2694: Namespace 'm2' has no exported member 'connectModule'. + + +==== declFileImportModuleWithExportAssignment_1.d.ts (3 errors) ==== + /**This is on import declaration*/ + import a1 = require("./declFileImportModuleWithExportAssignment_0"); + export declare var a: { + (): a1.connectExport; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectExport'. + test1: a1.connectModule; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. + test2(): a1.connectModule; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. + }; + +==== declFileImportModuleWithExportAssignment_0.d.ts (3 errors) ==== + declare namespace m2 { + } + declare var m2: { + (): m2.connectExport; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectExport'. + test1: m2.connectModule; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. + test2(): m2.connectModule; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. + }; + export = m2; + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.errors.txt b/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.errors.txt deleted file mode 100644 index c3f7d845dc4e2..0000000000000 --- a/tests/baselines/reference/declarationEmitPrivateReadonlyLiterals.errors.txt +++ /dev/null @@ -1,22 +0,0 @@ -declarationEmitPrivateReadonlyLiterals.ts(2,29): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"a"'. -declarationEmitPrivateReadonlyLiterals.ts(3,22): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"b"'. -declarationEmitPrivateReadonlyLiterals.ts(4,29): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '42'. -declarationEmitPrivateReadonlyLiterals.ts(5,22): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '42'. - - -==== declarationEmitPrivateReadonlyLiterals.ts (4 errors) ==== - class Foo { - private static readonly A = "a"; - ~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"a"'. - private readonly B = "b"; - ~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"b"'. - private static readonly C = 42; - ~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '42'. - private readonly D = 42; - ~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '42'. - } - \ No newline at end of file diff --git a/tests/baselines/reference/declarationMaps.js b/tests/baselines/reference/declarationMaps.js index 1129dcac17795..1c37b90241f66 100644 --- a/tests/baselines/reference/declarationMaps.js +++ b/tests/baselines/reference/declarationMaps.js @@ -28,13 +28,6 @@ module.exports = m2; //// [declarationMaps.d.ts] declare namespace m2 { - interface connectModule { - (res: any, req: any, next: any): void; - } - interface connectExport { - use: (mod: connectModule) => connectExport; - listen: (port: number) => void; - } } declare var m2: { (): m2.connectExport; @@ -42,4 +35,29 @@ declare var m2: { test2(): m2.connectModule; }; export = m2; -//# sourceMappingURL=declarationMaps.d.ts.map \ No newline at end of file +//# sourceMappingURL=declarationMaps.d.ts.map + +//// [DtsFileErrors] + + +declarationMaps.d.ts(4,12): error TS2694: Namespace 'm2' has no exported member 'connectExport'. +declarationMaps.d.ts(5,15): error TS2694: Namespace 'm2' has no exported member 'connectModule'. +declarationMaps.d.ts(6,17): error TS2694: Namespace 'm2' has no exported member 'connectModule'. + + +==== declarationMaps.d.ts (3 errors) ==== + declare namespace m2 { + } + declare var m2: { + (): m2.connectExport; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectExport'. + test1: m2.connectModule; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. + test2(): m2.connectModule; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. + }; + export = m2; + //# sourceMappingURL=declarationMaps.d.ts.map \ No newline at end of file diff --git a/tests/baselines/reference/declarationMaps.js.map b/tests/baselines/reference/declarationMaps.js.map index e26401dd61deb..3cd149787e18a 100644 --- a/tests/baselines/reference/declarationMaps.js.map +++ b/tests/baselines/reference/declarationMaps.js.map @@ -1,3 +1,3 @@ //// [declarationMaps.d.ts.map] -{"version":3,"file":"declarationMaps.d.ts","sourceRoot":"","sources":["declarationMaps.ts"],"names":[],"mappings":"AAAA,kBAAO,EAAE,CAAC;IACN,UAAiB,aAAa;QAC1B,CAAC,GAAG,KAAA,EAAE,GAAG,KAAA,EAAE,IAAI,KAAA,GAAG,IAAI,CAAC;KAC1B;IACD,UAAiB,aAAa;QAC1B,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,aAAa,CAAC;QAC3C,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;KAClC;CAEJ;AAED,QAAA,IAAI,EAAE,EAAE;IACJ,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC;IACxB,KAAK,IAAI,EAAE,CAAC,aAAa,CAAC;CAC7B,CAAC;AAEF,SAAS,EAAE,CAAC"} -//// https://sokra.github.io/source-map-visualization#base64,ZGVjbGFyZSBuYW1lc3BhY2UgbTIgew0KICAgIGludGVyZmFjZSBjb25uZWN0TW9kdWxlIHsNCiAgICAgICAgKHJlczogYW55LCByZXE6IGFueSwgbmV4dDogYW55KTogdm9pZDsNCiAgICB9DQogICAgaW50ZXJmYWNlIGNvbm5lY3RFeHBvcnQgew0KICAgICAgICB1c2U6IChtb2Q6IGNvbm5lY3RNb2R1bGUpID0+IGNvbm5lY3RFeHBvcnQ7DQogICAgICAgIGxpc3RlbjogKHBvcnQ6IG51bWJlcikgPT4gdm9pZDsNCiAgICB9DQp9DQpkZWNsYXJlIHZhciBtMjogew0KICAgICgpOiBtMi5jb25uZWN0RXhwb3J0Ow0KICAgIHRlc3QxOiBtMi5jb25uZWN0TW9kdWxlOw0KICAgIHRlc3QyKCk6IG0yLmNvbm5lY3RNb2R1bGU7DQp9Ow0KZXhwb3J0ID0gbTI7DQovLyMgc291cmNlTWFwcGluZ1VSTD1kZWNsYXJhdGlvbk1hcHMuZC50cy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjbGFyYXRpb25NYXBzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJkZWNsYXJhdGlvbk1hcHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsa0JBQU8sRUFBRSxDQUFDO0lBQ04sVUFBaUIsYUFBYTtRQUMxQixDQUFDLEdBQUcsS0FBQSxFQUFFLEdBQUcsS0FBQSxFQUFFLElBQUksS0FBQSxHQUFHLElBQUksQ0FBQztLQUMxQjtJQUNELFVBQWlCLGFBQWE7UUFDMUIsR0FBRyxFQUFFLENBQUMsR0FBRyxFQUFFLGFBQWEsS0FBSyxhQUFhLENBQUM7UUFDM0MsTUFBTSxFQUFFLENBQUMsSUFBSSxFQUFFLE1BQU0sS0FBSyxJQUFJLENBQUM7S0FDbEM7Q0FFSjtBQUVELFFBQUEsSUFBSSxFQUFFLEVBQUU7SUFDSixJQUFJLEVBQUUsQ0FBQyxhQUFhLENBQUM7SUFDckIsS0FBSyxFQUFFLEVBQUUsQ0FBQyxhQUFhLENBQUM7SUFDeEIsS0FBSyxJQUFJLEVBQUUsQ0FBQyxhQUFhLENBQUM7Q0FDN0IsQ0FBQztBQUVGLFNBQVMsRUFBRSxDQUFDIn0=,bW9kdWxlIG0yIHsKICAgIGV4cG9ydCBpbnRlcmZhY2UgY29ubmVjdE1vZHVsZSB7CiAgICAgICAgKHJlcywgcmVxLCBuZXh0KTogdm9pZDsKICAgIH0KICAgIGV4cG9ydCBpbnRlcmZhY2UgY29ubmVjdEV4cG9ydCB7CiAgICAgICAgdXNlOiAobW9kOiBjb25uZWN0TW9kdWxlKSA9PiBjb25uZWN0RXhwb3J0OwogICAgICAgIGxpc3RlbjogKHBvcnQ6IG51bWJlcikgPT4gdm9pZDsKICAgIH0KCn0KCnZhciBtMjogewogICAgKCk6IG0yLmNvbm5lY3RFeHBvcnQ7CiAgICB0ZXN0MTogbTIuY29ubmVjdE1vZHVsZTsKICAgIHRlc3QyKCk6IG0yLmNvbm5lY3RNb2R1bGU7Cn07CgpleHBvcnQgPSBtMjs= +{"version":3,"file":"declarationMaps.d.ts","sourceRoot":"","sources":["declarationMaps.ts"],"names":[],"mappings":"AAAA,kBAAO,EAAE,CAAC;CAST;AAED,QAAA,IAAI,EAAE,EAAE;IACJ,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC;IACxB,KAAK,IAAI,EAAE,CAAC,aAAa,CAAC;CAC7B,CAAC;AAEF,SAAS,EAAE,CAAC"} +//// https://sokra.github.io/source-map-visualization#base64,ZGVjbGFyZSBuYW1lc3BhY2UgbTIgew0KfQ0KZGVjbGFyZSB2YXIgbTI6IHsNCiAgICAoKTogbTIuY29ubmVjdEV4cG9ydDsNCiAgICB0ZXN0MTogbTIuY29ubmVjdE1vZHVsZTsNCiAgICB0ZXN0MigpOiBtMi5jb25uZWN0TW9kdWxlOw0KfTsNCmV4cG9ydCA9IG0yOw0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZGVjbGFyYXRpb25NYXBzLmQudHMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjbGFyYXRpb25NYXBzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJkZWNsYXJhdGlvbk1hcHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsa0JBQU8sRUFBRSxDQUFDO0NBU1Q7QUFFRCxRQUFBLElBQUksRUFBRSxFQUFFO0lBQ0osSUFBSSxFQUFFLENBQUMsYUFBYSxDQUFDO0lBQ3JCLEtBQUssRUFBRSxFQUFFLENBQUMsYUFBYSxDQUFDO0lBQ3hCLEtBQUssSUFBSSxFQUFFLENBQUMsYUFBYSxDQUFDO0NBQzdCLENBQUM7QUFFRixTQUFTLEVBQUUsQ0FBQyJ9,bW9kdWxlIG0yIHsKICAgIGV4cG9ydCBpbnRlcmZhY2UgY29ubmVjdE1vZHVsZSB7CiAgICAgICAgKHJlcywgcmVxLCBuZXh0KTogdm9pZDsKICAgIH0KICAgIGV4cG9ydCBpbnRlcmZhY2UgY29ubmVjdEV4cG9ydCB7CiAgICAgICAgdXNlOiAobW9kOiBjb25uZWN0TW9kdWxlKSA9PiBjb25uZWN0RXhwb3J0OwogICAgICAgIGxpc3RlbjogKHBvcnQ6IG51bWJlcikgPT4gdm9pZDsKICAgIH0KCn0KCnZhciBtMjogewogICAgKCk6IG0yLmNvbm5lY3RFeHBvcnQ7CiAgICB0ZXN0MTogbTIuY29ubmVjdE1vZHVsZTsKICAgIHRlc3QyKCk6IG0yLmNvbm5lY3RNb2R1bGU7Cn07CgpleHBvcnQgPSBtMjs= diff --git a/tests/baselines/reference/declarationMaps.sourcemap.txt b/tests/baselines/reference/declarationMaps.sourcemap.txt index c1784ff9afa8a..b8995f04d8de2 100644 --- a/tests/baselines/reference/declarationMaps.sourcemap.txt +++ b/tests/baselines/reference/declarationMaps.sourcemap.txt @@ -13,7 +13,6 @@ sourceFile:declarationMaps.ts 2 >^^^^^^^^^^^^^^^^^^ 3 > ^^ 4 > ^ -5 > ^^^^^^^^^-> 1 > 2 >module 3 > m2 @@ -23,160 +22,20 @@ sourceFile:declarationMaps.ts 3 >Emitted(1, 21) Source(1, 10) + SourceIndex(0) 4 >Emitted(1, 22) Source(1, 11) + SourceIndex(0) --- ->>> interface connectModule { -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^-> -1->{ - > -2 > export interface -3 > connectModule -1->Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 15) Source(2, 22) + SourceIndex(0) -3 >Emitted(2, 28) Source(2, 35) + SourceIndex(0) ---- ->>> (res: any, req: any, next: any): void; -1->^^^^^^^^ -2 > ^ -3 > ^^^ -4 > ^^^^^ -5 > ^^ -6 > ^^^ -7 > ^^^^^ -8 > ^^ -9 > ^^^^ -10> ^^^^^ -11> ^^^ -12> ^^^^ -13> ^ -1-> { - > -2 > ( -3 > res -4 > -5 > , -6 > req -7 > -8 > , -9 > next -10> -11> ): -12> void -13> ; -1->Emitted(3, 9) Source(3, 9) + SourceIndex(0) -2 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) -3 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) -4 >Emitted(3, 18) Source(3, 13) + SourceIndex(0) -5 >Emitted(3, 20) Source(3, 15) + SourceIndex(0) -6 >Emitted(3, 23) Source(3, 18) + SourceIndex(0) -7 >Emitted(3, 28) Source(3, 18) + SourceIndex(0) -8 >Emitted(3, 30) Source(3, 20) + SourceIndex(0) -9 >Emitted(3, 34) Source(3, 24) + SourceIndex(0) -10>Emitted(3, 39) Source(3, 24) + SourceIndex(0) -11>Emitted(3, 42) Source(3, 27) + SourceIndex(0) -12>Emitted(3, 46) Source(3, 31) + SourceIndex(0) -13>Emitted(3, 47) Source(3, 32) + SourceIndex(0) ---- ->>> } -1 >^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > - > } -1 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) ---- ->>> interface connectExport { -1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> - > -2 > export interface -3 > connectExport -1->Emitted(5, 5) Source(5, 5) + SourceIndex(0) -2 >Emitted(5, 15) Source(5, 22) + SourceIndex(0) -3 >Emitted(5, 28) Source(5, 35) + SourceIndex(0) ---- ->>> use: (mod: connectModule) => connectExport; -1->^^^^^^^^ -2 > ^^^ -3 > ^^ -4 > ^ -5 > ^^^ -6 > ^^ -7 > ^^^^^^^^^^^^^ -8 > ^^^^^ -9 > ^^^^^^^^^^^^^ -10> ^ -1-> { - > -2 > use -3 > : -4 > ( -5 > mod -6 > : -7 > connectModule -8 > ) => -9 > connectExport -10> ; -1->Emitted(6, 9) Source(6, 9) + SourceIndex(0) -2 >Emitted(6, 12) Source(6, 12) + SourceIndex(0) -3 >Emitted(6, 14) Source(6, 14) + SourceIndex(0) -4 >Emitted(6, 15) Source(6, 15) + SourceIndex(0) -5 >Emitted(6, 18) Source(6, 18) + SourceIndex(0) -6 >Emitted(6, 20) Source(6, 20) + SourceIndex(0) -7 >Emitted(6, 33) Source(6, 33) + SourceIndex(0) -8 >Emitted(6, 38) Source(6, 38) + SourceIndex(0) -9 >Emitted(6, 51) Source(6, 51) + SourceIndex(0) -10>Emitted(6, 52) Source(6, 52) + SourceIndex(0) ---- ->>> listen: (port: number) => void; -1 >^^^^^^^^ -2 > ^^^^^^ -3 > ^^ -4 > ^ -5 > ^^^^ -6 > ^^ -7 > ^^^^^^ -8 > ^^^^^ -9 > ^^^^ -10> ^ -1 > - > -2 > listen -3 > : -4 > ( -5 > port -6 > : -7 > number -8 > ) => -9 > void -10> ; -1 >Emitted(7, 9) Source(7, 9) + SourceIndex(0) -2 >Emitted(7, 15) Source(7, 15) + SourceIndex(0) -3 >Emitted(7, 17) Source(7, 17) + SourceIndex(0) -4 >Emitted(7, 18) Source(7, 18) + SourceIndex(0) -5 >Emitted(7, 22) Source(7, 22) + SourceIndex(0) -6 >Emitted(7, 24) Source(7, 24) + SourceIndex(0) -7 >Emitted(7, 30) Source(7, 30) + SourceIndex(0) -8 >Emitted(7, 35) Source(7, 35) + SourceIndex(0) -9 >Emitted(7, 39) Source(7, 39) + SourceIndex(0) -10>Emitted(7, 40) Source(7, 40) + SourceIndex(0) ---- ->>> } -1 >^^^^^ -1 > - > } -1 >Emitted(8, 6) Source(8, 6) + SourceIndex(0) ---- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> -1 > +1 >{ + > export interface connectModule { + > (res, req, next): void; + > } + > export interface connectExport { + > use: (mod: connectModule) => connectExport; + > listen: (port: number) => void; + > } > >} -1 >Emitted(9, 2) Source(10, 2) + SourceIndex(0) +1 >Emitted(2, 2) Source(10, 2) + SourceIndex(0) --- >>>declare var m2: { 1-> @@ -192,11 +51,11 @@ sourceFile:declarationMaps.ts 3 > var 4 > m2 5 > : -1->Emitted(10, 1) Source(12, 1) + SourceIndex(0) -2 >Emitted(10, 9) Source(12, 1) + SourceIndex(0) -3 >Emitted(10, 13) Source(12, 5) + SourceIndex(0) -4 >Emitted(10, 15) Source(12, 7) + SourceIndex(0) -5 >Emitted(10, 17) Source(12, 9) + SourceIndex(0) +1->Emitted(3, 1) Source(12, 1) + SourceIndex(0) +2 >Emitted(3, 9) Source(12, 1) + SourceIndex(0) +3 >Emitted(3, 13) Source(12, 5) + SourceIndex(0) +4 >Emitted(3, 15) Source(12, 7) + SourceIndex(0) +5 >Emitted(3, 17) Source(12, 9) + SourceIndex(0) --- >>> (): m2.connectExport; 1->^^^^ @@ -213,12 +72,12 @@ sourceFile:declarationMaps.ts 4 > . 5 > connectExport 6 > ; -1->Emitted(11, 5) Source(13, 5) + SourceIndex(0) -2 >Emitted(11, 9) Source(13, 9) + SourceIndex(0) -3 >Emitted(11, 11) Source(13, 11) + SourceIndex(0) -4 >Emitted(11, 12) Source(13, 12) + SourceIndex(0) -5 >Emitted(11, 25) Source(13, 25) + SourceIndex(0) -6 >Emitted(11, 26) Source(13, 26) + SourceIndex(0) +1->Emitted(4, 5) Source(13, 5) + SourceIndex(0) +2 >Emitted(4, 9) Source(13, 9) + SourceIndex(0) +3 >Emitted(4, 11) Source(13, 11) + SourceIndex(0) +4 >Emitted(4, 12) Source(13, 12) + SourceIndex(0) +5 >Emitted(4, 25) Source(13, 25) + SourceIndex(0) +6 >Emitted(4, 26) Source(13, 26) + SourceIndex(0) --- >>> test1: m2.connectModule; 1->^^^^ @@ -237,13 +96,13 @@ sourceFile:declarationMaps.ts 5 > . 6 > connectModule 7 > ; -1->Emitted(12, 5) Source(14, 5) + SourceIndex(0) -2 >Emitted(12, 10) Source(14, 10) + SourceIndex(0) -3 >Emitted(12, 12) Source(14, 12) + SourceIndex(0) -4 >Emitted(12, 14) Source(14, 14) + SourceIndex(0) -5 >Emitted(12, 15) Source(14, 15) + SourceIndex(0) -6 >Emitted(12, 28) Source(14, 28) + SourceIndex(0) -7 >Emitted(12, 29) Source(14, 29) + SourceIndex(0) +1->Emitted(5, 5) Source(14, 5) + SourceIndex(0) +2 >Emitted(5, 10) Source(14, 10) + SourceIndex(0) +3 >Emitted(5, 12) Source(14, 12) + SourceIndex(0) +4 >Emitted(5, 14) Source(14, 14) + SourceIndex(0) +5 >Emitted(5, 15) Source(14, 15) + SourceIndex(0) +6 >Emitted(5, 28) Source(14, 28) + SourceIndex(0) +7 >Emitted(5, 29) Source(14, 29) + SourceIndex(0) --- >>> test2(): m2.connectModule; 1->^^^^ @@ -261,13 +120,13 @@ sourceFile:declarationMaps.ts 5 > . 6 > connectModule 7 > ; -1->Emitted(13, 5) Source(15, 5) + SourceIndex(0) -2 >Emitted(13, 10) Source(15, 10) + SourceIndex(0) -3 >Emitted(13, 14) Source(15, 14) + SourceIndex(0) -4 >Emitted(13, 16) Source(15, 16) + SourceIndex(0) -5 >Emitted(13, 17) Source(15, 17) + SourceIndex(0) -6 >Emitted(13, 30) Source(15, 30) + SourceIndex(0) -7 >Emitted(13, 31) Source(15, 31) + SourceIndex(0) +1->Emitted(6, 5) Source(15, 5) + SourceIndex(0) +2 >Emitted(6, 10) Source(15, 10) + SourceIndex(0) +3 >Emitted(6, 14) Source(15, 14) + SourceIndex(0) +4 >Emitted(6, 16) Source(15, 16) + SourceIndex(0) +5 >Emitted(6, 17) Source(15, 17) + SourceIndex(0) +6 >Emitted(6, 30) Source(15, 30) + SourceIndex(0) +7 >Emitted(6, 31) Source(15, 31) + SourceIndex(0) --- >>>}; 1 >^ @@ -276,8 +135,8 @@ sourceFile:declarationMaps.ts 1 > >} 2 > ; -1 >Emitted(14, 2) Source(16, 2) + SourceIndex(0) -2 >Emitted(14, 3) Source(16, 3) + SourceIndex(0) +1 >Emitted(7, 2) Source(16, 2) + SourceIndex(0) +2 >Emitted(7, 3) Source(16, 3) + SourceIndex(0) --- >>>export = m2; 1-> @@ -291,9 +150,9 @@ sourceFile:declarationMaps.ts 2 >export = 3 > m2 4 > ; -1->Emitted(15, 1) Source(18, 1) + SourceIndex(0) -2 >Emitted(15, 10) Source(18, 10) + SourceIndex(0) -3 >Emitted(15, 12) Source(18, 12) + SourceIndex(0) -4 >Emitted(15, 13) Source(18, 13) + SourceIndex(0) +1->Emitted(8, 1) Source(18, 1) + SourceIndex(0) +2 >Emitted(8, 10) Source(18, 10) + SourceIndex(0) +3 >Emitted(8, 12) Source(18, 12) + SourceIndex(0) +4 >Emitted(8, 13) Source(18, 13) + SourceIndex(0) --- >>>//# sourceMappingURL=declarationMaps.d.ts.map \ No newline at end of file diff --git a/tests/baselines/reference/declareFileExportAssignment.js b/tests/baselines/reference/declareFileExportAssignment.js index ed4b9e960e965..e831033368cad 100644 --- a/tests/baselines/reference/declareFileExportAssignment.js +++ b/tests/baselines/reference/declareFileExportAssignment.js @@ -28,13 +28,6 @@ module.exports = m2; //// [declareFileExportAssignment.d.ts] declare namespace m2 { - interface connectModule { - (res: any, req: any, next: any): void; - } - interface connectExport { - use: (mod: connectModule) => connectExport; - listen: (port: number) => void; - } } declare var m2: { (): m2.connectExport; @@ -42,3 +35,29 @@ declare var m2: { test2(): m2.connectModule; }; export = m2; + + +//// [DtsFileErrors] + + +declareFileExportAssignment.d.ts(4,12): error TS2694: Namespace 'm2' has no exported member 'connectExport'. +declareFileExportAssignment.d.ts(5,15): error TS2694: Namespace 'm2' has no exported member 'connectModule'. +declareFileExportAssignment.d.ts(6,17): error TS2694: Namespace 'm2' has no exported member 'connectModule'. + + +==== declareFileExportAssignment.d.ts (3 errors) ==== + declare namespace m2 { + } + declare var m2: { + (): m2.connectExport; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectExport'. + test1: m2.connectModule; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. + test2(): m2.connectModule; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. + }; + export = m2; + \ No newline at end of file diff --git a/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.js b/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.js index a442fcc99fe5f..3fa4e7302f6e8 100644 --- a/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.js +++ b/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.js @@ -28,13 +28,6 @@ module.exports = m2; //// [declareFileExportAssignmentWithVarFromVariableStatement.d.ts] declare namespace m2 { - interface connectModule { - (res: any, req: any, next: any): void; - } - interface connectExport { - use: (mod: connectModule) => connectExport; - listen: (port: number) => void; - } } declare var m2: { (): m2.connectExport; @@ -42,3 +35,29 @@ declare var m2: { test2(): m2.connectModule; }; export = m2; + + +//// [DtsFileErrors] + + +declareFileExportAssignmentWithVarFromVariableStatement.d.ts(4,12): error TS2694: Namespace 'm2' has no exported member 'connectExport'. +declareFileExportAssignmentWithVarFromVariableStatement.d.ts(5,15): error TS2694: Namespace 'm2' has no exported member 'connectModule'. +declareFileExportAssignmentWithVarFromVariableStatement.d.ts(6,17): error TS2694: Namespace 'm2' has no exported member 'connectModule'. + + +==== declareFileExportAssignmentWithVarFromVariableStatement.d.ts (3 errors) ==== + declare namespace m2 { + } + declare var m2: { + (): m2.connectExport; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectExport'. + test1: m2.connectModule; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. + test2(): m2.connectModule; + ~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. + }; + export = m2; + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeGenericTypes.js b/tests/baselines/reference/importTypeGenericTypes.js index 926ed5a8da391..af0cc6ae26e9c 100644 --- a/tests/baselines/reference/importTypeGenericTypes.js +++ b/tests/baselines/reference/importTypeGenericTypes.js @@ -84,11 +84,6 @@ interface Point { export = Point; //// [foo2.d.ts] declare namespace Bar { - interface I { - a: string; - b: number; - data: T; - } } export declare namespace Baz { interface J { @@ -119,3 +114,58 @@ export declare class Bar2 { constructor(input?: any); } export declare let shim: typeof import("./foo2"); + + +//// [DtsFileErrors] + + +foo2.d.ts(11,15): error TS2694: Namespace 'Bar' has no exported member 'I'. +usage.d.ts(4,44): error TS2694: Namespace '"foo2".Bar' has no exported member 'I'. + + +==== foo.d.ts (0 errors) ==== + interface Point { + x: number; + y: number; + data: T; + } + export = Point; + +==== foo2.d.ts (1 errors) ==== + declare namespace Bar { + } + export declare namespace Baz { + interface J { + a: number; + b: string; + data: T; + } + } + declare class Bar { + item: Bar.I; + ~ +!!! error TS2694: Namespace 'Bar' has no exported member 'I'. + constructor(input: Baz.J); + } + export { Bar }; + +==== usage.d.ts (1 errors) ==== + export declare const x: import("./foo")<{ + x: number; + }>; + export declare let y: import("./foo2").Bar.I<{ + ~ +!!! error TS2694: Namespace '"foo2".Bar' has no exported member 'I'. + x: number; + }>; + export declare class Bar2 { + item: { + a: string; + b: number; + c: object; + data: T; + }; + constructor(input?: any); + } + export declare let shim: typeof import("./foo2"); + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeLocal.js b/tests/baselines/reference/importTypeLocal.js index 23b7bd3c9951a..5238e92d17adc 100644 --- a/tests/baselines/reference/importTypeLocal.js +++ b/tests/baselines/reference/importTypeLocal.js @@ -80,10 +80,6 @@ interface Point { export = Point; //// [foo2.d.ts] declare namespace Bar { - interface I { - a: string; - b: number; - } } export declare namespace Baz { interface J { @@ -108,3 +104,51 @@ export declare class Bar2 { constructor(input?: any); } export declare let shim: typeof import("./foo2"); + + +//// [DtsFileErrors] + + +foo2.d.ts(10,15): error TS2694: Namespace 'Bar' has no exported member 'I'. +usage.d.ts(2,44): error TS2694: Namespace '"foo2".Bar' has no exported member 'I'. + + +==== foo.d.ts (0 errors) ==== + interface Point { + x: number; + y: number; + } + export = Point; + +==== foo2.d.ts (1 errors) ==== + declare namespace Bar { + } + export declare namespace Baz { + interface J { + a: number; + b: string; + } + } + declare class Bar { + item: Bar.I; + ~ +!!! error TS2694: Namespace 'Bar' has no exported member 'I'. + constructor(input: Baz.J); + } + export { Bar }; + +==== usage.d.ts (1 errors) ==== + export declare const x: import("./foo"); + export declare let y: import("./foo2").Bar.I; + ~ +!!! error TS2694: Namespace '"foo2".Bar' has no exported member 'I'. + export declare class Bar2 { + item: { + a: string; + b: number; + c: object; + }; + constructor(input?: any); + } + export declare let shim: typeof import("./foo2"); + \ No newline at end of file diff --git a/tests/baselines/reference/importTypeLocalMissing.js b/tests/baselines/reference/importTypeLocalMissing.js index 756ce97f2976d..8177400cb58f9 100644 --- a/tests/baselines/reference/importTypeLocalMissing.js +++ b/tests/baselines/reference/importTypeLocalMissing.js @@ -82,10 +82,6 @@ interface Point { export = Point; //// [foo2.d.ts] declare namespace Bar { - interface I { - a: string; - b: number; - } } export declare namespace Baz { interface J { diff --git a/tests/baselines/reference/intraExpressionInferences.errors.txt b/tests/baselines/reference/intraExpressionInferences.errors.txt index 74864b5494605..82da18c788e9b 100644 --- a/tests/baselines/reference/intraExpressionInferences.errors.txt +++ b/tests/baselines/reference/intraExpressionInferences.errors.txt @@ -3,11 +3,9 @@ intraExpressionInferences.ts(131,5): error TS2322: Type '(inputs: Unwrap<{ num: The types of 'str' are incompatible between these types. Type 'number' is not assignable to type 'string'. intraExpressionInferences.ts(133,26): error TS2339: Property 'nonexistent' does not exist on type 'Unwrap<{ num: Wrapper; str: Wrapper; }>'. -intraExpressionInferences.ts(148,57): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '2 | 1'. -intraExpressionInferences.ts(149,34): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '2 | 1'. -==== intraExpressionInferences.ts (4 errors) ==== +==== intraExpressionInferences.ts (2 errors) ==== // Repros from #47599 declare function callIt(obj: { @@ -164,11 +162,7 @@ intraExpressionInferences.ts(149,34): error TS2856: The type of this declaration simplified({ generator: () => 123, receiver: (t) => console.log(t + 2) }) whatIWant({ generator: (bob) => bob ? 1 : 2, receiver: (t) => console.log(t + 2) }) - ~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '2 | 1'. nonObject((bob) => bob ? 1 : 2, (t) => console.log(t + 2)) - ~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '2 | 1'. // Repro from #48466 diff --git a/tests/baselines/reference/literalTypes2.errors.txt b/tests/baselines/reference/literalTypes2.errors.txt index f20ffd3b3c7ec..281b3b9c2e507 100644 --- a/tests/baselines/reference/literalTypes2.errors.txt +++ b/tests/baselines/reference/literalTypes2.errors.txt @@ -1,10 +1,8 @@ -literalTypes2.ts(102,24): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 0'. -literalTypes2.ts(102,32): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"foo" | "bar"'. literalTypes2.ts(155,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. literalTypes2.ts(156,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or '1 | "two"'. -==== literalTypes2.ts (4 errors) ==== +==== literalTypes2.ts (2 errors) ==== enum E { A, B, C } @@ -107,10 +105,6 @@ literalTypes2.ts(156,7): error TS2856: The type of this declaration is ambiguous function f6() { const { c1 = true, c2 = 0, c3 = "foo" } = { c1: false, c2: 1, c3: "bar" }; - ~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 0'. - ~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"foo" | "bar"'. let { x1 = true, x2 = 0, x3 = "foo" } = { x1: false, x2: 1, x3: "bar" }; } diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js index fc036be496f20..b21f7355650f1 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js @@ -80,12 +80,6 @@ export declare class B { } //// [f3.d.ts] declare namespace N { - interface Ifc { - a: any; - } - interface Cls { - a: any; - } } declare module "./f1" { import { B } from "./f2"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js index 905f347ea992a..9c5cb81be5e46 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js @@ -78,12 +78,6 @@ export declare class B { } //// [f3.d.ts] declare namespace N { - interface Ifc { - a: any; - } - interface Cls { - a: any; - } } declare module "./f1" { import { B } from "./f2"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js index 290ed7c81eedf..41ba5a4a94184 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js @@ -83,12 +83,6 @@ export declare class B { //// [f3.d.ts] import { B } from "./f2"; declare namespace N { - interface Ifc { - a: number; - } - interface Cls { - b: number; - } } import I = N.Ifc; import C = N.Cls; @@ -102,3 +96,43 @@ declare module "./f1" { export {}; //// [f4.d.ts] import "./f3"; + + +//// [DtsFileErrors] + + +f3.d.ts(4,14): error TS2694: Namespace 'N' has no exported member 'Ifc'. +f3.d.ts(5,14): error TS2694: Namespace 'N' has no exported member 'Cls'. + + +==== f1.d.ts (0 errors) ==== + export declare class A { + } + +==== f2.d.ts (0 errors) ==== + export declare class B { + n: number; + } + +==== f3.d.ts (2 errors) ==== + import { B } from "./f2"; + declare namespace N { + } + import I = N.Ifc; + ~~~ +!!! error TS2694: Namespace 'N' has no exported member 'Ifc'. + import C = N.Cls; + ~~~ +!!! error TS2694: Namespace 'N' has no exported member 'Cls'. + declare module "./f1" { + interface A { + foo(): B; + bar(): I; + baz(): C; + } + } + export {}; + +==== f4.d.ts (0 errors) ==== + import "./f3"; + \ No newline at end of file diff --git a/tests/baselines/reference/privacyAccessorDeclFile.js b/tests/baselines/reference/privacyAccessorDeclFile.js index 69c0208e5d84f..59cffbf930bdc 100644 --- a/tests/baselines/reference/privacyAccessorDeclFile.js +++ b/tests/baselines/reference/privacyAccessorDeclFile.js @@ -3654,10 +3654,34 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { +} +export {}; +//// [privacyAccessorDeclFile_GlobalFile.d.ts] +declare class publicClassInGlobal { +} +declare class publicClassInGlobalWithPublicGetAccessorTypes { + static get myPublicStaticMethod(): publicClassInGlobal; + private static get myPrivateStaticMethod(); + get myPublicMethod(): publicClassInGlobal; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): publicClassInGlobal; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): publicClassInGlobal; + private get myPrivateMethod1(); +} +declare class publicClassInGlobalWithWithPublicSetAccessorTypes { + static set myPublicStaticMethod(param: publicClassInGlobal); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: publicClassInGlobal); + private set myPrivateMethod(value); +} +declare namespace publicModuleInGlobal { class privateClass { } export class publicClass { } + namespace privateModule { + } export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod(): privateClass; private static get myPrivateStaticMethod(); @@ -3693,8 +3717,8 @@ declare namespace privateModule { export class publicClassWithPrivateModuleGetAccessorTypes { static get myPublicStaticMethod(): privateModule.publicClass; get myPublicMethod(): privateModule.publicClass; - static get myPublicStaticMethod1(): publicClass; - get myPublicMethod1(): publicClass; + static get myPublicStaticMethod1(): privateModule.publicClass; + get myPublicMethod1(): privateModule.publicClass; } export class publicClassWithPrivateModuleSetAccessorTypes { static set myPublicStaticMethod(param: privateModule.publicClass); @@ -3702,32 +3726,91 @@ declare namespace privateModule { } export {}; } -export {}; -//// [privacyAccessorDeclFile_GlobalFile.d.ts] -declare class publicClassInGlobal { -} -declare class publicClassInGlobalWithPublicGetAccessorTypes { - static get myPublicStaticMethod(): publicClassInGlobal; - private static get myPrivateStaticMethod(); - get myPublicMethod(): publicClassInGlobal; - private get myPrivateMethod(); - static get myPublicStaticMethod1(): publicClassInGlobal; - private static get myPrivateStaticMethod1(); - get myPublicMethod1(): publicClassInGlobal; - private get myPrivateMethod1(); -} -declare class publicClassInGlobalWithWithPublicSetAccessorTypes { - static set myPublicStaticMethod(param: publicClassInGlobal); - private static set myPrivateStaticMethod(value); - set myPublicMethod(param: publicClassInGlobal); - private set myPrivateMethod(value); -} -declare namespace publicModuleInGlobal { - class privateClass { + + +//// [DtsFileErrors] + + +privacyAccessorDeclFile_GlobalFile.d.ts(59,58): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_GlobalFile.d.ts(60,45): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_GlobalFile.d.ts(61,59): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_GlobalFile.d.ts(62,46): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_GlobalFile.d.ts(65,62): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_GlobalFile.d.ts(66,49): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(38,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(39,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(40,55): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(41,42): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(44,58): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(45,45): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(85,58): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(86,45): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(87,59): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(88,46): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(91,62): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyAccessorDeclFile_externalModule.d.ts(92,49): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + + +==== privacyAccessorDeclFile_externalModule.d.ts (12 errors) ==== + declare class privateClass { } - export class publicClass { + export declare class publicClass { } - namespace privateModule { + export declare class publicClassWithWithPrivateGetAccessorTypes { + static get myPublicStaticMethod(): privateClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): privateClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): privateClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): privateClass; + private get myPrivateMethod1(); + } + export declare class publicClassWithWithPublicGetAccessorTypes { + static get myPublicStaticMethod(): publicClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): publicClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): publicClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): publicClass; + private get myPrivateMethod1(); + } + export declare class publicClassWithWithPrivateSetAccessorTypes { + static set myPublicStaticMethod(param: privateClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: privateClass); + private set myPrivateMethod(value); + } + export declare class publicClassWithWithPublicSetAccessorTypes { + static set myPublicStaticMethod(param: publicClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: publicClass); + private set myPrivateMethod(value); + } + export declare class publicClassWithPrivateModuleGetAccessorTypes { + static get myPublicStaticMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + get myPublicMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + static get myPublicStaticMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + get myPublicMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export declare class publicClassWithPrivateModuleSetAccessorTypes { + static set myPublicStaticMethod(param: privateModule.publicClass); + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + set myPublicMethod(param: privateModule.publicClass); + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export declare namespace publicModule { class privateClass { } export class publicClass { @@ -3766,57 +3849,112 @@ declare namespace publicModuleInGlobal { } export class publicClassWithPrivateModuleGetAccessorTypes { static get myPublicStaticMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. get myPublicMethod(): privateModule.publicClass; - static get myPublicStaticMethod1(): publicClass; - get myPublicMethod1(): publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + static get myPublicStaticMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + get myPublicMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export class publicClassWithPrivateModuleSetAccessorTypes { static set myPublicStaticMethod(param: privateModule.publicClass); + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. set myPublicMethod(param: privateModule.publicClass); + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export {}; } - export class publicClassWithWithPrivateGetAccessorTypes { - static get myPublicStaticMethod(): privateClass; - private static get myPrivateStaticMethod(); - get myPublicMethod(): privateClass; - private get myPrivateMethod(); - static get myPublicStaticMethod1(): privateClass; - private static get myPrivateStaticMethod1(); - get myPublicMethod1(): privateClass; - private get myPrivateMethod1(); + declare namespace privateModule { } - export class publicClassWithWithPublicGetAccessorTypes { - static get myPublicStaticMethod(): publicClass; + export {}; + +==== privacyAccessorDeclFile_GlobalFile.d.ts (6 errors) ==== + declare class publicClassInGlobal { + } + declare class publicClassInGlobalWithPublicGetAccessorTypes { + static get myPublicStaticMethod(): publicClassInGlobal; private static get myPrivateStaticMethod(); - get myPublicMethod(): publicClass; + get myPublicMethod(): publicClassInGlobal; private get myPrivateMethod(); - static get myPublicStaticMethod1(): publicClass; + static get myPublicStaticMethod1(): publicClassInGlobal; private static get myPrivateStaticMethod1(); - get myPublicMethod1(): publicClass; + get myPublicMethod1(): publicClassInGlobal; private get myPrivateMethod1(); } - export class publicClassWithWithPrivateSetAccessorTypes { - static set myPublicStaticMethod(param: privateClass); + declare class publicClassInGlobalWithWithPublicSetAccessorTypes { + static set myPublicStaticMethod(param: publicClassInGlobal); private static set myPrivateStaticMethod(value); - set myPublicMethod(param: privateClass); + set myPublicMethod(param: publicClassInGlobal); private set myPrivateMethod(value); } - export class publicClassWithWithPublicSetAccessorTypes { - static set myPublicStaticMethod(param: publicClass); - private static set myPrivateStaticMethod(value); - set myPublicMethod(param: publicClass); - private set myPrivateMethod(value); - } - export class publicClassWithPrivateModuleGetAccessorTypes { - static get myPublicStaticMethod(): privateModule.publicClass; - get myPublicMethod(): privateModule.publicClass; - static get myPublicStaticMethod1(): privateModule.publicClass; - get myPublicMethod1(): privateModule.publicClass; - } - export class publicClassWithPrivateModuleSetAccessorTypes { - static set myPublicStaticMethod(param: privateModule.publicClass); - set myPublicMethod(param: privateModule.publicClass); + declare namespace publicModuleInGlobal { + class privateClass { + } + export class publicClass { + } + namespace privateModule { + } + export class publicClassWithWithPrivateGetAccessorTypes { + static get myPublicStaticMethod(): privateClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): privateClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): privateClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): privateClass; + private get myPrivateMethod1(); + } + export class publicClassWithWithPublicGetAccessorTypes { + static get myPublicStaticMethod(): publicClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): publicClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): publicClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): publicClass; + private get myPrivateMethod1(); + } + export class publicClassWithWithPrivateSetAccessorTypes { + static set myPublicStaticMethod(param: privateClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: privateClass); + private set myPrivateMethod(value); + } + export class publicClassWithWithPublicSetAccessorTypes { + static set myPublicStaticMethod(param: publicClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: publicClass); + private set myPrivateMethod(value); + } + export class publicClassWithPrivateModuleGetAccessorTypes { + static get myPublicStaticMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + get myPublicMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + static get myPublicStaticMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + get myPublicMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export class publicClassWithPrivateModuleSetAccessorTypes { + static set myPublicStaticMethod(param: privateModule.publicClass); + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + set myPublicMethod(param: privateModule.publicClass); + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export {}; } - export {}; -} + \ No newline at end of file diff --git a/tests/baselines/reference/privacyFunctionParameterDeclFile.js b/tests/baselines/reference/privacyFunctionParameterDeclFile.js index f74a60b8e45c6..5ff1fa60bc909 100644 --- a/tests/baselines/reference/privacyFunctionParameterDeclFile.js +++ b/tests/baselines/reference/privacyFunctionParameterDeclFile.js @@ -1386,10 +1386,34 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { +} +export {}; +//// [privacyFunctionParameterDeclFile_GlobalFile.d.ts] +declare class publicClassInGlobal { +} +interface publicInterfaceWithPublicParmeterTypesInGlobal { + new (param: publicClassInGlobal): publicClassInGlobal; + (param: publicClassInGlobal): publicClassInGlobal; + myMethod(param: publicClassInGlobal): void; +} +declare class publicClassWithWithPublicParmeterTypesInGlobal { + private param1; + param2: publicClassInGlobal; + static myPublicStaticMethod(param: publicClassInGlobal): void; + private static myPrivateStaticMethod; + myPublicMethod(param: publicClassInGlobal): void; + private myPrivateMethod; + constructor(param: publicClassInGlobal, param1: publicClassInGlobal, param2: publicClassInGlobal); +} +declare function publicFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; +declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; +declare namespace publicModuleInGlobal { class privateClass { } export class publicClass { } + namespace privateModule { + } export interface publicInterfaceWithPrivateParmeterTypes { new (param: privateClass): publicClass; (param: privateClass): publicClass; @@ -1438,32 +1462,120 @@ declare namespace privateModule { export function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; export {}; } -export {}; -//// [privacyFunctionParameterDeclFile_GlobalFile.d.ts] -declare class publicClassInGlobal { -} -interface publicInterfaceWithPublicParmeterTypesInGlobal { - new (param: publicClassInGlobal): publicClassInGlobal; - (param: publicClassInGlobal): publicClassInGlobal; - myMethod(param: publicClassInGlobal): void; -} -declare class publicClassWithWithPublicParmeterTypesInGlobal { - private param1; - param2: publicClassInGlobal; - static myPublicStaticMethod(param: publicClassInGlobal): void; - private static myPrivateStaticMethod; - myPublicMethod(param: publicClassInGlobal): void; - private myPrivateMethod; - constructor(param: publicClassInGlobal, param1: publicClassInGlobal, param2: publicClassInGlobal); -} -declare function publicFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; -declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; -declare namespace publicModuleInGlobal { - class privateClass { + + +//// [DtsFileErrors] + + +privacyFunctionParameterDeclFile_GlobalFile.d.ts(59,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_GlobalFile.d.ts(60,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_GlobalFile.d.ts(61,39): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_GlobalFile.d.ts(65,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_GlobalFile.d.ts(66,58): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_GlobalFile.d.ts(67,45): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_GlobalFile.d.ts(68,42): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_GlobalFile.d.ts(68,77): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_GlobalFile.d.ts(68,112): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_GlobalFile.d.ts(70,88): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_GlobalFile.d.ts(71,95): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(38,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(39,27): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(40,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(44,27): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(45,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(46,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(47,38): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(47,73): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(47,108): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(49,92): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(50,99): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(89,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(90,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(91,39): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(95,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(96,58): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(97,45): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(98,42): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(98,77): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(98,112): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(100,88): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionParameterDeclFile_externalModule.d.ts(101,95): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + + +==== privacyFunctionParameterDeclFile_externalModule.d.ts (22 errors) ==== + declare class privateClass { } - export class publicClass { + export declare class publicClass { } - namespace privateModule { + export interface publicInterfaceWithPrivateParmeterTypes { + new (param: privateClass): publicClass; + (param: privateClass): publicClass; + myMethod(param: privateClass): void; + } + export interface publicInterfaceWithPublicParmeterTypes { + new (param: publicClass): publicClass; + (param: publicClass): publicClass; + myMethod(param: publicClass): void; + } + export declare class publicClassWithWithPrivateParmeterTypes { + private param1; + param2: privateClass; + static myPublicStaticMethod(param: privateClass): void; + private static myPrivateStaticMethod; + myPublicMethod(param: privateClass): void; + private myPrivateMethod; + constructor(param: privateClass, param1: privateClass, param2: privateClass); + } + export declare class publicClassWithWithPublicParmeterTypes { + private param1; + param2: publicClass; + static myPublicStaticMethod(param: publicClass): void; + private static myPrivateStaticMethod; + myPublicMethod(param: publicClass): void; + private myPrivateMethod; + constructor(param: publicClass, param1: publicClass, param2: publicClass); + } + export declare function publicFunctionWithPrivateParmeterTypes(param: privateClass): void; + export declare function publicFunctionWithPublicParmeterTypes(param: publicClass): void; + export declare function publicAmbientFunctionWithPrivateParmeterTypes(param: privateClass): void; + export declare function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; + export interface publicInterfaceWithPrivateModuleParameterTypes { + new (param: privateModule.publicClass): publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + (param: privateModule.publicClass): publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myMethod(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export declare class publicClassWithPrivateModuleParameterTypes { + private param1; + param2: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + static myPublicStaticMethod(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myPublicMethod(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export declare function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export declare namespace publicModule { class privateClass { } export class publicClass { @@ -1502,65 +1614,140 @@ declare namespace publicModuleInGlobal { export function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; export interface publicInterfaceWithPrivateModuleParameterTypes { new (param: privateModule.publicClass): publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. (param: privateModule.publicClass): publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. myMethod(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export class publicClassWithPrivateModuleParameterTypes { private param1; param2: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. static myPublicStaticMethod(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. myPublicMethod(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. export function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. export {}; } - export interface publicInterfaceWithPrivateParmeterTypes { - new (param: privateClass): publicClass; - (param: privateClass): publicClass; - myMethod(param: privateClass): void; + declare namespace privateModule { } - export interface publicInterfaceWithPublicParmeterTypes { - new (param: publicClass): publicClass; - (param: publicClass): publicClass; - myMethod(param: publicClass): void; + export {}; + +==== privacyFunctionParameterDeclFile_GlobalFile.d.ts (11 errors) ==== + declare class publicClassInGlobal { } - export class publicClassWithWithPrivateParmeterTypes { - private param1; - param2: privateClass; - static myPublicStaticMethod(param: privateClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: privateClass): void; - private myPrivateMethod; - constructor(param: privateClass, param1: privateClass, param2: privateClass); + interface publicInterfaceWithPublicParmeterTypesInGlobal { + new (param: publicClassInGlobal): publicClassInGlobal; + (param: publicClassInGlobal): publicClassInGlobal; + myMethod(param: publicClassInGlobal): void; } - export class publicClassWithWithPublicParmeterTypes { + declare class publicClassWithWithPublicParmeterTypesInGlobal { private param1; - param2: publicClass; - static myPublicStaticMethod(param: publicClass): void; + param2: publicClassInGlobal; + static myPublicStaticMethod(param: publicClassInGlobal): void; private static myPrivateStaticMethod; - myPublicMethod(param: publicClass): void; + myPublicMethod(param: publicClassInGlobal): void; private myPrivateMethod; - constructor(param: publicClass, param1: publicClass, param2: publicClass); - } - export function publicFunctionWithPrivateParmeterTypes(param: privateClass): void; - export function publicFunctionWithPublicParmeterTypes(param: publicClass): void; - export function publicAmbientFunctionWithPrivateParmeterTypes(param: privateClass): void; - export function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; - export interface publicInterfaceWithPrivateModuleParameterTypes { - new (param: privateModule.publicClass): publicClass; - (param: privateModule.publicClass): publicClass; - myMethod(param: privateModule.publicClass): void; + constructor(param: publicClassInGlobal, param1: publicClassInGlobal, param2: publicClassInGlobal); } - export class publicClassWithPrivateModuleParameterTypes { - private param1; - param2: privateModule.publicClass; - static myPublicStaticMethod(param: privateModule.publicClass): void; - myPublicMethod(param: privateModule.publicClass): void; - constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); + declare function publicFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; + declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; + declare namespace publicModuleInGlobal { + class privateClass { + } + export class publicClass { + } + namespace privateModule { + } + export interface publicInterfaceWithPrivateParmeterTypes { + new (param: privateClass): publicClass; + (param: privateClass): publicClass; + myMethod(param: privateClass): void; + } + export interface publicInterfaceWithPublicParmeterTypes { + new (param: publicClass): publicClass; + (param: publicClass): publicClass; + myMethod(param: publicClass): void; + } + export class publicClassWithWithPrivateParmeterTypes { + private param1; + param2: privateClass; + static myPublicStaticMethod(param: privateClass): void; + private static myPrivateStaticMethod; + myPublicMethod(param: privateClass): void; + private myPrivateMethod; + constructor(param: privateClass, param1: privateClass, param2: privateClass); + } + export class publicClassWithWithPublicParmeterTypes { + private param1; + param2: publicClass; + static myPublicStaticMethod(param: publicClass): void; + private static myPrivateStaticMethod; + myPublicMethod(param: publicClass): void; + private myPrivateMethod; + constructor(param: publicClass, param1: publicClass, param2: publicClass); + } + export function publicFunctionWithPrivateParmeterTypes(param: privateClass): void; + export function publicFunctionWithPublicParmeterTypes(param: publicClass): void; + export function publicAmbientFunctionWithPrivateParmeterTypes(param: privateClass): void; + export function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; + export interface publicInterfaceWithPrivateModuleParameterTypes { + new (param: privateModule.publicClass): publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + (param: privateModule.publicClass): publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myMethod(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export class publicClassWithPrivateModuleParameterTypes { + private param1; + param2: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + static myPublicStaticMethod(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myPublicMethod(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export {}; } - export function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - export function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - export {}; -} + \ No newline at end of file diff --git a/tests/baselines/reference/privacyFunctionParameterDeclFile.types b/tests/baselines/reference/privacyFunctionParameterDeclFile.types index a1096e0ae870f..4cc77e5514951 100644 --- a/tests/baselines/reference/privacyFunctionParameterDeclFile.types +++ b/tests/baselines/reference/privacyFunctionParameterDeclFile.types @@ -783,7 +783,7 @@ module privateModule { >privateModule : any myMethod(param: privateModule.publicClass): void; ->myMethod : (param: privateModule.publicClass) => void +>myMethod : (param: publicClass) => void >param : publicClass >privateModule : any } @@ -791,12 +791,12 @@ module privateModule { >publicClassWithPrivateModuleParameterTypes : publicClassWithPrivateModuleParameterTypes static myPublicStaticMethod(param: privateModule.publicClass) { ->myPublicStaticMethod : (param: privateModule.publicClass) => void +>myPublicStaticMethod : (param: publicClass) => void >param : publicClass >privateModule : any } myPublicMethod(param: privateModule.publicClass) { ->myPublicMethod : (param: privateModule.publicClass) => void +>myPublicMethod : (param: publicClass) => void >param : publicClass >privateModule : any } @@ -810,12 +810,12 @@ module privateModule { } } export function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass) { ->publicFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void +>publicFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void >param : publicClass >privateModule : any } export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; ->publicAmbientFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void +>publicAmbientFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void >param : publicClass >privateModule : any @@ -829,7 +829,7 @@ module privateModule { >privateModule : any myMethod(param: privateModule.publicClass): void; ->myMethod : (param: privateModule.publicClass) => void +>myMethod : (param: publicClass) => void >param : publicClass >privateModule : any } @@ -837,12 +837,12 @@ module privateModule { >privateClassWithPrivateModuleParameterTypes : privateClassWithPrivateModuleParameterTypes static myPublicStaticMethod(param: privateModule.publicClass) { ->myPublicStaticMethod : (param: privateModule.publicClass) => void +>myPublicStaticMethod : (param: publicClass) => void >param : publicClass >privateModule : any } myPublicMethod(param: privateModule.publicClass) { ->myPublicMethod : (param: privateModule.publicClass) => void +>myPublicMethod : (param: publicClass) => void >param : publicClass >privateModule : any } @@ -856,12 +856,12 @@ module privateModule { } } function privateFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass) { ->privateFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void +>privateFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void >param : publicClass >privateModule : any } declare function privateAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; ->privateAmbientFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void +>privateAmbientFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void >param : publicClass >privateModule : any } @@ -1131,7 +1131,7 @@ module publicModuleInGlobal { >privateModule : any myMethod(param: privateModule.publicClass): void; ->myMethod : (param: privateModule.publicClass) => void +>myMethod : (param: publicClass) => void >param : publicClass >privateModule : any } @@ -1139,12 +1139,12 @@ module publicModuleInGlobal { >publicClassWithPrivateModuleParameterTypes : publicClassWithPrivateModuleParameterTypes static myPublicStaticMethod(param: privateModule.publicClass) { ->myPublicStaticMethod : (param: privateModule.publicClass) => void +>myPublicStaticMethod : (param: publicClass) => void >param : publicClass >privateModule : any } myPublicMethod(param: privateModule.publicClass) { ->myPublicMethod : (param: privateModule.publicClass) => void +>myPublicMethod : (param: publicClass) => void >param : publicClass >privateModule : any } @@ -1158,12 +1158,12 @@ module publicModuleInGlobal { } } export function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass) { ->publicFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void +>publicFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void >param : publicClass >privateModule : any } export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; ->publicAmbientFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void +>publicAmbientFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void >param : publicClass >privateModule : any @@ -1177,7 +1177,7 @@ module publicModuleInGlobal { >privateModule : any myMethod(param: privateModule.publicClass): void; ->myMethod : (param: privateModule.publicClass) => void +>myMethod : (param: publicClass) => void >param : publicClass >privateModule : any } @@ -1185,12 +1185,12 @@ module publicModuleInGlobal { >privateClassWithPrivateModuleParameterTypes : privateClassWithPrivateModuleParameterTypes static myPublicStaticMethod(param: privateModule.publicClass) { ->myPublicStaticMethod : (param: privateModule.publicClass) => void +>myPublicStaticMethod : (param: publicClass) => void >param : publicClass >privateModule : any } myPublicMethod(param: privateModule.publicClass) { ->myPublicMethod : (param: privateModule.publicClass) => void +>myPublicMethod : (param: publicClass) => void >param : publicClass >privateModule : any } @@ -1204,12 +1204,12 @@ module publicModuleInGlobal { } } function privateFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass) { ->privateFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void +>privateFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void >param : publicClass >privateModule : any } declare function privateAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; ->privateAmbientFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void +>privateAmbientFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void >param : publicClass >privateModule : any } diff --git a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js index b9907650a57ae..960410c76b0d8 100644 --- a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js +++ b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js @@ -2400,10 +2400,37 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { +} +export {}; +//// [privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts] +declare class publicClassInGlobal { +} +interface publicInterfaceWithPublicParmeterTypesInGlobal { + new (): publicClassInGlobal; + (): publicClassInGlobal; + [x: number]: publicClassInGlobal; + myMethod(): publicClassInGlobal; +} +declare class publicClassWithWithPublicParmeterTypesInGlobal { + static myPublicStaticMethod(): publicClassInGlobal; + private static myPrivateStaticMethod; + myPublicMethod(): publicClassInGlobal; + private myPrivateMethod; + static myPublicStaticMethod1(): publicClassInGlobal; + private static myPrivateStaticMethod1; + myPublicMethod1(): publicClassInGlobal; + private myPrivateMethod1; +} +declare function publicFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; +declare function publicFunctionWithPublicParmeterTypesInGlobal1(): publicClassInGlobal; +declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; +declare namespace publicModuleInGlobal { class privateClass { } export class publicClass { } + namespace privateModule { + } export interface publicInterfaceWithPrivateParmeterTypes { new (): privateClass; (): privateClass; @@ -2451,43 +2478,135 @@ declare namespace privateModule { export class publicClassWithPrivateModuleParameterTypes { static myPublicStaticMethod(): privateModule.publicClass; myPublicMethod(): privateModule.publicClass; - static myPublicStaticMethod1(): publicClass; - myPublicMethod1(): publicClass; + static myPublicStaticMethod1(): privateModule.publicClass; + myPublicMethod1(): privateModule.publicClass; } export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - export function publicFunctionWithPrivateModuleParameterTypes1(): publicClass; + export function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; export function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; export {}; } -export {}; -//// [privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts] -declare class publicClassInGlobal { -} -interface publicInterfaceWithPublicParmeterTypesInGlobal { - new (): publicClassInGlobal; - (): publicClassInGlobal; - [x: number]: publicClassInGlobal; - myMethod(): publicClassInGlobal; -} -declare class publicClassWithWithPublicParmeterTypesInGlobal { - static myPublicStaticMethod(): publicClassInGlobal; - private static myPrivateStaticMethod; - myPublicMethod(): publicClassInGlobal; - private myPrivateMethod; - static myPublicStaticMethod1(): publicClassInGlobal; - private static myPrivateStaticMethod1; - myPublicMethod1(): publicClassInGlobal; - private myPrivateMethod1; -} -declare function publicFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; -declare function publicFunctionWithPublicParmeterTypesInGlobal1(): publicClassInGlobal; -declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; -declare namespace publicModuleInGlobal { - class privateClass { + + +//// [DtsFileErrors] + + +privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(68,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(69,27): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(70,36): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(71,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(74,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(75,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(76,55): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(77,42): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(79,84): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(80,85): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(81,91): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(44,27): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(45,23): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(46,32): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(47,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(50,50): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(51,37): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(52,51): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(53,38): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(55,88): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(56,89): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(57,95): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(102,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(103,27): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(104,36): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(105,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(108,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(109,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(110,55): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(111,42): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(113,84): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(114,85): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +privacyFunctionReturnTypeDeclFile_externalModule.d.ts(115,91): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + + +==== privacyFunctionReturnTypeDeclFile_externalModule.d.ts (22 errors) ==== + declare class privateClass { } - export class publicClass { + export declare class publicClass { } - namespace privateModule { + export interface publicInterfaceWithPrivateParmeterTypes { + new (): privateClass; + (): privateClass; + [x: number]: privateClass; + myMethod(): privateClass; + } + export interface publicInterfaceWithPublicParmeterTypes { + new (): publicClass; + (): publicClass; + [x: number]: publicClass; + myMethod(): publicClass; + } + export declare class publicClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod(): privateClass; + private static myPrivateStaticMethod; + myPublicMethod(): privateClass; + private myPrivateMethod; + static myPublicStaticMethod1(): privateClass; + private static myPrivateStaticMethod1; + myPublicMethod1(): privateClass; + private myPrivateMethod1; + } + export declare class publicClassWithWithPublicParmeterTypes { + static myPublicStaticMethod(): publicClass; + private static myPrivateStaticMethod; + myPublicMethod(): publicClass; + private myPrivateMethod; + static myPublicStaticMethod1(): publicClass; + private static myPrivateStaticMethod1; + myPublicMethod1(): publicClass; + private myPrivateMethod1; + } + export declare function publicFunctionWithPrivateParmeterTypes(): privateClass; + export declare function publicFunctionWithPublicParmeterTypes(): publicClass; + export declare function publicFunctionWithPrivateParmeterTypes1(): privateClass; + export declare function publicFunctionWithPublicParmeterTypes1(): publicClass; + export declare function publicAmbientFunctionWithPrivateParmeterTypes(): privateClass; + export declare function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; + export interface publicInterfaceWithPrivateModuleParameterTypes { + new (): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + (): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + [x: number]: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export declare class publicClassWithPrivateModuleParameterTypes { + static myPublicStaticMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myPublicMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + static myPublicStaticMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myPublicMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export declare function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export declare function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export declare namespace publicModule { class privateClass { } export class publicClass { @@ -2532,73 +2651,151 @@ declare namespace publicModuleInGlobal { export function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; export interface publicInterfaceWithPrivateModuleParameterTypes { new (): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. (): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. [x: number]: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. myMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export class publicClassWithPrivateModuleParameterTypes { static myPublicStaticMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. myPublicMethod(): privateModule.publicClass; - static myPublicStaticMethod1(): publicClass; - myPublicMethod1(): publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + static myPublicStaticMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myPublicMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - export function publicFunctionWithPrivateModuleParameterTypes1(): publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. export function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. export {}; } - export interface publicInterfaceWithPrivateParmeterTypes { - new (): privateClass; - (): privateClass; - [x: number]: privateClass; - myMethod(): privateClass; - } - export interface publicInterfaceWithPublicParmeterTypes { - new (): publicClass; - (): publicClass; - [x: number]: publicClass; - myMethod(): publicClass; + declare namespace privateModule { } - export class publicClassWithWithPrivateParmeterTypes { - static myPublicStaticMethod(): privateClass; + export {}; + +==== privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts (11 errors) ==== + declare class publicClassInGlobal { + } + interface publicInterfaceWithPublicParmeterTypesInGlobal { + new (): publicClassInGlobal; + (): publicClassInGlobal; + [x: number]: publicClassInGlobal; + myMethod(): publicClassInGlobal; + } + declare class publicClassWithWithPublicParmeterTypesInGlobal { + static myPublicStaticMethod(): publicClassInGlobal; private static myPrivateStaticMethod; - myPublicMethod(): privateClass; + myPublicMethod(): publicClassInGlobal; private myPrivateMethod; - static myPublicStaticMethod1(): privateClass; + static myPublicStaticMethod1(): publicClassInGlobal; private static myPrivateStaticMethod1; - myPublicMethod1(): privateClass; + myPublicMethod1(): publicClassInGlobal; private myPrivateMethod1; } - export class publicClassWithWithPublicParmeterTypes { - static myPublicStaticMethod(): publicClass; - private static myPrivateStaticMethod; - myPublicMethod(): publicClass; - private myPrivateMethod; - static myPublicStaticMethod1(): publicClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): publicClass; - private myPrivateMethod1; - } - export function publicFunctionWithPrivateParmeterTypes(): privateClass; - export function publicFunctionWithPublicParmeterTypes(): publicClass; - export function publicFunctionWithPrivateParmeterTypes1(): privateClass; - export function publicFunctionWithPublicParmeterTypes1(): publicClass; - export function publicAmbientFunctionWithPrivateParmeterTypes(): privateClass; - export function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; - export interface publicInterfaceWithPrivateModuleParameterTypes { - new (): privateModule.publicClass; - (): privateModule.publicClass; - [x: number]: privateModule.publicClass; - myMethod(): privateModule.publicClass; - } - export class publicClassWithPrivateModuleParameterTypes { - static myPublicStaticMethod(): privateModule.publicClass; - myPublicMethod(): privateModule.publicClass; - static myPublicStaticMethod1(): privateModule.publicClass; - myPublicMethod1(): privateModule.publicClass; + declare function publicFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; + declare function publicFunctionWithPublicParmeterTypesInGlobal1(): publicClassInGlobal; + declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; + declare namespace publicModuleInGlobal { + class privateClass { + } + export class publicClass { + } + namespace privateModule { + } + export interface publicInterfaceWithPrivateParmeterTypes { + new (): privateClass; + (): privateClass; + [x: number]: privateClass; + myMethod(): privateClass; + } + export interface publicInterfaceWithPublicParmeterTypes { + new (): publicClass; + (): publicClass; + [x: number]: publicClass; + myMethod(): publicClass; + } + export class publicClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod(): privateClass; + private static myPrivateStaticMethod; + myPublicMethod(): privateClass; + private myPrivateMethod; + static myPublicStaticMethod1(): privateClass; + private static myPrivateStaticMethod1; + myPublicMethod1(): privateClass; + private myPrivateMethod1; + } + export class publicClassWithWithPublicParmeterTypes { + static myPublicStaticMethod(): publicClass; + private static myPrivateStaticMethod; + myPublicMethod(): publicClass; + private myPrivateMethod; + static myPublicStaticMethod1(): publicClass; + private static myPrivateStaticMethod1; + myPublicMethod1(): publicClass; + private myPrivateMethod1; + } + export function publicFunctionWithPrivateParmeterTypes(): privateClass; + export function publicFunctionWithPublicParmeterTypes(): publicClass; + export function publicFunctionWithPrivateParmeterTypes1(): privateClass; + export function publicFunctionWithPublicParmeterTypes1(): publicClass; + export function publicAmbientFunctionWithPrivateParmeterTypes(): privateClass; + export function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; + export interface publicInterfaceWithPrivateModuleParameterTypes { + new (): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + (): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + [x: number]: privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export class publicClassWithPrivateModuleParameterTypes { + static myPublicStaticMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myPublicMethod(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + static myPublicStaticMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + myPublicMethod1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + } + export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; + ~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export {}; } - export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - export function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; - export function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - export {}; -} + \ No newline at end of file diff --git a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.types b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.types index f52514eb598ef..3e61fc928af78 100644 --- a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.types +++ b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.types @@ -1255,20 +1255,20 @@ module privateModule { >privateModule : any myMethod(): privateModule.publicClass; ->myMethod : () => privateModule.publicClass +>myMethod : () => publicClass >privateModule : any } export class publicClassWithPrivateModuleParameterTypes { >publicClassWithPrivateModuleParameterTypes : publicClassWithPrivateModuleParameterTypes static myPublicStaticMethod(): privateModule.publicClass { ->myPublicStaticMethod : () => privateModule.publicClass +>myPublicStaticMethod : () => publicClass >privateModule : any return null; } myPublicMethod(): privateModule.publicClass { ->myPublicMethod : () => privateModule.publicClass +>myPublicMethod : () => publicClass >privateModule : any return null; @@ -1293,7 +1293,7 @@ module privateModule { } } export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass { ->publicFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass +>publicFunctionWithPrivateModuleParameterTypes : () => publicClass >privateModule : any return null; @@ -1308,7 +1308,7 @@ module privateModule { >publicClass : typeof publicClass } export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; ->publicAmbientFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass +>publicAmbientFunctionWithPrivateModuleParameterTypes : () => publicClass >privateModule : any interface privateInterfaceWithPrivateModuleParameterTypes { @@ -1323,20 +1323,20 @@ module privateModule { >privateModule : any myMethod(): privateModule.publicClass; ->myMethod : () => privateModule.publicClass +>myMethod : () => publicClass >privateModule : any } class privateClassWithPrivateModuleParameterTypes { >privateClassWithPrivateModuleParameterTypes : privateClassWithPrivateModuleParameterTypes static myPublicStaticMethod(): privateModule.publicClass { ->myPublicStaticMethod : () => privateModule.publicClass +>myPublicStaticMethod : () => publicClass >privateModule : any return null; } myPublicMethod(): privateModule.publicClass { ->myPublicMethod : () => privateModule.publicClass +>myPublicMethod : () => publicClass >privateModule : any return null; @@ -1361,7 +1361,7 @@ module privateModule { } } function privateFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass { ->privateFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass +>privateFunctionWithPrivateModuleParameterTypes : () => publicClass >privateModule : any return null; @@ -1376,7 +1376,7 @@ module privateModule { >publicClass : typeof publicClass } declare function privateAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; ->privateAmbientFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass +>privateAmbientFunctionWithPrivateModuleParameterTypes : () => publicClass >privateModule : any } @@ -1807,20 +1807,20 @@ module publicModuleInGlobal { >privateModule : any myMethod(): privateModule.publicClass; ->myMethod : () => privateModule.publicClass +>myMethod : () => publicClass >privateModule : any } export class publicClassWithPrivateModuleParameterTypes { >publicClassWithPrivateModuleParameterTypes : publicClassWithPrivateModuleParameterTypes static myPublicStaticMethod(): privateModule.publicClass { ->myPublicStaticMethod : () => privateModule.publicClass +>myPublicStaticMethod : () => publicClass >privateModule : any return null; } myPublicMethod(): privateModule.publicClass { ->myPublicMethod : () => privateModule.publicClass +>myPublicMethod : () => publicClass >privateModule : any return null; @@ -1845,7 +1845,7 @@ module publicModuleInGlobal { } } export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass { ->publicFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass +>publicFunctionWithPrivateModuleParameterTypes : () => publicClass >privateModule : any return null; @@ -1860,7 +1860,7 @@ module publicModuleInGlobal { >publicClass : typeof publicClass } export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; ->publicAmbientFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass +>publicAmbientFunctionWithPrivateModuleParameterTypes : () => publicClass >privateModule : any interface privateInterfaceWithPrivateModuleParameterTypes { @@ -1875,20 +1875,20 @@ module publicModuleInGlobal { >privateModule : any myMethod(): privateModule.publicClass; ->myMethod : () => privateModule.publicClass +>myMethod : () => publicClass >privateModule : any } class privateClassWithPrivateModuleParameterTypes { >privateClassWithPrivateModuleParameterTypes : privateClassWithPrivateModuleParameterTypes static myPublicStaticMethod(): privateModule.publicClass { ->myPublicStaticMethod : () => privateModule.publicClass +>myPublicStaticMethod : () => publicClass >privateModule : any return null; } myPublicMethod(): privateModule.publicClass { ->myPublicMethod : () => privateModule.publicClass +>myPublicMethod : () => publicClass >privateModule : any return null; @@ -1913,7 +1913,7 @@ module publicModuleInGlobal { } } function privateFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass { ->privateFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass +>privateFunctionWithPrivateModuleParameterTypes : () => publicClass >privateModule : any return null; @@ -1928,7 +1928,7 @@ module publicModuleInGlobal { >publicClass : typeof publicClass } declare function privateAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; ->privateAmbientFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass +>privateAmbientFunctionWithPrivateModuleParameterTypes : () => publicClass >privateModule : any } diff --git a/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js b/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js index a0c721acc99f4..46a35ea73234b 100644 --- a/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js +++ b/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js @@ -425,19 +425,58 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { - class privateClassInPrivateModule { +} +export {}; + + +//// [DtsFileErrors] + + +privacyTypeParametersOfClassDeclFile.d.ts(14,93): error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. +privacyTypeParametersOfClassDeclFile.d.ts(31,89): error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. + + +==== privacyTypeParametersOfClassDeclFile.d.ts (2 errors) ==== + declare class privateClass { } - export class publicClassInPrivateModule { + export declare class publicClass { } - export class publicClassWithPrivateTypeParameters { + export declare class publicClassWithPrivateTypeParameters { myMethod(val: T): T; } - export class publicClassWithPublicTypeParameters { + export declare class publicClassWithPublicTypeParameters { myMethod(val: T): T; } - export class publicClassWithPublicTypeParametersWithoutExtends { + export declare class publicClassWithPublicTypeParametersWithoutExtends { + myMethod(val: T): T; + } + export declare class publicClassWithTypeParametersFromPrivateModule { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. myMethod(val: T): T; } + export declare namespace publicModule { + class privateClassInPublicModule { + } + export class publicClassInPublicModule { + } + export class publicClassWithPrivateTypeParameters { + myMethod(val: T): T; + } + export class publicClassWithPublicTypeParameters { + myMethod(val: T): T; + } + export class publicClassWithPublicTypeParametersWithoutExtends { + myMethod(val: T): T; + } + export class publicClassWithTypeParametersFromPrivateModule { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. + myMethod(val: T): T; + } + export {}; + } + declare namespace privateModule { + } export {}; -} -export {}; + \ No newline at end of file diff --git a/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js b/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js index 66f07c0dcc677..00fa9f9644694 100644 --- a/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js +++ b/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js @@ -335,34 +335,86 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { - class privateClassInPrivateModule { +} +export {}; + + +//// [DtsFileErrors] + + +privacyTypeParametersOfInterfaceDeclFile.d.ts(29,99): error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. +privacyTypeParametersOfInterfaceDeclFile.d.ts(60,103): error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. + + +==== privacyTypeParametersOfInterfaceDeclFile.d.ts (2 errors) ==== + declare class privateClass { } - export class publicClassInPrivateModule { + export declare class publicClass { } - class privateClassInPrivateModuleT { + declare class privateClassT { } - export class publicClassInPrivateModuleT { + export declare class publicClassT { } - export interface publicInterfaceWithPrivateTypeParameters { + export interface publicInterfaceWithPrivateTypeParameters { myMethod(val: T): T; - myMethod0(): publicClassInPrivateModuleT; - myMethod1(): privateClassInPrivateModuleT; - myMethod2(): privateClassInPrivateModuleT; - myMethod3(): publicClassInPrivateModuleT; - myMethod4(): publicClassInPrivateModuleT; + myMethod0(): publicClassT; + myMethod1(): privateClassT; + myMethod2(): privateClassT; + myMethod3(): publicClassT; + myMethod4(): publicClassT; } - export interface publicInterfaceWithPublicTypeParameters { + export interface publicInterfaceWithPublicTypeParameters { myMethod(val: T): T; - myMethod0(): publicClassInPrivateModuleT; - myMethod1(): privateClassInPrivateModuleT; - myMethod2(): privateClassInPrivateModuleT; - myMethod3(): publicClassInPrivateModuleT; - myMethod4(): publicClassInPrivateModuleT; + myMethod0(): publicClassT; + myMethod1(): privateClassT; + myMethod2(): privateClassT; + myMethod3(): publicClassT; + myMethod4(): publicClassT; } export interface publicInterfaceWithPublicTypeParametersWithoutExtends { myMethod(val: T): T; - myMethod0(): publicClassInPrivateModuleT; + myMethod0(): publicClassT; + } + export interface publicInterfaceWithPrivateModuleTypeParameterConstraints { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. + } + export declare namespace publicModule { + class privateClassInPublicModule { + } + export class publicClassInPublicModule { + } + class privateClassInPublicModuleT { + } + export class publicClassInPublicModuleT { + } + export interface publicInterfaceWithPrivateTypeParameters { + myMethod(val: T): T; + myMethod0(): publicClassInPublicModuleT; + myMethod1(): privateClassInPublicModuleT; + myMethod2(): privateClassInPublicModuleT; + myMethod3(): publicClassInPublicModuleT; + myMethod4(): publicClassInPublicModuleT; + } + export interface publicInterfaceWithPublicTypeParameters { + myMethod(val: T): T; + myMethod0(): publicClassInPublicModuleT; + myMethod1(): privateClassInPublicModuleT; + myMethod2(): privateClassInPublicModuleT; + myMethod3(): publicClassInPublicModuleT; + myMethod4(): publicClassInPublicModuleT; + } + export interface publicInterfaceWithPublicTypeParametersWithoutExtends { + myMethod(val: T): T; + myMethod0(): publicClassInPublicModuleT; + } + export interface publicInterfaceWithPrivateModuleTypeParameterConstraints { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. + } + export {}; + } + declare namespace privateModule { } export {}; -} -export {}; + \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt index 5e8d24d28f969..4befe8603ae9c 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt @@ -1,8 +1,7 @@ -typeArgumentInferenceWithObjectLiteral.ts(30,18): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '0'. typeArgumentInferenceWithObjectLiteral.ts(35,43): error TS2345: Argument of type 'E2' is not assignable to parameter of type 'E1'. -==== typeArgumentInferenceWithObjectLiteral.ts (2 errors) ==== +==== typeArgumentInferenceWithObjectLiteral.ts (1 errors) ==== interface Computed { read(): T; write(value: T); @@ -33,8 +32,6 @@ typeArgumentInferenceWithObjectLiteral.ts(35,43): error TS2345: Argument of type var v1 = f1({ w: x => x, r: () => 0 }, 0); var v1 = f1({ w: x => x, r: () => 0 }, E1.X); var v1 = f1({ w: x => x, r: () => E1.X }, 0); - ~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '0'. var v2: E1; var v2 = f1({ w: x => x, r: () => E1.X }, E1.X); diff --git a/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt b/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt index c70badcb65ab7..7d1beaf9615f0 100644 --- a/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt +++ b/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt @@ -1,12 +1,9 @@ typeInferenceConflictingCandidates.ts(3,7): error TS2345: Argument of type '3' is not assignable to parameter of type '""'. -typeInferenceConflictingCandidates.ts(3,10): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '""'. -==== typeInferenceConflictingCandidates.ts (2 errors) ==== +==== typeInferenceConflictingCandidates.ts (1 errors) ==== declare function g(a: T, b: T, c: (t: T) => T): T; g("", 3, a => a); ~ -!!! error TS2345: Argument of type '3' is not assignable to parameter of type '""'. - ~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '""'. \ No newline at end of file +!!! error TS2345: Argument of type '3' is not assignable to parameter of type '""'. \ No newline at end of file From 538130f100a452af5f8c5501d2c322b630bce58c Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 26 Sep 2023 11:04:21 -0700 Subject: [PATCH 7/8] Don't complain unless declaration emit is enabled --- src/compiler/checker.ts | 3 +- .../importCallExpression5ES2020.errors.txt | 5 +- ...onalPropertiesToIndexSignatures.errors.txt | 31 --- ...ortTypeReferenceToStringLiteral.errors.txt | 12 -- .../reference/literalTypes2.errors.txt | 188 ------------------ .../nullishCoalescingOperator2.errors.txt | 41 ---- .../nullishCoalescingOperator3.errors.txt | 16 -- .../nullishCoalescingOperator7.errors.txt | 21 -- ...ullishCoalescingOperator_es2020.errors.txt | 59 ------ ...shCoalescingOperator_not_strict.errors.txt | 41 ---- 10 files changed, 3 insertions(+), 414 deletions(-) delete mode 100644 tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.errors.txt delete mode 100644 tests/baselines/reference/jsdocImportTypeReferenceToStringLiteral.errors.txt delete mode 100644 tests/baselines/reference/literalTypes2.errors.txt delete mode 100644 tests/baselines/reference/nullishCoalescingOperator2.errors.txt delete mode 100644 tests/baselines/reference/nullishCoalescingOperator3.errors.txt delete mode 100644 tests/baselines/reference/nullishCoalescingOperator7.errors.txt delete mode 100644 tests/baselines/reference/nullishCoalescingOperator_es2020.errors.txt delete mode 100644 tests/baselines/reference/nullishCoalescingOperator_not_strict.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1f3551294b38a..e6ec1a7e3eef2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -41991,7 +41991,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if ( - !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) + getEmitDeclarations(compilerOptions) + && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) && !shouldPrintWithInitializer(node) && !isPrivateDeclaration(node) && isVisibleExternally(node) diff --git a/tests/baselines/reference/importCallExpression5ES2020.errors.txt b/tests/baselines/reference/importCallExpression5ES2020.errors.txt index 4768923043a6b..703aceefef8fa 100644 --- a/tests/baselines/reference/importCallExpression5ES2020.errors.txt +++ b/tests/baselines/reference/importCallExpression5ES2020.errors.txt @@ -1,4 +1,3 @@ -2.ts(2,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | undefined' or '"./0" | undefined'. 2.ts(3,23): error TS7036: Dynamic import's specifier must be of type 'string', but here has type '"./0" | undefined'. 2.ts(4,24): error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'undefined'. 2.ts(5,24): error TS7036: Dynamic import's specifier must be of type 'string', but here has type '"./1" | null'. @@ -15,11 +14,9 @@ ==== 1.ts (0 errors) ==== export function backup() { return "backup"; } -==== 2.ts (5 errors) ==== +==== 2.ts (4 errors) ==== declare function bar(): boolean; const specify = bar() ? "./0" : undefined; - ~~~~~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | undefined' or '"./0" | undefined'. let myModule = import(specify); ~~~~~~~ !!! error TS7036: Dynamic import's specifier must be of type 'string', but here has type '"./0" | undefined'. diff --git a/tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.errors.txt b/tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.errors.txt deleted file mode 100644 index 34598d58a5804..0000000000000 --- a/tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.errors.txt +++ /dev/null @@ -1,31 +0,0 @@ -inferenceOptionalPropertiesToIndexSignatures.ts(15,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | null' or '"value2" | null'. - - -==== inferenceOptionalPropertiesToIndexSignatures.ts (1 errors) ==== - declare function foo(obj: { [x: string]: T }): T; - - declare const x1: { a: string, b: number }; - declare const x2: { a: string, b: number | undefined }; - declare const x3: { a: string, b?: number }; - declare const x4: { a: string, b?: number | undefined }; - - let a1 = foo(x1); // string | number - let a2 = foo(x2); // string | number | undefined - let a3 = foo(x3); // string | number - let a4 = foo(x4); // string | number - - // Repro from #43045 - - const param2 = Math.random() < 0.5 ? 'value2' : null; - ~~~~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | null' or '"value2" | null'. - - const obj = { - param1: 'value1', - ...(param2 ? {param2} : {}) - }; - - const query = Object.entries(obj).map( - ([k, v]) => `${k}=${encodeURIComponent(v)}` - ).join('&'); - \ No newline at end of file diff --git a/tests/baselines/reference/jsdocImportTypeReferenceToStringLiteral.errors.txt b/tests/baselines/reference/jsdocImportTypeReferenceToStringLiteral.errors.txt deleted file mode 100644 index c365fa58510ee..0000000000000 --- a/tests/baselines/reference/jsdocImportTypeReferenceToStringLiteral.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -a.js(2,5): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"foo"'. - - -==== b.js (0 errors) ==== - export const FOO = "foo"; - -==== a.js (1 errors) ==== - /** @type {import('./b').FOO} */ - let x; - ~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"foo"'. - \ No newline at end of file diff --git a/tests/baselines/reference/literalTypes2.errors.txt b/tests/baselines/reference/literalTypes2.errors.txt deleted file mode 100644 index 281b3b9c2e507..0000000000000 --- a/tests/baselines/reference/literalTypes2.errors.txt +++ /dev/null @@ -1,188 +0,0 @@ -literalTypes2.ts(155,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. -literalTypes2.ts(156,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or '1 | "two"'. - - -==== literalTypes2.ts (2 errors) ==== - enum E { - A, B, C - } - - let cond: boolean; - - function f1(p1 = 1, p2 = "abc", p3 = true, p4 = E.A) { - var v1 = 1; - var v2 = -123; - var v3 = 3 + 4; - var v4 = "abc"; - var v5 = ""; - var v6 = "abc" + "def"; - var v7 = true; - var v8 = E.A; - let x1 = 1; - let x2 = -123; - let x3 = 3 + 4; - let x4 = "abc"; - let x5 = ""; - let x6 = "abc" + "def"; - let x7 = true; - var x8 = E.A; - const c1 = 1; - const c2 = -123; - const c3 = 3 + 4; - const c4 = "abc"; - const c5 = ""; - const c6 = "abc" + "def"; - const c7 = true; - const c8 = E.A; - } - - function f2(p1: 1 = 1, p2: "abc" = "abc", p3: true = true, p4: E.A = E.A) { - var v1: 1 = 1; - var v2: -123 = -123; - var v3: "abc" = "abc"; - var v4: true = true; - var v5: E.A = E.A; - let x1: 1 = 1; - let x2: -123 = -123; - let x3: "abc" = "abc"; - let x4: true = true; - let x5: E.A = E.A; - } - - function f3() { - const c1 = cond ? 1 : 2; - const c2 = cond ? 1 : "two"; - const c3 = cond ? E.A : cond ? true : 123; - const c4 = cond ? "abc" : null; - const c5 = cond ? 456 : undefined; - const c6: { kind: 123 } = { kind: 123 }; - const c7: [1 | 2, "foo" | "bar"] = [1, "bar"]; - const c8 = cond ? c6 : cond ? c7 : "hello"; - let x1 = c1; - let x2 = c2; - let x3 = c3; - let x4 = c4; - let x5 = c5; - let x6 = c6; - let x7 = c7; - let x8 = c8; - } - - class C1 { - x1 = 1; - x2 = -123; - x3 = 3 + 4; - x4 = "abc"; - x5 = ""; - x6 = "abc" + "def"; - x7 = true; - x8 = E.A; - readonly c1 = 1; - readonly c2 = -123; - readonly c3 = 3 + 4; - readonly c4 = "abc"; - readonly c5 = ""; - readonly c6 = "abc" + "def"; - readonly c7 = true; - readonly c8 = E.A; - } - - function f4() { - const c1 = { a: 1, b: "foo" }; - const c2: { a : 0 | 1, b: "foo" | "bar" } = { a: 1, b: "foo" }; - let x1 = { a: 1, b: "foo" }; - let x2: { a : 0 | 1, b: "foo" | "bar" } = { a: 1, b: "foo" }; - } - - function f5() { - const c1 = [1, "foo"]; - const c2: (1 | "foo")[] = [1, "foo"]; - const c3: [1, "foo"] = [1, "foo"]; - let x1 = [1, "foo"]; - let x2: (1 | "foo")[] = [1, "foo"]; - let x3: [1, "foo"] = [1, "foo"]; - } - - function f6() { - const { c1 = true, c2 = 0, c3 = "foo" } = { c1: false, c2: 1, c3: "bar" }; - let { x1 = true, x2 = 0, x3 = "foo" } = { x1: false, x2: 1, x3: "bar" }; - } - - function f10() { - return "hello"; - } - - function f11() { - return cond ? 1 : "two"; - } - - function f12() { - if (cond) { - return 1; - } - else { - return "two"; - } - } - - class C2 { - foo() { - return 0; - } - bar() { - return cond ? 0 : 1; - } - } - - function f20() { - const f1 = () => 0; - const f2 = () => "hello"; - const f3 = () => true; - const f4 = () => E.C; - const f5 = (): "foo" => "foo"; - const f6: () => "foo" | "bar" = () => "bar"; - const f7: (() => "foo") | (() => "bar") = () => "bar"; - } - - declare function g1(x: T): T; - declare function g2(x: T, y: T): T; - declare function g3(x: T, y: U): T | U; - declare function g4(x: T): T[]; - declare function g5(x: T, y: T): T[]; - declare function g6(x: T[]): T; - declare function g7(x: T[]): T[]; - declare function g8(x: T, f: (p: T) => T): T; - - const a: (1 | 2)[] = [1, 2]; - - const x1 = g1(1); // Type 1 - const x2 = g2(1, 1); // Type 1 - const x3 = g2(1, 2); // Type 1 | 2 - ~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. - const x4 = g3(1, "two"); // Type 1 | "two" - ~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | number' or '1 | "two"'. - const x5 = g4(1); // Type number[] - const x6 = g5(1, 2); // Type (1 | 2)[] - const x7 = g6([1, 2]); // Type number - const x8 = g6(a); // Type 1 | 2 - const x9 = g7(a); // Type (1 | 2)[] - const x10 = g8(1, x => x); // Type number - const x11 = g8(1, x => x + 1); // Type number - - function makeArray(x: T): T[] { - return [x]; - } - - function append(a: T[], x: T): T[] { - let result = a.slice(); - result.push(x); - return result; - } - - type Bit = 0 | 1; - - let aa = makeArray(0); - aa = append(aa, 1); - \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperator2.errors.txt b/tests/baselines/reference/nullishCoalescingOperator2.errors.txt deleted file mode 100644 index 1620173ec55b0..0000000000000 --- a/tests/baselines/reference/nullishCoalescingOperator2.errors.txt +++ /dev/null @@ -1,41 +0,0 @@ -nullishCoalescingOperator2.ts(12,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. -nullishCoalescingOperator2.ts(13,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. -nullishCoalescingOperator2.ts(14,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. -nullishCoalescingOperator2.ts(15,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. -nullishCoalescingOperator2.ts(16,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. -nullishCoalescingOperator2.ts(17,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. - - -==== nullishCoalescingOperator2.ts (6 errors) ==== - declare const a1: 'literal' | undefined | null - declare const a2: '' | undefined | null - declare const a3: 1 | undefined | null - declare const a4: 0 | undefined | null - declare const a5: true | undefined | null - declare const a6: false | undefined | null - declare const a7: unknown | null - declare const a8: never | null - declare const a9: any | null - - - const aa1 = a1 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. - const aa2 = a2 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. - const aa3 = a3 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. - const aa4 = a4 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. - const aa5 = a5 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. - const aa6 = a6 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. - const aa7 = a7 ?? 'whatever' - const aa8 = a8 ?? 'whatever' - const aa9 = a9 ?? 'whatever' \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperator3.errors.txt b/tests/baselines/reference/nullishCoalescingOperator3.errors.txt deleted file mode 100644 index 59f28d152fbae..0000000000000 --- a/tests/baselines/reference/nullishCoalescingOperator3.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -nullishCoalescingOperator3.ts(9,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | boolean | 0 | 1' or 'boolean | "" | 0 | "literal" | 1 | "whatever"'. - - -==== nullishCoalescingOperator3.ts (1 errors) ==== - declare const a1: 'literal' | undefined | null - declare const a2: '' | undefined | null - declare const a3: 1 | undefined | null - declare const a4: 0 | undefined | null - declare const a5: true | undefined | null - declare const a6: false | undefined | null - - - const aa1 = a1 ?? a2 ?? a3 ?? a4 ?? a5 ?? a6 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | boolean | 0 | 1' or 'boolean | "" | 0 | "literal" | 1 | "whatever"'. - \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperator7.errors.txt b/tests/baselines/reference/nullishCoalescingOperator7.errors.txt deleted file mode 100644 index 53611a6bb76a9..0000000000000 --- a/tests/baselines/reference/nullishCoalescingOperator7.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -nullishCoalescingOperator7.ts(5,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. -nullishCoalescingOperator7.ts(6,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. - - -==== nullishCoalescingOperator7.ts (2 errors) ==== - declare const a: string | undefined; - declare const b: string | undefined; - declare const c: string | undefined; - - const foo1 = a ? 1 : 2; - ~~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. - const foo2 = a ?? 'foo' ? 1 : 2; - ~~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'number' or '1 | 2'. - const foo3 = a ?? 'foo' ? (b ?? 'bar') : (c ?? 'baz'); - - function f () { - const foo4 = a ?? 'foo' ? b ?? 'bar' : c ?? 'baz'; - } - \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperator_es2020.errors.txt b/tests/baselines/reference/nullishCoalescingOperator_es2020.errors.txt deleted file mode 100644 index 5e4a642d8d8c6..0000000000000 --- a/tests/baselines/reference/nullishCoalescingOperator_es2020.errors.txt +++ /dev/null @@ -1,59 +0,0 @@ -nullishCoalescingOperator_es2020.ts(12,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. -nullishCoalescingOperator_es2020.ts(13,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. -nullishCoalescingOperator_es2020.ts(14,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. -nullishCoalescingOperator_es2020.ts(15,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. -nullishCoalescingOperator_es2020.ts(16,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. -nullishCoalescingOperator_es2020.ts(17,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. - - -==== nullishCoalescingOperator_es2020.ts (6 errors) ==== - declare const a1: 'literal' | undefined | null - declare const a2: '' | undefined | null - declare const a3: 1 | undefined | null - declare const a4: 0 | undefined | null - declare const a5: true | undefined | null - declare const a6: false | undefined | null - declare const a7: unknown | null - declare const a8: never | null - declare const a9: any | null - - - const aa1 = a1 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. - const aa2 = a2 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. - const aa3 = a3 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. - const aa4 = a4 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. - const aa5 = a5 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. - const aa6 = a6 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. - const aa7 = a7 ?? 'whatever' - const aa8 = a8 ?? 'whatever' - const aa9 = a9 ?? 'whatever' - - - declare let a: any, b: any, c: any; - - let x1 = (a ?? b as any) || c; - let x2 = c || (a ?? b as any); - let x3 = ((a ?? b) as any) || c; - let x4 = c || ((a ?? b) as any); - let x5 = (a ?? b) as any || c; - let x6 = c || (a ?? b) as any; - - let y1 = (a ?? b as any) && c; - let y2 = c && (a ?? b as any); - let y3 = ((a ?? b) as any) && c; - let y4 = c && ((a ?? b) as any); - let y5 = (a ?? b) as any && c; - let y6 = c && (a ?? b) as any; - \ No newline at end of file diff --git a/tests/baselines/reference/nullishCoalescingOperator_not_strict.errors.txt b/tests/baselines/reference/nullishCoalescingOperator_not_strict.errors.txt deleted file mode 100644 index 95478bcd8330a..0000000000000 --- a/tests/baselines/reference/nullishCoalescingOperator_not_strict.errors.txt +++ /dev/null @@ -1,41 +0,0 @@ -nullishCoalescingOperator_not_strict.ts(12,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. -nullishCoalescingOperator_not_strict.ts(13,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. -nullishCoalescingOperator_not_strict.ts(14,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. -nullishCoalescingOperator_not_strict.ts(15,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. -nullishCoalescingOperator_not_strict.ts(16,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. -nullishCoalescingOperator_not_strict.ts(17,7): error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. - - -==== nullishCoalescingOperator_not_strict.ts (6 errors) ==== - declare const a1: 'literal' | undefined | null - declare const a2: '' | undefined | null - declare const a3: 1 | undefined | null - declare const a4: 0 | undefined | null - declare const a5: true | undefined | null - declare const a6: false | undefined | null - declare const a7: unknown | null - declare const a8: never | null - declare const a9: any | null - - - const aa1 = a1 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"literal" | "whatever"'. - const aa2 = a2 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string' or '"" | "whatever"'. - const aa3 = a3 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 1' or '1 | "whatever"'. - const aa4 = a4 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | 0' or '0 | "whatever"'. - const aa5 = a5 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | true' or 'true | "whatever"'. - const aa6 = a6 ?? 'whatever' - ~~~ -!!! error TS2856: The type of this declaration is ambiguous and may be observed as either 'string | false' or 'false | "whatever"'. - const aa7 = a7 ?? 'whatever' - const aa8 = a8 ?? 'whatever' - const aa9 = a9 ?? 'whatever' \ No newline at end of file From 4ef662f2ca4c9574165f379d284847d65fb8076b Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 26 Sep 2023 12:17:50 -0700 Subject: [PATCH 8/8] Defer new check until after everything else has run --- src/compiler/checker.ts | 42 +- ...ileExportAssignmentImportInternalModule.js | 14 + ...eclFileImportModuleWithExportAssignment.js | 51 +-- ...ationEmitImportInExportAssignmentModule.js | 6 + tests/baselines/reference/declarationMaps.js | 34 +- .../reference/declarationMaps.js.map | 4 +- .../reference/declarationMaps.sourcemap.txt | 221 +++++++++-- .../reference/declareFileExportAssignment.js | 33 +- ...tAssignmentWithVarFromVariableStatement.js | 33 +- tests/baselines/reference/es6ExportClause.js | 1 + .../reference/es6ExportClauseInEs5.js | 1 + .../reference/importTypeGenericTypes.js | 60 +-- tests/baselines/reference/importTypeLocal.js | 52 +-- .../reference/importTypeLocalMissing.js | 4 + .../moduleAugmentationImportsAndExports2.js | 6 + .../moduleAugmentationImportsAndExports3.js | 6 + .../moduleAugmentationImportsAndExports5.js | 46 +-- .../reference/privacyAccessorDeclFile.js | 262 +++---------- .../privacyCheckTypeOfInvisibleModuleError.js | 19 +- ...rivacyCheckTypeOfInvisibleModuleNoError.js | 19 +- .../privacyFunctionParameterDeclFile.js | 315 ++++----------- .../privacyFunctionParameterDeclFile.types | 40 +- .../privacyFunctionReturnTypeDeclFile.js | 359 ++++-------------- .../privacyFunctionReturnTypeDeclFile.types | 40 +- tests/baselines/reference/privacyGloImport.js | 102 +---- .../reference/privacyGloImportParseErrors.js | 5 + tests/baselines/reference/privacyImport.js | 78 +--- ...yLocalInternalReferenceImportWithExport.js | 122 +----- ...calInternalReferenceImportWithoutExport.js | 91 +---- ...pLevelInternalReferenceImportWithExport.js | 120 +----- ...velInternalReferenceImportWithoutExport.js | 89 +---- .../privacyTypeParametersOfClassDeclFile.js | 53 +-- ...rivacyTypeParametersOfInterfaceDeclFile.js | 90 +---- .../baselines/reference/privacyVarDeclFile.js | 203 +++------- 34 files changed, 700 insertions(+), 1921 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e6ec1a7e3eef2..1588c99a6c7df 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2213,6 +2213,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { var potentialReflectCollisions: Node[] = []; var potentialUnusedRenamedBindingElementsInTypes: BindingElement[] = []; var awaitedTypeStack: number[] = []; + var ambiguousVariableDeclarationsWhenWidened: [node: ParameterDeclaration | PropertyDeclaration | PropertySignature | VariableDeclaration | BindingElement, type: Type, widenedLiteralType: Type][] = []; var diagnostics = createDiagnosticCollection(); var suggestionDiagnostics = createDiagnosticCollection(); @@ -41978,28 +41979,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return hasEffectiveModifier(node, ModifierFlags.Private) || isPrivateIdentifierClassElementDeclaration(node); } - function isVisibleExternally(elem: ParameterDeclaration | PropertyDeclaration | PropertySignature | VariableDeclaration | BindingElement | OmittedExpression): boolean { - if (isOmittedExpression(elem)) { - return false; - } - if (isBindingPattern(elem.name)) { - return some(elem.name.elements, isVisibleExternally); - } - else { - return isDeclarationVisible(elem); - } - } - if ( getEmitDeclarations(compilerOptions) && !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.Signature)) && !shouldPrintWithInitializer(node) && !isPrivateDeclaration(node) - && isVisibleExternally(node) ) { const widenedLiteralType = getWidenedLiteralType(type); if (!isTypeIdenticalTo(type, widenedLiteralType)) { - error(node.name, Diagnostics.The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1, typeToString(widenedLiteralType), typeToString(type)); + ambiguousVariableDeclarationsWhenWidened.push([node, type, widenedLiteralType]); } } } @@ -46079,6 +46067,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { clear(potentialWeakMapSetCollisions); clear(potentialReflectCollisions); clear(potentialUnusedRenamedBindingElementsInTypes); + clear(ambiguousVariableDeclarationsWhenWidened); forEach(node.statements, checkSourceElement); checkSourceElement(node.endOfFileToken); @@ -46103,6 +46092,26 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } }); + addLazyDiagnostic(() => { + function isVisibleExternally(elem: ParameterDeclaration | PropertyDeclaration | PropertySignature | VariableDeclaration | BindingElement | OmittedExpression): boolean { + if (isOmittedExpression(elem)) { + return false; + } + if (isBindingPattern(elem.name)) { + return some(elem.name.elements, isVisibleExternally); + } + else { + return isDeclarationVisible(elem); + } + } + + for (const [node, type, widenedLiteralType] of ambiguousVariableDeclarationsWhenWidened) { + if (isVisibleExternally(node)) { + error(node.name, Diagnostics.The_type_of_this_declaration_is_ambiguous_and_may_be_observed_as_either_0_or_1, typeToString(widenedLiteralType), typeToString(type)); + } + } + }); + if ( compilerOptions.importsNotUsedAsValues === ImportsNotUsedAsValues.Error && !node.isDeclarationFile && @@ -46135,6 +46144,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { clear(potentialReflectCollisions); } + if (ambiguousVariableDeclarationsWhenWidened.length) { + // forEach(potentialAmbiguousDeclarationsWhenWidened, checkAmbiguousDeclaration); + clear(ambiguousVariableDeclarationsWhenWidened); + } + links.flags |= NodeCheckFlags.TypeChecked; } } diff --git a/tests/baselines/reference/declFileExportAssignmentImportInternalModule.js b/tests/baselines/reference/declFileExportAssignmentImportInternalModule.js index 240ce9fe26655..10633bbae1e23 100644 --- a/tests/baselines/reference/declFileExportAssignmentImportInternalModule.js +++ b/tests/baselines/reference/declFileExportAssignmentImportInternalModule.js @@ -34,6 +34,20 @@ module.exports = m; //// [declFileExportAssignmentImportInternalModule.d.ts] declare namespace m3 { + namespace m2 { + interface connectModule { + (res: any, req: any, next: any): void; + } + interface connectExport { + use: (mod: connectModule) => connectExport; + listen: (port: number) => void; + } + } + var server: { + (): m2.connectExport; + test1: m2.connectModule; + test2(): m2.connectModule; + }; } import m = m3; export = m; diff --git a/tests/baselines/reference/declFileImportModuleWithExportAssignment.js b/tests/baselines/reference/declFileImportModuleWithExportAssignment.js index 7fb4a35d7b153..65bac37e0e884 100644 --- a/tests/baselines/reference/declFileImportModuleWithExportAssignment.js +++ b/tests/baselines/reference/declFileImportModuleWithExportAssignment.js @@ -41,6 +41,13 @@ exports.a.test1(null, null, null); //// [declFileImportModuleWithExportAssignment_0.d.ts] declare namespace m2 { + interface connectModule { + (res: any, req: any, next: any): void; + } + interface connectExport { + use: (mod: connectModule) => connectExport; + listen: (port: number) => void; + } } declare var m2: { (): m2.connectExport; @@ -56,47 +63,3 @@ export declare var a: { test1: a1.connectModule; test2(): a1.connectModule; }; - - -//// [DtsFileErrors] - - -declFileImportModuleWithExportAssignment_0.d.ts(4,12): error TS2694: Namespace 'm2' has no exported member 'connectExport'. -declFileImportModuleWithExportAssignment_0.d.ts(5,15): error TS2694: Namespace 'm2' has no exported member 'connectModule'. -declFileImportModuleWithExportAssignment_0.d.ts(6,17): error TS2694: Namespace 'm2' has no exported member 'connectModule'. -declFileImportModuleWithExportAssignment_1.d.ts(4,12): error TS2694: Namespace 'm2' has no exported member 'connectExport'. -declFileImportModuleWithExportAssignment_1.d.ts(5,15): error TS2694: Namespace 'm2' has no exported member 'connectModule'. -declFileImportModuleWithExportAssignment_1.d.ts(6,17): error TS2694: Namespace 'm2' has no exported member 'connectModule'. - - -==== declFileImportModuleWithExportAssignment_1.d.ts (3 errors) ==== - /**This is on import declaration*/ - import a1 = require("./declFileImportModuleWithExportAssignment_0"); - export declare var a: { - (): a1.connectExport; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectExport'. - test1: a1.connectModule; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. - test2(): a1.connectModule; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. - }; - -==== declFileImportModuleWithExportAssignment_0.d.ts (3 errors) ==== - declare namespace m2 { - } - declare var m2: { - (): m2.connectExport; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectExport'. - test1: m2.connectModule; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. - test2(): m2.connectModule; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. - }; - export = m2; - \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js b/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js index 7466ba3b74bc1..7f220e5ed5151 100644 --- a/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js +++ b/tests/baselines/reference/declarationEmitImportInExportAssignmentModule.js @@ -30,5 +30,11 @@ module.exports = m; //// [declarationEmitImportInExportAssignmentModule.d.ts] declare namespace m { + namespace c { + class c { + } + } + import x = c; + var a: typeof x; } export = m; diff --git a/tests/baselines/reference/declarationMaps.js b/tests/baselines/reference/declarationMaps.js index 1c37b90241f66..1129dcac17795 100644 --- a/tests/baselines/reference/declarationMaps.js +++ b/tests/baselines/reference/declarationMaps.js @@ -28,6 +28,13 @@ module.exports = m2; //// [declarationMaps.d.ts] declare namespace m2 { + interface connectModule { + (res: any, req: any, next: any): void; + } + interface connectExport { + use: (mod: connectModule) => connectExport; + listen: (port: number) => void; + } } declare var m2: { (): m2.connectExport; @@ -35,29 +42,4 @@ declare var m2: { test2(): m2.connectModule; }; export = m2; -//# sourceMappingURL=declarationMaps.d.ts.map - -//// [DtsFileErrors] - - -declarationMaps.d.ts(4,12): error TS2694: Namespace 'm2' has no exported member 'connectExport'. -declarationMaps.d.ts(5,15): error TS2694: Namespace 'm2' has no exported member 'connectModule'. -declarationMaps.d.ts(6,17): error TS2694: Namespace 'm2' has no exported member 'connectModule'. - - -==== declarationMaps.d.ts (3 errors) ==== - declare namespace m2 { - } - declare var m2: { - (): m2.connectExport; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectExport'. - test1: m2.connectModule; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. - test2(): m2.connectModule; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. - }; - export = m2; - //# sourceMappingURL=declarationMaps.d.ts.map \ No newline at end of file +//# sourceMappingURL=declarationMaps.d.ts.map \ No newline at end of file diff --git a/tests/baselines/reference/declarationMaps.js.map b/tests/baselines/reference/declarationMaps.js.map index 3cd149787e18a..e26401dd61deb 100644 --- a/tests/baselines/reference/declarationMaps.js.map +++ b/tests/baselines/reference/declarationMaps.js.map @@ -1,3 +1,3 @@ //// [declarationMaps.d.ts.map] -{"version":3,"file":"declarationMaps.d.ts","sourceRoot":"","sources":["declarationMaps.ts"],"names":[],"mappings":"AAAA,kBAAO,EAAE,CAAC;CAST;AAED,QAAA,IAAI,EAAE,EAAE;IACJ,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC;IACxB,KAAK,IAAI,EAAE,CAAC,aAAa,CAAC;CAC7B,CAAC;AAEF,SAAS,EAAE,CAAC"} -//// https://sokra.github.io/source-map-visualization#base64,ZGVjbGFyZSBuYW1lc3BhY2UgbTIgew0KfQ0KZGVjbGFyZSB2YXIgbTI6IHsNCiAgICAoKTogbTIuY29ubmVjdEV4cG9ydDsNCiAgICB0ZXN0MTogbTIuY29ubmVjdE1vZHVsZTsNCiAgICB0ZXN0MigpOiBtMi5jb25uZWN0TW9kdWxlOw0KfTsNCmV4cG9ydCA9IG0yOw0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZGVjbGFyYXRpb25NYXBzLmQudHMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjbGFyYXRpb25NYXBzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJkZWNsYXJhdGlvbk1hcHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsa0JBQU8sRUFBRSxDQUFDO0NBU1Q7QUFFRCxRQUFBLElBQUksRUFBRSxFQUFFO0lBQ0osSUFBSSxFQUFFLENBQUMsYUFBYSxDQUFDO0lBQ3JCLEtBQUssRUFBRSxFQUFFLENBQUMsYUFBYSxDQUFDO0lBQ3hCLEtBQUssSUFBSSxFQUFFLENBQUMsYUFBYSxDQUFDO0NBQzdCLENBQUM7QUFFRixTQUFTLEVBQUUsQ0FBQyJ9,bW9kdWxlIG0yIHsKICAgIGV4cG9ydCBpbnRlcmZhY2UgY29ubmVjdE1vZHVsZSB7CiAgICAgICAgKHJlcywgcmVxLCBuZXh0KTogdm9pZDsKICAgIH0KICAgIGV4cG9ydCBpbnRlcmZhY2UgY29ubmVjdEV4cG9ydCB7CiAgICAgICAgdXNlOiAobW9kOiBjb25uZWN0TW9kdWxlKSA9PiBjb25uZWN0RXhwb3J0OwogICAgICAgIGxpc3RlbjogKHBvcnQ6IG51bWJlcikgPT4gdm9pZDsKICAgIH0KCn0KCnZhciBtMjogewogICAgKCk6IG0yLmNvbm5lY3RFeHBvcnQ7CiAgICB0ZXN0MTogbTIuY29ubmVjdE1vZHVsZTsKICAgIHRlc3QyKCk6IG0yLmNvbm5lY3RNb2R1bGU7Cn07CgpleHBvcnQgPSBtMjs= +{"version":3,"file":"declarationMaps.d.ts","sourceRoot":"","sources":["declarationMaps.ts"],"names":[],"mappings":"AAAA,kBAAO,EAAE,CAAC;IACN,UAAiB,aAAa;QAC1B,CAAC,GAAG,KAAA,EAAE,GAAG,KAAA,EAAE,IAAI,KAAA,GAAG,IAAI,CAAC;KAC1B;IACD,UAAiB,aAAa;QAC1B,GAAG,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,aAAa,CAAC;QAC3C,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;KAClC;CAEJ;AAED,QAAA,IAAI,EAAE,EAAE;IACJ,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC;IACxB,KAAK,IAAI,EAAE,CAAC,aAAa,CAAC;CAC7B,CAAC;AAEF,SAAS,EAAE,CAAC"} +//// https://sokra.github.io/source-map-visualization#base64,ZGVjbGFyZSBuYW1lc3BhY2UgbTIgew0KICAgIGludGVyZmFjZSBjb25uZWN0TW9kdWxlIHsNCiAgICAgICAgKHJlczogYW55LCByZXE6IGFueSwgbmV4dDogYW55KTogdm9pZDsNCiAgICB9DQogICAgaW50ZXJmYWNlIGNvbm5lY3RFeHBvcnQgew0KICAgICAgICB1c2U6IChtb2Q6IGNvbm5lY3RNb2R1bGUpID0+IGNvbm5lY3RFeHBvcnQ7DQogICAgICAgIGxpc3RlbjogKHBvcnQ6IG51bWJlcikgPT4gdm9pZDsNCiAgICB9DQp9DQpkZWNsYXJlIHZhciBtMjogew0KICAgICgpOiBtMi5jb25uZWN0RXhwb3J0Ow0KICAgIHRlc3QxOiBtMi5jb25uZWN0TW9kdWxlOw0KICAgIHRlc3QyKCk6IG0yLmNvbm5lY3RNb2R1bGU7DQp9Ow0KZXhwb3J0ID0gbTI7DQovLyMgc291cmNlTWFwcGluZ1VSTD1kZWNsYXJhdGlvbk1hcHMuZC50cy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjbGFyYXRpb25NYXBzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJkZWNsYXJhdGlvbk1hcHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsa0JBQU8sRUFBRSxDQUFDO0lBQ04sVUFBaUIsYUFBYTtRQUMxQixDQUFDLEdBQUcsS0FBQSxFQUFFLEdBQUcsS0FBQSxFQUFFLElBQUksS0FBQSxHQUFHLElBQUksQ0FBQztLQUMxQjtJQUNELFVBQWlCLGFBQWE7UUFDMUIsR0FBRyxFQUFFLENBQUMsR0FBRyxFQUFFLGFBQWEsS0FBSyxhQUFhLENBQUM7UUFDM0MsTUFBTSxFQUFFLENBQUMsSUFBSSxFQUFFLE1BQU0sS0FBSyxJQUFJLENBQUM7S0FDbEM7Q0FFSjtBQUVELFFBQUEsSUFBSSxFQUFFLEVBQUU7SUFDSixJQUFJLEVBQUUsQ0FBQyxhQUFhLENBQUM7SUFDckIsS0FBSyxFQUFFLEVBQUUsQ0FBQyxhQUFhLENBQUM7SUFDeEIsS0FBSyxJQUFJLEVBQUUsQ0FBQyxhQUFhLENBQUM7Q0FDN0IsQ0FBQztBQUVGLFNBQVMsRUFBRSxDQUFDIn0=,bW9kdWxlIG0yIHsKICAgIGV4cG9ydCBpbnRlcmZhY2UgY29ubmVjdE1vZHVsZSB7CiAgICAgICAgKHJlcywgcmVxLCBuZXh0KTogdm9pZDsKICAgIH0KICAgIGV4cG9ydCBpbnRlcmZhY2UgY29ubmVjdEV4cG9ydCB7CiAgICAgICAgdXNlOiAobW9kOiBjb25uZWN0TW9kdWxlKSA9PiBjb25uZWN0RXhwb3J0OwogICAgICAgIGxpc3RlbjogKHBvcnQ6IG51bWJlcikgPT4gdm9pZDsKICAgIH0KCn0KCnZhciBtMjogewogICAgKCk6IG0yLmNvbm5lY3RFeHBvcnQ7CiAgICB0ZXN0MTogbTIuY29ubmVjdE1vZHVsZTsKICAgIHRlc3QyKCk6IG0yLmNvbm5lY3RNb2R1bGU7Cn07CgpleHBvcnQgPSBtMjs= diff --git a/tests/baselines/reference/declarationMaps.sourcemap.txt b/tests/baselines/reference/declarationMaps.sourcemap.txt index b8995f04d8de2..c1784ff9afa8a 100644 --- a/tests/baselines/reference/declarationMaps.sourcemap.txt +++ b/tests/baselines/reference/declarationMaps.sourcemap.txt @@ -13,6 +13,7 @@ sourceFile:declarationMaps.ts 2 >^^^^^^^^^^^^^^^^^^ 3 > ^^ 4 > ^ +5 > ^^^^^^^^^-> 1 > 2 >module 3 > m2 @@ -22,20 +23,160 @@ sourceFile:declarationMaps.ts 3 >Emitted(1, 21) Source(1, 10) + SourceIndex(0) 4 >Emitted(1, 22) Source(1, 11) + SourceIndex(0) --- +>>> interface connectModule { +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^^^^^^^^^ +4 > ^^^^^^^^^^^^^^^^^^^^-> +1->{ + > +2 > export interface +3 > connectModule +1->Emitted(2, 5) Source(2, 5) + SourceIndex(0) +2 >Emitted(2, 15) Source(2, 22) + SourceIndex(0) +3 >Emitted(2, 28) Source(2, 35) + SourceIndex(0) +--- +>>> (res: any, req: any, next: any): void; +1->^^^^^^^^ +2 > ^ +3 > ^^^ +4 > ^^^^^ +5 > ^^ +6 > ^^^ +7 > ^^^^^ +8 > ^^ +9 > ^^^^ +10> ^^^^^ +11> ^^^ +12> ^^^^ +13> ^ +1-> { + > +2 > ( +3 > res +4 > +5 > , +6 > req +7 > +8 > , +9 > next +10> +11> ): +12> void +13> ; +1->Emitted(3, 9) Source(3, 9) + SourceIndex(0) +2 >Emitted(3, 10) Source(3, 10) + SourceIndex(0) +3 >Emitted(3, 13) Source(3, 13) + SourceIndex(0) +4 >Emitted(3, 18) Source(3, 13) + SourceIndex(0) +5 >Emitted(3, 20) Source(3, 15) + SourceIndex(0) +6 >Emitted(3, 23) Source(3, 18) + SourceIndex(0) +7 >Emitted(3, 28) Source(3, 18) + SourceIndex(0) +8 >Emitted(3, 30) Source(3, 20) + SourceIndex(0) +9 >Emitted(3, 34) Source(3, 24) + SourceIndex(0) +10>Emitted(3, 39) Source(3, 24) + SourceIndex(0) +11>Emitted(3, 42) Source(3, 27) + SourceIndex(0) +12>Emitted(3, 46) Source(3, 31) + SourceIndex(0) +13>Emitted(3, 47) Source(3, 32) + SourceIndex(0) +--- +>>> } +1 >^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > } +1 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) +--- +>>> interface connectExport { +1->^^^^ +2 > ^^^^^^^^^^ +3 > ^^^^^^^^^^^^^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +2 > export interface +3 > connectExport +1->Emitted(5, 5) Source(5, 5) + SourceIndex(0) +2 >Emitted(5, 15) Source(5, 22) + SourceIndex(0) +3 >Emitted(5, 28) Source(5, 35) + SourceIndex(0) +--- +>>> use: (mod: connectModule) => connectExport; +1->^^^^^^^^ +2 > ^^^ +3 > ^^ +4 > ^ +5 > ^^^ +6 > ^^ +7 > ^^^^^^^^^^^^^ +8 > ^^^^^ +9 > ^^^^^^^^^^^^^ +10> ^ +1-> { + > +2 > use +3 > : +4 > ( +5 > mod +6 > : +7 > connectModule +8 > ) => +9 > connectExport +10> ; +1->Emitted(6, 9) Source(6, 9) + SourceIndex(0) +2 >Emitted(6, 12) Source(6, 12) + SourceIndex(0) +3 >Emitted(6, 14) Source(6, 14) + SourceIndex(0) +4 >Emitted(6, 15) Source(6, 15) + SourceIndex(0) +5 >Emitted(6, 18) Source(6, 18) + SourceIndex(0) +6 >Emitted(6, 20) Source(6, 20) + SourceIndex(0) +7 >Emitted(6, 33) Source(6, 33) + SourceIndex(0) +8 >Emitted(6, 38) Source(6, 38) + SourceIndex(0) +9 >Emitted(6, 51) Source(6, 51) + SourceIndex(0) +10>Emitted(6, 52) Source(6, 52) + SourceIndex(0) +--- +>>> listen: (port: number) => void; +1 >^^^^^^^^ +2 > ^^^^^^ +3 > ^^ +4 > ^ +5 > ^^^^ +6 > ^^ +7 > ^^^^^^ +8 > ^^^^^ +9 > ^^^^ +10> ^ +1 > + > +2 > listen +3 > : +4 > ( +5 > port +6 > : +7 > number +8 > ) => +9 > void +10> ; +1 >Emitted(7, 9) Source(7, 9) + SourceIndex(0) +2 >Emitted(7, 15) Source(7, 15) + SourceIndex(0) +3 >Emitted(7, 17) Source(7, 17) + SourceIndex(0) +4 >Emitted(7, 18) Source(7, 18) + SourceIndex(0) +5 >Emitted(7, 22) Source(7, 22) + SourceIndex(0) +6 >Emitted(7, 24) Source(7, 24) + SourceIndex(0) +7 >Emitted(7, 30) Source(7, 30) + SourceIndex(0) +8 >Emitted(7, 35) Source(7, 35) + SourceIndex(0) +9 >Emitted(7, 39) Source(7, 39) + SourceIndex(0) +10>Emitted(7, 40) Source(7, 40) + SourceIndex(0) +--- +>>> } +1 >^^^^^ +1 > + > } +1 >Emitted(8, 6) Source(8, 6) + SourceIndex(0) +--- >>>} 1 >^ 2 > ^^^^^^^^^^^^^^^^^-> -1 >{ - > export interface connectModule { - > (res, req, next): void; - > } - > export interface connectExport { - > use: (mod: connectModule) => connectExport; - > listen: (port: number) => void; - > } +1 > > >} -1 >Emitted(2, 2) Source(10, 2) + SourceIndex(0) +1 >Emitted(9, 2) Source(10, 2) + SourceIndex(0) --- >>>declare var m2: { 1-> @@ -51,11 +192,11 @@ sourceFile:declarationMaps.ts 3 > var 4 > m2 5 > : -1->Emitted(3, 1) Source(12, 1) + SourceIndex(0) -2 >Emitted(3, 9) Source(12, 1) + SourceIndex(0) -3 >Emitted(3, 13) Source(12, 5) + SourceIndex(0) -4 >Emitted(3, 15) Source(12, 7) + SourceIndex(0) -5 >Emitted(3, 17) Source(12, 9) + SourceIndex(0) +1->Emitted(10, 1) Source(12, 1) + SourceIndex(0) +2 >Emitted(10, 9) Source(12, 1) + SourceIndex(0) +3 >Emitted(10, 13) Source(12, 5) + SourceIndex(0) +4 >Emitted(10, 15) Source(12, 7) + SourceIndex(0) +5 >Emitted(10, 17) Source(12, 9) + SourceIndex(0) --- >>> (): m2.connectExport; 1->^^^^ @@ -72,12 +213,12 @@ sourceFile:declarationMaps.ts 4 > . 5 > connectExport 6 > ; -1->Emitted(4, 5) Source(13, 5) + SourceIndex(0) -2 >Emitted(4, 9) Source(13, 9) + SourceIndex(0) -3 >Emitted(4, 11) Source(13, 11) + SourceIndex(0) -4 >Emitted(4, 12) Source(13, 12) + SourceIndex(0) -5 >Emitted(4, 25) Source(13, 25) + SourceIndex(0) -6 >Emitted(4, 26) Source(13, 26) + SourceIndex(0) +1->Emitted(11, 5) Source(13, 5) + SourceIndex(0) +2 >Emitted(11, 9) Source(13, 9) + SourceIndex(0) +3 >Emitted(11, 11) Source(13, 11) + SourceIndex(0) +4 >Emitted(11, 12) Source(13, 12) + SourceIndex(0) +5 >Emitted(11, 25) Source(13, 25) + SourceIndex(0) +6 >Emitted(11, 26) Source(13, 26) + SourceIndex(0) --- >>> test1: m2.connectModule; 1->^^^^ @@ -96,13 +237,13 @@ sourceFile:declarationMaps.ts 5 > . 6 > connectModule 7 > ; -1->Emitted(5, 5) Source(14, 5) + SourceIndex(0) -2 >Emitted(5, 10) Source(14, 10) + SourceIndex(0) -3 >Emitted(5, 12) Source(14, 12) + SourceIndex(0) -4 >Emitted(5, 14) Source(14, 14) + SourceIndex(0) -5 >Emitted(5, 15) Source(14, 15) + SourceIndex(0) -6 >Emitted(5, 28) Source(14, 28) + SourceIndex(0) -7 >Emitted(5, 29) Source(14, 29) + SourceIndex(0) +1->Emitted(12, 5) Source(14, 5) + SourceIndex(0) +2 >Emitted(12, 10) Source(14, 10) + SourceIndex(0) +3 >Emitted(12, 12) Source(14, 12) + SourceIndex(0) +4 >Emitted(12, 14) Source(14, 14) + SourceIndex(0) +5 >Emitted(12, 15) Source(14, 15) + SourceIndex(0) +6 >Emitted(12, 28) Source(14, 28) + SourceIndex(0) +7 >Emitted(12, 29) Source(14, 29) + SourceIndex(0) --- >>> test2(): m2.connectModule; 1->^^^^ @@ -120,13 +261,13 @@ sourceFile:declarationMaps.ts 5 > . 6 > connectModule 7 > ; -1->Emitted(6, 5) Source(15, 5) + SourceIndex(0) -2 >Emitted(6, 10) Source(15, 10) + SourceIndex(0) -3 >Emitted(6, 14) Source(15, 14) + SourceIndex(0) -4 >Emitted(6, 16) Source(15, 16) + SourceIndex(0) -5 >Emitted(6, 17) Source(15, 17) + SourceIndex(0) -6 >Emitted(6, 30) Source(15, 30) + SourceIndex(0) -7 >Emitted(6, 31) Source(15, 31) + SourceIndex(0) +1->Emitted(13, 5) Source(15, 5) + SourceIndex(0) +2 >Emitted(13, 10) Source(15, 10) + SourceIndex(0) +3 >Emitted(13, 14) Source(15, 14) + SourceIndex(0) +4 >Emitted(13, 16) Source(15, 16) + SourceIndex(0) +5 >Emitted(13, 17) Source(15, 17) + SourceIndex(0) +6 >Emitted(13, 30) Source(15, 30) + SourceIndex(0) +7 >Emitted(13, 31) Source(15, 31) + SourceIndex(0) --- >>>}; 1 >^ @@ -135,8 +276,8 @@ sourceFile:declarationMaps.ts 1 > >} 2 > ; -1 >Emitted(7, 2) Source(16, 2) + SourceIndex(0) -2 >Emitted(7, 3) Source(16, 3) + SourceIndex(0) +1 >Emitted(14, 2) Source(16, 2) + SourceIndex(0) +2 >Emitted(14, 3) Source(16, 3) + SourceIndex(0) --- >>>export = m2; 1-> @@ -150,9 +291,9 @@ sourceFile:declarationMaps.ts 2 >export = 3 > m2 4 > ; -1->Emitted(8, 1) Source(18, 1) + SourceIndex(0) -2 >Emitted(8, 10) Source(18, 10) + SourceIndex(0) -3 >Emitted(8, 12) Source(18, 12) + SourceIndex(0) -4 >Emitted(8, 13) Source(18, 13) + SourceIndex(0) +1->Emitted(15, 1) Source(18, 1) + SourceIndex(0) +2 >Emitted(15, 10) Source(18, 10) + SourceIndex(0) +3 >Emitted(15, 12) Source(18, 12) + SourceIndex(0) +4 >Emitted(15, 13) Source(18, 13) + SourceIndex(0) --- >>>//# sourceMappingURL=declarationMaps.d.ts.map \ No newline at end of file diff --git a/tests/baselines/reference/declareFileExportAssignment.js b/tests/baselines/reference/declareFileExportAssignment.js index e831033368cad..ed4b9e960e965 100644 --- a/tests/baselines/reference/declareFileExportAssignment.js +++ b/tests/baselines/reference/declareFileExportAssignment.js @@ -28,6 +28,13 @@ module.exports = m2; //// [declareFileExportAssignment.d.ts] declare namespace m2 { + interface connectModule { + (res: any, req: any, next: any): void; + } + interface connectExport { + use: (mod: connectModule) => connectExport; + listen: (port: number) => void; + } } declare var m2: { (): m2.connectExport; @@ -35,29 +42,3 @@ declare var m2: { test2(): m2.connectModule; }; export = m2; - - -//// [DtsFileErrors] - - -declareFileExportAssignment.d.ts(4,12): error TS2694: Namespace 'm2' has no exported member 'connectExport'. -declareFileExportAssignment.d.ts(5,15): error TS2694: Namespace 'm2' has no exported member 'connectModule'. -declareFileExportAssignment.d.ts(6,17): error TS2694: Namespace 'm2' has no exported member 'connectModule'. - - -==== declareFileExportAssignment.d.ts (3 errors) ==== - declare namespace m2 { - } - declare var m2: { - (): m2.connectExport; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectExport'. - test1: m2.connectModule; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. - test2(): m2.connectModule; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. - }; - export = m2; - \ No newline at end of file diff --git a/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.js b/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.js index 3fa4e7302f6e8..a442fcc99fe5f 100644 --- a/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.js +++ b/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.js @@ -28,6 +28,13 @@ module.exports = m2; //// [declareFileExportAssignmentWithVarFromVariableStatement.d.ts] declare namespace m2 { + interface connectModule { + (res: any, req: any, next: any): void; + } + interface connectExport { + use: (mod: connectModule) => connectExport; + listen: (port: number) => void; + } } declare var m2: { (): m2.connectExport; @@ -35,29 +42,3 @@ declare var m2: { test2(): m2.connectModule; }; export = m2; - - -//// [DtsFileErrors] - - -declareFileExportAssignmentWithVarFromVariableStatement.d.ts(4,12): error TS2694: Namespace 'm2' has no exported member 'connectExport'. -declareFileExportAssignmentWithVarFromVariableStatement.d.ts(5,15): error TS2694: Namespace 'm2' has no exported member 'connectModule'. -declareFileExportAssignmentWithVarFromVariableStatement.d.ts(6,17): error TS2694: Namespace 'm2' has no exported member 'connectModule'. - - -==== declareFileExportAssignmentWithVarFromVariableStatement.d.ts (3 errors) ==== - declare namespace m2 { - } - declare var m2: { - (): m2.connectExport; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectExport'. - test1: m2.connectModule; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. - test2(): m2.connectModule; - ~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'm2' has no exported member 'connectModule'. - }; - export = m2; - \ No newline at end of file diff --git a/tests/baselines/reference/es6ExportClause.js b/tests/baselines/reference/es6ExportClause.js index 02ed12d099d94..eaf6536aafe4a 100644 --- a/tests/baselines/reference/es6ExportClause.js +++ b/tests/baselines/reference/es6ExportClause.js @@ -37,6 +37,7 @@ declare class c { interface i { } declare namespace m { + var x: number; } declare var x: number; declare namespace uninstantiated { diff --git a/tests/baselines/reference/es6ExportClauseInEs5.js b/tests/baselines/reference/es6ExportClauseInEs5.js index 740bad51cc6b2..b2d30fa7567a3 100644 --- a/tests/baselines/reference/es6ExportClauseInEs5.js +++ b/tests/baselines/reference/es6ExportClauseInEs5.js @@ -42,6 +42,7 @@ declare class c { interface i { } declare namespace m { + var x: number; } declare var x: number; declare namespace uninstantiated { diff --git a/tests/baselines/reference/importTypeGenericTypes.js b/tests/baselines/reference/importTypeGenericTypes.js index af0cc6ae26e9c..926ed5a8da391 100644 --- a/tests/baselines/reference/importTypeGenericTypes.js +++ b/tests/baselines/reference/importTypeGenericTypes.js @@ -84,6 +84,11 @@ interface Point { export = Point; //// [foo2.d.ts] declare namespace Bar { + interface I { + a: string; + b: number; + data: T; + } } export declare namespace Baz { interface J { @@ -114,58 +119,3 @@ export declare class Bar2 { constructor(input?: any); } export declare let shim: typeof import("./foo2"); - - -//// [DtsFileErrors] - - -foo2.d.ts(11,15): error TS2694: Namespace 'Bar' has no exported member 'I'. -usage.d.ts(4,44): error TS2694: Namespace '"foo2".Bar' has no exported member 'I'. - - -==== foo.d.ts (0 errors) ==== - interface Point { - x: number; - y: number; - data: T; - } - export = Point; - -==== foo2.d.ts (1 errors) ==== - declare namespace Bar { - } - export declare namespace Baz { - interface J { - a: number; - b: string; - data: T; - } - } - declare class Bar { - item: Bar.I; - ~ -!!! error TS2694: Namespace 'Bar' has no exported member 'I'. - constructor(input: Baz.J); - } - export { Bar }; - -==== usage.d.ts (1 errors) ==== - export declare const x: import("./foo")<{ - x: number; - }>; - export declare let y: import("./foo2").Bar.I<{ - ~ -!!! error TS2694: Namespace '"foo2".Bar' has no exported member 'I'. - x: number; - }>; - export declare class Bar2 { - item: { - a: string; - b: number; - c: object; - data: T; - }; - constructor(input?: any); - } - export declare let shim: typeof import("./foo2"); - \ No newline at end of file diff --git a/tests/baselines/reference/importTypeLocal.js b/tests/baselines/reference/importTypeLocal.js index 5238e92d17adc..23b7bd3c9951a 100644 --- a/tests/baselines/reference/importTypeLocal.js +++ b/tests/baselines/reference/importTypeLocal.js @@ -80,6 +80,10 @@ interface Point { export = Point; //// [foo2.d.ts] declare namespace Bar { + interface I { + a: string; + b: number; + } } export declare namespace Baz { interface J { @@ -104,51 +108,3 @@ export declare class Bar2 { constructor(input?: any); } export declare let shim: typeof import("./foo2"); - - -//// [DtsFileErrors] - - -foo2.d.ts(10,15): error TS2694: Namespace 'Bar' has no exported member 'I'. -usage.d.ts(2,44): error TS2694: Namespace '"foo2".Bar' has no exported member 'I'. - - -==== foo.d.ts (0 errors) ==== - interface Point { - x: number; - y: number; - } - export = Point; - -==== foo2.d.ts (1 errors) ==== - declare namespace Bar { - } - export declare namespace Baz { - interface J { - a: number; - b: string; - } - } - declare class Bar { - item: Bar.I; - ~ -!!! error TS2694: Namespace 'Bar' has no exported member 'I'. - constructor(input: Baz.J); - } - export { Bar }; - -==== usage.d.ts (1 errors) ==== - export declare const x: import("./foo"); - export declare let y: import("./foo2").Bar.I; - ~ -!!! error TS2694: Namespace '"foo2".Bar' has no exported member 'I'. - export declare class Bar2 { - item: { - a: string; - b: number; - c: object; - }; - constructor(input?: any); - } - export declare let shim: typeof import("./foo2"); - \ No newline at end of file diff --git a/tests/baselines/reference/importTypeLocalMissing.js b/tests/baselines/reference/importTypeLocalMissing.js index 8177400cb58f9..756ce97f2976d 100644 --- a/tests/baselines/reference/importTypeLocalMissing.js +++ b/tests/baselines/reference/importTypeLocalMissing.js @@ -82,6 +82,10 @@ interface Point { export = Point; //// [foo2.d.ts] declare namespace Bar { + interface I { + a: string; + b: number; + } } export declare namespace Baz { interface J { diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js index b21f7355650f1..fc036be496f20 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js @@ -80,6 +80,12 @@ export declare class B { } //// [f3.d.ts] declare namespace N { + interface Ifc { + a: any; + } + interface Cls { + a: any; + } } declare module "./f1" { import { B } from "./f2"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js index 9c5cb81be5e46..905f347ea992a 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js @@ -78,6 +78,12 @@ export declare class B { } //// [f3.d.ts] declare namespace N { + interface Ifc { + a: any; + } + interface Cls { + a: any; + } } declare module "./f1" { import { B } from "./f2"; diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js index 41ba5a4a94184..290ed7c81eedf 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js @@ -83,6 +83,12 @@ export declare class B { //// [f3.d.ts] import { B } from "./f2"; declare namespace N { + interface Ifc { + a: number; + } + interface Cls { + b: number; + } } import I = N.Ifc; import C = N.Cls; @@ -96,43 +102,3 @@ declare module "./f1" { export {}; //// [f4.d.ts] import "./f3"; - - -//// [DtsFileErrors] - - -f3.d.ts(4,14): error TS2694: Namespace 'N' has no exported member 'Ifc'. -f3.d.ts(5,14): error TS2694: Namespace 'N' has no exported member 'Cls'. - - -==== f1.d.ts (0 errors) ==== - export declare class A { - } - -==== f2.d.ts (0 errors) ==== - export declare class B { - n: number; - } - -==== f3.d.ts (2 errors) ==== - import { B } from "./f2"; - declare namespace N { - } - import I = N.Ifc; - ~~~ -!!! error TS2694: Namespace 'N' has no exported member 'Ifc'. - import C = N.Cls; - ~~~ -!!! error TS2694: Namespace 'N' has no exported member 'Cls'. - declare module "./f1" { - interface A { - foo(): B; - bar(): I; - baz(): C; - } - } - export {}; - -==== f4.d.ts (0 errors) ==== - import "./f3"; - \ No newline at end of file diff --git a/tests/baselines/reference/privacyAccessorDeclFile.js b/tests/baselines/reference/privacyAccessorDeclFile.js index 59cffbf930bdc..69c0208e5d84f 100644 --- a/tests/baselines/reference/privacyAccessorDeclFile.js +++ b/tests/baselines/reference/privacyAccessorDeclFile.js @@ -3654,34 +3654,10 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { -} -export {}; -//// [privacyAccessorDeclFile_GlobalFile.d.ts] -declare class publicClassInGlobal { -} -declare class publicClassInGlobalWithPublicGetAccessorTypes { - static get myPublicStaticMethod(): publicClassInGlobal; - private static get myPrivateStaticMethod(); - get myPublicMethod(): publicClassInGlobal; - private get myPrivateMethod(); - static get myPublicStaticMethod1(): publicClassInGlobal; - private static get myPrivateStaticMethod1(); - get myPublicMethod1(): publicClassInGlobal; - private get myPrivateMethod1(); -} -declare class publicClassInGlobalWithWithPublicSetAccessorTypes { - static set myPublicStaticMethod(param: publicClassInGlobal); - private static set myPrivateStaticMethod(value); - set myPublicMethod(param: publicClassInGlobal); - private set myPrivateMethod(value); -} -declare namespace publicModuleInGlobal { class privateClass { } export class publicClass { } - namespace privateModule { - } export class publicClassWithWithPrivateGetAccessorTypes { static get myPublicStaticMethod(): privateClass; private static get myPrivateStaticMethod(); @@ -3717,8 +3693,8 @@ declare namespace publicModuleInGlobal { export class publicClassWithPrivateModuleGetAccessorTypes { static get myPublicStaticMethod(): privateModule.publicClass; get myPublicMethod(): privateModule.publicClass; - static get myPublicStaticMethod1(): privateModule.publicClass; - get myPublicMethod1(): privateModule.publicClass; + static get myPublicStaticMethod1(): publicClass; + get myPublicMethod1(): publicClass; } export class publicClassWithPrivateModuleSetAccessorTypes { static set myPublicStaticMethod(param: privateModule.publicClass); @@ -3726,91 +3702,32 @@ declare namespace publicModuleInGlobal { } export {}; } - - -//// [DtsFileErrors] - - -privacyAccessorDeclFile_GlobalFile.d.ts(59,58): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_GlobalFile.d.ts(60,45): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_GlobalFile.d.ts(61,59): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_GlobalFile.d.ts(62,46): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_GlobalFile.d.ts(65,62): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_GlobalFile.d.ts(66,49): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(38,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(39,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(40,55): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(41,42): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(44,58): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(45,45): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(85,58): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(86,45): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(87,59): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(88,46): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(91,62): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyAccessorDeclFile_externalModule.d.ts(92,49): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - - -==== privacyAccessorDeclFile_externalModule.d.ts (12 errors) ==== - declare class privateClass { - } - export declare class publicClass { - } - export declare class publicClassWithWithPrivateGetAccessorTypes { - static get myPublicStaticMethod(): privateClass; - private static get myPrivateStaticMethod(); - get myPublicMethod(): privateClass; - private get myPrivateMethod(); - static get myPublicStaticMethod1(): privateClass; - private static get myPrivateStaticMethod1(); - get myPublicMethod1(): privateClass; - private get myPrivateMethod1(); - } - export declare class publicClassWithWithPublicGetAccessorTypes { - static get myPublicStaticMethod(): publicClass; - private static get myPrivateStaticMethod(); - get myPublicMethod(): publicClass; - private get myPrivateMethod(); - static get myPublicStaticMethod1(): publicClass; - private static get myPrivateStaticMethod1(); - get myPublicMethod1(): publicClass; - private get myPrivateMethod1(); - } - export declare class publicClassWithWithPrivateSetAccessorTypes { - static set myPublicStaticMethod(param: privateClass); - private static set myPrivateStaticMethod(value); - set myPublicMethod(param: privateClass); - private set myPrivateMethod(value); - } - export declare class publicClassWithWithPublicSetAccessorTypes { - static set myPublicStaticMethod(param: publicClass); - private static set myPrivateStaticMethod(value); - set myPublicMethod(param: publicClass); - private set myPrivateMethod(value); - } - export declare class publicClassWithPrivateModuleGetAccessorTypes { - static get myPublicStaticMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - get myPublicMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - static get myPublicStaticMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - get myPublicMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +export {}; +//// [privacyAccessorDeclFile_GlobalFile.d.ts] +declare class publicClassInGlobal { +} +declare class publicClassInGlobalWithPublicGetAccessorTypes { + static get myPublicStaticMethod(): publicClassInGlobal; + private static get myPrivateStaticMethod(); + get myPublicMethod(): publicClassInGlobal; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): publicClassInGlobal; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): publicClassInGlobal; + private get myPrivateMethod1(); +} +declare class publicClassInGlobalWithWithPublicSetAccessorTypes { + static set myPublicStaticMethod(param: publicClassInGlobal); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: publicClassInGlobal); + private set myPrivateMethod(value); +} +declare namespace publicModuleInGlobal { + class privateClass { } - export declare class publicClassWithPrivateModuleSetAccessorTypes { - static set myPublicStaticMethod(param: privateModule.publicClass); - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - set myPublicMethod(param: privateModule.publicClass); - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export class publicClass { } - export declare namespace publicModule { + namespace privateModule { class privateClass { } export class publicClass { @@ -3849,112 +3766,57 @@ privacyAccessorDeclFile_externalModule.d.ts(92,49): error TS2694: Namespace 'pri } export class publicClassWithPrivateModuleGetAccessorTypes { static get myPublicStaticMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. get myPublicMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - static get myPublicStaticMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - get myPublicMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + static get myPublicStaticMethod1(): publicClass; + get myPublicMethod1(): publicClass; } export class publicClassWithPrivateModuleSetAccessorTypes { static set myPublicStaticMethod(param: privateModule.publicClass); - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. set myPublicMethod(param: privateModule.publicClass); - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export {}; } - declare namespace privateModule { - } - export {}; - -==== privacyAccessorDeclFile_GlobalFile.d.ts (6 errors) ==== - declare class publicClassInGlobal { + export class publicClassWithWithPrivateGetAccessorTypes { + static get myPublicStaticMethod(): privateClass; + private static get myPrivateStaticMethod(); + get myPublicMethod(): privateClass; + private get myPrivateMethod(); + static get myPublicStaticMethod1(): privateClass; + private static get myPrivateStaticMethod1(); + get myPublicMethod1(): privateClass; + private get myPrivateMethod1(); } - declare class publicClassInGlobalWithPublicGetAccessorTypes { - static get myPublicStaticMethod(): publicClassInGlobal; + export class publicClassWithWithPublicGetAccessorTypes { + static get myPublicStaticMethod(): publicClass; private static get myPrivateStaticMethod(); - get myPublicMethod(): publicClassInGlobal; + get myPublicMethod(): publicClass; private get myPrivateMethod(); - static get myPublicStaticMethod1(): publicClassInGlobal; + static get myPublicStaticMethod1(): publicClass; private static get myPrivateStaticMethod1(); - get myPublicMethod1(): publicClassInGlobal; + get myPublicMethod1(): publicClass; private get myPrivateMethod1(); } - declare class publicClassInGlobalWithWithPublicSetAccessorTypes { - static set myPublicStaticMethod(param: publicClassInGlobal); + export class publicClassWithWithPrivateSetAccessorTypes { + static set myPublicStaticMethod(param: privateClass); private static set myPrivateStaticMethod(value); - set myPublicMethod(param: publicClassInGlobal); + set myPublicMethod(param: privateClass); private set myPrivateMethod(value); } - declare namespace publicModuleInGlobal { - class privateClass { - } - export class publicClass { - } - namespace privateModule { - } - export class publicClassWithWithPrivateGetAccessorTypes { - static get myPublicStaticMethod(): privateClass; - private static get myPrivateStaticMethod(); - get myPublicMethod(): privateClass; - private get myPrivateMethod(); - static get myPublicStaticMethod1(): privateClass; - private static get myPrivateStaticMethod1(); - get myPublicMethod1(): privateClass; - private get myPrivateMethod1(); - } - export class publicClassWithWithPublicGetAccessorTypes { - static get myPublicStaticMethod(): publicClass; - private static get myPrivateStaticMethod(); - get myPublicMethod(): publicClass; - private get myPrivateMethod(); - static get myPublicStaticMethod1(): publicClass; - private static get myPrivateStaticMethod1(); - get myPublicMethod1(): publicClass; - private get myPrivateMethod1(); - } - export class publicClassWithWithPrivateSetAccessorTypes { - static set myPublicStaticMethod(param: privateClass); - private static set myPrivateStaticMethod(value); - set myPublicMethod(param: privateClass); - private set myPrivateMethod(value); - } - export class publicClassWithWithPublicSetAccessorTypes { - static set myPublicStaticMethod(param: publicClass); - private static set myPrivateStaticMethod(value); - set myPublicMethod(param: publicClass); - private set myPrivateMethod(value); - } - export class publicClassWithPrivateModuleGetAccessorTypes { - static get myPublicStaticMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - get myPublicMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - static get myPublicStaticMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - get myPublicMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - } - export class publicClassWithPrivateModuleSetAccessorTypes { - static set myPublicStaticMethod(param: privateModule.publicClass); - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - set myPublicMethod(param: privateModule.publicClass); - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - } - export {}; + export class publicClassWithWithPublicSetAccessorTypes { + static set myPublicStaticMethod(param: publicClass); + private static set myPrivateStaticMethod(value); + set myPublicMethod(param: publicClass); + private set myPrivateMethod(value); + } + export class publicClassWithPrivateModuleGetAccessorTypes { + static get myPublicStaticMethod(): privateModule.publicClass; + get myPublicMethod(): privateModule.publicClass; + static get myPublicStaticMethod1(): privateModule.publicClass; + get myPublicMethod1(): privateModule.publicClass; } - \ No newline at end of file + export class publicClassWithPrivateModuleSetAccessorTypes { + static set myPublicStaticMethod(param: privateModule.publicClass); + set myPublicMethod(param: privateModule.publicClass); + } + export {}; +} diff --git a/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleError.js b/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleError.js index 5e215408513b3..ba5a1fad8140d 100644 --- a/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleError.js +++ b/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleError.js @@ -22,25 +22,8 @@ var Outer; //// [privacyCheckTypeOfInvisibleModuleError.d.ts] declare namespace Outer { namespace Inner { + var m: typeof Inner; } export var f: typeof Inner; export {}; } - - -//// [DtsFileErrors] - - -privacyCheckTypeOfInvisibleModuleError.d.ts(4,26): error TS2708: Cannot use namespace 'Inner' as a value. - - -==== privacyCheckTypeOfInvisibleModuleError.d.ts (1 errors) ==== - declare namespace Outer { - namespace Inner { - } - export var f: typeof Inner; - ~~~~~ -!!! error TS2708: Cannot use namespace 'Inner' as a value. - export {}; - } - \ No newline at end of file diff --git a/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleNoError.js b/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleNoError.js index 9dcf2490c729f..8d48438936da2 100644 --- a/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleNoError.js +++ b/tests/baselines/reference/privacyCheckTypeOfInvisibleModuleNoError.js @@ -22,25 +22,8 @@ var Outer; //// [privacyCheckTypeOfInvisibleModuleNoError.d.ts] declare namespace Outer { namespace Inner { + var m: number; } export var f: typeof Inner; export {}; } - - -//// [DtsFileErrors] - - -privacyCheckTypeOfInvisibleModuleNoError.d.ts(4,26): error TS2708: Cannot use namespace 'Inner' as a value. - - -==== privacyCheckTypeOfInvisibleModuleNoError.d.ts (1 errors) ==== - declare namespace Outer { - namespace Inner { - } - export var f: typeof Inner; - ~~~~~ -!!! error TS2708: Cannot use namespace 'Inner' as a value. - export {}; - } - \ No newline at end of file diff --git a/tests/baselines/reference/privacyFunctionParameterDeclFile.js b/tests/baselines/reference/privacyFunctionParameterDeclFile.js index 5ff1fa60bc909..f74a60b8e45c6 100644 --- a/tests/baselines/reference/privacyFunctionParameterDeclFile.js +++ b/tests/baselines/reference/privacyFunctionParameterDeclFile.js @@ -1386,34 +1386,10 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { -} -export {}; -//// [privacyFunctionParameterDeclFile_GlobalFile.d.ts] -declare class publicClassInGlobal { -} -interface publicInterfaceWithPublicParmeterTypesInGlobal { - new (param: publicClassInGlobal): publicClassInGlobal; - (param: publicClassInGlobal): publicClassInGlobal; - myMethod(param: publicClassInGlobal): void; -} -declare class publicClassWithWithPublicParmeterTypesInGlobal { - private param1; - param2: publicClassInGlobal; - static myPublicStaticMethod(param: publicClassInGlobal): void; - private static myPrivateStaticMethod; - myPublicMethod(param: publicClassInGlobal): void; - private myPrivateMethod; - constructor(param: publicClassInGlobal, param1: publicClassInGlobal, param2: publicClassInGlobal); -} -declare function publicFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; -declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; -declare namespace publicModuleInGlobal { class privateClass { } export class publicClass { } - namespace privateModule { - } export interface publicInterfaceWithPrivateParmeterTypes { new (param: privateClass): publicClass; (param: privateClass): publicClass; @@ -1462,120 +1438,32 @@ declare namespace publicModuleInGlobal { export function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; export {}; } - - -//// [DtsFileErrors] - - -privacyFunctionParameterDeclFile_GlobalFile.d.ts(59,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_GlobalFile.d.ts(60,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_GlobalFile.d.ts(61,39): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_GlobalFile.d.ts(65,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_GlobalFile.d.ts(66,58): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_GlobalFile.d.ts(67,45): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_GlobalFile.d.ts(68,42): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_GlobalFile.d.ts(68,77): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_GlobalFile.d.ts(68,112): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_GlobalFile.d.ts(70,88): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_GlobalFile.d.ts(71,95): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(38,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(39,27): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(40,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(44,27): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(45,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(46,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(47,38): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(47,73): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(47,108): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(49,92): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(50,99): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(89,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(90,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(91,39): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(95,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(96,58): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(97,45): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(98,42): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(98,77): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(98,112): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(100,88): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionParameterDeclFile_externalModule.d.ts(101,95): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - - -==== privacyFunctionParameterDeclFile_externalModule.d.ts (22 errors) ==== - declare class privateClass { - } - export declare class publicClass { - } - export interface publicInterfaceWithPrivateParmeterTypes { - new (param: privateClass): publicClass; - (param: privateClass): publicClass; - myMethod(param: privateClass): void; - } - export interface publicInterfaceWithPublicParmeterTypes { - new (param: publicClass): publicClass; - (param: publicClass): publicClass; - myMethod(param: publicClass): void; - } - export declare class publicClassWithWithPrivateParmeterTypes { - private param1; - param2: privateClass; - static myPublicStaticMethod(param: privateClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: privateClass): void; - private myPrivateMethod; - constructor(param: privateClass, param1: privateClass, param2: privateClass); - } - export declare class publicClassWithWithPublicParmeterTypes { - private param1; - param2: publicClass; - static myPublicStaticMethod(param: publicClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: publicClass): void; - private myPrivateMethod; - constructor(param: publicClass, param1: publicClass, param2: publicClass); - } - export declare function publicFunctionWithPrivateParmeterTypes(param: privateClass): void; - export declare function publicFunctionWithPublicParmeterTypes(param: publicClass): void; - export declare function publicAmbientFunctionWithPrivateParmeterTypes(param: privateClass): void; - export declare function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; - export interface publicInterfaceWithPrivateModuleParameterTypes { - new (param: privateModule.publicClass): publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - (param: privateModule.publicClass): publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myMethod(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. +export {}; +//// [privacyFunctionParameterDeclFile_GlobalFile.d.ts] +declare class publicClassInGlobal { +} +interface publicInterfaceWithPublicParmeterTypesInGlobal { + new (param: publicClassInGlobal): publicClassInGlobal; + (param: publicClassInGlobal): publicClassInGlobal; + myMethod(param: publicClassInGlobal): void; +} +declare class publicClassWithWithPublicParmeterTypesInGlobal { + private param1; + param2: publicClassInGlobal; + static myPublicStaticMethod(param: publicClassInGlobal): void; + private static myPrivateStaticMethod; + myPublicMethod(param: publicClassInGlobal): void; + private myPrivateMethod; + constructor(param: publicClassInGlobal, param1: publicClassInGlobal, param2: publicClassInGlobal); +} +declare function publicFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; +declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; +declare namespace publicModuleInGlobal { + class privateClass { } - export declare class publicClassWithPrivateModuleParameterTypes { - private param1; - param2: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - static myPublicStaticMethod(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myPublicMethod(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export class publicClass { } - export declare function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export declare namespace publicModule { + namespace privateModule { class privateClass { } export class publicClass { @@ -1614,140 +1502,65 @@ privacyFunctionParameterDeclFile_externalModule.d.ts(101,95): error TS2694: Name export function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; export interface publicInterfaceWithPrivateModuleParameterTypes { new (param: privateModule.publicClass): publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. (param: privateModule.publicClass): publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. myMethod(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export class publicClassWithPrivateModuleParameterTypes { private param1; param2: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. static myPublicStaticMethod(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. myPublicMethod(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. export function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. export {}; } - declare namespace privateModule { + export interface publicInterfaceWithPrivateParmeterTypes { + new (param: privateClass): publicClass; + (param: privateClass): publicClass; + myMethod(param: privateClass): void; } - export {}; - -==== privacyFunctionParameterDeclFile_GlobalFile.d.ts (11 errors) ==== - declare class publicClassInGlobal { + export interface publicInterfaceWithPublicParmeterTypes { + new (param: publicClass): publicClass; + (param: publicClass): publicClass; + myMethod(param: publicClass): void; } - interface publicInterfaceWithPublicParmeterTypesInGlobal { - new (param: publicClassInGlobal): publicClassInGlobal; - (param: publicClassInGlobal): publicClassInGlobal; - myMethod(param: publicClassInGlobal): void; + export class publicClassWithWithPrivateParmeterTypes { + private param1; + param2: privateClass; + static myPublicStaticMethod(param: privateClass): void; + private static myPrivateStaticMethod; + myPublicMethod(param: privateClass): void; + private myPrivateMethod; + constructor(param: privateClass, param1: privateClass, param2: privateClass); } - declare class publicClassWithWithPublicParmeterTypesInGlobal { + export class publicClassWithWithPublicParmeterTypes { private param1; - param2: publicClassInGlobal; - static myPublicStaticMethod(param: publicClassInGlobal): void; + param2: publicClass; + static myPublicStaticMethod(param: publicClass): void; private static myPrivateStaticMethod; - myPublicMethod(param: publicClassInGlobal): void; + myPublicMethod(param: publicClass): void; private myPrivateMethod; - constructor(param: publicClassInGlobal, param1: publicClassInGlobal, param2: publicClassInGlobal); + constructor(param: publicClass, param1: publicClass, param2: publicClass); } - declare function publicFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; - declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(param: publicClassInGlobal): void; - declare namespace publicModuleInGlobal { - class privateClass { - } - export class publicClass { - } - namespace privateModule { - } - export interface publicInterfaceWithPrivateParmeterTypes { - new (param: privateClass): publicClass; - (param: privateClass): publicClass; - myMethod(param: privateClass): void; - } - export interface publicInterfaceWithPublicParmeterTypes { - new (param: publicClass): publicClass; - (param: publicClass): publicClass; - myMethod(param: publicClass): void; - } - export class publicClassWithWithPrivateParmeterTypes { - private param1; - param2: privateClass; - static myPublicStaticMethod(param: privateClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: privateClass): void; - private myPrivateMethod; - constructor(param: privateClass, param1: privateClass, param2: privateClass); - } - export class publicClassWithWithPublicParmeterTypes { - private param1; - param2: publicClass; - static myPublicStaticMethod(param: publicClass): void; - private static myPrivateStaticMethod; - myPublicMethod(param: publicClass): void; - private myPrivateMethod; - constructor(param: publicClass, param1: publicClass, param2: publicClass); - } - export function publicFunctionWithPrivateParmeterTypes(param: privateClass): void; - export function publicFunctionWithPublicParmeterTypes(param: publicClass): void; - export function publicAmbientFunctionWithPrivateParmeterTypes(param: privateClass): void; - export function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; - export interface publicInterfaceWithPrivateModuleParameterTypes { - new (param: privateModule.publicClass): publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - (param: privateModule.publicClass): publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myMethod(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - } - export class publicClassWithPrivateModuleParameterTypes { - private param1; - param2: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - static myPublicStaticMethod(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myPublicMethod(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - } - export function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export {}; + export function publicFunctionWithPrivateParmeterTypes(param: privateClass): void; + export function publicFunctionWithPublicParmeterTypes(param: publicClass): void; + export function publicAmbientFunctionWithPrivateParmeterTypes(param: privateClass): void; + export function publicAmbientFunctionWithPublicParmeterTypes(param: publicClass): void; + export interface publicInterfaceWithPrivateModuleParameterTypes { + new (param: privateModule.publicClass): publicClass; + (param: privateModule.publicClass): publicClass; + myMethod(param: privateModule.publicClass): void; } - \ No newline at end of file + export class publicClassWithPrivateModuleParameterTypes { + private param1; + param2: privateModule.publicClass; + static myPublicStaticMethod(param: privateModule.publicClass): void; + myPublicMethod(param: privateModule.publicClass): void; + constructor(param: privateModule.publicClass, param1: privateModule.publicClass, param2: privateModule.publicClass); + } + export function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; + export function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; + export {}; +} diff --git a/tests/baselines/reference/privacyFunctionParameterDeclFile.types b/tests/baselines/reference/privacyFunctionParameterDeclFile.types index 4cc77e5514951..a1096e0ae870f 100644 --- a/tests/baselines/reference/privacyFunctionParameterDeclFile.types +++ b/tests/baselines/reference/privacyFunctionParameterDeclFile.types @@ -783,7 +783,7 @@ module privateModule { >privateModule : any myMethod(param: privateModule.publicClass): void; ->myMethod : (param: publicClass) => void +>myMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } @@ -791,12 +791,12 @@ module privateModule { >publicClassWithPrivateModuleParameterTypes : publicClassWithPrivateModuleParameterTypes static myPublicStaticMethod(param: privateModule.publicClass) { ->myPublicStaticMethod : (param: publicClass) => void +>myPublicStaticMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } myPublicMethod(param: privateModule.publicClass) { ->myPublicMethod : (param: publicClass) => void +>myPublicMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } @@ -810,12 +810,12 @@ module privateModule { } } export function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass) { ->publicFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void +>publicFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; ->publicAmbientFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void +>publicAmbientFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any @@ -829,7 +829,7 @@ module privateModule { >privateModule : any myMethod(param: privateModule.publicClass): void; ->myMethod : (param: publicClass) => void +>myMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } @@ -837,12 +837,12 @@ module privateModule { >privateClassWithPrivateModuleParameterTypes : privateClassWithPrivateModuleParameterTypes static myPublicStaticMethod(param: privateModule.publicClass) { ->myPublicStaticMethod : (param: publicClass) => void +>myPublicStaticMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } myPublicMethod(param: privateModule.publicClass) { ->myPublicMethod : (param: publicClass) => void +>myPublicMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } @@ -856,12 +856,12 @@ module privateModule { } } function privateFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass) { ->privateFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void +>privateFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } declare function privateAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; ->privateAmbientFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void +>privateAmbientFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } @@ -1131,7 +1131,7 @@ module publicModuleInGlobal { >privateModule : any myMethod(param: privateModule.publicClass): void; ->myMethod : (param: publicClass) => void +>myMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } @@ -1139,12 +1139,12 @@ module publicModuleInGlobal { >publicClassWithPrivateModuleParameterTypes : publicClassWithPrivateModuleParameterTypes static myPublicStaticMethod(param: privateModule.publicClass) { ->myPublicStaticMethod : (param: publicClass) => void +>myPublicStaticMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } myPublicMethod(param: privateModule.publicClass) { ->myPublicMethod : (param: publicClass) => void +>myPublicMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } @@ -1158,12 +1158,12 @@ module publicModuleInGlobal { } } export function publicFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass) { ->publicFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void +>publicFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; ->publicAmbientFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void +>publicAmbientFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any @@ -1177,7 +1177,7 @@ module publicModuleInGlobal { >privateModule : any myMethod(param: privateModule.publicClass): void; ->myMethod : (param: publicClass) => void +>myMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } @@ -1185,12 +1185,12 @@ module publicModuleInGlobal { >privateClassWithPrivateModuleParameterTypes : privateClassWithPrivateModuleParameterTypes static myPublicStaticMethod(param: privateModule.publicClass) { ->myPublicStaticMethod : (param: publicClass) => void +>myPublicStaticMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } myPublicMethod(param: privateModule.publicClass) { ->myPublicMethod : (param: publicClass) => void +>myPublicMethod : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } @@ -1204,12 +1204,12 @@ module publicModuleInGlobal { } } function privateFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass) { ->privateFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void +>privateFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } declare function privateAmbientFunctionWithPrivateModuleParameterTypes(param: privateModule.publicClass): void; ->privateAmbientFunctionWithPrivateModuleParameterTypes : (param: publicClass) => void +>privateAmbientFunctionWithPrivateModuleParameterTypes : (param: privateModule.publicClass) => void >param : publicClass >privateModule : any } diff --git a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js index 960410c76b0d8..b9907650a57ae 100644 --- a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js +++ b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.js @@ -2400,37 +2400,10 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { -} -export {}; -//// [privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts] -declare class publicClassInGlobal { -} -interface publicInterfaceWithPublicParmeterTypesInGlobal { - new (): publicClassInGlobal; - (): publicClassInGlobal; - [x: number]: publicClassInGlobal; - myMethod(): publicClassInGlobal; -} -declare class publicClassWithWithPublicParmeterTypesInGlobal { - static myPublicStaticMethod(): publicClassInGlobal; - private static myPrivateStaticMethod; - myPublicMethod(): publicClassInGlobal; - private myPrivateMethod; - static myPublicStaticMethod1(): publicClassInGlobal; - private static myPrivateStaticMethod1; - myPublicMethod1(): publicClassInGlobal; - private myPrivateMethod1; -} -declare function publicFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; -declare function publicFunctionWithPublicParmeterTypesInGlobal1(): publicClassInGlobal; -declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; -declare namespace publicModuleInGlobal { class privateClass { } export class publicClass { } - namespace privateModule { - } export interface publicInterfaceWithPrivateParmeterTypes { new (): privateClass; (): privateClass; @@ -2478,135 +2451,43 @@ declare namespace publicModuleInGlobal { export class publicClassWithPrivateModuleParameterTypes { static myPublicStaticMethod(): privateModule.publicClass; myPublicMethod(): privateModule.publicClass; - static myPublicStaticMethod1(): privateModule.publicClass; - myPublicMethod1(): privateModule.publicClass; + static myPublicStaticMethod1(): publicClass; + myPublicMethod1(): publicClass; } export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - export function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; + export function publicFunctionWithPrivateModuleParameterTypes1(): publicClass; export function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; export {}; } - - -//// [DtsFileErrors] - - -privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(68,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(69,27): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(70,36): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(71,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(74,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(75,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(76,55): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(77,42): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(79,84): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(80,85): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts(81,91): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(44,27): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(45,23): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(46,32): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(47,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(50,50): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(51,37): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(52,51): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(53,38): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(55,88): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(56,89): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(57,95): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(102,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(103,27): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(104,36): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(105,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(108,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(109,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(110,55): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(111,42): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(113,84): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(114,85): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyFunctionReturnTypeDeclFile_externalModule.d.ts(115,91): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - - -==== privacyFunctionReturnTypeDeclFile_externalModule.d.ts (22 errors) ==== - declare class privateClass { - } - export declare class publicClass { - } - export interface publicInterfaceWithPrivateParmeterTypes { - new (): privateClass; - (): privateClass; - [x: number]: privateClass; - myMethod(): privateClass; - } - export interface publicInterfaceWithPublicParmeterTypes { - new (): publicClass; - (): publicClass; - [x: number]: publicClass; - myMethod(): publicClass; - } - export declare class publicClassWithWithPrivateParmeterTypes { - static myPublicStaticMethod(): privateClass; - private static myPrivateStaticMethod; - myPublicMethod(): privateClass; - private myPrivateMethod; - static myPublicStaticMethod1(): privateClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): privateClass; - private myPrivateMethod1; - } - export declare class publicClassWithWithPublicParmeterTypes { - static myPublicStaticMethod(): publicClass; - private static myPrivateStaticMethod; - myPublicMethod(): publicClass; - private myPrivateMethod; - static myPublicStaticMethod1(): publicClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): publicClass; - private myPrivateMethod1; +export {}; +//// [privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts] +declare class publicClassInGlobal { +} +interface publicInterfaceWithPublicParmeterTypesInGlobal { + new (): publicClassInGlobal; + (): publicClassInGlobal; + [x: number]: publicClassInGlobal; + myMethod(): publicClassInGlobal; +} +declare class publicClassWithWithPublicParmeterTypesInGlobal { + static myPublicStaticMethod(): publicClassInGlobal; + private static myPrivateStaticMethod; + myPublicMethod(): publicClassInGlobal; + private myPrivateMethod; + static myPublicStaticMethod1(): publicClassInGlobal; + private static myPrivateStaticMethod1; + myPublicMethod1(): publicClassInGlobal; + private myPrivateMethod1; +} +declare function publicFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; +declare function publicFunctionWithPublicParmeterTypesInGlobal1(): publicClassInGlobal; +declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; +declare namespace publicModuleInGlobal { + class privateClass { } - export declare function publicFunctionWithPrivateParmeterTypes(): privateClass; - export declare function publicFunctionWithPublicParmeterTypes(): publicClass; - export declare function publicFunctionWithPrivateParmeterTypes1(): privateClass; - export declare function publicFunctionWithPublicParmeterTypes1(): publicClass; - export declare function publicAmbientFunctionWithPrivateParmeterTypes(): privateClass; - export declare function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; - export interface publicInterfaceWithPrivateModuleParameterTypes { - new (): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - (): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - [x: number]: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export class publicClass { } - export declare class publicClassWithPrivateModuleParameterTypes { - static myPublicStaticMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myPublicMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - static myPublicStaticMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myPublicMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - } - export declare function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export declare function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export declare namespace publicModule { + namespace privateModule { class privateClass { } export class publicClass { @@ -2651,151 +2532,73 @@ privacyFunctionReturnTypeDeclFile_externalModule.d.ts(115,91): error TS2694: Nam export function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; export interface publicInterfaceWithPrivateModuleParameterTypes { new (): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. (): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. [x: number]: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. myMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export class publicClassWithPrivateModuleParameterTypes { static myPublicStaticMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. myPublicMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - static myPublicStaticMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myPublicMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + static myPublicStaticMethod1(): publicClass; + myPublicMethod1(): publicClass; } export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export function publicFunctionWithPrivateModuleParameterTypes1(): publicClass; export function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. export {}; } - declare namespace privateModule { + export interface publicInterfaceWithPrivateParmeterTypes { + new (): privateClass; + (): privateClass; + [x: number]: privateClass; + myMethod(): privateClass; } - export {}; - -==== privacyFunctionReturnTypeDeclFile_GlobalFile.d.ts (11 errors) ==== - declare class publicClassInGlobal { - } - interface publicInterfaceWithPublicParmeterTypesInGlobal { - new (): publicClassInGlobal; - (): publicClassInGlobal; - [x: number]: publicClassInGlobal; - myMethod(): publicClassInGlobal; - } - declare class publicClassWithWithPublicParmeterTypesInGlobal { - static myPublicStaticMethod(): publicClassInGlobal; + export interface publicInterfaceWithPublicParmeterTypes { + new (): publicClass; + (): publicClass; + [x: number]: publicClass; + myMethod(): publicClass; + } + export class publicClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod(): privateClass; private static myPrivateStaticMethod; - myPublicMethod(): publicClassInGlobal; + myPublicMethod(): privateClass; private myPrivateMethod; - static myPublicStaticMethod1(): publicClassInGlobal; + static myPublicStaticMethod1(): privateClass; private static myPrivateStaticMethod1; - myPublicMethod1(): publicClassInGlobal; + myPublicMethod1(): privateClass; private myPrivateMethod1; } - declare function publicFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; - declare function publicFunctionWithPublicParmeterTypesInGlobal1(): publicClassInGlobal; - declare function publicAmbientFunctionWithPublicParmeterTypesInGlobal(): publicClassInGlobal; - declare namespace publicModuleInGlobal { - class privateClass { - } - export class publicClass { - } - namespace privateModule { - } - export interface publicInterfaceWithPrivateParmeterTypes { - new (): privateClass; - (): privateClass; - [x: number]: privateClass; - myMethod(): privateClass; - } - export interface publicInterfaceWithPublicParmeterTypes { - new (): publicClass; - (): publicClass; - [x: number]: publicClass; - myMethod(): publicClass; - } - export class publicClassWithWithPrivateParmeterTypes { - static myPublicStaticMethod(): privateClass; - private static myPrivateStaticMethod; - myPublicMethod(): privateClass; - private myPrivateMethod; - static myPublicStaticMethod1(): privateClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): privateClass; - private myPrivateMethod1; - } - export class publicClassWithWithPublicParmeterTypes { - static myPublicStaticMethod(): publicClass; - private static myPrivateStaticMethod; - myPublicMethod(): publicClass; - private myPrivateMethod; - static myPublicStaticMethod1(): publicClass; - private static myPrivateStaticMethod1; - myPublicMethod1(): publicClass; - private myPrivateMethod1; - } - export function publicFunctionWithPrivateParmeterTypes(): privateClass; - export function publicFunctionWithPublicParmeterTypes(): publicClass; - export function publicFunctionWithPrivateParmeterTypes1(): privateClass; - export function publicFunctionWithPublicParmeterTypes1(): publicClass; - export function publicAmbientFunctionWithPrivateParmeterTypes(): privateClass; - export function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; - export interface publicInterfaceWithPrivateModuleParameterTypes { - new (): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - (): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - [x: number]: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - } - export class publicClassWithPrivateModuleParameterTypes { - static myPublicStaticMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myPublicMethod(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - static myPublicStaticMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myPublicMethod1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - } - export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export {}; + export class publicClassWithWithPublicParmeterTypes { + static myPublicStaticMethod(): publicClass; + private static myPrivateStaticMethod; + myPublicMethod(): publicClass; + private myPrivateMethod; + static myPublicStaticMethod1(): publicClass; + private static myPrivateStaticMethod1; + myPublicMethod1(): publicClass; + private myPrivateMethod1; + } + export function publicFunctionWithPrivateParmeterTypes(): privateClass; + export function publicFunctionWithPublicParmeterTypes(): publicClass; + export function publicFunctionWithPrivateParmeterTypes1(): privateClass; + export function publicFunctionWithPublicParmeterTypes1(): publicClass; + export function publicAmbientFunctionWithPrivateParmeterTypes(): privateClass; + export function publicAmbientFunctionWithPublicParmeterTypes(): publicClass; + export interface publicInterfaceWithPrivateModuleParameterTypes { + new (): privateModule.publicClass; + (): privateModule.publicClass; + [x: number]: privateModule.publicClass; + myMethod(): privateModule.publicClass; } - \ No newline at end of file + export class publicClassWithPrivateModuleParameterTypes { + static myPublicStaticMethod(): privateModule.publicClass; + myPublicMethod(): privateModule.publicClass; + static myPublicStaticMethod1(): privateModule.publicClass; + myPublicMethod1(): privateModule.publicClass; + } + export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; + export function publicFunctionWithPrivateModuleParameterTypes1(): privateModule.publicClass; + export function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; + export {}; +} diff --git a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.types b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.types index 3e61fc928af78..f52514eb598ef 100644 --- a/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.types +++ b/tests/baselines/reference/privacyFunctionReturnTypeDeclFile.types @@ -1255,20 +1255,20 @@ module privateModule { >privateModule : any myMethod(): privateModule.publicClass; ->myMethod : () => publicClass +>myMethod : () => privateModule.publicClass >privateModule : any } export class publicClassWithPrivateModuleParameterTypes { >publicClassWithPrivateModuleParameterTypes : publicClassWithPrivateModuleParameterTypes static myPublicStaticMethod(): privateModule.publicClass { ->myPublicStaticMethod : () => publicClass +>myPublicStaticMethod : () => privateModule.publicClass >privateModule : any return null; } myPublicMethod(): privateModule.publicClass { ->myPublicMethod : () => publicClass +>myPublicMethod : () => privateModule.publicClass >privateModule : any return null; @@ -1293,7 +1293,7 @@ module privateModule { } } export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass { ->publicFunctionWithPrivateModuleParameterTypes : () => publicClass +>publicFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass >privateModule : any return null; @@ -1308,7 +1308,7 @@ module privateModule { >publicClass : typeof publicClass } export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; ->publicAmbientFunctionWithPrivateModuleParameterTypes : () => publicClass +>publicAmbientFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass >privateModule : any interface privateInterfaceWithPrivateModuleParameterTypes { @@ -1323,20 +1323,20 @@ module privateModule { >privateModule : any myMethod(): privateModule.publicClass; ->myMethod : () => publicClass +>myMethod : () => privateModule.publicClass >privateModule : any } class privateClassWithPrivateModuleParameterTypes { >privateClassWithPrivateModuleParameterTypes : privateClassWithPrivateModuleParameterTypes static myPublicStaticMethod(): privateModule.publicClass { ->myPublicStaticMethod : () => publicClass +>myPublicStaticMethod : () => privateModule.publicClass >privateModule : any return null; } myPublicMethod(): privateModule.publicClass { ->myPublicMethod : () => publicClass +>myPublicMethod : () => privateModule.publicClass >privateModule : any return null; @@ -1361,7 +1361,7 @@ module privateModule { } } function privateFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass { ->privateFunctionWithPrivateModuleParameterTypes : () => publicClass +>privateFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass >privateModule : any return null; @@ -1376,7 +1376,7 @@ module privateModule { >publicClass : typeof publicClass } declare function privateAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; ->privateAmbientFunctionWithPrivateModuleParameterTypes : () => publicClass +>privateAmbientFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass >privateModule : any } @@ -1807,20 +1807,20 @@ module publicModuleInGlobal { >privateModule : any myMethod(): privateModule.publicClass; ->myMethod : () => publicClass +>myMethod : () => privateModule.publicClass >privateModule : any } export class publicClassWithPrivateModuleParameterTypes { >publicClassWithPrivateModuleParameterTypes : publicClassWithPrivateModuleParameterTypes static myPublicStaticMethod(): privateModule.publicClass { ->myPublicStaticMethod : () => publicClass +>myPublicStaticMethod : () => privateModule.publicClass >privateModule : any return null; } myPublicMethod(): privateModule.publicClass { ->myPublicMethod : () => publicClass +>myPublicMethod : () => privateModule.publicClass >privateModule : any return null; @@ -1845,7 +1845,7 @@ module publicModuleInGlobal { } } export function publicFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass { ->publicFunctionWithPrivateModuleParameterTypes : () => publicClass +>publicFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass >privateModule : any return null; @@ -1860,7 +1860,7 @@ module publicModuleInGlobal { >publicClass : typeof publicClass } export declare function publicAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; ->publicAmbientFunctionWithPrivateModuleParameterTypes : () => publicClass +>publicAmbientFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass >privateModule : any interface privateInterfaceWithPrivateModuleParameterTypes { @@ -1875,20 +1875,20 @@ module publicModuleInGlobal { >privateModule : any myMethod(): privateModule.publicClass; ->myMethod : () => publicClass +>myMethod : () => privateModule.publicClass >privateModule : any } class privateClassWithPrivateModuleParameterTypes { >privateClassWithPrivateModuleParameterTypes : privateClassWithPrivateModuleParameterTypes static myPublicStaticMethod(): privateModule.publicClass { ->myPublicStaticMethod : () => publicClass +>myPublicStaticMethod : () => privateModule.publicClass >privateModule : any return null; } myPublicMethod(): privateModule.publicClass { ->myPublicMethod : () => publicClass +>myPublicMethod : () => privateModule.publicClass >privateModule : any return null; @@ -1913,7 +1913,7 @@ module publicModuleInGlobal { } } function privateFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass { ->privateFunctionWithPrivateModuleParameterTypes : () => publicClass +>privateFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass >privateModule : any return null; @@ -1928,7 +1928,7 @@ module publicModuleInGlobal { >publicClass : typeof publicClass } declare function privateAmbientFunctionWithPrivateModuleParameterTypes(): privateModule.publicClass; ->privateAmbientFunctionWithPrivateModuleParameterTypes : () => publicClass +>privateAmbientFunctionWithPrivateModuleParameterTypes : () => privateModule.publicClass >privateModule : any } diff --git a/tests/baselines/reference/privacyGloImport.js b/tests/baselines/reference/privacyGloImport.js index e84acb0770421..d99ccda06e2c3 100644 --- a/tests/baselines/reference/privacyGloImport.js +++ b/tests/baselines/reference/privacyGloImport.js @@ -275,6 +275,11 @@ declare namespace m1 { var v2: c1; } namespace m1_M2_private { + class c1 { + } + function f1(): c1; + var v1: typeof c1; + var v2: c1; } import m1_im1_private = m1_M1_public; export var m1_im1_private_v1_public: typeof m1_im1_private.c1; @@ -342,100 +347,3 @@ declare module "anotherParseError" { } declare namespace m2 { } - - -//// [DtsFileErrors] - - -privacyGloImport.d.ts(17,49): error TS2708: Cannot use namespace 'm1_im2_private' as a value. -privacyGloImport.d.ts(18,57): error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. -privacyGloImport.d.ts(19,49): error TS2708: Cannot use namespace 'm1_im2_private' as a value. -privacyGloImport.d.ts(20,57): error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. - - -==== privacyGloImport.d.ts (4 errors) ==== - declare namespace m1 { - export namespace m1_M1_public { - class c1 { - } - function f1(): c1; - var v1: typeof c1; - var v2: c1; - } - namespace m1_M2_private { - } - import m1_im1_private = m1_M1_public; - export var m1_im1_private_v1_public: typeof m1_im1_private.c1; - export var m1_im1_private_v2_public: m1_im1_private.c1; - export var m1_im1_private_v3_public: typeof m1_im1_private.f1; - export var m1_im1_private_v4_public: m1_im1_private.c1; - import m1_im2_private = m1_M2_private; - export var m1_im2_private_v1_public: typeof m1_im2_private.c1; - ~~~~~~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm1_im2_private' as a value. - export var m1_im2_private_v2_public: m1_im2_private.c1; - ~~ -!!! error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. - export var m1_im2_private_v3_public: typeof m1_im2_private.f1; - ~~~~~~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm1_im2_private' as a value. - export var m1_im2_private_v4_public: m1_im2_private.c1; - ~~ -!!! error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. - export import m1_im1_public = m1_M1_public; - export import m1_im2_public = m1_M2_private; - export {}; - } - declare namespace glo_M1_public { - class c1 { - } - function f1(): c1; - var v1: typeof c1; - var v2: c1; - } - declare module "glo_M2_public" { - function f1(): any; - class c1 { - } - var v1: { - new (): c1; - }; - var v2: c1; - } - declare module "use_glo_M1_public" { - import use_glo_M1_public = glo_M1_public; - var use_glo_M1_public_v1_public: { - new (): use_glo_M1_public.c1; - }; - var use_glo_M1_public_v2_public: typeof use_glo_M1_public; - var use_glo_M1_public_v3_public: () => use_glo_M1_public.c1; - var use_glo_M1_public_v1_private: { - new (): use_glo_M1_public.c1; - }; - var use_glo_M1_public_v2_private: typeof use_glo_M1_public; - var use_glo_M1_public_v3_private: () => use_glo_M1_public.c1; - import use_glo_M2_public = require("glo_M2_public"); - var use_glo_M2_public_v1_public: { - new (): use_glo_M2_public.c1; - }; - var use_glo_M2_public_v2_public: typeof use_glo_M2_public; - var use_glo_M2_public_v3_public: () => use_glo_M2_public.c1; - var use_glo_M2_public_v1_private: { - new (): use_glo_M2_public.c1; - }; - var use_glo_M2_public_v2_private: typeof use_glo_M2_public; - var use_glo_M2_public_v3_private: () => use_glo_M2_public.c1; - namespace m2 { - namespace m5 { - } - } - } - declare module "anotherParseError" { - namespace m2 { - } - namespace m2 { - } - } - declare namespace m2 { - } - \ No newline at end of file diff --git a/tests/baselines/reference/privacyGloImportParseErrors.js b/tests/baselines/reference/privacyGloImportParseErrors.js index e19197080fe57..1a1252819e394 100644 --- a/tests/baselines/reference/privacyGloImportParseErrors.js +++ b/tests/baselines/reference/privacyGloImportParseErrors.js @@ -255,6 +255,11 @@ declare namespace m1 { var v2: c1; } namespace m1_M2_private { + class c1 { + } + function f1(): c1; + var v1: typeof c1; + var v2: c1; } export module "m1_M3_public" { function f1(): any; diff --git a/tests/baselines/reference/privacyImport.js b/tests/baselines/reference/privacyImport.js index 6859532b14c6a..0681c429ff05f 100644 --- a/tests/baselines/reference/privacyImport.js +++ b/tests/baselines/reference/privacyImport.js @@ -717,6 +717,11 @@ export declare namespace m1 { var v2: c1; } namespace m1_M2_private { + class c1 { + } + function f1(): c1; + var v1: typeof c1; + var v2: c1; } import m1_im1_private = m1_M1_public; export var m1_im1_private_v1_public: typeof m1_im1_private.c1; @@ -760,76 +765,3 @@ export import glo_im1_public = glo_M1_public; export import glo_im2_public = glo_M3_private; export declare namespace m3 { } - - -//// [DtsFileErrors] - - -privacyImport.d.ts(17,49): error TS2708: Cannot use namespace 'm1_im2_private' as a value. -privacyImport.d.ts(18,57): error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. -privacyImport.d.ts(19,49): error TS2708: Cannot use namespace 'm1_im2_private' as a value. -privacyImport.d.ts(20,57): error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. - - -==== privacyImport.d.ts (4 errors) ==== - export declare namespace m1 { - export namespace m1_M1_public { - class c1 { - } - function f1(): c1; - var v1: typeof c1; - var v2: c1; - } - namespace m1_M2_private { - } - import m1_im1_private = m1_M1_public; - export var m1_im1_private_v1_public: typeof m1_im1_private.c1; - export var m1_im1_private_v2_public: m1_im1_private.c1; - export var m1_im1_private_v3_public: typeof m1_im1_private.f1; - export var m1_im1_private_v4_public: m1_im1_private.c1; - import m1_im2_private = m1_M2_private; - export var m1_im2_private_v1_public: typeof m1_im2_private.c1; - ~~~~~~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm1_im2_private' as a value. - export var m1_im2_private_v2_public: m1_im2_private.c1; - ~~ -!!! error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. - export var m1_im2_private_v3_public: typeof m1_im2_private.f1; - ~~~~~~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm1_im2_private' as a value. - export var m1_im2_private_v4_public: m1_im2_private.c1; - ~~ -!!! error TS2694: Namespace 'm1_M2_private' has no exported member 'c1'. - export import m1_im1_public = m1_M1_public; - export import m1_im2_public = m1_M2_private; - export {}; - } - export declare namespace glo_M1_public { - class c1 { - } - function f1(): c1; - var v1: typeof c1; - var v2: c1; - } - export declare namespace glo_M3_private { - class c1 { - } - function f1(): c1; - var v1: typeof c1; - var v2: c1; - } - import glo_im1_private = glo_M1_public; - export declare var glo_im1_private_v1_public: typeof glo_im1_private.c1; - export declare var glo_im1_private_v2_public: glo_im1_private.c1; - export declare var glo_im1_private_v3_public: typeof glo_im1_private.f1; - export declare var glo_im1_private_v4_public: glo_im1_private.c1; - import glo_im3_private = glo_M3_private; - export declare var glo_im3_private_v1_public: typeof glo_im3_private.c1; - export declare var glo_im3_private_v2_public: glo_im3_private.c1; - export declare var glo_im3_private_v3_public: typeof glo_im3_private.f1; - export declare var glo_im3_private_v4_public: glo_im3_private.c1; - export import glo_im1_public = glo_M1_public; - export import glo_im2_public = glo_M3_private; - export declare namespace m3 { - } - \ No newline at end of file diff --git a/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js b/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js index e10087d529837..5ce9646b771d1 100644 --- a/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js +++ b/tests/baselines/reference/privacyLocalInternalReferenceImportWithExport.js @@ -302,6 +302,24 @@ var import_private; //// [privacyLocalInternalReferenceImportWithExport.d.ts] declare namespace m_private { + class c_private { + } + enum e_private { + Happy = 0, + Grumpy = 1 + } + function f_private(): c_private; + var v_private: c_private; + interface i_private { + } + namespace mi_private { + class c { + } + } + namespace mu_private { + interface i { + } + } } export declare namespace m_public { class c_public { @@ -354,107 +372,3 @@ export declare namespace import_public { var publicUse_im_public_mu_public: im_public_mu_public.i; } export {}; - - -//// [DtsFileErrors] - - -privacyLocalInternalReferenceImportWithExport.d.ts(24,41): error TS2708: Cannot use namespace 'm_private' as a value. -privacyLocalInternalReferenceImportWithExport.d.ts(24,51): error TS2694: Namespace 'm_private' has no exported member 'c_private'. -privacyLocalInternalReferenceImportWithExport.d.ts(25,41): error TS2708: Cannot use namespace 'm_private' as a value. -privacyLocalInternalReferenceImportWithExport.d.ts(25,51): error TS2694: Namespace 'm_private' has no exported member 'e_private'. -privacyLocalInternalReferenceImportWithExport.d.ts(26,41): error TS2708: Cannot use namespace 'm_private' as a value. -privacyLocalInternalReferenceImportWithExport.d.ts(26,51): error TS2694: Namespace 'm_private' has no exported member 'f_private'. -privacyLocalInternalReferenceImportWithExport.d.ts(27,41): error TS2708: Cannot use namespace 'm_private' as a value. -privacyLocalInternalReferenceImportWithExport.d.ts(27,51): error TS2694: Namespace 'm_private' has no exported member 'v_private'. -privacyLocalInternalReferenceImportWithExport.d.ts(28,41): error TS2708: Cannot use namespace 'm_private' as a value. -privacyLocalInternalReferenceImportWithExport.d.ts(28,51): error TS2694: Namespace 'm_private' has no exported member 'i_private'. -privacyLocalInternalReferenceImportWithExport.d.ts(29,42): error TS2708: Cannot use namespace 'm_private' as a value. -privacyLocalInternalReferenceImportWithExport.d.ts(29,52): error TS2694: Namespace 'm_private' has no exported member 'mi_private'. -privacyLocalInternalReferenceImportWithExport.d.ts(30,42): error TS2708: Cannot use namespace 'm_private' as a value. -privacyLocalInternalReferenceImportWithExport.d.ts(30,52): error TS2694: Namespace 'm_private' has no exported member 'mu_private'. - - -==== privacyLocalInternalReferenceImportWithExport.d.ts (14 errors) ==== - declare namespace m_private { - } - export declare namespace m_public { - class c_public { - } - enum e_public { - Happy = 0, - Grumpy = 1 - } - function f_public(): c_public; - var v_public: number; - interface i_public { - } - namespace mi_public { - class c { - } - } - namespace mu_public { - interface i { - } - } - } - export declare namespace import_public { - export import im_public_c_private = m_private.c_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'c_private'. - export import im_public_e_private = m_private.e_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'e_private'. - export import im_public_f_private = m_private.f_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'f_private'. - export import im_public_v_private = m_private.v_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'v_private'. - export import im_public_i_private = m_private.i_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'i_private'. - export import im_public_mi_private = m_private.mi_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'mi_private'. - export import im_public_mu_private = m_private.mu_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'mu_private'. - var publicUse_im_public_c_private: im_public_c_private; - var publicUse_im_public_e_private: im_public_e_private; - var publicUse_im_public_f_private: im_public_c_private; - var publicUse_im_public_v_private: im_public_c_private; - var publicUse_im_public_i_private: im_public_i_private; - var publicUse_im_public_mi_private: im_public_mi_private.c; - var publicUse_im_public_mu_private: im_public_mu_private.i; - export import im_public_c_public = m_public.c_public; - export import im_public_e_public = m_public.e_public; - export import im_public_f_public = m_public.f_public; - export import im_public_v_public = m_public.v_public; - export import im_public_i_public = m_public.i_public; - export import im_public_mi_public = m_public.mi_public; - export import im_public_mu_public = m_public.mu_public; - var publicUse_im_public_c_public: im_public_c_public; - var publicUse_im_public_e_public: im_public_e_public; - var publicUse_im_public_f_public: im_public_c_public; - var publicUse_im_public_v_public: number; - var publicUse_im_public_i_public: im_public_i_public; - var publicUse_im_public_mi_public: im_public_mi_public.c; - var publicUse_im_public_mu_public: im_public_mu_public.i; - } - export {}; - \ No newline at end of file diff --git a/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js b/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js index 72c0a020f77d2..9b88c75388c4f 100644 --- a/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js +++ b/tests/baselines/reference/privacyLocalInternalReferenceImportWithoutExport.js @@ -304,6 +304,24 @@ define(["require", "exports"], function (require, exports) { //// [privacyLocalInternalReferenceImportWithoutExport.d.ts] declare namespace m_private { + class c_private { + } + enum e_private { + Happy = 0, + Grumpy = 1 + } + function f_private(): c_private; + var v_private: c_private; + interface i_private { + } + namespace mi_private { + class c { + } + } + namespace mu_private { + interface i { + } + } } export declare namespace m_public { class c_public { @@ -352,76 +370,3 @@ export declare namespace import_public { var publicUse_im_private_mu_public: im_private_mu_public.i; } export {}; - - -//// [DtsFileErrors] - - -privacyLocalInternalReferenceImportWithoutExport.d.ts(24,45): error TS2694: Namespace 'm_private' has no exported member 'c_private'. -privacyLocalInternalReferenceImportWithoutExport.d.ts(25,45): error TS2694: Namespace 'm_private' has no exported member 'e_private'. -privacyLocalInternalReferenceImportWithoutExport.d.ts(26,45): error TS2694: Namespace 'm_private' has no exported member 'i_private'. -privacyLocalInternalReferenceImportWithoutExport.d.ts(27,46): error TS2694: Namespace 'm_private' has no exported member 'mi_private'. -privacyLocalInternalReferenceImportWithoutExport.d.ts(28,46): error TS2694: Namespace 'm_private' has no exported member 'mu_private'. - - -==== privacyLocalInternalReferenceImportWithoutExport.d.ts (5 errors) ==== - declare namespace m_private { - } - export declare namespace m_public { - class c_public { - } - enum e_public { - Happy = 0, - Grumpy = 1 - } - function f_public(): c_public; - var v_public: number; - interface i_public { - } - namespace mi_public { - class c { - } - } - namespace mu_public { - interface i { - } - } - } - export declare namespace import_public { - import im_private_c_private = m_private.c_private; - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'c_private'. - import im_private_e_private = m_private.e_private; - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'e_private'. - import im_private_i_private = m_private.i_private; - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'i_private'. - import im_private_mi_private = m_private.mi_private; - ~~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'mi_private'. - import im_private_mu_private = m_private.mu_private; - ~~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'mu_private'. - var publicUse_im_private_c_private: im_private_c_private; - var publicUse_im_private_e_private: im_private_e_private; - var publicUse_im_private_f_private: im_private_c_private; - var publicUse_im_private_v_private: im_private_c_private; - var publicUse_im_private_i_private: im_private_i_private; - var publicUse_im_private_mi_private: im_private_mi_private.c; - var publicUse_im_private_mu_private: im_private_mu_private.i; - import im_private_c_public = m_public.c_public; - import im_private_e_public = m_public.e_public; - import im_private_i_public = m_public.i_public; - import im_private_mi_public = m_public.mi_public; - import im_private_mu_public = m_public.mu_public; - var publicUse_im_private_c_public: im_private_c_public; - var publicUse_im_private_e_public: im_private_e_public; - var publicUse_im_private_f_public: im_private_c_public; - var publicUse_im_private_v_public: number; - var publicUse_im_private_i_public: im_private_i_public; - var publicUse_im_private_mi_public: im_private_mi_public.c; - var publicUse_im_private_mu_public: im_private_mu_public.i; - } - export {}; - \ No newline at end of file diff --git a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js index f72ef24a9c3e4..99397be4c408e 100644 --- a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js +++ b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithExport.js @@ -207,6 +207,24 @@ define(["require", "exports"], function (require, exports) { //// [privacyTopLevelInternalReferenceImportWithExport.d.ts] declare namespace m_private { + class c_private { + } + enum e_private { + Happy = 0, + Grumpy = 1 + } + function f_private(): c_private; + var v_private: c_private; + interface i_private { + } + namespace mi_private { + class c { + } + } + namespace mu_private { + interface i { + } + } } export declare namespace m_public { class c_public { @@ -257,105 +275,3 @@ export declare var publicUse_im_public_i_public: im_public_i_public; export declare var publicUse_im_public_mi_public: im_public_mi_public.c; export declare var publicUse_im_public_mu_public: im_public_mu_public.i; export {}; - - -//// [DtsFileErrors] - - -privacyTopLevelInternalReferenceImportWithExport.d.ts(23,37): error TS2708: Cannot use namespace 'm_private' as a value. -privacyTopLevelInternalReferenceImportWithExport.d.ts(23,47): error TS2694: Namespace 'm_private' has no exported member 'c_private'. -privacyTopLevelInternalReferenceImportWithExport.d.ts(24,37): error TS2708: Cannot use namespace 'm_private' as a value. -privacyTopLevelInternalReferenceImportWithExport.d.ts(24,47): error TS2694: Namespace 'm_private' has no exported member 'e_private'. -privacyTopLevelInternalReferenceImportWithExport.d.ts(25,37): error TS2708: Cannot use namespace 'm_private' as a value. -privacyTopLevelInternalReferenceImportWithExport.d.ts(25,47): error TS2694: Namespace 'm_private' has no exported member 'f_private'. -privacyTopLevelInternalReferenceImportWithExport.d.ts(26,37): error TS2708: Cannot use namespace 'm_private' as a value. -privacyTopLevelInternalReferenceImportWithExport.d.ts(26,47): error TS2694: Namespace 'm_private' has no exported member 'v_private'. -privacyTopLevelInternalReferenceImportWithExport.d.ts(27,37): error TS2708: Cannot use namespace 'm_private' as a value. -privacyTopLevelInternalReferenceImportWithExport.d.ts(27,47): error TS2694: Namespace 'm_private' has no exported member 'i_private'. -privacyTopLevelInternalReferenceImportWithExport.d.ts(28,38): error TS2708: Cannot use namespace 'm_private' as a value. -privacyTopLevelInternalReferenceImportWithExport.d.ts(28,48): error TS2694: Namespace 'm_private' has no exported member 'mi_private'. -privacyTopLevelInternalReferenceImportWithExport.d.ts(29,38): error TS2708: Cannot use namespace 'm_private' as a value. -privacyTopLevelInternalReferenceImportWithExport.d.ts(29,48): error TS2694: Namespace 'm_private' has no exported member 'mu_private'. - - -==== privacyTopLevelInternalReferenceImportWithExport.d.ts (14 errors) ==== - declare namespace m_private { - } - export declare namespace m_public { - class c_public { - } - enum e_public { - Happy = 0, - Grumpy = 1 - } - function f_public(): c_public; - var v_public: number; - interface i_public { - } - namespace mi_public { - class c { - } - } - namespace mu_public { - interface i { - } - } - } - export import im_public_c_private = m_private.c_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'c_private'. - export import im_public_e_private = m_private.e_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'e_private'. - export import im_public_f_private = m_private.f_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'f_private'. - export import im_public_v_private = m_private.v_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'v_private'. - export import im_public_i_private = m_private.i_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'i_private'. - export import im_public_mi_private = m_private.mi_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'mi_private'. - export import im_public_mu_private = m_private.mu_private; - ~~~~~~~~~ -!!! error TS2708: Cannot use namespace 'm_private' as a value. - ~~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'mu_private'. - export declare var publicUse_im_public_c_private: im_public_c_private; - export declare var publicUse_im_public_e_private: im_public_e_private; - export declare var publicUse_im_public_f_private: im_public_c_private; - export declare var publicUse_im_public_v_private: im_public_c_private; - export declare var publicUse_im_public_i_private: im_public_i_private; - export declare var publicUse_im_public_mi_private: im_public_mi_private.c; - export declare var publicUse_im_public_mu_private: im_public_mu_private.i; - export import im_public_c_public = m_public.c_public; - export import im_public_e_public = m_public.e_public; - export import im_public_f_public = m_public.f_public; - export import im_public_v_public = m_public.v_public; - export import im_public_i_public = m_public.i_public; - export import im_public_mi_public = m_public.mi_public; - export import im_public_mu_public = m_public.mu_public; - export declare var publicUse_im_public_c_public: im_public_c_public; - export declare var publicUse_im_public_e_public: im_public_e_public; - export declare var publicUse_im_public_f_public: im_public_c_public; - export declare var publicUse_im_public_v_public: number; - export declare var publicUse_im_public_i_public: im_public_i_public; - export declare var publicUse_im_public_mi_public: im_public_mi_public.c; - export declare var publicUse_im_public_mu_public: im_public_mu_public.i; - export {}; - \ No newline at end of file diff --git a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js index f4afec1707e92..a7158320d678c 100644 --- a/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js +++ b/tests/baselines/reference/privacyTopLevelInternalReferenceImportWithoutExport.js @@ -207,6 +207,24 @@ define(["require", "exports"], function (require, exports) { //// [privacyTopLevelInternalReferenceImportWithoutExport.d.ts] declare namespace m_private { + class c_private { + } + enum e_private { + Happy = 0, + Grumpy = 1 + } + function f_private(): c_private; + var v_private: c_private; + interface i_private { + } + namespace mi_private { + class c { + } + } + namespace mu_private { + interface i { + } + } } export declare namespace m_public { class c_public { @@ -253,74 +271,3 @@ export declare var publicUse_im_private_i_public: im_private_i_public; export declare var publicUse_im_private_mi_public: im_private_mi_public.c; export declare var publicUse_im_private_mu_public: im_private_mu_public.i; export {}; - - -//// [DtsFileErrors] - - -privacyTopLevelInternalReferenceImportWithoutExport.d.ts(23,41): error TS2694: Namespace 'm_private' has no exported member 'c_private'. -privacyTopLevelInternalReferenceImportWithoutExport.d.ts(24,41): error TS2694: Namespace 'm_private' has no exported member 'e_private'. -privacyTopLevelInternalReferenceImportWithoutExport.d.ts(25,41): error TS2694: Namespace 'm_private' has no exported member 'i_private'. -privacyTopLevelInternalReferenceImportWithoutExport.d.ts(26,42): error TS2694: Namespace 'm_private' has no exported member 'mi_private'. -privacyTopLevelInternalReferenceImportWithoutExport.d.ts(27,42): error TS2694: Namespace 'm_private' has no exported member 'mu_private'. - - -==== privacyTopLevelInternalReferenceImportWithoutExport.d.ts (5 errors) ==== - declare namespace m_private { - } - export declare namespace m_public { - class c_public { - } - enum e_public { - Happy = 0, - Grumpy = 1 - } - function f_public(): c_public; - var v_public: number; - interface i_public { - } - namespace mi_public { - class c { - } - } - namespace mu_public { - interface i { - } - } - } - import im_private_c_private = m_private.c_private; - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'c_private'. - import im_private_e_private = m_private.e_private; - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'e_private'. - import im_private_i_private = m_private.i_private; - ~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'i_private'. - import im_private_mi_private = m_private.mi_private; - ~~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'mi_private'. - import im_private_mu_private = m_private.mu_private; - ~~~~~~~~~~ -!!! error TS2694: Namespace 'm_private' has no exported member 'mu_private'. - export declare var publicUse_im_private_c_private: im_private_c_private; - export declare var publicUse_im_private_e_private: im_private_e_private; - export declare var publicUse_im_private_f_private: im_private_c_private; - export declare var publicUse_im_private_v_private: im_private_c_private; - export declare var publicUse_im_private_i_private: im_private_i_private; - export declare var publicUse_im_private_mi_private: im_private_mi_private.c; - export declare var publicUse_im_private_mu_private: im_private_mu_private.i; - import im_private_c_public = m_public.c_public; - import im_private_e_public = m_public.e_public; - import im_private_i_public = m_public.i_public; - import im_private_mi_public = m_public.mi_public; - import im_private_mu_public = m_public.mu_public; - export declare var publicUse_im_private_c_public: im_private_c_public; - export declare var publicUse_im_private_e_public: im_private_e_public; - export declare var publicUse_im_private_f_public: im_private_c_public; - export declare var publicUse_im_private_v_public: number; - export declare var publicUse_im_private_i_public: im_private_i_public; - export declare var publicUse_im_private_mi_public: im_private_mi_public.c; - export declare var publicUse_im_private_mu_public: im_private_mu_public.i; - export {}; - \ No newline at end of file diff --git a/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js b/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js index 46a35ea73234b..a0c721acc99f4 100644 --- a/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js +++ b/tests/baselines/reference/privacyTypeParametersOfClassDeclFile.js @@ -425,58 +425,19 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { -} -export {}; - - -//// [DtsFileErrors] - - -privacyTypeParametersOfClassDeclFile.d.ts(14,93): error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. -privacyTypeParametersOfClassDeclFile.d.ts(31,89): error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. - - -==== privacyTypeParametersOfClassDeclFile.d.ts (2 errors) ==== - declare class privateClass { + class privateClassInPrivateModule { } - export declare class publicClass { + export class publicClassInPrivateModule { } - export declare class publicClassWithPrivateTypeParameters { + export class publicClassWithPrivateTypeParameters { myMethod(val: T): T; } - export declare class publicClassWithPublicTypeParameters { + export class publicClassWithPublicTypeParameters { myMethod(val: T): T; } - export declare class publicClassWithPublicTypeParametersWithoutExtends { - myMethod(val: T): T; - } - export declare class publicClassWithTypeParametersFromPrivateModule { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. + export class publicClassWithPublicTypeParametersWithoutExtends { myMethod(val: T): T; } - export declare namespace publicModule { - class privateClassInPublicModule { - } - export class publicClassInPublicModule { - } - export class publicClassWithPrivateTypeParameters { - myMethod(val: T): T; - } - export class publicClassWithPublicTypeParameters { - myMethod(val: T): T; - } - export class publicClassWithPublicTypeParametersWithoutExtends { - myMethod(val: T): T; - } - export class publicClassWithTypeParametersFromPrivateModule { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. - myMethod(val: T): T; - } - export {}; - } - declare namespace privateModule { - } export {}; - \ No newline at end of file +} +export {}; diff --git a/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js b/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js index 00fa9f9644694..66f07c0dcc677 100644 --- a/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js +++ b/tests/baselines/reference/privacyTypeParametersOfInterfaceDeclFile.js @@ -335,86 +335,34 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { -} -export {}; - - -//// [DtsFileErrors] - - -privacyTypeParametersOfInterfaceDeclFile.d.ts(29,99): error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. -privacyTypeParametersOfInterfaceDeclFile.d.ts(60,103): error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. - - -==== privacyTypeParametersOfInterfaceDeclFile.d.ts (2 errors) ==== - declare class privateClass { + class privateClassInPrivateModule { } - export declare class publicClass { + export class publicClassInPrivateModule { } - declare class privateClassT { + class privateClassInPrivateModuleT { } - export declare class publicClassT { + export class publicClassInPrivateModuleT { } - export interface publicInterfaceWithPrivateTypeParameters { + export interface publicInterfaceWithPrivateTypeParameters { myMethod(val: T): T; - myMethod0(): publicClassT; - myMethod1(): privateClassT; - myMethod2(): privateClassT; - myMethod3(): publicClassT; - myMethod4(): publicClassT; + myMethod0(): publicClassInPrivateModuleT; + myMethod1(): privateClassInPrivateModuleT; + myMethod2(): privateClassInPrivateModuleT; + myMethod3(): publicClassInPrivateModuleT; + myMethod4(): publicClassInPrivateModuleT; } - export interface publicInterfaceWithPublicTypeParameters { + export interface publicInterfaceWithPublicTypeParameters { myMethod(val: T): T; - myMethod0(): publicClassT; - myMethod1(): privateClassT; - myMethod2(): privateClassT; - myMethod3(): publicClassT; - myMethod4(): publicClassT; + myMethod0(): publicClassInPrivateModuleT; + myMethod1(): privateClassInPrivateModuleT; + myMethod2(): privateClassInPrivateModuleT; + myMethod3(): publicClassInPrivateModuleT; + myMethod4(): publicClassInPrivateModuleT; } export interface publicInterfaceWithPublicTypeParametersWithoutExtends { myMethod(val: T): T; - myMethod0(): publicClassT; - } - export interface publicInterfaceWithPrivateModuleTypeParameterConstraints { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. - } - export declare namespace publicModule { - class privateClassInPublicModule { - } - export class publicClassInPublicModule { - } - class privateClassInPublicModuleT { - } - export class publicClassInPublicModuleT { - } - export interface publicInterfaceWithPrivateTypeParameters { - myMethod(val: T): T; - myMethod0(): publicClassInPublicModuleT; - myMethod1(): privateClassInPublicModuleT; - myMethod2(): privateClassInPublicModuleT; - myMethod3(): publicClassInPublicModuleT; - myMethod4(): publicClassInPublicModuleT; - } - export interface publicInterfaceWithPublicTypeParameters { - myMethod(val: T): T; - myMethod0(): publicClassInPublicModuleT; - myMethod1(): privateClassInPublicModuleT; - myMethod2(): privateClassInPublicModuleT; - myMethod3(): publicClassInPublicModuleT; - myMethod4(): publicClassInPublicModuleT; - } - export interface publicInterfaceWithPublicTypeParametersWithoutExtends { - myMethod(val: T): T; - myMethod0(): publicClassInPublicModuleT; - } - export interface publicInterfaceWithPrivateModuleTypeParameterConstraints { - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClassInPrivateModule'. - } - export {}; - } - declare namespace privateModule { + myMethod0(): publicClassInPrivateModuleT; } export {}; - \ No newline at end of file +} +export {}; diff --git a/tests/baselines/reference/privacyVarDeclFile.js b/tests/baselines/reference/privacyVarDeclFile.js index 3bd117870abde..83f6ef53f1aea 100644 --- a/tests/baselines/reference/privacyVarDeclFile.js +++ b/tests/baselines/reference/privacyVarDeclFile.js @@ -764,29 +764,10 @@ export declare namespace publicModule { export {}; } declare namespace privateModule { -} -export {}; -//// [privacyVarDeclFile_GlobalFile.d.ts] -declare class publicClassInGlobal { -} -interface publicInterfaceWithPublicPropertyTypesInGlobal { - myProperty: publicClassInGlobal; -} -declare class publicClassWithWithPublicPropertyTypesInGlobal { - static myPublicStaticProperty: publicClassInGlobal; - private static myPrivateStaticProperty; - myPublicProperty: publicClassInGlobal; - private myPrivateProperty; -} -declare var publicVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; -declare var publicAmbientVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; -declare namespace publicModuleInGlobal { class privateClass { } export class publicClass { } - namespace privateModule { - } export interface publicInterfaceWithPrivatePropertyTypes { myProperty: privateClass; } @@ -820,75 +801,27 @@ declare namespace publicModuleInGlobal { export var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; export {}; } - - -//// [DtsFileErrors] - - -privacyVarDeclFile_GlobalFile.d.ts(44,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_GlobalFile.d.ts(47,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_GlobalFile.d.ts(48,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_GlobalFile.d.ts(50,71): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_GlobalFile.d.ts(51,78): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_externalModule.d.ts(28,31): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_externalModule.d.ts(31,50): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_externalModule.d.ts(32,37): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_externalModule.d.ts(34,75): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_externalModule.d.ts(35,82): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_externalModule.d.ts(64,35): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_externalModule.d.ts(67,54): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_externalModule.d.ts(68,41): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_externalModule.d.ts(70,71): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. -privacyVarDeclFile_externalModule.d.ts(71,78): error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - - -==== privacyVarDeclFile_externalModule.d.ts (10 errors) ==== - declare class privateClass { - } - export declare class publicClass { - } - export interface publicInterfaceWithPrivatePropertyTypes { - myProperty: privateClass; - } - export interface publicInterfaceWithPublicPropertyTypes { - myProperty: publicClass; - } - export declare class publicClassWithWithPrivatePropertyTypes { - static myPublicStaticProperty: privateClass; - private static myPrivateStaticProperty; - myPublicProperty: privateClass; - private myPrivateProperty; - } - export declare class publicClassWithWithPublicPropertyTypes { - static myPublicStaticProperty: publicClass; - private static myPrivateStaticProperty; - myPublicProperty: publicClass; - private myPrivateProperty; +export {}; +//// [privacyVarDeclFile_GlobalFile.d.ts] +declare class publicClassInGlobal { +} +interface publicInterfaceWithPublicPropertyTypesInGlobal { + myProperty: publicClassInGlobal; +} +declare class publicClassWithWithPublicPropertyTypesInGlobal { + static myPublicStaticProperty: publicClassInGlobal; + private static myPrivateStaticProperty; + myPublicProperty: publicClassInGlobal; + private myPrivateProperty; +} +declare var publicVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; +declare var publicAmbientVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; +declare namespace publicModuleInGlobal { + class privateClass { } - export declare var publicVarWithPrivatePropertyTypes: privateClass; - export declare var publicVarWithPublicPropertyTypes: publicClass; - export declare var publicAmbientVarWithPrivatePropertyTypes: privateClass; - export declare var publicAmbientVarWithPublicPropertyTypes: publicClass; - export interface publicInterfaceWithPrivateModulePropertyTypes { - myProperty: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. + export class publicClass { } - export declare class publicClassWithPrivateModulePropertyTypes { - static myPublicStaticProperty: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myPublicProperty: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - } - export declare var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export declare var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export declare namespace publicModule { + namespace privateModule { class privateClass { } export class publicClass { @@ -917,91 +850,45 @@ privacyVarDeclFile_externalModule.d.ts(71,78): error TS2694: Namespace 'privateM export var publicAmbientVarWithPublicPropertyTypes: publicClass; export interface publicInterfaceWithPrivateModulePropertyTypes { myProperty: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export class publicClassWithPrivateModulePropertyTypes { static myPublicStaticProperty: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. myPublicProperty: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. } export var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. export var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. export {}; } - declare namespace privateModule { + export interface publicInterfaceWithPrivatePropertyTypes { + myProperty: privateClass; } - export {}; - -==== privacyVarDeclFile_GlobalFile.d.ts (5 errors) ==== - declare class publicClassInGlobal { + export interface publicInterfaceWithPublicPropertyTypes { + myProperty: publicClass; } - interface publicInterfaceWithPublicPropertyTypesInGlobal { - myProperty: publicClassInGlobal; + export class publicClassWithWithPrivatePropertyTypes { + static myPublicStaticProperty: privateClass; + private static myPrivateStaticProperty; + myPublicProperty: privateClass; + private myPrivateProperty; } - declare class publicClassWithWithPublicPropertyTypesInGlobal { - static myPublicStaticProperty: publicClassInGlobal; + export class publicClassWithWithPublicPropertyTypes { + static myPublicStaticProperty: publicClass; private static myPrivateStaticProperty; - myPublicProperty: publicClassInGlobal; + myPublicProperty: publicClass; private myPrivateProperty; } - declare var publicVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; - declare var publicAmbientVarWithPublicPropertyTypesInGlobal: publicClassInGlobal; - declare namespace publicModuleInGlobal { - class privateClass { - } - export class publicClass { - } - namespace privateModule { - } - export interface publicInterfaceWithPrivatePropertyTypes { - myProperty: privateClass; - } - export interface publicInterfaceWithPublicPropertyTypes { - myProperty: publicClass; - } - export class publicClassWithWithPrivatePropertyTypes { - static myPublicStaticProperty: privateClass; - private static myPrivateStaticProperty; - myPublicProperty: privateClass; - private myPrivateProperty; - } - export class publicClassWithWithPublicPropertyTypes { - static myPublicStaticProperty: publicClass; - private static myPrivateStaticProperty; - myPublicProperty: publicClass; - private myPrivateProperty; - } - export var publicVarWithPrivatePropertyTypes: privateClass; - export var publicVarWithPublicPropertyTypes: publicClass; - export var publicAmbientVarWithPrivatePropertyTypes: privateClass; - export var publicAmbientVarWithPublicPropertyTypes: publicClass; - export interface publicInterfaceWithPrivateModulePropertyTypes { - myProperty: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - } - export class publicClassWithPrivateModulePropertyTypes { - static myPublicStaticProperty: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - myPublicProperty: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - } - export var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'privateModule' has no exported member 'publicClass'. - export {}; + export var publicVarWithPrivatePropertyTypes: privateClass; + export var publicVarWithPublicPropertyTypes: publicClass; + export var publicAmbientVarWithPrivatePropertyTypes: privateClass; + export var publicAmbientVarWithPublicPropertyTypes: publicClass; + export interface publicInterfaceWithPrivateModulePropertyTypes { + myProperty: privateModule.publicClass; } - \ No newline at end of file + export class publicClassWithPrivateModulePropertyTypes { + static myPublicStaticProperty: privateModule.publicClass; + myPublicProperty: privateModule.publicClass; + } + export var publicVarWithPrivateModulePropertyTypes: privateModule.publicClass; + export var publicAmbientVarWithPrivateModulePropertyTypes: privateModule.publicClass; + export {}; +}