mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-11 09:24:19 -06:00
Allow subpath imports that start with #/ (#62844)
This commit is contained in:
parent
ab142be459
commit
3b9acae97c
@ -1690,13 +1690,16 @@ export enum NodeResolutionFeatures {
|
||||
// allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"`
|
||||
// not supported in node 12 - https://github.com/nodejs/Release/issues/690
|
||||
ExportsPatternTrailers = 1 << 4,
|
||||
AllFeatures = Imports | SelfName | Exports | ExportsPatternTrailers,
|
||||
// allowing `#/` root imports in package.json imports field
|
||||
// not supported until mass adoption - https://github.com/nodejs/node/pull/60864
|
||||
ImportsPatternRoot = 1 << 6,
|
||||
AllFeatures = Imports | SelfName | Exports | ExportsPatternTrailers | ImportsPatternRoot,
|
||||
|
||||
Node16Default = Imports | SelfName | Exports | ExportsPatternTrailers,
|
||||
|
||||
NodeNextDefault = AllFeatures,
|
||||
|
||||
BundlerDefault = Imports | SelfName | Exports | ExportsPatternTrailers,
|
||||
BundlerDefault = Imports | SelfName | Exports | ExportsPatternTrailers | ImportsPatternRoot,
|
||||
|
||||
EsmMode = 1 << 5,
|
||||
}
|
||||
@ -2646,7 +2649,7 @@ function loadModuleFromExports(scope: PackageJsonInfo, extensions: Extensions, s
|
||||
}
|
||||
|
||||
function loadModuleFromImports(extensions: Extensions, moduleName: string, directory: string, state: ModuleResolutionState, cache: ModuleResolutionCache | undefined, redirectedReference: ResolvedProjectReference | undefined): SearchResult<Resolved> {
|
||||
if (moduleName === "#" || startsWith(moduleName, "#/")) {
|
||||
if (moduleName === "#" || (startsWith(moduleName, "#/") && !(state.features & NodeResolutionFeatures.ImportsPatternRoot))) {
|
||||
if (state.traceEnabled) {
|
||||
trace(state.host, Diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions, moduleName);
|
||||
}
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
//// [tests/cases/conformance/node/nodeModulesPackageImportsRootWildcard.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"imports": {
|
||||
"#/*": "./src/*"
|
||||
}
|
||||
}
|
||||
//// [foo.ts]
|
||||
export const foo = "foo";
|
||||
//// [bar.ts]
|
||||
export const bar = "bar";
|
||||
//// [baz.ts]
|
||||
export const baz = "baz";
|
||||
//// [index.ts]
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
import { bar } from "#/features/bar.js";
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
foo;
|
||||
bar;
|
||||
baz;
|
||||
//// [index.mts]
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
import { bar } from "#/features/bar.js";
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
foo;
|
||||
bar;
|
||||
baz;
|
||||
//// [index.cts]
|
||||
// cjs format file
|
||||
import { foo } from "#/foo.js";
|
||||
import { bar } from "#/features/bar.js";
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
foo;
|
||||
bar;
|
||||
baz;
|
||||
|
||||
|
||||
//// [foo.js]
|
||||
export const foo = "foo";
|
||||
//// [bar.js]
|
||||
export const bar = "bar";
|
||||
//// [baz.js]
|
||||
export const baz = "baz";
|
||||
//// [index.js]
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
import { bar } from "#/features/bar.js";
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
foo;
|
||||
bar;
|
||||
baz;
|
||||
//// [index.mjs]
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
import { bar } from "#/features/bar.js";
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
foo;
|
||||
bar;
|
||||
baz;
|
||||
//// [index.cjs]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// cjs format file
|
||||
const foo_js_1 = require("#/foo.js");
|
||||
const bar_js_1 = require("#/features/bar.js");
|
||||
const baz_js_1 = require("#/nested/deep/baz.js");
|
||||
foo_js_1.foo;
|
||||
bar_js_1.bar;
|
||||
baz_js_1.baz;
|
||||
|
||||
|
||||
//// [foo.d.ts]
|
||||
export declare const foo = "foo";
|
||||
//// [bar.d.ts]
|
||||
export declare const bar = "bar";
|
||||
//// [baz.d.ts]
|
||||
export declare const baz = "baz";
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
//// [index.d.mts]
|
||||
export {};
|
||||
//// [index.d.cts]
|
||||
export {};
|
||||
@ -0,0 +1,74 @@
|
||||
//// [tests/cases/conformance/node/nodeModulesPackageImportsRootWildcard.ts] ////
|
||||
|
||||
=== src/foo.ts ===
|
||||
export const foo = "foo";
|
||||
>foo : Symbol(foo, Decl(foo.ts, 0, 12))
|
||||
|
||||
=== src/features/bar.ts ===
|
||||
export const bar = "bar";
|
||||
>bar : Symbol(bar, Decl(bar.ts, 0, 12))
|
||||
|
||||
=== src/nested/deep/baz.ts ===
|
||||
export const baz = "baz";
|
||||
>baz : Symbol(baz, Decl(baz.ts, 0, 12))
|
||||
|
||||
=== index.ts ===
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
>foo : Symbol(foo, Decl(index.ts, 1, 8))
|
||||
|
||||
import { bar } from "#/features/bar.js";
|
||||
>bar : Symbol(bar, Decl(index.ts, 2, 8))
|
||||
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
>baz : Symbol(baz, Decl(index.ts, 3, 8))
|
||||
|
||||
foo;
|
||||
>foo : Symbol(foo, Decl(index.ts, 1, 8))
|
||||
|
||||
bar;
|
||||
>bar : Symbol(bar, Decl(index.ts, 2, 8))
|
||||
|
||||
baz;
|
||||
>baz : Symbol(baz, Decl(index.ts, 3, 8))
|
||||
|
||||
=== index.mts ===
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
>foo : Symbol(foo, Decl(index.mts, 1, 8))
|
||||
|
||||
import { bar } from "#/features/bar.js";
|
||||
>bar : Symbol(bar, Decl(index.mts, 2, 8))
|
||||
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
>baz : Symbol(baz, Decl(index.mts, 3, 8))
|
||||
|
||||
foo;
|
||||
>foo : Symbol(foo, Decl(index.mts, 1, 8))
|
||||
|
||||
bar;
|
||||
>bar : Symbol(bar, Decl(index.mts, 2, 8))
|
||||
|
||||
baz;
|
||||
>baz : Symbol(baz, Decl(index.mts, 3, 8))
|
||||
|
||||
=== index.cts ===
|
||||
// cjs format file
|
||||
import { foo } from "#/foo.js";
|
||||
>foo : Symbol(foo, Decl(index.cts, 1, 8))
|
||||
|
||||
import { bar } from "#/features/bar.js";
|
||||
>bar : Symbol(bar, Decl(index.cts, 2, 8))
|
||||
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
>baz : Symbol(baz, Decl(index.cts, 3, 8))
|
||||
|
||||
foo;
|
||||
>foo : Symbol(foo, Decl(index.cts, 1, 8))
|
||||
|
||||
bar;
|
||||
>bar : Symbol(bar, Decl(index.cts, 2, 8))
|
||||
|
||||
baz;
|
||||
>baz : Symbol(baz, Decl(index.cts, 3, 8))
|
||||
|
||||
@ -0,0 +1,243 @@
|
||||
[
|
||||
"File '/.src/src/package.json' does not exist.",
|
||||
"Found 'package.json' at '/.src/package.json'.",
|
||||
"File '/.src/src/features/package.json' does not exist.",
|
||||
"File '/.src/src/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.src/package.json' exists according to earlier cached lookups.",
|
||||
"File '/.src/src/nested/deep/package.json' does not exist.",
|
||||
"File '/.src/src/nested/package.json' does not exist.",
|
||||
"File '/.src/src/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.src/package.json' exists according to earlier cached lookups.",
|
||||
"File '/.src/package.json' exists according to earlier cached lookups.",
|
||||
"======== Resolving module '#/foo.js' from '/.src/index.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeNext'.",
|
||||
"Resolving in ESM mode with conditions 'import', 'types', 'node'.",
|
||||
"File '/.src/package.json' exists according to earlier cached lookups.",
|
||||
"Using 'imports' subpath '#/*' with target './src/foo.js'.",
|
||||
"File name '/.src/src/foo.js' has a '.js' extension - stripping it.",
|
||||
"File '/.src/src/foo.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name '#/foo.js' was successfully resolved to '/.src/src/foo.ts'. ========",
|
||||
"======== Resolving module '#/features/bar.js' from '/.src/index.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeNext'.",
|
||||
"Resolving in ESM mode with conditions 'import', 'types', 'node'.",
|
||||
"File '/.src/package.json' exists according to earlier cached lookups.",
|
||||
"Using 'imports' subpath '#/*' with target './src/features/bar.js'.",
|
||||
"File name '/.src/src/features/bar.js' has a '.js' extension - stripping it.",
|
||||
"File '/.src/src/features/bar.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name '#/features/bar.js' was successfully resolved to '/.src/src/features/bar.ts'. ========",
|
||||
"======== Resolving module '#/nested/deep/baz.js' from '/.src/index.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeNext'.",
|
||||
"Resolving in ESM mode with conditions 'import', 'types', 'node'.",
|
||||
"File '/.src/package.json' exists according to earlier cached lookups.",
|
||||
"Using 'imports' subpath '#/*' with target './src/nested/deep/baz.js'.",
|
||||
"File name '/.src/src/nested/deep/baz.js' has a '.js' extension - stripping it.",
|
||||
"File '/.src/src/nested/deep/baz.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name '#/nested/deep/baz.js' was successfully resolved to '/.src/src/nested/deep/baz.ts'. ========",
|
||||
"======== Resolving module '#/foo.js' from '/.src/index.mts'. ========",
|
||||
"Resolution for module '#/foo.js' was found in cache from location '/.src'.",
|
||||
"======== Module name '#/foo.js' was successfully resolved to '/.src/src/foo.ts'. ========",
|
||||
"======== Resolving module '#/features/bar.js' from '/.src/index.mts'. ========",
|
||||
"Resolution for module '#/features/bar.js' was found in cache from location '/.src'.",
|
||||
"======== Module name '#/features/bar.js' was successfully resolved to '/.src/src/features/bar.ts'. ========",
|
||||
"======== Resolving module '#/nested/deep/baz.js' from '/.src/index.mts'. ========",
|
||||
"Resolution for module '#/nested/deep/baz.js' was found in cache from location '/.src'.",
|
||||
"======== Module name '#/nested/deep/baz.js' was successfully resolved to '/.src/src/nested/deep/baz.ts'. ========",
|
||||
"======== Resolving module '#/foo.js' from '/.src/index.cts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeNext'.",
|
||||
"Resolving in CJS mode with conditions 'require', 'types', 'node'.",
|
||||
"File '/.src/package.json' exists according to earlier cached lookups.",
|
||||
"Using 'imports' subpath '#/*' with target './src/foo.js'.",
|
||||
"File name '/.src/src/foo.js' has a '.js' extension - stripping it.",
|
||||
"File '/.src/src/foo.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name '#/foo.js' was successfully resolved to '/.src/src/foo.ts'. ========",
|
||||
"======== Resolving module '#/features/bar.js' from '/.src/index.cts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeNext'.",
|
||||
"Resolving in CJS mode with conditions 'require', 'types', 'node'.",
|
||||
"File '/.src/package.json' exists according to earlier cached lookups.",
|
||||
"Using 'imports' subpath '#/*' with target './src/features/bar.js'.",
|
||||
"File name '/.src/src/features/bar.js' has a '.js' extension - stripping it.",
|
||||
"File '/.src/src/features/bar.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name '#/features/bar.js' was successfully resolved to '/.src/src/features/bar.ts'. ========",
|
||||
"======== Resolving module '#/nested/deep/baz.js' from '/.src/index.cts'. ========",
|
||||
"Module resolution kind is not specified, using 'NodeNext'.",
|
||||
"Resolving in CJS mode with conditions 'require', 'types', 'node'.",
|
||||
"File '/.src/package.json' exists according to earlier cached lookups.",
|
||||
"Using 'imports' subpath '#/*' with target './src/nested/deep/baz.js'.",
|
||||
"File name '/.src/src/nested/deep/baz.js' has a '.js' extension - stripping it.",
|
||||
"File '/.src/src/nested/deep/baz.ts' exists - use it as a name resolution result.",
|
||||
"======== Module name '#/nested/deep/baz.js' was successfully resolved to '/.src/src/nested/deep/baz.ts'. ========",
|
||||
"File '/.ts/package.json' does not exist.",
|
||||
"File '/package.json' does not exist.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups."
|
||||
]
|
||||
@ -0,0 +1,101 @@
|
||||
//// [tests/cases/conformance/node/nodeModulesPackageImportsRootWildcard.ts] ////
|
||||
|
||||
=== src/foo.ts ===
|
||||
export const foo = "foo";
|
||||
>foo : "foo"
|
||||
> : ^^^^^
|
||||
>"foo" : "foo"
|
||||
> : ^^^^^
|
||||
|
||||
=== src/features/bar.ts ===
|
||||
export const bar = "bar";
|
||||
>bar : "bar"
|
||||
> : ^^^^^
|
||||
>"bar" : "bar"
|
||||
> : ^^^^^
|
||||
|
||||
=== src/nested/deep/baz.ts ===
|
||||
export const baz = "baz";
|
||||
>baz : "baz"
|
||||
> : ^^^^^
|
||||
>"baz" : "baz"
|
||||
> : ^^^^^
|
||||
|
||||
=== index.ts ===
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
>foo : "foo"
|
||||
> : ^^^^^
|
||||
|
||||
import { bar } from "#/features/bar.js";
|
||||
>bar : "bar"
|
||||
> : ^^^^^
|
||||
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
>baz : "baz"
|
||||
> : ^^^^^
|
||||
|
||||
foo;
|
||||
>foo : "foo"
|
||||
> : ^^^^^
|
||||
|
||||
bar;
|
||||
>bar : "bar"
|
||||
> : ^^^^^
|
||||
|
||||
baz;
|
||||
>baz : "baz"
|
||||
> : ^^^^^
|
||||
|
||||
=== index.mts ===
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
>foo : "foo"
|
||||
> : ^^^^^
|
||||
|
||||
import { bar } from "#/features/bar.js";
|
||||
>bar : "bar"
|
||||
> : ^^^^^
|
||||
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
>baz : "baz"
|
||||
> : ^^^^^
|
||||
|
||||
foo;
|
||||
>foo : "foo"
|
||||
> : ^^^^^
|
||||
|
||||
bar;
|
||||
>bar : "bar"
|
||||
> : ^^^^^
|
||||
|
||||
baz;
|
||||
>baz : "baz"
|
||||
> : ^^^^^
|
||||
|
||||
=== index.cts ===
|
||||
// cjs format file
|
||||
import { foo } from "#/foo.js";
|
||||
>foo : "foo"
|
||||
> : ^^^^^
|
||||
|
||||
import { bar } from "#/features/bar.js";
|
||||
>bar : "bar"
|
||||
> : ^^^^^
|
||||
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
>baz : "baz"
|
||||
> : ^^^^^
|
||||
|
||||
foo;
|
||||
>foo : "foo"
|
||||
> : ^^^^^
|
||||
|
||||
bar;
|
||||
>bar : "bar"
|
||||
> : ^^^^^
|
||||
|
||||
baz;
|
||||
>baz : "baz"
|
||||
> : ^^^^^
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
index.ts(2,21): error TS2307: Cannot find module '#/foo.js' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== package.json (0 errors) ====
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"imports": {
|
||||
"#/*": "./src/*"
|
||||
}
|
||||
}
|
||||
==== src/foo.ts (0 errors) ====
|
||||
export const foo = "foo";
|
||||
==== index.ts (1 errors) ====
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module '#/foo.js' or its corresponding type declarations.
|
||||
foo;
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
//// [tests/cases/conformance/node/nodeModulesPackageImportsRootWildcardNode16.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"imports": {
|
||||
"#/*": "./src/*"
|
||||
}
|
||||
}
|
||||
//// [foo.ts]
|
||||
export const foo = "foo";
|
||||
//// [index.ts]
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
foo;
|
||||
|
||||
|
||||
//// [foo.js]
|
||||
export const foo = "foo";
|
||||
//// [index.js]
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
foo;
|
||||
|
||||
|
||||
//// [foo.d.ts]
|
||||
export declare const foo = "foo";
|
||||
//// [index.d.ts]
|
||||
export {};
|
||||
@ -0,0 +1,14 @@
|
||||
//// [tests/cases/conformance/node/nodeModulesPackageImportsRootWildcardNode16.ts] ////
|
||||
|
||||
=== src/foo.ts ===
|
||||
export const foo = "foo";
|
||||
>foo : Symbol(foo, Decl(foo.ts, 0, 12))
|
||||
|
||||
=== index.ts ===
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
>foo : Symbol(foo, Decl(index.ts, 1, 8))
|
||||
|
||||
foo;
|
||||
>foo : Symbol(foo, Decl(index.ts, 1, 8))
|
||||
|
||||
@ -0,0 +1,150 @@
|
||||
[
|
||||
"File '/.src/src/package.json' does not exist.",
|
||||
"Found 'package.json' at '/.src/package.json'.",
|
||||
"File '/.src/package.json' exists according to earlier cached lookups.",
|
||||
"======== Resolving module '#/foo.js' from '/.src/index.ts'. ========",
|
||||
"Module resolution kind is not specified, using 'Node16'.",
|
||||
"Resolving in ESM mode with conditions 'import', 'types', 'node'.",
|
||||
"Invalid import specifier '#/foo.js' has no possible resolutions.",
|
||||
"File '/.src/package.json' exists according to earlier cached lookups.",
|
||||
"Loading module '#/foo.js' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.",
|
||||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"File name '/.src/node_modules/#/foo.js' has a '.js' extension - stripping it.",
|
||||
"File name '/.src/node_modules/@types/#/foo.js' has a '.js' extension - stripping it.",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"File name '/node_modules/#/foo.js' has a '.js' extension - stripping it.",
|
||||
"File name '/node_modules/@types/#/foo.js' has a '.js' extension - stripping it.",
|
||||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.",
|
||||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.",
|
||||
"File name '/.src/node_modules/#/foo.js' has a '.js' extension - stripping it.",
|
||||
"Directory '/node_modules' does not exist, skipping all lookups in it.",
|
||||
"File name '/node_modules/#/foo.js' has a '.js' extension - stripping it.",
|
||||
"======== Module name '#/foo.js' was not resolved. ========",
|
||||
"File '/.ts/package.json' does not exist.",
|
||||
"File '/package.json' does not exist.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/.ts/package.json' does not exist according to earlier cached lookups.",
|
||||
"File '/package.json' does not exist according to earlier cached lookups."
|
||||
]
|
||||
@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/node/nodeModulesPackageImportsRootWildcardNode16.ts] ////
|
||||
|
||||
=== src/foo.ts ===
|
||||
export const foo = "foo";
|
||||
>foo : "foo"
|
||||
> : ^^^^^
|
||||
>"foo" : "foo"
|
||||
> : ^^^^^
|
||||
|
||||
=== index.ts ===
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
>foo : any
|
||||
> : ^^^
|
||||
|
||||
foo;
|
||||
>foo : any
|
||||
> : ^^^
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
// @module: nodenext
|
||||
// @declaration: true
|
||||
// @traceResolution: true
|
||||
// @filename: package.json
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"imports": {
|
||||
"#/*": "./src/*"
|
||||
}
|
||||
}
|
||||
// @filename: src/foo.ts
|
||||
export const foo = "foo";
|
||||
// @filename: src/features/bar.ts
|
||||
export const bar = "bar";
|
||||
// @filename: src/nested/deep/baz.ts
|
||||
export const baz = "baz";
|
||||
// @filename: index.ts
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
import { bar } from "#/features/bar.js";
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
foo;
|
||||
bar;
|
||||
baz;
|
||||
// @filename: index.mts
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
import { bar } from "#/features/bar.js";
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
foo;
|
||||
bar;
|
||||
baz;
|
||||
// @filename: index.cts
|
||||
// cjs format file
|
||||
import { foo } from "#/foo.js";
|
||||
import { bar } from "#/features/bar.js";
|
||||
import { baz } from "#/nested/deep/baz.js";
|
||||
foo;
|
||||
bar;
|
||||
baz;
|
||||
@ -0,0 +1,18 @@
|
||||
// @module: node16
|
||||
// @declaration: true
|
||||
// @traceResolution: true
|
||||
// @filename: package.json
|
||||
{
|
||||
"name": "package",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"imports": {
|
||||
"#/*": "./src/*"
|
||||
}
|
||||
}
|
||||
// @filename: src/foo.ts
|
||||
export const foo = "foo";
|
||||
// @filename: index.ts
|
||||
// esm format file
|
||||
import { foo } from "#/foo.js";
|
||||
foo;
|
||||
@ -0,0 +1,25 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @module: nodenext
|
||||
|
||||
// @Filename: /package.json
|
||||
//// {
|
||||
//// "imports": {
|
||||
//// "#/*": "./src/*"
|
||||
//// }
|
||||
//// }
|
||||
|
||||
// @Filename: /src/something.ts
|
||||
//// export function something(name: string): any;
|
||||
|
||||
// @Filename: /src/features/bar.ts
|
||||
//// export function bar(): any;
|
||||
|
||||
// @Filename: /a.ts
|
||||
//// import {} from "#//*1*/";
|
||||
|
||||
verify.completions({
|
||||
marker: ["1"],
|
||||
exact: ["something.js", "features"],
|
||||
isNewIdentifierLocation: true,
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user