Skip to content

Invalid Syntax but no warning #15868

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

Closed
MrAmericanMike opened this issue May 6, 2025 · 3 comments
Closed

Invalid Syntax but no warning #15868

MrAmericanMike opened this issue May 6, 2025 · 3 comments

Comments

@MrAmericanMike
Copy link

Describe the bug

So I was following the tutorials on the website, and came across this issue.

This syntax doesn't create a warning and works:

<script>
	import PackageInfo from './PackageInfo.svelte';

	const pkg = {
		name: 'svelte',
		version: 5,
		description: 'blazing fast',
		website: 'https://svelte.dev'
	};
</script>

<PackageInfo <PackageInfo {...pkg} PackageInfo {...pkg} {...pkg} {...pkg} />

Also tested on a local project a more basic attempt to reproduce, and this also works, even when it's unvalid.

<script>
	import NavBar from "$/components/NavBar.svelte";
	import "../global.css";
</script>

<NavBar <Navbar />

<slot />

Reproduction

Visit https://svelte.dev/tutorial/svelte/spread-props and try the solution on the report.

Logs

System Info

Binaries:
    Node: 22.13.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 10.10.0 - ~\AppData\Local\pnpm\pnpm.CMD
  Browsers:
    Edge: Spartan (44.22621.730.0), Chromium (112.0.1722.58)  
    Internet Explorer: 11.0.22621.1
  npmPackages:
    svelte: 5.28.2 => 5.28.2

Severity

annoyance

@7nik
Copy link
Contributor

7nik commented May 6, 2025

<whatever is a valid attribute/prop name by the specs.

@MrAmericanMike
Copy link
Author

<whatever is a valid attribute/prop name by the specs.

I see.

So at that point it thinks that those are attributes and passes them fo the component, but as they are not used, Svelte removes them, resulting in clean code?

Thanks for the clarification, wasn't sure what was happening.

@7nik
Copy link
Contributor

7nik commented May 6, 2025

So at that point it thinks that those are attributes and passes them fo the component, but as they are not used, Svelte removes them, resulting in clean code?

No. For components, prop is shorthand of prop={true}. For HTML elements, it is shorthand of attr="" unless it is a known boolean attribute.

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

No branches or pull requests

2 participants