Open hyunbinseo opened 3 months ago
This is the workaround I've come up with:
https://github.com/hyunbinseo/svelte-kit-templates/commits/tsconfigs
Seems to work as expected:
// src/routes/+page.ts
import { PUBLIC_SITE_NAME } from '$env/static/public';
import type { PageLoad } from './$types';
export const load = (() => {
[].at(-1); // Property at does not exist on type never[].
return { title: PUBLIC_SITE_NAME };
}) satisfies PageLoad;
// src/routes/+page.server.ts
import { PUBLIC_SITE_NAME } from '$env/static/public';
import type { PageServerLoad } from './$types';
export const load = (() => {
[].at(-1); // No error
return { title: PUBLIC_SITE_NAME };
}) satisfies PageServerLoad;
svelte-check
seems to only utilize the root tsconfig.json
file.
svelte-check
results// src/routes/+page.server.ts
[].at(-1); // No error in the editor
pnpm check
# Error: Property 'at' does not exist on type 'never[]'.
# Do you need to change your target library?
# Try changing the 'lib' compiler option to 'es2022' or later.
Describe the problem
Out-of-the box, SvelteKit uses:
node18.13
for SSR. This is a hard-coded value.Therefore, users can safely assume that SvelteKit and Svelte requires ES2020[^1].
[^1]: SvelteKit v2 did require ES2022 in its early stages, but it was rolled back.
However, the default
tsconfig.json
enablesesnext
APIs to be used globally.Since Vite does not automatically polyfill APIs, this could be problematic.
Describe the proposed solution
compilerOptions.lib
toes2020
(or the value SvelteKit v3 requires)compilerOptions.lib
toes2022
for the server files. (or the SK3 requirements)compilerOptions.lib
andbuild.target
.Alternatives considered
No response
Importance
would make my life easier
Additional Information
This will have the added benefit of specifying Svelte v5, SvelteKit v3 requirements.
Blocked by: