Skip to content
Closed
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
5 changes: 4 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10398,7 +10398,10 @@ namespace ts {
return symbol;
}
}
return getPropertyOfObjectType(globalObjectType, name);
if (globalObjectType) {
return getPropertyOfObjectType(globalObjectType, name);
}
return undefined;
}
if (type.flags & TypeFlags.UnionOrIntersection) {
return getPropertyOfUnionOrIntersectionType(<UnionOrIntersectionType>type, name);
Expand Down
22 changes: 22 additions & 0 deletions tests/baselines/reference/importNonExistentDeclaration.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
tests/cases/compiler/bar.d.ts(1,10): error TS2305: Module '"./foo"' has no exported member 'Bar'.


==== tests/cases/compiler/foo.d.ts (0 errors) ====
export = Foo;
export as namespace Foo;

declare namespace Foo {
function foo();
}

declare global {
namespace Bar {}
}

==== tests/cases/compiler/bar.d.ts (1 errors) ====
import { Bar } from './foo';
~~~
!!! error TS2305: Module '"./foo"' has no exported member 'Bar'.
export = Bar;
export as namespace Bar;

31 changes: 31 additions & 0 deletions tests/baselines/reference/importNonExistentDeclaration.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
=== tests/cases/compiler/foo.d.ts ===
export = Foo;
>Foo : Symbol(Foo, Decl(foo.d.ts, 1, 24))

export as namespace Foo;
>Foo : Symbol(Foo, Decl(foo.d.ts, 0, 13))

declare namespace Foo {
>Foo : Symbol(Foo, Decl(foo.d.ts, 1, 24))

function foo();
>foo : Symbol(foo, Decl(foo.d.ts, 3, 23))
}

declare global {
>global : Symbol(global, Decl(foo.d.ts, 5, 1))

namespace Bar {}
>Bar : Symbol(Bar, Decl(foo.d.ts, 7, 16))
}

=== tests/cases/compiler/bar.d.ts ===
import { Bar } from './foo';
>Bar : Symbol(Bar, Decl(bar.d.ts, 0, 8))

export = Bar;
>Bar : Symbol(Bar, Decl(bar.d.ts, 0, 8))

export as namespace Bar;
>Bar : Symbol(Bar, Decl(bar.d.ts, 1, 13))

30 changes: 30 additions & 0 deletions tests/baselines/reference/importNonExistentDeclaration.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
=== tests/cases/compiler/foo.d.ts ===
export = Foo;
>Foo : typeof Foo

export as namespace Foo;
>Foo : typeof Foo

declare namespace Foo {
>Foo : typeof Foo

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

declare global {
>global : any

namespace Bar {}
}

=== tests/cases/compiler/bar.d.ts ===
import { Bar } from './foo';
>Bar : any

export = Bar;
>Bar : any

export as namespace Bar;
>Bar : any

16 changes: 16 additions & 0 deletions tests/cases/compiler/importNonExistentDeclaration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// @filename: foo.d.ts
export = Foo;
export as namespace Foo;

declare namespace Foo {
function foo();
}

declare global {
namespace Bar {}
}

// @filename: bar.d.ts
import { Bar } from './foo';
export = Bar;
export as namespace Bar;