diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7266f90b861..86acdb7c44b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2621,7 +2621,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (resolvedTarget === unknownSymbol) { return source; } - target = cloneSymbol(resolvedTarget); + if ( + !(resolvedTarget.flags & getExcludedSymbolFlags(source.flags)) || + (source.flags | resolvedTarget.flags) & SymbolFlags.Assignment + ) { + target = cloneSymbol(resolvedTarget); + } + else { + reportMergeSymbolError(target, source); + return source; + } } // Javascript static-property-assignment declarations always merge, even though they are also values if (source.flags & SymbolFlags.ValueModule && target.flags & SymbolFlags.ValueModule && target.constEnumOnlyModule && !source.constEnumOnlyModule) { @@ -2657,7 +2666,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ); } } - else { // error + else { + reportMergeSymbolError(target, source); + } + return target; + + function reportMergeSymbolError(target: Symbol, source: Symbol) { const isEitherEnum = !!(target.flags & SymbolFlags.Enum || source.flags & SymbolFlags.Enum); const isEitherBlockScoped = !!(target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable); const message = isEitherEnum ? Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations @@ -2684,7 +2698,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!isTargetPlainJs) addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source); } } - return target; function addDuplicateLocations(locs: Declaration[], symbol: Symbol): void { if (symbol.declarations) { diff --git a/tests/baselines/reference/checkMergedGlobalUMDSymbol.errors.txt b/tests/baselines/reference/checkMergedGlobalUMDSymbol.errors.txt index 5a129d15ef5..61bc044bed4 100644 --- a/tests/baselines/reference/checkMergedGlobalUMDSymbol.errors.txt +++ b/tests/baselines/reference/checkMergedGlobalUMDSymbol.errors.txt @@ -1,4 +1,5 @@ -global.d.ts(6,16): error TS2403: Subsequent variable declarations must have the same type. Variable 'THREE' must be of type 'typeof import("global")', but here has type 'typeof import("three")'. +global.d.ts(3,21): error TS2451: Cannot redeclare block-scoped variable 'THREE'. +global.d.ts(6,16): error TS2451: Cannot redeclare block-scoped variable 'THREE'. ==== three.d.ts (0 errors) ==== @@ -6,16 +7,19 @@ global.d.ts(6,16): error TS2403: Subsequent variable declarations must have the export class Vector2 {} } -==== global.d.ts (1 errors) ==== +==== global.d.ts (2 errors) ==== import * as _three from './three'; export as namespace THREE; + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'THREE'. +!!! related TS6203 global.d.ts:6:16: 'THREE' was also declared here. declare global { export const THREE: typeof _three; ~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'THREE' must be of type 'typeof import("global")', but here has type 'typeof import("three")'. -!!! related TS6203 global.d.ts:1:1: 'THREE' was also declared here. +!!! error TS2451: Cannot redeclare block-scoped variable 'THREE'. +!!! related TS6203 global.d.ts:3:21: 'THREE' was also declared here. } ==== test.ts (0 errors) ==== diff --git a/tests/baselines/reference/checkMergedGlobalUMDSymbol.symbols b/tests/baselines/reference/checkMergedGlobalUMDSymbol.symbols index d9e86c98f70..b7d9e217b29 100644 --- a/tests/baselines/reference/checkMergedGlobalUMDSymbol.symbols +++ b/tests/baselines/reference/checkMergedGlobalUMDSymbol.symbols @@ -19,12 +19,12 @@ declare global { >global : Symbol(global, Decl(global.d.ts, 2, 26)) export const THREE: typeof _three; ->THREE : Symbol(THREE, Decl(global.d.ts, 0, 0), Decl(global.d.ts, 5, 14)) +>THREE : Symbol(THREE, Decl(global.d.ts, 5, 14)) >_three : Symbol(_three, Decl(global.d.ts, 0, 6)) } === test.ts === const m = THREE >m : Symbol(m, Decl(test.ts, 0, 5)) ->THREE : Symbol(THREE, Decl(global.d.ts, 0, 0), Decl(global.d.ts, 5, 14)) +>THREE : Symbol(THREE, Decl(global.d.ts, 5, 14)) diff --git a/tests/baselines/reference/checkMergedGlobalUMDSymbol.types b/tests/baselines/reference/checkMergedGlobalUMDSymbol.types index 992975fc45c..d8518354944 100644 --- a/tests/baselines/reference/checkMergedGlobalUMDSymbol.types +++ b/tests/baselines/reference/checkMergedGlobalUMDSymbol.types @@ -24,16 +24,16 @@ declare global { > : ^^^^^^^^^^^^^ export const THREE: typeof _three; ->THREE : typeof import("global") -> : ^^^^^^^^^^^^^^^^^^^^^^^ +>THREE : typeof _three +> : ^^^^^^^^^^^^^ >_three : typeof _three > : ^^^^^^^^^^^^^ } === test.ts === const m = THREE ->m : typeof import("global") -> : ^^^^^^^^^^^^^^^^^^^^^^^ ->THREE : typeof import("global") -> : ^^^^^^^^^^^^^^^^^^^^^^^ +>m : typeof import("three") +> : ^^^^^^^^^^^^^^^^^^^^^^ +>THREE : typeof import("three") +> : ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/baselines/reference/checkerInitializationCrash.errors.txt b/tests/baselines/reference/checkerInitializationCrash.errors.txt new file mode 100644 index 00000000000..e1f28e265e2 --- /dev/null +++ b/tests/baselines/reference/checkerInitializationCrash.errors.txt @@ -0,0 +1,47 @@ +/node_modules/@fullcalendar/core/index.d.ts(4,10): error TS2300: Duplicate identifier 'VNode'. +/node_modules/@fullcalendar/react/index.d.ts(4,19): error TS2300: Duplicate identifier 'VNode'. + + +==== /node_modules/@fullcalendar/react/index.d.ts (1 errors) ==== + import * as react from 'react'; + declare global { + namespace FullCalendarVDom { + export import VNode = react.ReactNode; + ~~~~~ +!!! error TS2300: Duplicate identifier 'VNode'. +!!! related TS6203 /node_modules/@fullcalendar/core/index.d.ts:4:10: 'VNode' was also declared here. + } + } + + export default class FullCalendar { + } + +==== /node_modules/@fullcalendar/core/index.d.ts (1 errors) ==== + import * as preact from 'preact'; + declare global { + namespace FullCalendarVDom { + type VNode = preact.VNode; + ~~~~~ +!!! error TS2300: Duplicate identifier 'VNode'. +!!! related TS6203 /node_modules/@fullcalendar/react/index.d.ts:4:19: 'VNode' was also declared here. + } + } + + export type EventInput = any; + +==== /node_modules/@types/react/index.d.ts (0 errors) ==== + export = React; + export as namespace React; + declare namespace React { + type ReactNode = any; + function useMemo(factory: () => T, deps: undefined): T; + } + +==== /node_modules/preact/index.d.ts (0 errors) ==== + export as namespace preact; + export interface VNode

{} + +==== /index.tsx (0 errors) ==== + import FullCalendar from "@fullcalendar/react"; + import { EventInput } from "@fullcalendar/core"; + \ No newline at end of file diff --git a/tests/baselines/reference/checkerInitializationCrash.symbols b/tests/baselines/reference/checkerInitializationCrash.symbols index c1f5911773f..a0ef0593638 100644 --- a/tests/baselines/reference/checkerInitializationCrash.symbols +++ b/tests/baselines/reference/checkerInitializationCrash.symbols @@ -13,7 +13,7 @@ declare global { export import VNode = react.ReactNode; >VNode : Symbol(FullCalendarVDom.VNode, Decl(index.d.ts, 2, 30)) >react : Symbol(react, Decl(index.d.ts, 0, 6)) ->ReactNode : Symbol(react.ReactNode, Decl(index.d.ts, 2, 25), Decl(index.d.ts, 2, 30)) +>ReactNode : Symbol(react.ReactNode, Decl(index.d.ts, 2, 25)) } } @@ -32,7 +32,7 @@ declare global { >FullCalendarVDom : Symbol(FullCalendarVDom, Decl(index.d.ts, 1, 16), Decl(index.d.ts, 1, 16)) type VNode = preact.VNode; ->VNode : Symbol(React.ReactNode, Decl(index.d.ts, 2, 25), Decl(index.d.ts, 2, 30)) +>VNode : Symbol(VNode, Decl(index.d.ts, 2, 30)) >preact : Symbol(preact, Decl(index.d.ts, 0, 6)) >VNode : Symbol(preact.VNode, Decl(index.d.ts, 0, 27)) } @@ -52,7 +52,7 @@ declare namespace React { >React : Symbol(React, Decl(index.d.ts, 1, 26)) type ReactNode = any; ->ReactNode : Symbol(ReactNode, Decl(index.d.ts, 2, 25), Decl(index.d.ts, 2, 30)) +>ReactNode : Symbol(ReactNode, Decl(index.d.ts, 2, 25)) function useMemo(factory: () => T, deps: undefined): T; >useMemo : Symbol(useMemo, Decl(index.d.ts, 3, 25)) diff --git a/tests/baselines/reference/checkerInitializationCrash.types b/tests/baselines/reference/checkerInitializationCrash.types index c6eea1d6d9c..62a2daf6d99 100644 --- a/tests/baselines/reference/checkerInitializationCrash.types +++ b/tests/baselines/reference/checkerInitializationCrash.types @@ -39,7 +39,8 @@ declare global { namespace FullCalendarVDom { type VNode = preact.VNode; ->VNode : any +>VNode : VNode +> : ^^^^^ >preact : any > : ^^^ } @@ -47,6 +48,7 @@ declare global { export type EventInput = any; >EventInput : any +> : ^^^ === /node_modules/@types/react/index.d.ts === export = React; @@ -63,6 +65,7 @@ declare namespace React { type ReactNode = any; >ReactNode : any +> : ^^^ function useMemo(factory: () => T, deps: undefined): T; >useMemo : (factory: () => T, deps: undefined) => T diff --git a/tests/baselines/reference/crashDeclareGlobalTypeofExport.errors.txt b/tests/baselines/reference/crashDeclareGlobalTypeofExport.errors.txt new file mode 100644 index 00000000000..30ce2b462ba --- /dev/null +++ b/tests/baselines/reference/crashDeclareGlobalTypeofExport.errors.txt @@ -0,0 +1,33 @@ +bar.d.ts(2,21): error TS2451: Cannot redeclare block-scoped variable 'foo'. +bar.d.ts(6,11): error TS2451: Cannot redeclare block-scoped variable 'foo'. +bar.d.ts(6,11): error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + + +==== bar.d.ts (3 errors) ==== + import * as foo from './foo' + export as namespace foo + ~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo'. +!!! related TS6203 bar.d.ts:6:11: 'foo' was also declared here. + export = foo; + + declare global { + const foo: typeof foo; + ~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'foo'. +!!! related TS6203 bar.d.ts:2:21: 'foo' was also declared here. + ~~~ +!!! error TS2502: 'foo' is referenced directly or indirectly in its own type annotation. + } + +==== foo.d.ts (0 errors) ==== + interface Root { + /** + * A .default property for ES6 default import compatibility + */ + default: Root; + } + + declare const root: Root; + export = root; + \ No newline at end of file diff --git a/tests/baselines/reference/crashDeclareGlobalTypeofExport.symbols b/tests/baselines/reference/crashDeclareGlobalTypeofExport.symbols index 64f9b0df3e8..1afc266f932 100644 --- a/tests/baselines/reference/crashDeclareGlobalTypeofExport.symbols +++ b/tests/baselines/reference/crashDeclareGlobalTypeofExport.symbols @@ -14,8 +14,8 @@ declare global { >global : Symbol(global, Decl(bar.d.ts, 2, 13)) const foo: typeof foo; ->foo : Symbol(foo, Decl(foo.d.ts, 7, 13), Decl(bar.d.ts, 5, 9)) ->foo : Symbol(foo, Decl(foo.d.ts, 7, 13), Decl(bar.d.ts, 5, 9)) +>foo : Symbol(foo, Decl(bar.d.ts, 5, 9)) +>foo : Symbol(foo, Decl(bar.d.ts, 5, 9)) } === foo.d.ts === diff --git a/tests/baselines/reference/crashDeclareGlobalTypeofExport.types b/tests/baselines/reference/crashDeclareGlobalTypeofExport.types index 3893345c723..1a36e3e3316 100644 --- a/tests/baselines/reference/crashDeclareGlobalTypeofExport.types +++ b/tests/baselines/reference/crashDeclareGlobalTypeofExport.types @@ -18,10 +18,10 @@ declare global { > : ^^^^^^^^^^^^^ const foo: typeof foo; ->foo : Root -> : ^^^^ ->foo : Root -> : ^^^^ +>foo : any +> : ^^^ +>foo : any +> : ^^^ } === foo.d.ts === diff --git a/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.errors.txt b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.errors.txt index e08187f6173..d6e8ea7b47c 100644 --- a/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.errors.txt +++ b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.errors.txt @@ -1,8 +1,9 @@ input.ts(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -input.ts(6,14): error TS2323: Cannot redeclare exported variable 'Sub'. +input.ts(6,14): error TS2300: Duplicate identifier 'Sub'. +input.ts(12,14): error TS2300: Duplicate identifier 'Sub'. -==== input.ts (2 errors) ==== +==== input.ts (3 errors) ==== export = exports; ~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -12,11 +13,15 @@ input.ts(6,14): error TS2323: Cannot redeclare exported variable 'Sub'. } export class Sub { ~~~ -!!! error TS2323: Cannot redeclare exported variable 'Sub'. +!!! error TS2300: Duplicate identifier 'Sub'. +!!! related TS6203 input.ts:12:14: 'Sub' was also declared here. instance!: { t: number; }; } declare namespace exports { export { Sub }; + ~~~ +!!! error TS2300: Duplicate identifier 'Sub'. +!!! related TS6203 input.ts:6:14: 'Sub' was also declared here. } \ No newline at end of file diff --git a/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.symbols b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.symbols index 41d764f9752..6f90cca89eb 100644 --- a/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.symbols +++ b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.symbols @@ -14,7 +14,7 @@ declare class exports { >t : Symbol(exports.t, Decl(input.ts, 2, 27)) } export class Sub { ->Sub : Symbol(Sub, Decl(input.ts, 4, 1), Decl(input.ts, 4, 1)) +>Sub : Symbol(Sub, Decl(input.ts, 4, 1)) instance!: { >instance : Symbol(Sub.instance, Decl(input.ts, 5, 18)) diff --git a/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.types b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.types index 1432e9c42dd..561f76d04a6 100644 --- a/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.types +++ b/tests/baselines/reference/declarationFileNoCrashOnExtraExportModifier.types @@ -36,6 +36,6 @@ declare namespace exports { > : ^^^^^^^^^^^^^^ export { Sub }; ->Sub : typeof import("input").Sub -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>Sub : typeof Sub +> : ^^^^^^^^^^ } diff --git a/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc b/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc index 8c517bb1499..3516bee024d 100644 --- a/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc +++ b/tests/baselines/reference/findAllReferencesUmdModuleAsGlobalConst.baseline.jsonc @@ -3,31 +3,29 @@ // export * from "./three-core"; // <|export as namespace /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}THREE|];|> -// === /typings/global.d.ts === -// <|import * as _THREE from '[|three|]';|> -// declare global { -// <|const [|{| isWriteAccess: true |}THREE|]: typeof _THREE;|> -// } - -// === /src/index.ts === -// export const a = {}; -// let v = new [|THREE|].Vector2(); - // === Definitions === // === /node_modules/@types/three/index.d.ts === - // [|export * from "./three-core"; - // export as namespace /*FIND ALL REFS*/THREE;|] + // export * from "./three-core"; + // <|export as namespace /*FIND ALL REFS*/[|THREE|];|> // === Details === [ { "containerKind": "", "containerName": "", - "kind": "var", - "name": "module THREE\nvar THREE: typeof import(\"/node_modules/@types/three/index\")", + "kind": "alias", + "name": "export namespace THREE", "displayParts": [ { - "text": "module", + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "namespace", "kind": "keyword" }, { @@ -36,55 +34,7 @@ }, { "text": "THREE", - "kind": "localName" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "var", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "THREE", - "kind": "localName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "typeof", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "import", - "kind": "keyword" - }, - { - "text": "(", - "kind": "punctuation" - }, - { - "text": "\"/node_modules/@types/three/index\"", - "kind": "stringLiteral" - }, - { - "text": ")", - "kind": "punctuation" + "kind": "aliasName" } ] } @@ -93,20 +43,12 @@ // === findAllReferences === -// === /node_modules/@types/three/index.d.ts === -// export * from "./three-core"; -// <|export as namespace [|{| isWriteAccess: true |}THREE|];|> - // === /typings/global.d.ts === // <|import * as _THREE from '/*FIND ALL REFS*/[|three|]';|> // declare global { -// <|const [|{| isWriteAccess: true |}THREE|]: typeof _THREE;|> +// const THREE: typeof _THREE; // } -// === /src/index.ts === -// export const a = {}; -// let v = new [|THREE|].Vector2(); - // === Definitions === // === /node_modules/@types/three/index.d.ts === // [|export * from "./three-core"; @@ -117,8 +59,8 @@ { "containerKind": "", "containerName": "", - "kind": "var", - "name": "module THREE\nvar THREE: typeof import(\"/node_modules/@types/three/index\")", + "kind": "module", + "name": "module \"/node_modules/@types/three/index\"", "displayParts": [ { "text": "module", @@ -128,57 +70,9 @@ "text": " ", "kind": "space" }, - { - "text": "THREE", - "kind": "localName" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "var", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "THREE", - "kind": "localName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "typeof", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "import", - "kind": "keyword" - }, - { - "text": "(", - "kind": "punctuation" - }, { "text": "\"/node_modules/@types/three/index\"", "kind": "stringLiteral" - }, - { - "text": ")", - "kind": "punctuation" } ] } @@ -187,12 +81,8 @@ // === findAllReferences === -// === /node_modules/@types/three/index.d.ts === -// export * from "./three-core"; -// <|export as namespace [|{| isWriteAccess: true |}THREE|];|> - // === /typings/global.d.ts === -// <|import * as _THREE from '[|three|]';|> +// import * as _THREE from 'three'; // declare global { // <|const /*FIND ALL REFS*/[|{| isWriteAccess: true, isDefinition: true |}THREE|]: typeof _THREE;|> // } @@ -202,36 +92,22 @@ // let v = new [|THREE|].Vector2(); // === Definitions === - // === /node_modules/@types/three/index.d.ts === - // [|export * from "./three-core"; - // export as namespace THREE;|] + // === /typings/global.d.ts === + // import * as _THREE from 'three'; + // declare global { + // <|const /*FIND ALL REFS*/[|THREE|]: typeof _THREE;|> + // } // === Details === [ { "containerKind": "", "containerName": "", - "kind": "var", - "name": "module THREE\nvar THREE: typeof import(\"/node_modules/@types/three/index\")", + "kind": "const", + "name": "const THREE: typeof _THREE", "displayParts": [ { - "text": "module", - "kind": "keyword" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "THREE", - "kind": "localName" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "var", + "text": "const", "kind": "keyword" }, { @@ -259,20 +135,72 @@ "kind": "space" }, { - "text": "import", + "text": "_THREE", + "kind": "aliasName" + } + ] + } + ] + + + +// === findAllReferences === +// === /typings/global.d.ts === +// import * as _THREE from 'three'; +// declare global { +// <|const [|{| isWriteAccess: true |}THREE|]: typeof _THREE;|> +// } + +// === /src/index.ts === +// export const a = {}; +// let v = new /*FIND ALL REFS*/[|THREE|].Vector2(); + + // === Definitions === + // === /typings/global.d.ts === + // import * as _THREE from 'three'; + // declare global { + // <|const [|THREE|]: typeof _THREE;|> + // } + + // === Details === + [ + { + "containerKind": "", + "containerName": "", + "kind": "const", + "name": "const THREE: typeof _THREE", + "displayParts": [ + { + "text": "const", "kind": "keyword" }, { - "text": "(", + "text": " ", + "kind": "space" + }, + { + "text": "THREE", + "kind": "localName" + }, + { + "text": ":", "kind": "punctuation" }, { - "text": "\"/node_modules/@types/three/index\"", - "kind": "stringLiteral" + "text": " ", + "kind": "space" }, { - "text": ")", - "kind": "punctuation" + "text": "typeof", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "_THREE", + "kind": "aliasName" } ] } diff --git a/tests/baselines/reference/mergeSymbolReexportInterface.errors.txt b/tests/baselines/reference/mergeSymbolReexportInterface.errors.txt new file mode 100644 index 00000000000..86c3a073052 --- /dev/null +++ b/tests/baselines/reference/mergeSymbolReexportInterface.errors.txt @@ -0,0 +1,32 @@ +a.d.ts(3,8): error TS2300: Duplicate identifier 'Row2'. +index.d.ts(1,14): error TS2300: Duplicate identifier 'Row2'. +main.ts(2,7): error TS2741: Property 'a' is missing in type '{}' but required in type 'Row2'. + + +==== main.ts (1 errors) ==== + import {Row2, C} from '.' + const x : Row2 = { } + ~ +!!! error TS2741: Property 'a' is missing in type '{}' but required in type 'Row2'. +!!! related TS2728 a.d.ts:3:17: 'a' is declared here. + const y : C = { s: '' } + + +==== ./a.d.ts (1 errors) ==== + import '.' + declare module '.' { + type Row2 = { a: string } + ~~~~ +!!! error TS2300: Duplicate identifier 'Row2'. +!!! related TS6203 index.d.ts:1:14: 'Row2' was also declared here. + type C = { s : string } + } + +==== ./index.d.ts (1 errors) ==== + export type {Row2} from './common'; + ~~~~ +!!! error TS2300: Duplicate identifier 'Row2'. +!!! related TS6203 a.d.ts:3:8: 'Row2' was also declared here. + +==== ./common.d.ts (0 errors) ==== + export interface Row2 { b: string } \ No newline at end of file diff --git a/tests/baselines/reference/mergeSymbolReexportInterface.js b/tests/baselines/reference/mergeSymbolReexportInterface.js new file mode 100644 index 00000000000..32830400c13 --- /dev/null +++ b/tests/baselines/reference/mergeSymbolReexportInterface.js @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/mergeSymbolReexportInterface.ts] //// + +//// [main.ts] +import {Row2, C} from '.' +const x : Row2 = { } +const y : C = { s: '' } + + +//// [a.d.ts] +import '.' +declare module '.' { + type Row2 = { a: string } + type C = { s : string } +} + +//// [index.d.ts] +export type {Row2} from './common'; + +//// [common.d.ts] +export interface Row2 { b: string } + +//// [main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var x = {}; +var y = { s: '' }; diff --git a/tests/baselines/reference/mergeSymbolReexportInterface.symbols b/tests/baselines/reference/mergeSymbolReexportInterface.symbols new file mode 100644 index 00000000000..a958a96216a --- /dev/null +++ b/tests/baselines/reference/mergeSymbolReexportInterface.symbols @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/mergeSymbolReexportInterface.ts] //// + +=== main.ts === +import {Row2, C} from '.' +>Row2 : Symbol(Row2, Decl(main.ts, 0, 8)) +>C : Symbol(C, Decl(main.ts, 0, 13)) + +const x : Row2 = { } +>x : Symbol(x, Decl(main.ts, 1, 5)) +>Row2 : Symbol(Row2, Decl(main.ts, 0, 8)) + +const y : C = { s: '' } +>y : Symbol(y, Decl(main.ts, 2, 5)) +>C : Symbol(C, Decl(main.ts, 0, 13)) +>s : Symbol(s, Decl(main.ts, 2, 15)) + + +=== ./a.d.ts === +import '.' +declare module '.' { +>'.' : Symbol("index", Decl(index.d.ts, 0, 0), Decl(a.d.ts, 0, 10)) + + type Row2 = { a: string } +>Row2 : Symbol(Row2, Decl(a.d.ts, 1, 20)) +>a : Symbol(a, Decl(a.d.ts, 2, 15)) + + type C = { s : string } +>C : Symbol(C, Decl(a.d.ts, 2, 27)) +>s : Symbol(s, Decl(a.d.ts, 3, 12)) +} + +=== ./index.d.ts === +export type {Row2} from './common'; +>Row2 : Symbol(Row2, Decl(index.d.ts, 0, 13)) + +=== ./common.d.ts === +export interface Row2 { b: string } +>Row2 : Symbol(Row2, Decl(common.d.ts, 0, 0)) +>b : Symbol(Row2.b, Decl(common.d.ts, 0, 23)) + diff --git a/tests/baselines/reference/mergeSymbolReexportInterface.types b/tests/baselines/reference/mergeSymbolReexportInterface.types new file mode 100644 index 00000000000..99cc91fc848 --- /dev/null +++ b/tests/baselines/reference/mergeSymbolReexportInterface.types @@ -0,0 +1,55 @@ +//// [tests/cases/compiler/mergeSymbolReexportInterface.ts] //// + +=== main.ts === +import {Row2, C} from '.' +>Row2 : any +> : ^^^ +>C : any +> : ^^^ + +const x : Row2 = { } +>x : Row2 +> : ^^^^ +>{ } : {} +> : ^^ + +const y : C = { s: '' } +>y : C +> : ^ +>{ s: '' } : { s: string; } +> : ^^^^^^^^^^^^^^ +>s : string +> : ^^^^^^ +>'' : "" +> : ^^ + + +=== ./a.d.ts === +import '.' +declare module '.' { +>'.' : typeof import("index") +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + type Row2 = { a: string } +>Row2 : Row2 +> : ^^^^ +>a : string +> : ^^^^^^ + + type C = { s : string } +>C : C +> : ^ +>s : string +> : ^^^^^^ +} + +=== ./index.d.ts === +export type {Row2} from './common'; +>Row2 : import("common").Row2 +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +=== ./common.d.ts === +export interface Row2 { b: string } +>b : string +> : ^^^^^^ + diff --git a/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.errors.txt b/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.errors.txt new file mode 100644 index 00000000000..cbcda7964a7 --- /dev/null +++ b/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.errors.txt @@ -0,0 +1,27 @@ +a.d.ts(3,8): error TS2300: Duplicate identifier 'Row2'. +index.d.ts(1,14): error TS2300: Duplicate identifier 'Row2'. + + +==== main.ts (0 errors) ==== + import {Row2, C} from '.' + const x: ((rowData: Row2) => unknown) = (rowData: Row2) => (null) + const y : C = { s: '' } + +==== ./a.d.ts (1 errors) ==== + import '.' + declare module '.' { + type Row2 = {} + ~~~~ +!!! error TS2300: Duplicate identifier 'Row2'. +!!! related TS6203 index.d.ts:1:14: 'Row2' was also declared here. + type C = { s : string } + } + +==== ./index.d.ts (1 errors) ==== + export type {Row2} from './common'; + ~~~~ +!!! error TS2300: Duplicate identifier 'Row2'. +!!! related TS6203 a.d.ts:3:8: 'Row2' was also declared here. + +==== ./common.d.ts (0 errors) ==== + export interface Row2 {} \ No newline at end of file diff --git a/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.js b/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.js new file mode 100644 index 00000000000..b19a757e49c --- /dev/null +++ b/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/mergeSymbolReexportedTypeAliasInstantiation.ts] //// + +//// [main.ts] +import {Row2, C} from '.' +const x: ((rowData: Row2) => unknown) = (rowData: Row2) => (null) +const y : C = { s: '' } + +//// [a.d.ts] +import '.' +declare module '.' { + type Row2 = {} + type C = { s : string } +} + +//// [index.d.ts] +export type {Row2} from './common'; + +//// [common.d.ts] +export interface Row2 {} + +//// [main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var x = function (rowData) { return (null); }; +var y = { s: '' }; diff --git a/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.symbols b/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.symbols new file mode 100644 index 00000000000..e76794961a9 --- /dev/null +++ b/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.symbols @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/mergeSymbolReexportedTypeAliasInstantiation.ts] //// + +=== main.ts === +import {Row2, C} from '.' +>Row2 : Symbol(Row2, Decl(main.ts, 0, 8)) +>C : Symbol(C, Decl(main.ts, 0, 13)) + +const x: ((rowData: Row2) => unknown) = (rowData: Row2) => (null) +>x : Symbol(x, Decl(main.ts, 1, 5)) +>rowData : Symbol(rowData, Decl(main.ts, 1, 11)) +>Row2 : Symbol(Row2, Decl(main.ts, 0, 8)) +>rowData : Symbol(rowData, Decl(main.ts, 1, 49)) +>Row2 : Symbol(Row2, Decl(main.ts, 0, 8)) + +const y : C = { s: '' } +>y : Symbol(y, Decl(main.ts, 2, 5)) +>C : Symbol(C, Decl(main.ts, 0, 13)) +>s : Symbol(s, Decl(main.ts, 2, 15)) + +=== ./a.d.ts === +import '.' +declare module '.' { +>'.' : Symbol("index", Decl(index.d.ts, 0, 0), Decl(a.d.ts, 0, 10)) + + type Row2 = {} +>Row2 : Symbol(Row2, Decl(a.d.ts, 1, 20)) +>T : Symbol(T, Decl(a.d.ts, 2, 12)) + + type C = { s : string } +>C : Symbol(C, Decl(a.d.ts, 2, 19)) +>s : Symbol(s, Decl(a.d.ts, 3, 12)) +} + +=== ./index.d.ts === +export type {Row2} from './common'; +>Row2 : Symbol(Row2, Decl(index.d.ts, 0, 13)) + +=== ./common.d.ts === +export interface Row2 {} +>Row2 : Symbol(Row2, Decl(common.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.types b/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.types new file mode 100644 index 00000000000..1f50660ed7e --- /dev/null +++ b/tests/baselines/reference/mergeSymbolReexportedTypeAliasInstantiation.types @@ -0,0 +1,56 @@ +//// [tests/cases/compiler/mergeSymbolReexportedTypeAliasInstantiation.ts] //// + +=== main.ts === +import {Row2, C} from '.' +>Row2 : any +> : ^^^ +>C : any +> : ^^^ + +const x: ((rowData: Row2) => unknown) = (rowData: Row2) => (null) +>x : (rowData: Row2) => unknown +> : ^ ^^ ^^^^^ +>rowData : Row2 +> : ^^^^^^^^^^^^ +>(rowData: Row2) => (null) : (rowData: Row2) => any +> : ^ ^^ ^^^^^^^^ +>rowData : Row2 +> : ^^^^^^^^^ +>(null) : null +> : ^^^^ + +const y : C = { s: '' } +>y : C +> : ^ +>{ s: '' } : { s: string; } +> : ^^^^^^^^^^^^^^ +>s : string +> : ^^^^^^ +>'' : "" +> : ^^ + +=== ./a.d.ts === +import '.' +declare module '.' { +>'.' : typeof import("index") +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + type Row2 = {} +>Row2 : Row2 +> : ^^^^^^^ + + type C = { s : string } +>C : C +> : ^ +>s : string +> : ^^^^^^ +} + +=== ./index.d.ts === +export type {Row2} from './common'; +>Row2 : import("common").Row2 +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +=== ./common.d.ts === + +export interface Row2 {} diff --git a/tests/baselines/reference/mergeSymbolRexportFunction.errors.txt b/tests/baselines/reference/mergeSymbolRexportFunction.errors.txt new file mode 100644 index 00000000000..64432d15be0 --- /dev/null +++ b/tests/baselines/reference/mergeSymbolRexportFunction.errors.txt @@ -0,0 +1,25 @@ +a.d.ts(3,9): error TS2451: Cannot redeclare block-scoped variable 'Row'. +index.d.ts(1,14): error TS2451: Cannot redeclare block-scoped variable 'Row'. + + +==== main.ts (0 errors) ==== + import {Row} from '.' + Row(); + +==== ./a.d.ts (1 errors) ==== + import '.' + declare module '.' { + const Row: () => void; + ~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'Row'. +!!! related TS6203 index.d.ts:1:14: 'Row' was also declared here. + } + +==== ./index.d.ts (1 errors) ==== + export type {Row} from './common'; + ~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'Row'. +!!! related TS6203 a.d.ts:3:9: 'Row' was also declared here. + +==== ./common.d.ts (0 errors) ==== + export declare function Row(): void; \ No newline at end of file diff --git a/tests/baselines/reference/mergeSymbolRexportFunction.js b/tests/baselines/reference/mergeSymbolRexportFunction.js new file mode 100644 index 00000000000..ee7ba6b6cce --- /dev/null +++ b/tests/baselines/reference/mergeSymbolRexportFunction.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/mergeSymbolRexportFunction.ts] //// + +//// [main.ts] +import {Row} from '.' +Row(); + +//// [a.d.ts] +import '.' +declare module '.' { + const Row: () => void; +} + +//// [index.d.ts] +export type {Row} from './common'; + +//// [common.d.ts] +export declare function Row(): void; + +//// [main.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _1 = require("."); +(0, _1.Row)(); diff --git a/tests/baselines/reference/mergeSymbolRexportFunction.symbols b/tests/baselines/reference/mergeSymbolRexportFunction.symbols new file mode 100644 index 00000000000..3db7ac7a447 --- /dev/null +++ b/tests/baselines/reference/mergeSymbolRexportFunction.symbols @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/mergeSymbolRexportFunction.ts] //// + +=== main.ts === +import {Row} from '.' +>Row : Symbol(Row, Decl(main.ts, 0, 8)) + +Row(); +>Row : Symbol(Row, Decl(main.ts, 0, 8)) + +=== ./a.d.ts === +import '.' +declare module '.' { +>'.' : Symbol("index", Decl(index.d.ts, 0, 0), Decl(a.d.ts, 0, 10)) + + const Row: () => void; +>Row : Symbol(Row, Decl(a.d.ts, 2, 7)) +} + +=== ./index.d.ts === +export type {Row} from './common'; +>Row : Symbol(Row, Decl(index.d.ts, 0, 13)) + +=== ./common.d.ts === +export declare function Row(): void; +>Row : Symbol(Row, Decl(common.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/mergeSymbolRexportFunction.types b/tests/baselines/reference/mergeSymbolRexportFunction.types new file mode 100644 index 00000000000..4ca9dd96da3 --- /dev/null +++ b/tests/baselines/reference/mergeSymbolRexportFunction.types @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/mergeSymbolRexportFunction.ts] //// + +=== main.ts === +import {Row} from '.' +>Row : () => void +> : ^^^^^^ + +Row(); +>Row() : void +> : ^^^^ +>Row : () => void +> : ^^^^^^ + +=== ./a.d.ts === +import '.' +declare module '.' { +>'.' : typeof import("index") +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + const Row: () => void; +>Row : () => void +> : ^^^^^^ +} + +=== ./index.d.ts === +export type {Row} from './common'; +>Row : any +> : ^^^ + +=== ./common.d.ts === +export declare function Row(): void; +>Row : () => void +> : ^^^^^^ + diff --git a/tests/baselines/reference/umdGlobalAugmentationNoCrash.errors.txt b/tests/baselines/reference/umdGlobalAugmentationNoCrash.errors.txt new file mode 100644 index 00000000000..83eeb6fdec2 --- /dev/null +++ b/tests/baselines/reference/umdGlobalAugmentationNoCrash.errors.txt @@ -0,0 +1,28 @@ +global.d.ts(2,11): error TS2451: Cannot redeclare block-scoped variable 'React'. +module.d.ts(1,21): error TS2451: Cannot redeclare block-scoped variable 'React'. + + +==== global.d.ts (1 errors) ==== + declare global { + const React: typeof import("./module"); + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'React'. +!!! related TS6203 module.d.ts:1:21: 'React' was also declared here. + } + export {}; + +==== module.d.ts (1 errors) ==== + export as namespace React; + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'React'. +!!! related TS6203 global.d.ts:2:11: 'React' was also declared here. + export function foo(): string; + +==== some_module.ts (0 errors) ==== + export {} + React.foo; + +==== emits.ts (0 errors) ==== + console.log("hello"); + React.foo; + \ No newline at end of file diff --git a/tests/baselines/reference/umdGlobalAugmentationNoCrash.symbols b/tests/baselines/reference/umdGlobalAugmentationNoCrash.symbols index 30b2c1a60e6..05b3b6bc86d 100644 --- a/tests/baselines/reference/umdGlobalAugmentationNoCrash.symbols +++ b/tests/baselines/reference/umdGlobalAugmentationNoCrash.symbols @@ -5,7 +5,7 @@ declare global { >global : Symbol(global, Decl(global.d.ts, 0, 0)) const React: typeof import("./module"); ->React : Symbol(React, Decl(module.d.ts, 0, 0), Decl(global.d.ts, 1, 9)) +>React : Symbol(React, Decl(global.d.ts, 1, 9)) } export {}; @@ -20,7 +20,7 @@ export function foo(): string; export {} React.foo; >React.foo : Symbol(foo, Decl(module.d.ts, 0, 26)) ->React : Symbol(React, Decl(module.d.ts, 0, 0), Decl(global.d.ts, 1, 9)) +>React : Symbol(React, Decl(global.d.ts, 1, 9)) >foo : Symbol(foo, Decl(module.d.ts, 0, 26)) === emits.ts === @@ -31,6 +31,6 @@ console.log("hello"); React.foo; >React.foo : Symbol(foo, Decl(module.d.ts, 0, 26)) ->React : Symbol(React, Decl(module.d.ts, 0, 0), Decl(global.d.ts, 1, 9)) +>React : Symbol(React, Decl(global.d.ts, 1, 9)) >foo : Symbol(foo, Decl(module.d.ts, 0, 26)) diff --git a/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.errors.txt b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.errors.txt new file mode 100644 index 00000000000..66096c90798 --- /dev/null +++ b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.errors.txt @@ -0,0 +1,32 @@ +global.d.ts(2,11): error TS2451: Cannot redeclare block-scoped variable 'React'. +module.d.ts(2,21): error TS2451: Cannot redeclare block-scoped variable 'React'. + + +==== global.d.ts (1 errors) ==== + declare global { + const React: typeof import("./module"); + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'React'. +!!! related TS6203 module.d.ts:2:21: 'React' was also declared here. + } + + export { }; + +==== module.d.ts (1 errors) ==== + export = React; + export as namespace React; + ~~~~~ +!!! error TS2451: Cannot redeclare block-scoped variable 'React'. +!!! related TS6203 global.d.ts:2:11: 'React' was also declared here. + + declare namespace React { + function createRef(): any; + } + +==== some_module.ts (0 errors) ==== + export { }; + React.createRef; + +==== emits.ts (0 errors) ==== + console.log("hello"); + React.createRef; \ No newline at end of file diff --git a/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.symbols b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.symbols index a7dea80369b..557e82ac383 100644 --- a/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.symbols +++ b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.symbols @@ -5,20 +5,20 @@ declare global { >global : Symbol(global, Decl(global.d.ts, 0, 0)) const React: typeof import("./module"); ->React : Symbol(React, Decl(module.d.ts, 1, 26), Decl(global.d.ts, 1, 9)) +>React : Symbol(React, Decl(global.d.ts, 1, 9)) } export { }; === module.d.ts === export = React; ->React : Symbol(React, Decl(module.d.ts, 1, 26), Decl(global.d.ts, 1, 9)) +>React : Symbol(React, Decl(module.d.ts, 1, 26)) export as namespace React; >React : Symbol(React, Decl(module.d.ts, 0, 15)) declare namespace React { ->React : Symbol(React, Decl(module.d.ts, 1, 26), Decl(global.d.ts, 1, 9)) +>React : Symbol(React, Decl(module.d.ts, 1, 26)) function createRef(): any; >createRef : Symbol(createRef, Decl(module.d.ts, 3, 25)) @@ -28,7 +28,7 @@ declare namespace React { export { }; React.createRef; >React.createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25)) ->React : Symbol(React, Decl(module.d.ts, 1, 26), Decl(global.d.ts, 1, 9)) +>React : Symbol(React, Decl(global.d.ts, 1, 9)) >createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25)) === emits.ts === @@ -39,6 +39,6 @@ console.log("hello"); React.createRef; >React.createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25)) ->React : Symbol(React, Decl(module.d.ts, 1, 26), Decl(global.d.ts, 1, 9)) +>React : Symbol(React, Decl(global.d.ts, 1, 9)) >createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25)) diff --git a/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types index 0d557d01cd0..a9284f0a4c1 100644 --- a/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types +++ b/tests/baselines/reference/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.types @@ -6,8 +6,8 @@ declare global { > : ^^^^^^^^^^^^^ const React: typeof import("./module"); ->React : typeof React -> : ^^^^^^^^^^^^ +>React : typeof import("module") +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ } export { }; @@ -18,8 +18,8 @@ export = React; > : ^^^^^^^^^^^^ export as namespace React; ->React : typeof import("module") -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>React : typeof React +> : ^^^^^^^^^^^^ declare namespace React { >React : typeof React @@ -35,8 +35,8 @@ export { }; React.createRef; >React.createRef : () => any > : ^^^^^^ ->React : typeof React -> : ^^^^^^^^^^^^ +>React : typeof import("module") +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >createRef : () => any > : ^^^^^^ @@ -56,8 +56,8 @@ console.log("hello"); React.createRef; >React.createRef : () => any > : ^^^^^^ ->React : typeof React -> : ^^^^^^^^^^^^ +>React : typeof import("module") +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >createRef : () => any > : ^^^^^^ diff --git a/tests/cases/compiler/mergeSymbolReexportInterface.ts b/tests/cases/compiler/mergeSymbolReexportInterface.ts new file mode 100644 index 00000000000..184e82eae80 --- /dev/null +++ b/tests/cases/compiler/mergeSymbolReexportInterface.ts @@ -0,0 +1,20 @@ +// @moduleResolution: node + +// @filename: main.ts +import {Row2, C} from '.' +const x : Row2 = { } +const y : C = { s: '' } + + +// @filename: ./a.d.ts +import '.' +declare module '.' { + type Row2 = { a: string } + type C = { s : string } +} + +// @filename: ./index.d.ts +export type {Row2} from './common'; + +// @filename: ./common.d.ts +export interface Row2 { b: string } \ No newline at end of file diff --git a/tests/cases/compiler/mergeSymbolReexportedTypeAliasInstantiation.ts b/tests/cases/compiler/mergeSymbolReexportedTypeAliasInstantiation.ts new file mode 100644 index 00000000000..2cee6fd8df6 --- /dev/null +++ b/tests/cases/compiler/mergeSymbolReexportedTypeAliasInstantiation.ts @@ -0,0 +1,19 @@ +// @moduleResolution: node + +// @filename: main.ts +import {Row2, C} from '.' +const x: ((rowData: Row2) => unknown) = (rowData: Row2) => (null) +const y : C = { s: '' } + +// @filename: ./a.d.ts +import '.' +declare module '.' { + type Row2 = {} + type C = { s : string } +} + +// @filename: ./index.d.ts +export type {Row2} from './common'; + +// @filename: ./common.d.ts +export interface Row2 {} \ No newline at end of file diff --git a/tests/cases/compiler/mergeSymbolRexportFunction.ts b/tests/cases/compiler/mergeSymbolRexportFunction.ts new file mode 100644 index 00000000000..1721970bc08 --- /dev/null +++ b/tests/cases/compiler/mergeSymbolRexportFunction.ts @@ -0,0 +1,17 @@ +// @moduleResolution: node + +// @filename: main.ts +import {Row} from '.' +Row(); + +// @filename: ./a.d.ts +import '.' +declare module '.' { + const Row: () => void; +} + +// @filename: ./index.d.ts +export type {Row} from './common'; + +// @filename: ./common.d.ts +export declare function Row(): void; \ No newline at end of file diff --git a/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts b/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts index e8da0586717..336f9398ed2 100644 --- a/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts +++ b/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts @@ -38,4 +38,4 @@ //// "files": ["/src/index.ts", "typings/global.d.ts"] ////} -verify.baselineFindAllReferences('0', '1', '2') +verify.baselineFindAllReferences('0', '1', '2', '3'); diff --git a/tests/cases/fourslash/moduleReexportedIntoGlobalQuickInfo.ts b/tests/cases/fourslash/moduleReexportedIntoGlobalQuickInfo.ts index 8f00a71f5ac..e48eb6c3c32 100644 --- a/tests/cases/fourslash/moduleReexportedIntoGlobalQuickInfo.ts +++ b/tests/cases/fourslash/moduleReexportedIntoGlobalQuickInfo.ts @@ -12,5 +12,4 @@ // @Filename: /index.ts ////let v = new /*1*/THREE.Vector3(); -verify.quickInfoAt("1", `module THREE -var THREE: typeof import("/node_modules/@types/three/index")`); +verify.quickInfoAt("1", `const THREE: typeof import("/node_modules/@types/three/index")`);