Repository navigation
Recognize unresolved type-only default imports during alias lookup #64896
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
Open
Mateusz Burzyński (Andarist)
wants to merge
3
commits into
microsoft:main
Choose a base branch
from
Andarist:preserve-type-only-alias-on-resolution-failure
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+466
−7
Open
Changes from all commits
Commits
Show all changes
3 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
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
40 changes: 40 additions & 0 deletions
40
.../reference/compiler/decoratorMetadataTypeOnlyUnresolvedImport(module=commonjs).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,40 @@ | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(1,22): error TS2307: Cannot find module './missing-default' or its corresponding type declarations. | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(2,26): error TS2307: Cannot find module './missing-named' or its corresponding type declarations. | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(3,37): error TS2307: Cannot find module './missing-default-specifier' or its corresponding type declarations. | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(13,11): error TS1361: 'Foo' cannot be used as a value because it was imported using 'import type'. | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(14,11): error TS1361: 'Bar' cannot be used as a value because it was imported using 'import type'. | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(15,11): error TS1361: 'Baz' cannot be used as a value because it was imported using 'import type'. | ||
|
|
||
|
|
||
| ==== decoratorMetadataTypeOnlyUnresolvedImport.ts (6 errors) ==== | ||
| import type Foo from "./missing-default"; | ||
| ~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2307: Cannot find module './missing-default' or its corresponding type declarations. | ||
| import { type Bar } from "./missing-named"; | ||
| ~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2307: Cannot find module './missing-named' or its corresponding type declarations. | ||
| import type { default as Baz } from "./missing-default-specifier"; | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2307: Cannot find module './missing-default-specifier' or its corresponding type declarations. | ||
|
|
||
| function dec(_target: unknown, _key: unknown) {} | ||
|
|
||
| class C { | ||
| @dec a!: Foo; | ||
| @dec b!: Bar; | ||
| @dec c!: Baz; | ||
| } | ||
|
|
||
| const x = Foo; | ||
| ~~~ | ||
| !!! error TS1361: 'Foo' cannot be used as a value because it was imported using 'import type'. | ||
| !!! related TS1376 decoratorMetadataTypeOnlyUnresolvedImport.ts:1:8: 'Foo' was imported here. | ||
| const y = Bar; | ||
| ~~~ | ||
| !!! error TS1361: 'Bar' cannot be used as a value because it was imported using 'import type'. | ||
| !!! related TS1376 decoratorMetadataTypeOnlyUnresolvedImport.ts:2:10: 'Bar' was imported here. | ||
| const z = Baz; | ||
| ~~~ | ||
| !!! error TS1361: 'Baz' cannot be used as a value because it was imported using 'import type'. | ||
| !!! related TS1376 decoratorMetadataTypeOnlyUnresolvedImport.ts:3:15: 'Baz' was imported here. | ||
|
|
50 changes: 50 additions & 0 deletions
50
...aselines/reference/compiler/decoratorMetadataTypeOnlyUnresolvedImport(module=commonjs).js
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,50 @@ | ||
| //// [tests/cases/compiler/decoratorMetadataTypeOnlyUnresolvedImport.ts] //// | ||
|
|
||
| //// [decoratorMetadataTypeOnlyUnresolvedImport.ts] | ||
| import type Foo from "./missing-default"; | ||
| import { type Bar } from "./missing-named"; | ||
| import type { default as Baz } from "./missing-default-specifier"; | ||
|
|
||
| function dec(_target: unknown, _key: unknown) {} | ||
|
|
||
| class C { | ||
| @dec a!: Foo; | ||
| @dec b!: Bar; | ||
| @dec c!: Baz; | ||
| } | ||
|
|
||
| const x = Foo; | ||
| const y = Bar; | ||
| const z = Baz; | ||
|
|
||
|
|
||
| //// [decoratorMetadataTypeOnlyUnresolvedImport.js] | ||
| "use strict"; | ||
| var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
| var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
| if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
| else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
| return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
| }; | ||
| var __metadata = (this && this.__metadata) || function (k, v) { | ||
| if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| function dec(_target, _key) { } | ||
| class C { | ||
| } | ||
| __decorate([ | ||
| dec, | ||
| __metadata("design:type", Object) | ||
| ], C.prototype, "a", void 0); | ||
| __decorate([ | ||
| dec, | ||
| __metadata("design:type", Object) | ||
| ], C.prototype, "b", void 0); | ||
| __decorate([ | ||
| dec, | ||
| __metadata("design:type", Object) | ||
| ], C.prototype, "c", void 0); | ||
| const x = Foo; | ||
| const y = Bar; | ||
| const z = Baz; |
48 changes: 48 additions & 0 deletions
48
...nes/reference/compiler/decoratorMetadataTypeOnlyUnresolvedImport(module=commonjs).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,48 @@ | ||
| //// [tests/cases/compiler/decoratorMetadataTypeOnlyUnresolvedImport.ts] //// | ||
|
|
||
| === decoratorMetadataTypeOnlyUnresolvedImport.ts === | ||
| import type Foo from "./missing-default"; | ||
| >Foo : Symbol(Foo, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 0, 6)) | ||
|
|
||
| import { type Bar } from "./missing-named"; | ||
| >Bar : Symbol(Bar, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 1, 8)) | ||
|
|
||
| import type { default as Baz } from "./missing-default-specifier"; | ||
| >Baz : Symbol(Baz, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 13)) | ||
|
|
||
| function dec(_target: unknown, _key: unknown) {} | ||
| >dec : Symbol(dec, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 66)) | ||
| >_target : Symbol(_target, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 4, 13)) | ||
| >_key : Symbol(_key, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 4, 30)) | ||
|
|
||
| class C { | ||
| >C : Symbol(C, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 4, 48)) | ||
|
|
||
| @dec a!: Foo; | ||
| >dec : Symbol(dec, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 66)) | ||
| >a : Symbol(C.a, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 6, 9)) | ||
| >Foo : Symbol(Foo, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 0, 6)) | ||
|
|
||
| @dec b!: Bar; | ||
| >dec : Symbol(dec, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 66)) | ||
| >b : Symbol(C.b, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 7, 17)) | ||
| >Bar : Symbol(Bar, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 1, 8)) | ||
|
|
||
| @dec c!: Baz; | ||
| >dec : Symbol(dec, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 66)) | ||
| >c : Symbol(C.c, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 8, 17)) | ||
| >Baz : Symbol(Baz, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 13)) | ||
| } | ||
|
|
||
| const x = Foo; | ||
| >x : Symbol(x, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 12, 5)) | ||
| >Foo : Symbol(Foo, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 0, 6)) | ||
|
|
||
| const y = Bar; | ||
| >y : Symbol(y, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 13, 5)) | ||
| >Bar : Symbol(Bar, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 1, 8)) | ||
|
|
||
| const z = Baz; | ||
| >z : Symbol(z, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 14, 5)) | ||
| >Baz : Symbol(Baz, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 13)) | ||
|
|
46 changes: 46 additions & 0 deletions
46
...lines/reference/compiler/decoratorMetadataTypeOnlyUnresolvedImport(module=commonjs).types
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,46 @@ | ||
| //// [tests/cases/compiler/decoratorMetadataTypeOnlyUnresolvedImport.ts] //// | ||
|
|
||
| === decoratorMetadataTypeOnlyUnresolvedImport.ts === | ||
| import type Foo from "./missing-default"; | ||
| >Foo : any | ||
|
|
||
| import { type Bar } from "./missing-named"; | ||
| >Bar : any | ||
|
|
||
| import type { default as Baz } from "./missing-default-specifier"; | ||
| >default : any | ||
| >Baz : any | ||
|
|
||
| function dec(_target: unknown, _key: unknown) {} | ||
| >dec : (_target: unknown, _key: unknown) => void | ||
| >_target : unknown | ||
| >_key : unknown | ||
|
|
||
| class C { | ||
| >C : C | ||
|
|
||
| @dec a!: Foo; | ||
| >dec : (_target: unknown, _key: unknown) => void | ||
| >a : Foo | ||
|
|
||
| @dec b!: Bar; | ||
| >dec : (_target: unknown, _key: unknown) => void | ||
| >b : Bar | ||
|
|
||
| @dec c!: Baz; | ||
| >dec : (_target: unknown, _key: unknown) => void | ||
| >c : Baz | ||
| } | ||
|
|
||
| const x = Foo; | ||
| >x : any | ||
| >Foo : any | ||
|
|
||
| const y = Bar; | ||
| >y : any | ||
| >Bar : any | ||
|
|
||
| const z = Baz; | ||
| >z : any | ||
| >Baz : any | ||
|
|
40 changes: 40 additions & 0 deletions
40
...es/reference/compiler/decoratorMetadataTypeOnlyUnresolvedImport(module=esnext).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,40 @@ | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(1,22): error TS2307: Cannot find module './missing-default' or its corresponding type declarations. | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(2,26): error TS2307: Cannot find module './missing-named' or its corresponding type declarations. | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(3,37): error TS2307: Cannot find module './missing-default-specifier' or its corresponding type declarations. | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(13,11): error TS1361: 'Foo' cannot be used as a value because it was imported using 'import type'. | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(14,11): error TS1361: 'Bar' cannot be used as a value because it was imported using 'import type'. | ||
| decoratorMetadataTypeOnlyUnresolvedImport.ts(15,11): error TS1361: 'Baz' cannot be used as a value because it was imported using 'import type'. | ||
|
|
||
|
|
||
| ==== decoratorMetadataTypeOnlyUnresolvedImport.ts (6 errors) ==== | ||
| import type Foo from "./missing-default"; | ||
| ~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2307: Cannot find module './missing-default' or its corresponding type declarations. | ||
| import { type Bar } from "./missing-named"; | ||
| ~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2307: Cannot find module './missing-named' or its corresponding type declarations. | ||
| import type { default as Baz } from "./missing-default-specifier"; | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| !!! error TS2307: Cannot find module './missing-default-specifier' or its corresponding type declarations. | ||
|
|
||
| function dec(_target: unknown, _key: unknown) {} | ||
|
|
||
| class C { | ||
| @dec a!: Foo; | ||
| @dec b!: Bar; | ||
| @dec c!: Baz; | ||
| } | ||
|
|
||
| const x = Foo; | ||
| ~~~ | ||
| !!! error TS1361: 'Foo' cannot be used as a value because it was imported using 'import type'. | ||
| !!! related TS1376 decoratorMetadataTypeOnlyUnresolvedImport.ts:1:8: 'Foo' was imported here. | ||
| const y = Bar; | ||
| ~~~ | ||
| !!! error TS1361: 'Bar' cannot be used as a value because it was imported using 'import type'. | ||
| !!! related TS1376 decoratorMetadataTypeOnlyUnresolvedImport.ts:2:10: 'Bar' was imported here. | ||
| const z = Baz; | ||
| ~~~ | ||
| !!! error TS1361: 'Baz' cannot be used as a value because it was imported using 'import type'. | ||
| !!! related TS1376 decoratorMetadataTypeOnlyUnresolvedImport.ts:3:15: 'Baz' was imported here. | ||
|
|
49 changes: 49 additions & 0 deletions
49
.../baselines/reference/compiler/decoratorMetadataTypeOnlyUnresolvedImport(module=esnext).js
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,49 @@ | ||
| //// [tests/cases/compiler/decoratorMetadataTypeOnlyUnresolvedImport.ts] //// | ||
|
|
||
| //// [decoratorMetadataTypeOnlyUnresolvedImport.ts] | ||
| import type Foo from "./missing-default"; | ||
| import { type Bar } from "./missing-named"; | ||
| import type { default as Baz } from "./missing-default-specifier"; | ||
|
|
||
| function dec(_target: unknown, _key: unknown) {} | ||
|
|
||
| class C { | ||
| @dec a!: Foo; | ||
| @dec b!: Bar; | ||
| @dec c!: Baz; | ||
| } | ||
|
|
||
| const x = Foo; | ||
| const y = Bar; | ||
| const z = Baz; | ||
|
|
||
|
|
||
| //// [decoratorMetadataTypeOnlyUnresolvedImport.js] | ||
| var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
| var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
| if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
| else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
| return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
| }; | ||
| var __metadata = (this && this.__metadata) || function (k, v) { | ||
| if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
| }; | ||
| function dec(_target, _key) { } | ||
| class C { | ||
| } | ||
| __decorate([ | ||
| dec, | ||
| __metadata("design:type", Object) | ||
| ], C.prototype, "a", void 0); | ||
| __decorate([ | ||
| dec, | ||
| __metadata("design:type", Object) | ||
| ], C.prototype, "b", void 0); | ||
| __decorate([ | ||
| dec, | ||
| __metadata("design:type", Object) | ||
| ], C.prototype, "c", void 0); | ||
| const x = Foo; | ||
| const y = Bar; | ||
| const z = Baz; | ||
| export {}; |
48 changes: 48 additions & 0 deletions
48
...lines/reference/compiler/decoratorMetadataTypeOnlyUnresolvedImport(module=esnext).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,48 @@ | ||
| //// [tests/cases/compiler/decoratorMetadataTypeOnlyUnresolvedImport.ts] //// | ||
|
|
||
| === decoratorMetadataTypeOnlyUnresolvedImport.ts === | ||
| import type Foo from "./missing-default"; | ||
| >Foo : Symbol(Foo, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 0, 6)) | ||
|
|
||
| import { type Bar } from "./missing-named"; | ||
| >Bar : Symbol(Bar, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 1, 8)) | ||
|
|
||
| import type { default as Baz } from "./missing-default-specifier"; | ||
| >Baz : Symbol(Baz, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 13)) | ||
|
|
||
| function dec(_target: unknown, _key: unknown) {} | ||
| >dec : Symbol(dec, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 66)) | ||
| >_target : Symbol(_target, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 4, 13)) | ||
| >_key : Symbol(_key, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 4, 30)) | ||
|
|
||
| class C { | ||
| >C : Symbol(C, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 4, 48)) | ||
|
|
||
| @dec a!: Foo; | ||
| >dec : Symbol(dec, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 66)) | ||
| >a : Symbol(C.a, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 6, 9)) | ||
| >Foo : Symbol(Foo, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 0, 6)) | ||
|
|
||
| @dec b!: Bar; | ||
| >dec : Symbol(dec, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 66)) | ||
| >b : Symbol(C.b, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 7, 17)) | ||
| >Bar : Symbol(Bar, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 1, 8)) | ||
|
|
||
| @dec c!: Baz; | ||
| >dec : Symbol(dec, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 66)) | ||
| >c : Symbol(C.c, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 8, 17)) | ||
| >Baz : Symbol(Baz, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 13)) | ||
| } | ||
|
|
||
| const x = Foo; | ||
| >x : Symbol(x, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 12, 5)) | ||
| >Foo : Symbol(Foo, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 0, 6)) | ||
|
|
||
| const y = Bar; | ||
| >y : Symbol(y, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 13, 5)) | ||
| >Bar : Symbol(Bar, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 1, 8)) | ||
|
|
||
| const z = Baz; | ||
| >z : Symbol(z, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 14, 5)) | ||
| >Baz : Symbol(Baz, Decl(decoratorMetadataTypeOnlyUnresolvedImport.ts, 2, 13)) | ||
|
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.