-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dont look for properties of Object and Function type when looking to …
…resolve named import from module with `export=` (#37964) * Add tests * Dont look at object or function type when looking for members of `export=` type to be resolved by named imports Fixes #37165 * Create separate cache when skipping function and object property augmentation * Lookup in both cache if not skipObjectFunctionPropertyAugment
- Loading branch information
1 parent
b00870e
commit 9c60d5a
Showing
11 changed files
with
291 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/moduleAugmentationWithNonExistentNamedImport.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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
31
tests/baselines/reference/moduleAugmentationWithNonExistentNamedImport.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
30
tests/baselines/reference/moduleAugmentationWithNonExistentNamedImport.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
37 changes: 37 additions & 0 deletions
37
tests/baselines/reference/namedImportNonExistentName.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
tests/cases/compiler/bar.ts(1,10): error TS2305: Module '"./foo"' has no exported member 'Bar'. | ||
tests/cases/compiler/bar.ts(1,15): error TS2305: Module '"./foo"' has no exported member 'toString'. | ||
tests/cases/compiler/bar.ts(3,10): error TS2305: Module '"./foo2"' has no exported member 'a'. | ||
tests/cases/compiler/bar.ts(3,13): error TS2305: Module '"./foo2"' has no exported member 'b'. | ||
tests/cases/compiler/bar.ts(3,19): error TS2305: Module '"./foo2"' has no exported member 'd'. | ||
tests/cases/compiler/bar.ts(3,22): error TS2305: Module '"./foo2"' has no exported member 'toString'. | ||
|
||
|
||
==== tests/cases/compiler/foo.d.ts (0 errors) ==== | ||
export = Foo; | ||
export as namespace Foo; | ||
|
||
declare namespace Foo { | ||
function foo(); | ||
} | ||
|
||
==== tests/cases/compiler/foo2.ts (0 errors) ==== | ||
let x: { a: string; c: string; } | { b: number; c: number; }; | ||
export = x | ||
|
||
==== tests/cases/compiler/bar.ts (6 errors) ==== | ||
import { Bar, toString, foo } from './foo'; | ||
~~~ | ||
!!! error TS2305: Module '"./foo"' has no exported member 'Bar'. | ||
~~~~~~~~ | ||
!!! error TS2305: Module '"./foo"' has no exported member 'toString'. | ||
foo(); | ||
import { a, b, c, d, toString as foo2String } from './foo2'; | ||
~ | ||
!!! error TS2305: Module '"./foo2"' has no exported member 'a'. | ||
~ | ||
!!! error TS2305: Module '"./foo2"' has no exported member 'b'. | ||
~ | ||
!!! error TS2305: Module '"./foo2"' has no exported member 'd'. | ||
~~~~~~~~ | ||
!!! error TS2305: Module '"./foo2"' has no exported member 'toString'. | ||
c; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//// [tests/cases/compiler/namedImportNonExistentName.ts] //// | ||
|
||
//// [foo.d.ts] | ||
export = Foo; | ||
export as namespace Foo; | ||
|
||
declare namespace Foo { | ||
function foo(); | ||
} | ||
|
||
//// [foo2.ts] | ||
let x: { a: string; c: string; } | { b: number; c: number; }; | ||
export = x | ||
|
||
//// [bar.ts] | ||
import { Bar, toString, foo } from './foo'; | ||
foo(); | ||
import { a, b, c, d, toString as foo2String } from './foo2'; | ||
c; | ||
|
||
//// [foo2.js] | ||
"use strict"; | ||
var x; | ||
module.exports = x; | ||
//// [bar.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var foo_1 = require("./foo"); | ||
foo_1.foo(); | ||
var foo2_1 = require("./foo2"); | ||
foo2_1.c; |
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/namedImportNonExistentName.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
=== 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)) | ||
} | ||
|
||
=== tests/cases/compiler/foo2.ts === | ||
let x: { a: string; c: string; } | { b: number; c: number; }; | ||
>x : Symbol(x, Decl(foo2.ts, 0, 3)) | ||
>a : Symbol(a, Decl(foo2.ts, 0, 8)) | ||
>c : Symbol(c, Decl(foo2.ts, 0, 19)) | ||
>b : Symbol(b, Decl(foo2.ts, 0, 36)) | ||
>c : Symbol(c, Decl(foo2.ts, 0, 47)) | ||
|
||
export = x | ||
>x : Symbol(x, Decl(foo2.ts, 0, 3)) | ||
|
||
=== tests/cases/compiler/bar.ts === | ||
import { Bar, toString, foo } from './foo'; | ||
>Bar : Symbol(Bar, Decl(bar.ts, 0, 8)) | ||
>toString : Symbol(toString, Decl(bar.ts, 0, 13)) | ||
>foo : Symbol(foo, Decl(bar.ts, 0, 23)) | ||
|
||
foo(); | ||
>foo : Symbol(foo, Decl(bar.ts, 0, 23)) | ||
|
||
import { a, b, c, d, toString as foo2String } from './foo2'; | ||
>a : Symbol(a, Decl(bar.ts, 2, 8)) | ||
>b : Symbol(b, Decl(bar.ts, 2, 11)) | ||
>c : Symbol(c, Decl(bar.ts, 2, 14)) | ||
>d : Symbol(d, Decl(bar.ts, 2, 17)) | ||
>foo2String : Symbol(foo2String, Decl(bar.ts, 2, 20)) | ||
|
||
c; | ||
>c : Symbol(c, Decl(bar.ts, 2, 14)) | ||
|
46 changes: 46 additions & 0 deletions
46
tests/baselines/reference/namedImportNonExistentName.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
=== 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 | ||
} | ||
|
||
=== tests/cases/compiler/foo2.ts === | ||
let x: { a: string; c: string; } | { b: number; c: number; }; | ||
>x : { a: string; c: string; } | { b: number; c: number; } | ||
>a : string | ||
>c : string | ||
>b : number | ||
>c : number | ||
|
||
export = x | ||
>x : { a: string; c: string; } | { b: number; c: number; } | ||
|
||
=== tests/cases/compiler/bar.ts === | ||
import { Bar, toString, foo } from './foo'; | ||
>Bar : any | ||
>toString : any | ||
>foo : () => any | ||
|
||
foo(); | ||
>foo() : any | ||
>foo : () => any | ||
|
||
import { a, b, c, d, toString as foo2String } from './foo2'; | ||
>a : any | ||
>b : any | ||
>c : string | number | ||
>d : any | ||
>toString : any | ||
>foo2String : any | ||
|
||
c; | ||
>c : string | number | ||
|
16 changes: 16 additions & 0 deletions
16
tests/cases/compiler/moduleAugmentationWithNonExistentNamedImport.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// @filename: foo.d.ts | ||
export = Foo; | ||
export as namespace Foo; | ||
|
||
declare namespace Foo { | ||
function foo(); | ||
} | ||
|
||
// @filename: foo2.ts | ||
let x: { a: string; c: string; } | { b: number; c: number; }; | ||
export = x | ||
|
||
// @filename: bar.ts | ||
import { Bar, toString, foo } from './foo'; | ||
foo(); | ||
import { a, b, c, d, toString as foo2String } from './foo2'; | ||
c; |