svelte-material-ui icon indicating copy to clipboard operation
svelte-material-ui copied to clipboard

Type incompatible error in 8.0.0-beta.0

Open LittleSaya opened this issue 1 year ago • 5 comments
trafficstars

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

  1. pnpx sv create --template minimal --types ts svelte5_smui8_demo
  2. choose eslint + tailwindcss
  3. no tailwindcss plugin
  4. choose pnpm
  5. open project with vscode, enable svelte typescript plugin if asked (I'm using vscode with 'Svelte for VS Code' extension)
  6. pnpm add --save-dev @smui/[email protected]
  7. pnpm add --save-dev [email protected]
  8. import Button and 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

Screenshot 2024-11-19 213751

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

svelte5_smui8_demo.zip

LittleSaya avatar Nov 19 '24 13:11 LittleSaya

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
   },
   ...

mobilarte avatar Dec 06 '24 22:12 mobilarte

@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 avatar Dec 10 '24 05:12 alex-simplyonce

@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.

hperrin avatar Dec 10 '24 05:12 hperrin

Problem fixed with 8.0.0-beta.2. Works with this in svelte.config.js:

preprocess: vitePreprocess({ script: true }),
	compilerOptions: {
		runes: true, 
...

mobilarte avatar Dec 14 '24 16:12 mobilarte

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.

hperrin avatar Dec 15 '24 06:12 hperrin