Comments (4)
I suspect this has something to do with language-tools
I'll try to take a look later
from svelte.
I found other cases where types are not generated anymore. There also seems to be an issue using ComponentProps for components that have a Snippet on their props. For example the following causes the outer component to not generate types anymore.
Outer.svelte
<script lang="ts">
import type { ComponentProps } from 'svelte';
import Inner from './Inner.svelte';
let { foo }: ComponentProps<Inner> = $props();
</script>
Inner.svelte
<script lang="ts">
import { type Snippet } from 'svelte';
let {
foo,
footer
}: {
foo: string;
footer?: Snippet;
} = $props();
</script>
from svelte.
Investigating this. For some reason TypeScript seems to want to unpack the types when using the ComponentProps
type, likely because of the infer
used in there. That in combination with the generated d.ts output of the default export of components leads to TS breaking down somewhere. This not only happens for Snippet
, it can happen for other imported types, too.
Not sure what a good fix could be yet.
from svelte.
Investigated this further. Ultimately this is a TypeScript limitation: For reasons that I don't understand TypeScript is not able to correctly backtrack imports if the declaration file is written of the form
declare module "svelte" {
class Foo {}
export { Foo }
}
TypeScript will then error with something like Exported variable 'X' has or is using name 'Foo' from external module "svelte" but cannot be named.
If the module is declared like this instead
declare module "svelte" {
export class Foo {}
export {}
}
The error does not appear. It seems that the extra indirection is too much for TypeScript to know where to find the import and then errors.
The fix is to revert Rich-Harris/dts-buddy#82 in dts-buddy and instead add export {}
at the end, which has the same outcome with regards to which types can be imported.
from svelte.
Related Issues (20)
- Sveltekit + Svelte 5: Navigating only loads the layout, not the page HOT 2
- Svelte 5: Mutating data in load fn stops page reactivity HOT 4
- Svelte 5: this type of directive is not valid on components HOT 4
- Svelte 5: Inaccurate Error Message HOT 1
- `batch` function to update multiple sources at once HOT 4
- Svelte 5 reporting invalid type error on Svelte 4 component using slot
- Make aria- dependencies optional HOT 9
- Svelte 5: problems unmounting elements from the dom inside an each block HOT 5
- next.168 development mode and component snippets inside loop HOT 5
- next.168 broke unmounting content in my app HOT 5
- Breakpoints cannot be set on certain locations in Svelte generated code in V8 HOT 1
- Bad compilation of valid Svelte 4 components under Svelte 5 HOT 3
- components still not unmounted HOT 9
- `$effect` throws `Uncaught Error: effect_orphan` in a custom store HOT 3
- Make `bind:{value}` a shorthand to `bind:value={value}` HOT 2
- Investigate dropping the CJS build HOT 1
- Error on create multiple toasts with svelte-sonner HOT 2
- Validator type not exported in svelte/store
- Svelte 5: Incorrect Handling of Rest Props in Compiled Code. Error: $$props is not defined
- Svelte 5: Regression since next.167 and new regression with next.171 HOT 4
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.