diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs index 25a39b68d2..ddbc79cec1 100644 --- a/cli/tests/integration/npm_tests.rs +++ b/cli/tests/integration/npm_tests.rs @@ -433,6 +433,13 @@ itest!(types_no_types_entry { exit_code: 1, }); +itest!(types_d_ext { + args: "check --all npm/d_ext/main.ts", + output: "npm/d_ext/main.out", + envs: env_vars_for_npm_tests(), + http_server: true, +}); + itest!(typescript_file_in_package { args: "run npm/typescript_file_in_package/main.ts", output: "npm/typescript_file_in_package/main.out", diff --git a/cli/tests/testdata/npm/d_ext/main.out b/cli/tests/testdata/npm/d_ext/main.out new file mode 100644 index 0000000000..e96c6e3920 --- /dev/null +++ b/cli/tests/testdata/npm/d_ext/main.out @@ -0,0 +1,3 @@ +Download http://localhost:4545/npm/registry/@denotest/d-ext +Download http://localhost:4545/npm/registry/@denotest/d-ext/1.0.0.tgz +Check file:///[WILDCARD]/npm/d_ext/main.ts diff --git a/cli/tests/testdata/npm/d_ext/main.ts b/cli/tests/testdata/npm/d_ext/main.ts new file mode 100644 index 0000000000..c92dbe0659 --- /dev/null +++ b/cli/tests/testdata/npm/d_ext/main.ts @@ -0,0 +1,3 @@ +import { test } from "npm:@denotest/d-ext"; + +console.log(test); diff --git a/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/index.d.ts b/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/index.d.ts new file mode 100644 index 0000000000..47326c0f62 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/index.d.ts @@ -0,0 +1 @@ +export const test: typeof import("./types.d").value; diff --git a/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/index.js new file mode 100644 index 0000000000..62b353f3d6 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/index.js @@ -0,0 +1 @@ +module.exports.test = 5; diff --git a/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/package.json new file mode 100644 index 0000000000..a0702a56b4 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/package.json @@ -0,0 +1,5 @@ +{ + "name": "d-ext", + "version": "1.0.0", + "main": "./index.js" +} \ No newline at end of file diff --git a/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/types.d.ts b/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/types.d.ts new file mode 100644 index 0000000000..dedc54b038 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/d-ext/1.0.0/types.d.ts @@ -0,0 +1 @@ +export const value: 5; diff --git a/ext/node/resolution.rs b/ext/node/resolution.rs index 22ab47ce64..cbe9f643f9 100644 --- a/ext/node/resolution.rs +++ b/ext/node/resolution.rs @@ -1378,7 +1378,9 @@ fn is_relative_specifier(specifier: &str) -> bool { /// Alternate `PathBuf::with_extension` that will handle known extensions /// more intelligently. fn with_known_extension(path: &Path, ext: &str) -> PathBuf { - const NON_DECL_EXTS: &[&str] = &["cjs", "js", "json", "jsx", "mjs", "tsx"]; + const NON_DECL_EXTS: &[&str] = &[ + "cjs", "js", "json", "jsx", "mjs", "tsx", /* ex. types.d */ "d", + ]; const DECL_EXTS: &[&str] = &["cts", "mts", "ts"]; let file_name = match path.file_name() {