Compare commits
4 commits
main
...
disallow-g
Author | SHA1 | Date | |
---|---|---|---|
|
98df06dde8 | ||
|
d087db57e9 | ||
|
7e97680ff1 | ||
|
7631501256 |
|
@ -1026,7 +1026,8 @@ namespace ts {
|
|||
* If target is not transient, mergeSymbol will produce a transient clone, mutate that and return it.
|
||||
*/
|
||||
function mergeSymbol(target: Symbol, source: Symbol, unidirectional = false): Symbol {
|
||||
if (!(target.flags & getExcludedSymbolFlags(source.flags)) ||
|
||||
const resolvedTarget = resolveSymbol(target);
|
||||
if (!(resolvedTarget.flags & getExcludedSymbolFlags(source.flags)) ||
|
||||
(source.flags | target.flags) & SymbolFlags.Assignment) {
|
||||
if (source === target) {
|
||||
// This can happen when an export assigned namespace exports something also erroneously exported at the top level
|
||||
|
@ -1034,7 +1035,6 @@ namespace ts {
|
|||
return target;
|
||||
}
|
||||
if (!(target.flags & SymbolFlags.Transient)) {
|
||||
const resolvedTarget = resolveSymbol(target);
|
||||
if (resolvedTarget === unknownSymbol) {
|
||||
return source;
|
||||
}
|
||||
|
@ -7268,10 +7268,6 @@ namespace ts {
|
|||
|
||||
// Handle variable, parameter or property
|
||||
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
|
||||
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
||||
if (symbol.flags & SymbolFlags.ValueModule && !(symbol.flags & SymbolFlags.Assignment)) {
|
||||
return getTypeOfFuncClassEnumModule(symbol);
|
||||
}
|
||||
return reportCircularityError(symbol);
|
||||
}
|
||||
let type: Type | undefined;
|
||||
|
@ -7338,10 +7334,6 @@ namespace ts {
|
|||
}
|
||||
|
||||
if (!popTypeResolution()) {
|
||||
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
||||
if (symbol.flags & SymbolFlags.ValueModule && !(symbol.flags & SymbolFlags.Assignment)) {
|
||||
return getTypeOfFuncClassEnumModule(symbol);
|
||||
}
|
||||
return reportCircularityError(symbol);
|
||||
}
|
||||
return type;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
tests/cases/compiler/global.d.ts(6,16): error TS2403: Subsequent variable declarations must have the same type. Variable 'THREE' must be of type 'typeof import("tests/cases/compiler/global")', but here has type 'typeof import("tests/cases/compiler/three")'.
|
||||
tests/cases/compiler/global.d.ts(3,21): error TS2451: Cannot redeclare block-scoped variable 'THREE'.
|
||||
tests/cases/compiler/global.d.ts(6,16): error TS2451: Cannot redeclare block-scoped variable 'THREE'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/three.d.ts (0 errors) ====
|
||||
|
@ -6,16 +7,19 @@ tests/cases/compiler/global.d.ts(6,16): error TS2403: Subsequent variable declar
|
|||
export class Vector2 {}
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/global.d.ts (1 errors) ====
|
||||
==== tests/cases/compiler/global.d.ts (2 errors) ====
|
||||
import * as _three from './three';
|
||||
|
||||
export as namespace THREE;
|
||||
~~~~~
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'THREE'.
|
||||
!!! related TS6203 tests/cases/compiler/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("tests/cases/compiler/global")', but here has type 'typeof import("tests/cases/compiler/three")'.
|
||||
!!! related TS6203 tests/cases/compiler/global.d.ts:1:1: 'THREE' was also declared here.
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'THREE'.
|
||||
!!! related TS6203 tests/cases/compiler/global.d.ts:3:1: 'THREE' was also declared here.
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/test.ts (0 errors) ====
|
||||
|
|
|
@ -17,12 +17,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))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/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, 0, 34))
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@ declare global {
|
|||
>global : typeof global
|
||||
|
||||
export const THREE: typeof _three;
|
||||
>THREE : typeof import("tests/cases/compiler/global")
|
||||
>THREE : typeof _three
|
||||
>_three : typeof _three
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/test.ts ===
|
||||
const m = THREE
|
||||
>m : typeof import("tests/cases/compiler/global")
|
||||
>THREE : typeof import("tests/cases/compiler/global")
|
||||
>m : typeof THREE
|
||||
>THREE : typeof THREE
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
tests/cases/compiler/input.ts(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||
tests/cases/compiler/input.ts(6,14): error TS2323: Cannot redeclare exported variable 'Sub'.
|
||||
tests/cases/compiler/input.ts(6,14): error TS2300: Duplicate identifier 'Sub'.
|
||||
tests/cases/compiler/input.ts(12,14): error TS2300: Duplicate identifier 'Sub'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/input.ts (2 errors) ====
|
||||
==== tests/cases/compiler/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 @@ tests/cases/compiler/input.ts(6,14): error TS2323: Cannot redeclare exported var
|
|||
}
|
||||
export class Sub {
|
||||
~~~
|
||||
!!! error TS2323: Cannot redeclare exported variable 'Sub'.
|
||||
!!! error TS2300: Duplicate identifier 'Sub'.
|
||||
!!! related TS6203 tests/cases/compiler/input.ts:12:14: 'Sub' was also declared here.
|
||||
instance!: {
|
||||
t: number;
|
||||
};
|
||||
}
|
||||
declare namespace exports {
|
||||
export { Sub };
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'Sub'.
|
||||
!!! related TS6203 tests/cases/compiler/input.ts:6:14: 'Sub' was also declared here.
|
||||
}
|
|
@ -12,7 +12,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))
|
||||
|
@ -26,5 +26,5 @@ declare namespace exports {
|
|||
>exports : Symbol(exports, Decl(input.ts, 0, 17), Decl(input.ts, 9, 1))
|
||||
|
||||
export { Sub };
|
||||
>Sub : Symbol(exports.Sub, Decl(input.ts, 11, 12))
|
||||
>Sub : Symbol(Sub, Decl(input.ts, 11, 12))
|
||||
}
|
||||
|
|
|
@ -26,5 +26,5 @@ declare namespace exports {
|
|||
>exports : typeof exports
|
||||
|
||||
export { Sub };
|
||||
>Sub : typeof import("tests/cases/compiler/input").Sub
|
||||
>Sub : typeof Sub
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
in1.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
||||
in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
||||
in2.d.ts(1,1): error TS2440: Import declaration conflicts with local declaration of 'A'.
|
||||
|
||||
|
||||
==== decl.d.ts (0 errors) ====
|
||||
|
@ -15,13 +14,9 @@ in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
|||
class MyClass{ }
|
||||
}
|
||||
}
|
||||
==== in1.d.ts (1 errors) ====
|
||||
==== in1.d.ts (0 errors) ====
|
||||
import a = A;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
!!! related TS6203 in2.d.ts:1:8: 'a' was also declared here.
|
||||
==== in2.d.ts (1 errors) ====
|
||||
import a = A;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
!!! related TS6203 in1.d.ts:1:8: 'a' was also declared here.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2440: Import declaration conflicts with local declaration of 'A'.
|
|
@ -1,5 +1,4 @@
|
|||
in1.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
||||
in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
||||
in2.d.ts(1,1): error TS2440: Import declaration conflicts with local declaration of 'A'.
|
||||
|
||||
|
||||
==== decl.d.ts (0 errors) ====
|
||||
|
@ -15,13 +14,9 @@ in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.
|
|||
class MyClass{ }
|
||||
}
|
||||
}
|
||||
==== in1.d.ts (1 errors) ====
|
||||
==== in1.d.ts (0 errors) ====
|
||||
import a = A;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
!!! related TS6203 in2.d.ts:1:8: 'a' was also declared here.
|
||||
==== in2.d.ts (1 errors) ====
|
||||
import a = A;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
!!! related TS6203 in1.d.ts:1:8: 'a' was also declared here.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2440: Import declaration conflicts with local declaration of 'A'.
|
|
@ -0,0 +1,31 @@
|
|||
tests/cases/compiler/global.d.ts(2,11): error TS2451: Cannot redeclare block-scoped variable 'React'.
|
||||
tests/cases/compiler/module.d.ts(1,21): error TS2451: Cannot redeclare block-scoped variable 'React'.
|
||||
tests/cases/compiler/some_module.ts(2,1): error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.
|
||||
|
||||
|
||||
==== tests/cases/compiler/global.d.ts (1 errors) ====
|
||||
declare global {
|
||||
const React: typeof import("./module");
|
||||
~~~~~
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'React'.
|
||||
!!! related TS6203 /.src/tests/cases/compiler/module.d.ts:1:21: 'React' was also declared here.
|
||||
}
|
||||
export {};
|
||||
|
||||
==== tests/cases/compiler/module.d.ts (1 errors) ====
|
||||
export as namespace React;
|
||||
~~~~~
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'React'.
|
||||
!!! related TS6203 tests/cases/compiler/global.d.ts:2:11: 'React' was also declared here.
|
||||
export function foo(): string;
|
||||
|
||||
==== tests/cases/compiler/some_module.ts (1 errors) ====
|
||||
export {}
|
||||
React.foo;
|
||||
~~~~~
|
||||
!!! error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.
|
||||
|
||||
==== tests/cases/compiler/emits.ts (0 errors) ====
|
||||
console.log("hello");
|
||||
React.foo;
|
||||
|
|
@ -3,7 +3,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 {};
|
||||
|
||||
|
@ -18,7 +18,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(module.d.ts, 0, 0))
|
||||
>foo : Symbol(foo, Decl(module.d.ts, 0, 26))
|
||||
|
||||
=== tests/cases/compiler/emits.ts ===
|
||||
|
@ -28,7 +28,7 @@ console.log("hello");
|
|||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
|
||||
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))
|
||||
>foo : Symbol(foo, Decl(module.d.ts, 0, 26))
|
||||
>React.foo : Symbol(React.foo, Decl(module.d.ts, 0, 26))
|
||||
>React : Symbol(React, Decl(module.d.ts, 0, 0))
|
||||
>foo : Symbol(React.foo, Decl(module.d.ts, 0, 26))
|
||||
|
||||
|
|
|
@ -31,6 +31,6 @@ console.log("hello");
|
|||
|
||||
React.foo;
|
||||
>React.foo : () => string
|
||||
>React : typeof import("tests/cases/compiler/module")
|
||||
>React : typeof React
|
||||
>foo : () => string
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
tests/cases/compiler/global.d.ts(2,11): error TS2451: Cannot redeclare block-scoped variable 'React'.
|
||||
tests/cases/compiler/module.d.ts(2,21): error TS2451: Cannot redeclare block-scoped variable 'React'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/global.d.ts (1 errors) ====
|
||||
declare global {
|
||||
const React: typeof import("./module");
|
||||
~~~~~
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'React'.
|
||||
!!! related TS6203 /.src/tests/cases/compiler/module.d.ts:2:21: 'React' was also declared here.
|
||||
}
|
||||
|
||||
export { };
|
||||
|
||||
==== tests/cases/compiler/module.d.ts (1 errors) ====
|
||||
export = React;
|
||||
export as namespace React;
|
||||
~~~~~
|
||||
!!! error TS2451: Cannot redeclare block-scoped variable 'React'.
|
||||
!!! related TS6203 tests/cases/compiler/global.d.ts:2:11: 'React' was also declared here.
|
||||
|
||||
declare namespace React {
|
||||
function createRef(): any;
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/some_module.ts (0 errors) ====
|
||||
export { };
|
||||
React.createRef;
|
||||
|
||||
==== tests/cases/compiler/emits.ts (0 errors) ====
|
||||
console.log("hello");
|
||||
React.createRef;
|
||||
|
|
@ -21,7 +21,8 @@ React.createRef;
|
|||
|
||||
//// [emits.ts]
|
||||
console.log("hello");
|
||||
React.createRef;
|
||||
React.createRef;
|
||||
|
||||
|
||||
//// [some_module.js]
|
||||
React.createRef;
|
||||
|
|
|
@ -3,7 +3,7 @@ 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 { };
|
||||
|
@ -16,7 +16,7 @@ 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))
|
||||
|
@ -26,7 +26,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(module.d.ts, 0, 15))
|
||||
>createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25))
|
||||
|
||||
=== tests/cases/compiler/emits.ts ===
|
||||
|
@ -37,6 +37,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(module.d.ts, 0, 15))
|
||||
>createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25))
|
||||
|
||||
|
|
|
@ -3,17 +3,17 @@ declare global {
|
|||
>global : typeof global
|
||||
|
||||
const React: typeof import("./module");
|
||||
>React : typeof React
|
||||
>React : typeof import("tests/cases/compiler/module")
|
||||
}
|
||||
|
||||
export { };
|
||||
|
||||
=== tests/cases/compiler/module.d.ts ===
|
||||
export = React;
|
||||
>React : typeof import("tests/cases/compiler/module")
|
||||
>React : typeof React
|
||||
|
||||
export as namespace React;
|
||||
>React : typeof import("tests/cases/compiler/module")
|
||||
>React : typeof React
|
||||
|
||||
declare namespace React {
|
||||
>React : typeof React
|
||||
|
@ -26,7 +26,7 @@ declare namespace React {
|
|||
export { };
|
||||
React.createRef;
|
||||
>React.createRef : () => any
|
||||
>React : typeof React
|
||||
>React : typeof import("tests/cases/compiler/module")
|
||||
>createRef : () => any
|
||||
|
||||
=== tests/cases/compiler/emits.ts ===
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// @strict: true
|
||||
// @allowUmdGlobalAccess: true
|
||||
// @module: esnext
|
||||
// @moduleResolution: node
|
||||
// @target: es2018
|
||||
|
@ -23,4 +24,4 @@ React.createRef;
|
|||
|
||||
// @filename: emits.ts
|
||||
console.log("hello");
|
||||
React.createRef;
|
||||
React.createRef;
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /node_modules/@types/three/three-core.d.ts
|
||||
////export class Vector3 {
|
||||
//// constructor(x?: number, y?: number, z?: number);
|
||||
//// x: number;
|
||||
//// y: number;
|
||||
////}
|
||||
|
||||
// @Filename: /node_modules/@types/three/index.d.ts
|
||||
////export * from "./three-core";
|
||||
////[|export as namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}THREE|];|]
|
||||
|
||||
// @Filename: /typings/global.d.ts
|
||||
////[|import * as _THREE from '[|{| "contextRangeIndex": 2 |}three|]';|]
|
||||
////declare global {
|
||||
//// [|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}THREE|]: typeof _THREE;|]
|
||||
////}
|
||||
|
||||
// @Filename: /src/index.ts
|
||||
////export const a = {};
|
||||
////let v = new [|THREE|].Vector2();
|
||||
|
||||
// @Filename: /tsconfig.json
|
||||
////{
|
||||
//// "compilerOptions": {
|
||||
//// "esModuleInterop": true,
|
||||
//// "outDir": "./build/js/",
|
||||
//// "noImplicitAny": true,
|
||||
//// "module": "es6",
|
||||
//// "target": "es6",
|
||||
//// "allowJs": true,
|
||||
//// "skipLibCheck": true,
|
||||
//// "lib": ["es2016", "dom"],
|
||||
//// "typeRoots": ["node_modules/@types/"],
|
||||
//// "types": ["three"]
|
||||
//// },
|
||||
//// "files": ["/src/index.ts", "typings/global.d.ts"]
|
||||
////}
|
||||
|
||||
const [r0Def, r0, r1Def, r1, r2Def, ...rest] = test.ranges();
|
||||
verify.singleReferenceGroup(`module THREE
|
||||
var THREE: typeof import("/node_modules/@types/three/index")`, [r0, r1, ...rest]);
|
|
@ -1,16 +0,0 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: /node_modules/@types/three/index.d.ts
|
||||
////export class Vector3 {}
|
||||
////export as namespace THREE;
|
||||
// @Filename: /global.d.ts
|
||||
////import * as _THREE from 'three';
|
||||
////
|
||||
////declare global {
|
||||
//// const THREE: typeof _THREE;
|
||||
////}
|
||||
// @Filename: /index.ts
|
||||
////let v = new /*1*/THREE.Vector3();
|
||||
|
||||
verify.quickInfoAt("1", `module THREE
|
||||
var THREE: typeof import("/node_modules/@types/three/index")`);
|
Loading…
Reference in a new issue