From d09bc033123903f359c1ad6fd3a6d8d7fc19298a Mon Sep 17 00:00:00 2001 From: Tee Ming Date: Wed, 8 Jan 2025 17:26:14 +0800 Subject: [PATCH] fix: make param matcher generated type import with a .js extension (#13286) fixes #13280 Similar to #5907 we need to import the param matchers file ending with .js so that when the moduleResolution is set to something strict such as NodeNext (the default for libraries) the type inference isn't lost when it can't resolve the param matcher file due to the lack of a file extension. --- .changeset/slimy-cows-listen.md | 5 +++++ packages/kit/src/core/sync/write_types/index.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/slimy-cows-listen.md diff --git a/.changeset/slimy-cows-listen.md b/.changeset/slimy-cows-listen.md new file mode 100644 index 000000000000..adfca8dadc90 --- /dev/null +++ b/.changeset/slimy-cows-listen.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: make param matchers generated type import end with `.js` diff --git a/packages/kit/src/core/sync/write_types/index.js b/packages/kit/src/core/sync/write_types/index.js index 42728feaf187..e57b00183e6f 100644 --- a/packages/kit/src/core/sync/write_types/index.js +++ b/packages/kit/src/core/sync/write_types/index.js @@ -585,7 +585,7 @@ function replace_ext_with_js(file_path) { function generate_params_type(params, outdir, config) { /** @param {string} matcher */ const path_to_matcher = (matcher) => - posixify(path.relative(outdir, path.join(config.kit.files.params, matcher))); + posixify(path.relative(outdir, path.join(config.kit.files.params, matcher + '.js'))); return `{ ${params .map(