Comments (3)
Since they are spread tier, topNavItems are unrelated variables to that if, you would set tier somewhere before that if is executed. You would need to do pros.tier and props.topNavItems to keep narrowing.
from svelte.
Closing since this is how TS works (not much we can do here).
You can also use const { tier, topNavItems }: SideBar = $props()
if you don't reassign the values. Then TypeScript will be smart enough to infer the relationship, too.
from svelte.
As @jjones315 noted, the problem is the spread into individual properties.
This behaves the same in plain TS: Playground
You can change the props to a single object to retain the the full type like this:
- let { tier, topNavItems }: SideBar = $props()
+ let { ...props }: SideBar = $props()
(The destructuring is still a requirement.)
from svelte.
Related Issues (20)
- Spreadable actions (aka. `use:` directives) HOT 1
- [Svelte 4] bind:this is undefined when running action of child until all children initialize
- Svelte 4 and 5 adds spaces between html elements when mounting components through JavaScript HOT 10
- Custom element props not changeable after assigned value inside component HOT 2
- Svelte automatically binding this to function exports of components HOT 3
- `bind:this` weird behavior HOT 5
- Expose reactivity primitives to users HOT 5
- ReferenceError: $$props is not defined when calling $host()
- CustomElement $effect caused due to props read HOT 7
- `https://svelte.dev` unresponsive, keeps timing out HOT 1
- Web component styles missing when mounted more than once HOT 6
- Consider replacing `export const` and `export function` with a rune HOT 5
- a11y Invalid autocomplete value warning HOT 3
- Feature: Implement {#with } logic block from Ractive.js HOT 2
- Svelte v5 + Sveltekit: Index.d.ts is not generated when exporting components as object properties
- Passing reactive values to functions HOT 5
- ```$state``` rune should convert and track classes from external libraries HOT 2
- Injecting styles into components HOT 4
- Unexpected behaviour with `$state.frozen()` and `$bindable()` HOT 11
- Svelte 5 - $inspect rune breaking $state-reactivity
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte.