-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix reference marking of values merged with unresolvable type-only imports #54799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+512
−54
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,43 @@ | ||
//// [tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery2.ts] //// | ||
|
||
//// [z.ts] | ||
interface A {} | ||
export type { A }; | ||
|
||
//// [a.ts] | ||
import { A } from './z'; | ||
const A = 0; | ||
export { A }; | ||
export class B {}; | ||
|
||
//// [b.ts] | ||
import * as types from './a'; | ||
let t: typeof types = { | ||
A: undefined as any, // ok | ||
B: undefined as any, | ||
} | ||
|
||
|
||
//// [z.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//// [a.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.B = exports.A = void 0; | ||
var A = 0; | ||
exports.A = A; | ||
var B = /** @class */ (function () { | ||
function B() { | ||
} | ||
return B; | ||
}()); | ||
exports.B = B; | ||
; | ||
//// [b.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var t = { | ||
A: undefined, | ||
B: undefined, | ||
}; |
39 changes: 39 additions & 0 deletions
39
tests/baselines/reference/namespaceImportTypeQuery2.symbols
This file contains hidden or 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,39 @@ | ||
//// [tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery2.ts] //// | ||
|
||
=== /z.ts === | ||
interface A {} | ||
>A : Symbol(A, Decl(z.ts, 0, 0)) | ||
|
||
export type { A }; | ||
>A : Symbol(A, Decl(z.ts, 1, 13)) | ||
|
||
=== /a.ts === | ||
import { A } from './z'; | ||
>A : Symbol(A, Decl(a.ts, 0, 8), Decl(a.ts, 1, 5)) | ||
|
||
const A = 0; | ||
>A : Symbol(A, Decl(a.ts, 0, 8), Decl(a.ts, 1, 5)) | ||
|
||
export { A }; | ||
>A : Symbol(A, Decl(a.ts, 2, 8)) | ||
|
||
export class B {}; | ||
>B : Symbol(B, Decl(a.ts, 2, 13)) | ||
|
||
=== /b.ts === | ||
import * as types from './a'; | ||
>types : Symbol(types, Decl(b.ts, 0, 6)) | ||
|
||
let t: typeof types = { | ||
>t : Symbol(t, Decl(b.ts, 1, 3)) | ||
>types : Symbol(types, Decl(b.ts, 0, 6)) | ||
|
||
A: undefined as any, // ok | ||
>A : Symbol(A, Decl(b.ts, 1, 23)) | ||
>undefined : Symbol(undefined) | ||
|
||
B: undefined as any, | ||
>B : Symbol(B, Decl(b.ts, 2, 22)) | ||
>undefined : Symbol(undefined) | ||
} | ||
|
This file contains hidden or 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/conformance/externalModules/typeOnly/namespaceImportTypeQuery2.ts] //// | ||
|
||
=== /z.ts === | ||
interface A {} | ||
export type { A }; | ||
>A : A | ||
|
||
=== /a.ts === | ||
import { A } from './z'; | ||
>A : 0 | ||
|
||
const A = 0; | ||
>A : 0 | ||
>0 : 0 | ||
|
||
export { A }; | ||
>A : 0 | ||
|
||
export class B {}; | ||
>B : B | ||
|
||
=== /b.ts === | ||
import * as types from './a'; | ||
>types : typeof types | ||
|
||
let t: typeof types = { | ||
>t : typeof types | ||
>types : typeof types | ||
>{ A: undefined as any, // ok B: undefined as any,} : { A: any; B: any; } | ||
|
||
A: undefined as any, // ok | ||
>A : any | ||
>undefined as any : any | ||
>undefined : undefined | ||
|
||
B: undefined as any, | ||
>B : any | ||
>undefined as any : any | ||
>undefined : undefined | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/namespaceImportTypeQuery3.errors.txt
This file contains hidden or 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,18 @@ | ||
/a.ts(1,24): error TS2307: Cannot find module './z' or its corresponding type declarations. | ||
|
||
|
||
==== /a.ts (1 errors) ==== | ||
import type { A } from './z'; // unresolved | ||
~~~~~ | ||
!!! error TS2307: Cannot find module './z' or its corresponding type declarations. | ||
const A = 0; | ||
export { A }; | ||
export class B {}; | ||
|
||
==== /b.ts (0 errors) ==== | ||
import * as types from './a'; | ||
let t: typeof types = { | ||
A: undefined as any, // ok | ||
B: undefined as any, | ||
} | ||
|
This file contains hidden or 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,36 @@ | ||
//// [tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery3.ts] //// | ||
|
||
//// [a.ts] | ||
import type { A } from './z'; // unresolved | ||
const A = 0; | ||
export { A }; | ||
export class B {}; | ||
|
||
//// [b.ts] | ||
import * as types from './a'; | ||
let t: typeof types = { | ||
A: undefined as any, // ok | ||
B: undefined as any, | ||
} | ||
|
||
|
||
//// [a.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.B = exports.A = void 0; | ||
var A = 0; | ||
exports.A = A; | ||
var B = /** @class */ (function () { | ||
function B() { | ||
} | ||
return B; | ||
}()); | ||
exports.B = B; | ||
; | ||
//// [b.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var t = { | ||
A: undefined, | ||
B: undefined, | ||
}; |
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/namespaceImportTypeQuery3.symbols
This file contains hidden or 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,32 @@ | ||
//// [tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery3.ts] //// | ||
|
||
=== /a.ts === | ||
import type { A } from './z'; // unresolved | ||
>A : Symbol(A, Decl(a.ts, 0, 13), Decl(a.ts, 1, 5)) | ||
|
||
const A = 0; | ||
>A : Symbol(A, Decl(a.ts, 0, 13), Decl(a.ts, 1, 5)) | ||
|
||
export { A }; | ||
>A : Symbol(A, Decl(a.ts, 2, 8)) | ||
|
||
export class B {}; | ||
>B : Symbol(B, Decl(a.ts, 2, 13)) | ||
|
||
=== /b.ts === | ||
import * as types from './a'; | ||
>types : Symbol(types, Decl(b.ts, 0, 6)) | ||
|
||
let t: typeof types = { | ||
>t : Symbol(t, Decl(b.ts, 1, 3)) | ||
>types : Symbol(types, Decl(b.ts, 0, 6)) | ||
|
||
A: undefined as any, // ok | ||
>A : Symbol(A, Decl(b.ts, 1, 23)) | ||
>undefined : Symbol(undefined) | ||
|
||
B: undefined as any, | ||
>B : Symbol(B, Decl(b.ts, 2, 22)) | ||
>undefined : Symbol(undefined) | ||
} | ||
|
This file contains hidden or 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,36 @@ | ||
//// [tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery3.ts] //// | ||
|
||
=== /a.ts === | ||
import type { A } from './z'; // unresolved | ||
>A : any | ||
|
||
const A = 0; | ||
>A : 0 | ||
>0 : 0 | ||
|
||
export { A }; | ||
>A : 0 | ||
|
||
export class B {}; | ||
>B : B | ||
|
||
=== /b.ts === | ||
import * as types from './a'; | ||
>types : typeof types | ||
|
||
let t: typeof types = { | ||
>t : typeof types | ||
>types : typeof types | ||
>{ A: undefined as any, // ok B: undefined as any,} : { A: any; B: any; } | ||
|
||
A: undefined as any, // ok | ||
>A : any | ||
>undefined as any : any | ||
>undefined : undefined | ||
|
||
B: undefined as any, | ||
>B : any | ||
>undefined as any : any | ||
>undefined : undefined | ||
} | ||
|
23 changes: 23 additions & 0 deletions
23
tests/baselines/reference/namespaceImportTypeQuery4.errors.txt
This file contains hidden or 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,23 @@ | ||
/a.ts(1,24): error TS2307: Cannot find module './z' or its corresponding type declarations. | ||
/b.ts(3,3): error TS2322: Type '{ A: any; B: any; }' is not assignable to type 'typeof import("/a")'. | ||
Object literal may only specify known properties, and 'A' does not exist in type 'typeof import("/a")'. | ||
|
||
|
||
==== /a.ts (1 errors) ==== | ||
import type { A } from './z'; // unresolved | ||
~~~~~ | ||
!!! error TS2307: Cannot find module './z' or its corresponding type declarations. | ||
type A = 0; | ||
export { A }; | ||
export class B {}; | ||
|
||
==== /b.ts (1 errors) ==== | ||
import * as types from './a'; | ||
let t: typeof types = { | ||
A: undefined as any, // error | ||
~ | ||
!!! error TS2322: Type '{ A: any; B: any; }' is not assignable to type 'typeof import("/a")'. | ||
!!! error TS2322: Object literal may only specify known properties, and 'A' does not exist in type 'typeof import("/a")'. | ||
B: undefined as any, | ||
} | ||
|
This file contains hidden or 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,34 @@ | ||
//// [tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery4.ts] //// | ||
|
||
//// [a.ts] | ||
import type { A } from './z'; // unresolved | ||
type A = 0; | ||
export { A }; | ||
export class B {}; | ||
|
||
//// [b.ts] | ||
import * as types from './a'; | ||
let t: typeof types = { | ||
A: undefined as any, // error | ||
B: undefined as any, | ||
} | ||
|
||
|
||
//// [a.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.B = void 0; | ||
var B = /** @class */ (function () { | ||
function B() { | ||
} | ||
return B; | ||
}()); | ||
exports.B = B; | ||
; | ||
//// [b.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var t = { | ||
A: undefined, | ||
B: undefined, | ||
}; |
32 changes: 32 additions & 0 deletions
32
tests/baselines/reference/namespaceImportTypeQuery4.symbols
This file contains hidden or 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,32 @@ | ||
//// [tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery4.ts] //// | ||
|
||
=== /a.ts === | ||
import type { A } from './z'; // unresolved | ||
>A : Symbol(A, Decl(a.ts, 0, 13), Decl(a.ts, 0, 29)) | ||
|
||
type A = 0; | ||
>A : Symbol(A, Decl(a.ts, 0, 13), Decl(a.ts, 0, 29)) | ||
|
||
export { A }; | ||
>A : Symbol(A, Decl(a.ts, 2, 8)) | ||
|
||
export class B {}; | ||
>B : Symbol(B, Decl(a.ts, 2, 13)) | ||
|
||
=== /b.ts === | ||
import * as types from './a'; | ||
>types : Symbol(types, Decl(b.ts, 0, 6)) | ||
|
||
let t: typeof types = { | ||
>t : Symbol(t, Decl(b.ts, 1, 3)) | ||
>types : Symbol(types, Decl(b.ts, 0, 6)) | ||
|
||
A: undefined as any, // error | ||
>A : Symbol(A, Decl(b.ts, 1, 23)) | ||
>undefined : Symbol(undefined) | ||
|
||
B: undefined as any, | ||
>B : Symbol(B, Decl(b.ts, 2, 22)) | ||
>undefined : Symbol(undefined) | ||
} | ||
|
This file contains hidden or 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,35 @@ | ||
//// [tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery4.ts] //// | ||
|
||
=== /a.ts === | ||
import type { A } from './z'; // unresolved | ||
>A : 0 | ||
|
||
type A = 0; | ||
>A : 0 | ||
|
||
export { A }; | ||
>A : any | ||
|
||
export class B {}; | ||
>B : B | ||
|
||
=== /b.ts === | ||
import * as types from './a'; | ||
>types : typeof types | ||
|
||
let t: typeof types = { | ||
>t : typeof types | ||
>types : typeof types | ||
>{ A: undefined as any, // error B: undefined as any,} : { A: any; B: any; } | ||
|
||
A: undefined as any, // error | ||
>A : any | ||
>undefined as any : any | ||
>undefined : undefined | ||
|
||
B: undefined as any, | ||
>B : any | ||
>undefined as any : any | ||
>undefined : undefined | ||
} | ||
|
4 changes: 4 additions & 0 deletions
4
...pile/Preserves exported const merged with type-only import (verbatimModuleSyntax=true).js
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...s exported const merged with type-only import (verbatimModuleSyntax=true).oldTranspile.js
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
tests/baselines/reference/transpile/Preserves exported const merged with type-only import.js
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...reference/transpile/Preserves exported const merged with type-only import.oldTranspile.js
Oops, something went wrong.
This file contains hidden or 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
16 changes: 16 additions & 0 deletions
16
tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery2.ts
This file contains hidden or 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: /z.ts | ||
interface A {} | ||
export type { A }; | ||
|
||
// @Filename: /a.ts | ||
import { A } from './z'; | ||
const A = 0; | ||
export { A }; | ||
export class B {}; | ||
|
||
// @Filename: /b.ts | ||
import * as types from './a'; | ||
let t: typeof types = { | ||
A: undefined as any, // ok | ||
B: undefined as any, | ||
} |
12 changes: 12 additions & 0 deletions
12
tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery3.ts
This file contains hidden or 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,12 @@ | ||
// @Filename: /a.ts | ||
import type { A } from './z'; // unresolved | ||
const A = 0; | ||
export { A }; | ||
export class B {}; | ||
|
||
// @Filename: /b.ts | ||
import * as types from './a'; | ||
let t: typeof types = { | ||
A: undefined as any, // ok | ||
B: undefined as any, | ||
} |
12 changes: 12 additions & 0 deletions
12
tests/cases/conformance/externalModules/typeOnly/namespaceImportTypeQuery4.ts
This file contains hidden or 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,12 @@ | ||
// @Filename: /a.ts | ||
import type { A } from './z'; // unresolved | ||
type A = 0; | ||
export { A }; | ||
export class B {}; | ||
|
||
// @Filename: /b.ts | ||
import * as types from './a'; | ||
let t: typeof types = { | ||
A: undefined as any, // error | ||
B: undefined as any, | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some illegal merges that were previously counted as unreferenced for purposes of emit are now counted as referenced. Stuff is going to crash either way, and I don’t really think one is particularly more correct than the other.