Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generated path extension for AwaitedProperties types #5917

Merged
merged 4 commits into from Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/good-mails-crash.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Fix generated extension for AwaitedProperties
lachlancollins marked this conversation as resolved.
Show resolved Hide resolved
18 changes: 7 additions & 11 deletions packages/kit/src/core/sync/write_types.js
Expand Up @@ -431,17 +431,13 @@ function process_node(ts, node, outdir, params, groups) {
function get_data_type(file_path, method, fallback, proxy) {
if (proxy) {
if (proxy.exports.includes(method)) {
if (proxy.modified) {
const basename = path.basename(file_path);
return `Kit.AwaitedProperties<Awaited<ReturnType<typeof import('./proxy${basename}').${method}>>>`;
} else {
// If the file wasn't tweaked, we can use the return type of the original file.
// The advantage is that type updates are reflected without saving.
return `Kit.AwaitedProperties<Awaited<ReturnType<typeof import("${path_to_original(
outdir,
file_path
)}").${method}>>>`;
}
// If the file wasn't tweaked, we can use the return type of the original file.
// The advantage is that type updates are reflected without saving.
const basename = path.basename(file_path);
const from = proxy.modified
? `./proxy${replace_ext_with_js(basename)}`
: path_to_original(outdir, file_path);
lachlancollins marked this conversation as resolved.
Show resolved Hide resolved
return `Kit.AwaitedProperties<Awaited<ReturnType<typeof import('${from}').${method}>>>`;
} else {
return fallback;
}
Expand Down