svelte-material-ui
svelte-material-ui copied to clipboard
Type incompatible error in 8.0.0-beta.0
Describe the bug
When using Button like this:
<script lang="ts">
import '../app.css';
let { children } = $props();
import Button, { Label } from '@smui/button';
</script>
<Button>
<Label>sss</Label>
</Button>
{@render children()}
I get error:
Type '{ children: () => any; }' is not assignable to type 'Record<string, never> & { children?: any; }'.
Type '{ children: () => any; }' is not assignable to type 'Record<string, never>'.
Property 'children' is incompatible with index signature.
Type '() => any' is not assignable to type 'never'.ts(2322)
To Reproduce
pnpx sv create --template minimal --types ts svelte5_smui8_demo- choose
eslint+tailwindcss - no tailwindcss plugin
- choose
pnpm - open project with vscode, enable svelte typescript plugin if asked (I'm using vscode with 'Svelte for VS Code' extension)
pnpm add --save-dev @smui/[email protected]pnpm add --save-dev [email protected]- import
Buttonand use it like above
Update: I just checked that enabling the typescript plugin or not does not make a difference.
Expected behavior
No typescript error occurs.
Screenshots
Desktop (please complete the following information):
- nodejs: 20.11.0
- vscode: 1.59.3
- pnpm: 8.15.1
- OS: Windows 10 x86_64
Additional context
A small reproduction, the Button is used in src/routes/+layout.svelte
Probably changing this in your svelte.config.js file will help.
...
preprocess: vitePreprocess( {script: false} ),
compilerOptions: {
runes: true // Which could also be false if you want to force the Svelte 4 compiler/syntax
},
...
@LittleSaya @hperrin
Any updates on this?
I can't figure out how to make Typings work with Svelte 5 + SMUI 8 ... I am getting a lot of errors similar to Type '() => number' is not assignable to type 'never'. for almost every component
Using a new SvelteKit installation and following the Installation steps from SMUI / I don't want to stick with Svelte4
@alex-simplyonce I have the fix ready to go, but NPM was down (like, doing maintenance and wouldn't accept publishes) when I tried to push it on Sunday. I won't be able to try again until day after tomorrow.
Problem fixed with 8.0.0-beta.2.
Works with this in svelte.config.js:
preprocess: vitePreprocess({ script: true }),
compilerOptions: {
runes: true,
...
Problem fixed with 8.0.0-beta.2. Works with this in
svelte.config.js:preprocess: vitePreprocess({ script: true }), compilerOptions: { runes: true, ...
You shouldn't need the runes: true part, because every SMUI file turns in runes mode explicitly with svelte:options.