-
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.
Fix auto import file extensions with package.json imports wildcards (#…
- Loading branch information
1 parent
f3b118e
commit 4b12d82
Showing
5 changed files
with
161 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
41 changes: 41 additions & 0 deletions
41
tests/cases/fourslash/autoImportAllowImportingTsExtensionsPackageJsonImports1.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,41 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: nodenext | ||
// @allowImportingTsExtensions: true | ||
|
||
// @Filename: /node_modules/pkg/package.json | ||
//// { | ||
//// "name": "pkg", | ||
//// "type": "module", | ||
//// "exports": { | ||
//// "./*": { | ||
//// "types": "./types/*", | ||
//// "default": "./dist/*" | ||
//// } | ||
//// } | ||
//// } | ||
|
||
// @Filename: /node_modules/pkg/types/external.d.ts | ||
//// export declare function external(name: string): any; | ||
|
||
// @Filename: /package.json | ||
//// { | ||
//// "name": "self", | ||
//// "type": "module", | ||
//// "imports": { | ||
//// "#*": "./src/*" | ||
//// }, | ||
//// "dependencies": { | ||
//// "pkg": "*" | ||
//// } | ||
//// } | ||
|
||
// @Filename: /src/add.ts | ||
//// export function add(a: number, b: number) {} | ||
|
||
// @Filename: /src/index.ts | ||
//// add/*imports*/; | ||
//// external/*exports*/; | ||
|
||
verify.importFixModuleSpecifiers("imports", ["#add.ts"]); | ||
verify.importFixModuleSpecifiers("exports", ["pkg/external.js"]); |
34 changes: 34 additions & 0 deletions
34
tests/cases/fourslash/autoImportAllowImportingTsExtensionsPackageJsonImports2.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,34 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @Filename: /tsconfig.json | ||
//// { | ||
//// "compilerOptions": { | ||
//// "module": "nodenext", | ||
//// "allowImportingTsExtensions": true, | ||
//// "rootDir": "src", | ||
//// "outDir": "dist", | ||
//// "declarationDir": "types", | ||
//// "declaration": true | ||
//// } | ||
//// } | ||
|
||
// @Filename: /package.json | ||
//// { | ||
//// "name": "self", | ||
//// "type": "module", | ||
//// "imports": { | ||
//// "#*": { | ||
//// "types": "./types/*", | ||
//// "default": "./dist/*" | ||
//// } | ||
//// } | ||
//// } | ||
|
||
// @Filename: /src/add.ts | ||
//// export function add(a: number, b: number) {} | ||
|
||
// @Filename: /src/index.ts | ||
//// add/*imports*/; | ||
//// external/*exports*/; | ||
|
||
verify.importFixModuleSpecifiers("imports", ["#add.js"]); |
20 changes: 20 additions & 0 deletions
20
tests/cases/fourslash/autoImportPackageJsonImportsCaseSensitivity.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,20 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: nodenext | ||
// @allowImportingTsExtensions: true | ||
|
||
// @Filename: /package.json | ||
//// { | ||
//// "type": "module", | ||
//// "imports": { | ||
//// "#src/*": "./SRC/*" | ||
//// } | ||
//// } | ||
|
||
// @Filename: /src/add.ts | ||
//// export function add(a: number, b: number) {} | ||
|
||
// @Filename: /src/index.ts | ||
//// add/*imports*/; | ||
|
||
verify.importFixModuleSpecifiers("imports", ["#src/add.ts"], { importModuleSpecifierPreference: "non-relative" }); |