fix53287 mergeSymbol checks if the resolved target can merge with the source (#58326)

This commit is contained in:
Isabel Duan
2024-05-23 17:30:13 -07:00
committed by GitHub
parent abc37af88d
commit cffc425ad7
36 changed files with 764 additions and 206 deletions
+16 -3
View File
@@ -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) {
@@ -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) ====
@@ -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))
@@ -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")
> : ^^^^^^^^^^^^^^^^^^^^^^
@@ -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<any>;
~~~~~
!!! 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<T>(factory: () => T, deps: undefined): T;
}
==== /node_modules/preact/index.d.ts (0 errors) ====
export as namespace preact;
export interface VNode<P = {}> {}
==== /index.tsx (0 errors) ====
import FullCalendar from "@fullcalendar/react";
import { EventInput } from "@fullcalendar/core";
@@ -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<any>;
>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<T>(factory: () => T, deps: undefined): T;
>useMemo : Symbol(useMemo, Decl(index.d.ts, 3, 25))
@@ -39,7 +39,8 @@ declare global {
namespace FullCalendarVDom {
type VNode = preact.VNode<any>;
>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<T>(factory: () => T, deps: undefined): T;
>useMemo : <T>(factory: () => T, deps: undefined) => T
@@ -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;
@@ -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 ===
@@ -18,10 +18,10 @@ declare global {
> : ^^^^^^^^^^^^^
const foo: typeof foo;
>foo : Root
> : ^^^^
>foo : Root
> : ^^^^
>foo : any
> : ^^^
>foo : any
> : ^^^
}
=== foo.d.ts ===
@@ -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.
}
@@ -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))
@@ -36,6 +36,6 @@ declare namespace exports {
> : ^^^^^^^^^^^^^^
export { Sub };
>Sub : typeof import("input").Sub
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
>Sub : typeof Sub
> : ^^^^^^^^^^
}
@@ -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"
}
]
}
@@ -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 }
@@ -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: '' };
@@ -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))
@@ -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
> : ^^^^^^
@@ -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<string>) => unknown) = (rowData: Row2<any>) => (null)
const y : C = { s: '' }
==== ./a.d.ts (1 errors) ====
import '.'
declare module '.' {
type Row2<T> = {}
~~~~
!!! 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 {}
@@ -0,0 +1,25 @@
//// [tests/cases/compiler/mergeSymbolReexportedTypeAliasInstantiation.ts] ////
//// [main.ts]
import {Row2, C} from '.'
const x: ((rowData: Row2<string>) => unknown) = (rowData: Row2<any>) => (null)
const y : C = { s: '' }
//// [a.d.ts]
import '.'
declare module '.' {
type Row2<T> = {}
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: '' };
@@ -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<string>) => unknown) = (rowData: Row2<any>) => (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<T> = {}
>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))
@@ -0,0 +1,56 @@
//// [tests/cases/compiler/mergeSymbolReexportedTypeAliasInstantiation.ts] ////
=== main.ts ===
import {Row2, C} from '.'
>Row2 : any
> : ^^^
>C : any
> : ^^^
const x: ((rowData: Row2<string>) => unknown) = (rowData: Row2<any>) => (null)
>x : (rowData: Row2<string>) => unknown
> : ^ ^^ ^^^^^
>rowData : Row2<string>
> : ^^^^^^^^^^^^
>(rowData: Row2<any>) => (null) : (rowData: Row2<any>) => any
> : ^ ^^ ^^^^^^^^
>rowData : Row2<any>
> : ^^^^^^^^^
>(null) : null
> : ^^^^
const y : C = { s: '' }
>y : C
> : ^
>{ s: '' } : { s: string; }
> : ^^^^^^^^^^^^^^
>s : string
> : ^^^^^^
>'' : ""
> : ^^
=== ./a.d.ts ===
import '.'
declare module '.' {
>'.' : typeof import("index")
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
type Row2<T> = {}
>Row2 : Row2<T>
> : ^^^^^^^
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 {}
@@ -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;
@@ -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)();
@@ -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))
@@ -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
> : ^^^^^^
@@ -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;
@@ -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))
@@ -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;
@@ -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))
@@ -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
> : ^^^^^^
@@ -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 }
@@ -0,0 +1,19 @@
// @moduleResolution: node
// @filename: main.ts
import {Row2, C} from '.'
const x: ((rowData: Row2<string>) => unknown) = (rowData: Row2<any>) => (null)
const y : C = { s: '' }
// @filename: ./a.d.ts
import '.'
declare module '.' {
type Row2<T> = {}
type C = { s : string }
}
// @filename: ./index.d.ts
export type {Row2} from './common';
// @filename: ./common.d.ts
export interface Row2 {}
@@ -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;
@@ -38,4 +38,4 @@
//// "files": ["/src/index.ts", "typings/global.d.ts"]
////}
verify.baselineFindAllReferences('0', '1', '2')
verify.baselineFindAllReferences('0', '1', '2', '3');
@@ -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")`);