-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposal: importModuleSpecifierPreference: project-relative (#40637)
* Add new importModuleSpecifierPreference value * Add second test * Update API baselines * Clean up and add some comments * Rename option value
- Loading branch information
1 parent
de4a57a
commit 266d8de
Showing
13 changed files
with
197 additions
and
13 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
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
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
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
44 changes: 44 additions & 0 deletions
44
tests/cases/fourslash/server/importNameCodeFix_externalNonRelateive2.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,44 @@ | ||
/// <reference path="../fourslash.ts" /> | ||
|
||
// @Filename: /apps/app1/tsconfig.json | ||
//// { | ||
//// "compilerOptions": { | ||
//// "module": "commonjs", | ||
//// "paths": { | ||
//// "shared/*": ["../../shared/*"] | ||
//// } | ||
//// }, | ||
//// "include": ["src", "../../shared"] | ||
//// } | ||
|
||
// @Filename: /apps/app1/src/index.ts | ||
//// shared/*internal2external*/ | ||
|
||
// @Filename: /apps/app1/src/app.ts | ||
//// utils/*internal2internal*/ | ||
|
||
// @Filename: /apps/app1/src/utils.ts | ||
//// export const utils = 0; | ||
|
||
// @Filename: /shared/constants.ts | ||
//// export const shared = 0; | ||
|
||
// @Filename: /shared/data.ts | ||
//// shared/*external2external*/ | ||
|
||
format.setOption("newline", "\n"); | ||
|
||
goTo.marker("internal2external"); | ||
verify.importFixAtPosition([`import { shared } from "shared/constants";\n\nshared`], /*errorCode*/ undefined, { | ||
importModuleSpecifierPreference: "project-relative" | ||
}); | ||
|
||
goTo.marker("internal2internal"); | ||
verify.importFixAtPosition([`import { utils } from "./utils";\n\nutils`], /*errorCode*/ undefined, { | ||
importModuleSpecifierPreference: "project-relative" | ||
}); | ||
|
||
goTo.marker("external2external"); | ||
verify.importFixAtPosition([`import { shared } from "./constants";\n\nshared`], /*errorCode*/ undefined, { | ||
importModuleSpecifierPreference: "project-relative" | ||
}); |
58 changes: 58 additions & 0 deletions
58
tests/cases/fourslash/server/importNameCodeFix_externalNonRelative1.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,58 @@ | ||
/// <reference path="../fourslash.ts" /> | ||
|
||
// @Filename: /tsconfig.base.json | ||
//// { | ||
//// "compilerOptions": { | ||
//// "module": "commonjs", | ||
//// "paths": { | ||
//// "pkg-1/*": ["./packages/pkg-1/src/*"], | ||
//// "pkg-2/*": ["./packages/pkg-2/src/*"] | ||
//// } | ||
//// } | ||
//// } | ||
|
||
// @Filename: /packages/pkg-1/package.json | ||
//// { "dependencies": { "pkg-2": "*" } } | ||
|
||
// @Filename: /packages/pkg-1/tsconfig.json | ||
//// { | ||
//// "extends": "../../tsconfig.base.json", | ||
//// "references": [ | ||
//// { "path": "../pkg-2" } | ||
//// ] | ||
//// } | ||
|
||
// @Filename: /packages/pkg-1/src/index.ts | ||
//// Pkg2/*external*/ | ||
|
||
// @Filename: /packages/pkg-2/package.json | ||
//// { "types": "dist/index.d.ts" } | ||
|
||
// @Filename: /packages/pkg-2/tsconfig.json | ||
//// { | ||
//// "extends": "../../tsconfig.base.json", | ||
//// "compilerOptions": { "outDir": "dist", "rootDir": "src", "composite": true } | ||
//// } | ||
|
||
// @Filename: /packages/pkg-2/src/index.ts | ||
//// import "./utils"; | ||
|
||
// @Filename: /packages/pkg-2/src/utils.ts | ||
//// export const Pkg2 = {}; | ||
|
||
// @Filename: /packages/pkg-2/src/blah/foo/data.ts | ||
//// Pkg2/*internal*/ | ||
|
||
// @link: /packages/pkg-2 -> /packages/pkg-1/node_modules/pkg-2 | ||
|
||
format.setOption("newline", "\n"); | ||
|
||
goTo.marker("external"); | ||
verify.importFixAtPosition([`import { Pkg2 } from "pkg-2/utils";\n\nPkg2`], /*errorCode*/ undefined, { | ||
importModuleSpecifierPreference: "project-relative" | ||
}); | ||
|
||
goTo.marker("internal"); | ||
verify.importFixAtPosition([`import { Pkg2 } from "../../utils";\n\nPkg2`], /*errorCode*/ undefined, { | ||
importModuleSpecifierPreference: "project-relative" | ||
}); |