Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5426,6 +5426,10 @@ 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) {
return getTypeOfFuncClassEnumModule(symbol);
}
return errorType;
}
let type: Type | undefined;
Expand Down Expand Up @@ -5481,6 +5485,10 @@ 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) {
return getTypeOfFuncClassEnumModule(symbol);
}
type = reportCircularityError(symbol);
}
return type;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//// [tests/cases/compiler/umdNamespaceMergedWithGlobalAugmentationIsNotCircular.ts] ////

//// [global.d.ts]
declare global {
const React: typeof import("./module");
}

export { };

//// [module.d.ts]
export = React;
export as namespace React;

declare namespace React {
function createRef(): any;
}

//// [some_module.ts]
export { };
React.createRef;

//// [emits.ts]
console.log("hello");
React.createRef;

//// [some_module.js]
React.createRef;
//// [emits.js]
"use strict";
console.log("hello");
React.createRef;
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
=== tests/cases/compiler/global.d.ts ===
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))
}

export { };

=== tests/cases/compiler/module.d.ts ===
export = React;
>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))

function createRef(): any;
>createRef : Symbol(createRef, Decl(module.d.ts, 3, 25))
}

=== tests/cases/compiler/some_module.ts ===
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))
>createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25))

=== tests/cases/compiler/emits.ts ===
console.log("hello");
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))

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))
>createRef : Symbol(React.createRef, Decl(module.d.ts, 3, 25))

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
=== tests/cases/compiler/global.d.ts ===
declare global {
>global : typeof global

const React: typeof import("./module");
>React : typeof React
}

export { };

=== tests/cases/compiler/module.d.ts ===
export = React;
>React : typeof React

export as namespace React;
>React : typeof React

declare namespace React {
>React : typeof React

function createRef(): any;
>createRef : () => any
}

=== tests/cases/compiler/some_module.ts ===
export { };
React.createRef;
>React.createRef : () => any
>React : typeof React
>createRef : () => any

=== tests/cases/compiler/emits.ts ===
console.log("hello");
>console.log("hello") : void
>console.log : (message?: any, ...optionalParams: any[]) => void
>console : Console
>log : (message?: any, ...optionalParams: any[]) => void
>"hello" : "hello"

React.createRef;
>React.createRef : () => any
>React : typeof React
>createRef : () => any

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// @strict: true
// @module: esnext
// @moduleResolution: node
// @target: es2018
// @filename: global.d.ts
declare global {
const React: typeof import("./module");
}

export { };

// @filename: module.d.ts
export = React;
export as namespace React;

declare namespace React {
function createRef(): any;
}

// @filename: some_module.ts
export { };
React.createRef;

// @filename: emits.ts
console.log("hello");
React.createRef;