-
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.
Disambiguate types with same name from different namespaces in mapToT…
…ypeNodes (#37543) * Disambiguate types with same name from different namespaces in mapToTypeNodes * Update baseline with additional example * Fix typo
- Loading branch information
1 parent
c47aca0
commit 3e86f15
Showing
8 changed files
with
211 additions
and
1 deletion.
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
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
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/namespaceDisambiguationInUnion.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,29 @@ | ||
tests/cases/compiler/namespaceDisambiguationInUnion.ts(10,7): error TS2322: Type '{ type: string; }' is not assignable to type 'Foo.Yep | Bar.Yep'. | ||
Type '{ type: string; }' is not assignable to type 'Yep'. | ||
Types of property 'type' are incompatible. | ||
Type 'string' is not assignable to type '"bar.yep"'. | ||
tests/cases/compiler/namespaceDisambiguationInUnion.ts(13,7): error TS2739: Type '{ type: string; }[]' is missing the following properties from type '[Foo.Yep, Bar.Yep]': 0, 1 | ||
|
||
|
||
==== tests/cases/compiler/namespaceDisambiguationInUnion.ts (2 errors) ==== | ||
namespace Foo { | ||
export type Yep = { type: "foo.yep" }; | ||
} | ||
|
||
namespace Bar { | ||
export type Yep = { type: "bar.yep" }; | ||
} | ||
|
||
const x = { type: "wat.nup" }; | ||
const val1: Foo.Yep | Bar.Yep = x; | ||
~~~~ | ||
!!! error TS2322: Type '{ type: string; }' is not assignable to type 'Foo.Yep | Bar.Yep'. | ||
!!! error TS2322: Type '{ type: string; }' is not assignable to type 'Yep'. | ||
!!! error TS2322: Types of property 'type' are incompatible. | ||
!!! error TS2322: Type 'string' is not assignable to type '"bar.yep"'. | ||
|
||
const y = [{ type: "a" }, { type: "b" }]; | ||
const val2: [Foo.Yep, Bar.Yep] = y; | ||
~~~~ | ||
!!! error TS2739: Type '{ type: string; }[]' is missing the following properties from type '[Foo.Yep, Bar.Yep]': 0, 1 | ||
|
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/namespaceDisambiguationInUnion.js
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 @@ | ||
//// [namespaceDisambiguationInUnion.ts] | ||
namespace Foo { | ||
export type Yep = { type: "foo.yep" }; | ||
} | ||
|
||
namespace Bar { | ||
export type Yep = { type: "bar.yep" }; | ||
} | ||
|
||
const x = { type: "wat.nup" }; | ||
const val1: Foo.Yep | Bar.Yep = x; | ||
|
||
const y = [{ type: "a" }, { type: "b" }]; | ||
const val2: [Foo.Yep, Bar.Yep] = y; | ||
|
||
|
||
//// [namespaceDisambiguationInUnion.js] | ||
var x = { type: "wat.nup" }; | ||
var val1 = x; | ||
var y = [{ type: "a" }, { type: "b" }]; | ||
var val2 = y; |
42 changes: 42 additions & 0 deletions
42
tests/baselines/reference/namespaceDisambiguationInUnion.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,42 @@ | ||
=== tests/cases/compiler/namespaceDisambiguationInUnion.ts === | ||
namespace Foo { | ||
>Foo : Symbol(Foo, Decl(namespaceDisambiguationInUnion.ts, 0, 0)) | ||
|
||
export type Yep = { type: "foo.yep" }; | ||
>Yep : Symbol(Yep, Decl(namespaceDisambiguationInUnion.ts, 0, 15)) | ||
>type : Symbol(type, Decl(namespaceDisambiguationInUnion.ts, 1, 21)) | ||
} | ||
|
||
namespace Bar { | ||
>Bar : Symbol(Bar, Decl(namespaceDisambiguationInUnion.ts, 2, 1)) | ||
|
||
export type Yep = { type: "bar.yep" }; | ||
>Yep : Symbol(Yep, Decl(namespaceDisambiguationInUnion.ts, 4, 15)) | ||
>type : Symbol(type, Decl(namespaceDisambiguationInUnion.ts, 5, 21)) | ||
} | ||
|
||
const x = { type: "wat.nup" }; | ||
>x : Symbol(x, Decl(namespaceDisambiguationInUnion.ts, 8, 5)) | ||
>type : Symbol(type, Decl(namespaceDisambiguationInUnion.ts, 8, 11)) | ||
|
||
const val1: Foo.Yep | Bar.Yep = x; | ||
>val1 : Symbol(val1, Decl(namespaceDisambiguationInUnion.ts, 9, 5)) | ||
>Foo : Symbol(Foo, Decl(namespaceDisambiguationInUnion.ts, 0, 0)) | ||
>Yep : Symbol(Foo.Yep, Decl(namespaceDisambiguationInUnion.ts, 0, 15)) | ||
>Bar : Symbol(Bar, Decl(namespaceDisambiguationInUnion.ts, 2, 1)) | ||
>Yep : Symbol(Bar.Yep, Decl(namespaceDisambiguationInUnion.ts, 4, 15)) | ||
>x : Symbol(x, Decl(namespaceDisambiguationInUnion.ts, 8, 5)) | ||
|
||
const y = [{ type: "a" }, { type: "b" }]; | ||
>y : Symbol(y, Decl(namespaceDisambiguationInUnion.ts, 11, 5)) | ||
>type : Symbol(type, Decl(namespaceDisambiguationInUnion.ts, 11, 12)) | ||
>type : Symbol(type, Decl(namespaceDisambiguationInUnion.ts, 11, 27)) | ||
|
||
const val2: [Foo.Yep, Bar.Yep] = y; | ||
>val2 : Symbol(val2, Decl(namespaceDisambiguationInUnion.ts, 12, 5)) | ||
>Foo : Symbol(Foo, Decl(namespaceDisambiguationInUnion.ts, 0, 0)) | ||
>Yep : Symbol(Foo.Yep, Decl(namespaceDisambiguationInUnion.ts, 0, 15)) | ||
>Bar : Symbol(Bar, Decl(namespaceDisambiguationInUnion.ts, 2, 1)) | ||
>Yep : Symbol(Bar.Yep, Decl(namespaceDisambiguationInUnion.ts, 4, 15)) | ||
>y : Symbol(y, Decl(namespaceDisambiguationInUnion.ts, 11, 5)) | ||
|
41 changes: 41 additions & 0 deletions
41
tests/baselines/reference/namespaceDisambiguationInUnion.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,41 @@ | ||
=== tests/cases/compiler/namespaceDisambiguationInUnion.ts === | ||
namespace Foo { | ||
export type Yep = { type: "foo.yep" }; | ||
>Yep : Yep | ||
>type : "foo.yep" | ||
} | ||
|
||
namespace Bar { | ||
export type Yep = { type: "bar.yep" }; | ||
>Yep : Yep | ||
>type : "bar.yep" | ||
} | ||
|
||
const x = { type: "wat.nup" }; | ||
>x : { type: string; } | ||
>{ type: "wat.nup" } : { type: string; } | ||
>type : string | ||
>"wat.nup" : "wat.nup" | ||
|
||
const val1: Foo.Yep | Bar.Yep = x; | ||
>val1 : Foo.Yep | Bar.Yep | ||
>Foo : any | ||
>Bar : any | ||
>x : { type: string; } | ||
|
||
const y = [{ type: "a" }, { type: "b" }]; | ||
>y : { type: string; }[] | ||
>[{ type: "a" }, { type: "b" }] : { type: string; }[] | ||
>{ type: "a" } : { type: string; } | ||
>type : string | ||
>"a" : "a" | ||
>{ type: "b" } : { type: string; } | ||
>type : string | ||
>"b" : "b" | ||
|
||
const val2: [Foo.Yep, Bar.Yep] = y; | ||
>val2 : [Foo.Yep, Bar.Yep] | ||
>Foo : any | ||
>Bar : any | ||
>y : { type: string; }[] | ||
|
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,13 @@ | ||
namespace Foo { | ||
export type Yep = { type: "foo.yep" }; | ||
} | ||
|
||
namespace Bar { | ||
export type Yep = { type: "bar.yep" }; | ||
} | ||
|
||
const x = { type: "wat.nup" }; | ||
const val1: Foo.Yep | Bar.Yep = x; | ||
|
||
const y = [{ type: "a" }, { type: "b" }]; | ||
const val2: [Foo.Yep, Bar.Yep] = y; |