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

let {data} = $props() is not type safe, and we cannot use export let data in rune mode #11139

Closed
ryoppippi opened this issue Nov 29, 2023 · 4 comments

Comments

@ryoppippi
Copy link

Describe the bug

<script>
export let data; // type prediction works
</script>
<script>
let {data} = $props() // data is predicted as `any`
</script>

Also, we cannot mix export let data and runes ......

Reproduction

Create Sveltekit project and try using props instead of export let data

Logs

name: 'CompileError',
  id: '...app/src/routes/viewer/model/[modelId]/+page.svelte',
  message: '.../app/src/routes/viewer/model/[modelId]/+page.svelte:1:18 Cannot use `export let` in runes mode — use $props instead',
  frame: '1  |  <script lang="ts">\n' +
    '   |                    ^\n' +
    '2  |  \texport let data;\n' +
    '3  |  ',


### System Info

```Shell
System:
    OS: macOS 14.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 2.02 GB / 32.00 GB
    Shell: 3.6.1 - /usr/local/bin/fish
  Binaries:
    Node: 20.9.0 - ~/.volta/tools/image/node/20.9.0/bin/node
    Yarn: 1.22.21 - ~/.bun/bin/yarn
    npm: 10.1.0 - ~/.volta/tools/image/node/20.9.0/bin/npm
    pnpm: 8.11.0 - ~/.bun/bin/pnpm
    bun: 1.0.14 - ~/.local/share/aquaproj-aqua/bin/bun
  Browsers:
    Chrome: 119.0.6045.159
    Safari: 17.1
  npmPackages:
    @sveltejs/adapter-auto: ^2.1.1 => 2.1.1
    @sveltejs/kit: ^1.27.6 => 1.27.6
    svelte: 5.0.0-next.15 => 5.0.0-next.15
    vite: ^4.5.0 => 4.5.0


### Severity

annoyance

### Additional Information

_No response_
@ryoppippi ryoppippi changed the title let {data} = $props() is not type safe. let {data} = $props() is not type safe, and we cannot use export let data in rune mode Nov 29, 2023
@MotionlessTrain
Copy link

$props supports generics to indicate types:

<script lang="ts">
  import type { PageData } from './$types'
  const { data } = $props<{ data: PageData }>()
</script>

@ryoppippi
Copy link
Author

ryoppippi commented Nov 29, 2023

Yeah, currently I'm doing this ! Thanks

	import type { PageData } from './$types';

	// TODO: wait for eslint-plugin-svelte to support runes
	// eslint-disable-next-line no-undef
	let { data } = $props<{ data: PageData }>();

@dummdidumm
Copy link
Member

I assume you mean "zero types", as in, data is automatically typed as import('./$types').PageData? Which version of the VS Code extension and svelte-check are you using? This should work in their latest versions. If not, please provide a more complete reproducible.

@ryoppippi
Copy link
Author

@dummdidumm
I'm using Neovim.
I updated to the svelte-language-server@0.16.1, and I found that the zero types works fine!
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants