-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Description
If tsconfig.json does not contain compilerOptions and instead references other tsconfigs, svelte-preprocess fails to get the actual TS configs. In particular, it results in the fallbacked target ES2015, where object resting isn't supported yet (it was added in ES2018), and the following component fails to compile:
<script lang="ts">
let { foo = $bindable("foo"), ...rest } = $props();
</script>
{foo} {Object.keys(rest)}[plugin:vite-plugin-svelte] src/App.svelte:12:27 `$bindable()` can only be used inside a `$props()` declaration
https://svelte.dev/e/bindable_invalid_location
src/App.svelte:12:27
10 | return t;
11 | };
12 | let _a = $props(), { foo = $bindable("foo") } = _a, rest = __rest(_a, ["foo"]);
^
13 | </script>
14 |
To Reproduce
- Create a project via
npm create vite, select Svelte and Typescript. - Install svelte-preprocess
npm i svelte-preprocessand apply itvite.config.ts
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { sveltePreprocess } from 'svelte-preprocess';
// https://vite.dev/config/
export default defineConfig({
plugins: [svelte({
preprocess: sveltePreprocess()
})],
})- Add the aforementioned component.
- Run the project.
Expected behavior
The component is successfully compiled.
Information about your project:
svelte-preprocessversion 6.0.3
Metadata
Metadata
Assignees
Labels
No labels