-
Notifications
You must be signed in to change notification settings - Fork 651
Port TypeScript PR #59767: Rewrite relative import extensions with flag #1138
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
Merged
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
84de4c9
Initial plan for issue
Copilot e2fabea
Implement rewriteRelativeImportExtensions feature
Copilot 144f55f
Fix: make shouldRewriteModuleSpecifier function private
Copilot e9fde2c
Fix: debug and implement correct diagnostic logic for unsafe import r…
Copilot be25d24
Fix: move sourceFileMayBeEmitted to outputpaths and implement GetRela…
Copilot ba765e4
Update baselines for packageJsonImportsErrors tests
Copilot 08d918e
Refactor: move sourceFileMayBeEmitted to outputpaths and add forceDts…
Copilot 2ca8702
Refactor: move shouldRewriteModuleSpecifier to core package
Copilot 8cecfc9
Fix: restore sourceFileMayBeEmitted to emitter.go and add program con…
Copilot 9a3814a
Refactor: move sourceFileMayBeEmitted to Program interface as requested
Copilot 4a16dba
Merge branch 'main' into copilot/fix-1113-2
andrewbranch fef4f59
Format and fix test
andrewbranch 601d405
Implement project reference check for rewriteRelativeImportExtensions
Copilot 954314f
Use existing project reference mapping methods
andrewbranch eb63e5e
Use existing CommonSourceDirectory method name and remove unused methods
Copilot 6f1e067
Add project references tests
andrewbranch 10c3a00
Format
andrewbranch 2139af4
Fix test compilation
andrewbranch 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
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
12 changes: 12 additions & 0 deletions
12
testdata/baselines/reference/submodule/conformance/cjsErrors(module=node18).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,12 @@ | ||
index.ts(1,22): error TS2876: This relative import path is unsafe to rewrite because it looks like a file name, but actually resolves to "./foo.ts/index.ts". | ||
|
||
|
||
==== index.ts (1 errors) ==== | ||
import foo = require("./foo.ts"); // Error | ||
~~~~~~~~~~ | ||
!!! error TS2876: This relative import path is unsafe to rewrite because it looks like a file name, but actually resolves to "./foo.ts/index.ts". | ||
import type _foo = require("./foo.ts"); // Ok | ||
|
||
==== foo.ts/index.ts (0 errors) ==== | ||
export = {}; | ||
|
16 changes: 0 additions & 16 deletions
16
testdata/baselines/reference/submodule/conformance/cjsErrors(module=node18).errors.txt.diff
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
testdata/baselines/reference/submodule/conformance/cjsErrors(module=nodenext).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,12 @@ | ||
index.ts(1,22): error TS2876: This relative import path is unsafe to rewrite because it looks like a file name, but actually resolves to "./foo.ts/index.ts". | ||
|
||
|
||
==== index.ts (1 errors) ==== | ||
import foo = require("./foo.ts"); // Error | ||
~~~~~~~~~~ | ||
!!! error TS2876: This relative import path is unsafe to rewrite because it looks like a file name, but actually resolves to "./foo.ts/index.ts". | ||
import type _foo = require("./foo.ts"); // Ok | ||
|
||
==== foo.ts/index.ts (0 errors) ==== | ||
export = {}; | ||
|
16 changes: 0 additions & 16 deletions
16
...data/baselines/reference/submodule/conformance/cjsErrors(module=nodenext).errors.txt.diff
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
...elines/reference/submodule/conformance/packageJsonImportsErrors(module=node18).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,31 @@ | ||
/index.ts(2,16): error TS2877: This import uses a '.ts' extension to resolve to an input TypeScript file, but will not be rewritten during emit because it is not a relative path. | ||
|
||
|
||
==== /package.json (0 errors) ==== | ||
{ | ||
"name": "pkg", | ||
"type": "module", | ||
"imports": { | ||
"#foo.ts": "./foo.ts", | ||
"#internal/*": "./internal/*" | ||
}, | ||
"exports": { | ||
"./*.ts": { | ||
"source": "./*.ts", | ||
"default": "./*.js" | ||
} | ||
} | ||
} | ||
|
||
==== /foo.ts (0 errors) ==== | ||
export {}; | ||
|
||
==== /internal/foo.ts (0 errors) ==== | ||
export {}; | ||
|
||
==== /index.ts (1 errors) ==== | ||
import {} from "#foo.ts"; // Ok | ||
import {} from "#internal/foo.ts"; // Error | ||
~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2877: This import uses a '.ts' extension to resolve to an input TypeScript file, but will not be rewritten during emit because it is not a relative path. | ||
import {} from "pkg/foo.ts"; // Ok |
35 changes: 0 additions & 35 deletions
35
...s/reference/submodule/conformance/packageJsonImportsErrors(module=node18).errors.txt.diff
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
...ines/reference/submodule/conformance/packageJsonImportsErrors(module=nodenext).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,31 @@ | ||
/index.ts(2,16): error TS2877: This import uses a '.ts' extension to resolve to an input TypeScript file, but will not be rewritten during emit because it is not a relative path. | ||
|
||
|
||
==== /package.json (0 errors) ==== | ||
{ | ||
"name": "pkg", | ||
"type": "module", | ||
"imports": { | ||
"#foo.ts": "./foo.ts", | ||
"#internal/*": "./internal/*" | ||
}, | ||
"exports": { | ||
"./*.ts": { | ||
"source": "./*.ts", | ||
"default": "./*.js" | ||
} | ||
} | ||
} | ||
|
||
==== /foo.ts (0 errors) ==== | ||
export {}; | ||
|
||
==== /internal/foo.ts (0 errors) ==== | ||
export {}; | ||
|
||
==== /index.ts (1 errors) ==== | ||
import {} from "#foo.ts"; // Ok | ||
import {} from "#internal/foo.ts"; // Error | ||
~~~~~~~~~~~~~~~~~~ | ||
!!! error TS2877: This import uses a '.ts' extension to resolve to an input TypeScript file, but will not be rewritten during emit because it is not a relative path. | ||
import {} from "pkg/foo.ts"; // Ok |
35 changes: 0 additions & 35 deletions
35
...reference/submodule/conformance/packageJsonImportsErrors(module=nodenext).errors.txt.diff
This file was deleted.
Oops, something went wrong.
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.