Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f4b1508

Browse files
authored
fix(svelte5): ensure typings are actually included in the module (#402)
1 parent f215ad8 commit f4b1508

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"types": "svelte-check",
7373
"types:legacy": "svelte-check --tsconfig tsconfig.legacy.json",
7474
"validate": "npm-run-all test:vitest:* test:jest types build",
75-
"build": "tsc -p tsconfig.build.json",
75+
"build": "tsc -p tsconfig.build.json && cp src/component-types.d.ts types",
7676
"contributors:add": "all-contributors add",
7777
"contributors:generate": "all-contributors generate",
7878
"preview-release": "./scripts/preview-release"

‎src/component-types.d.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import type * as Svelte from 'svelte'
23

3-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
44
type IS_MODERN_SVELTE = any extends Svelte.Component ? false : true
55

66
/** A compiled, imported Svelte component. */
7-
export type Component<P> = IS_MODERN_SVELTE extends true
8-
? Svelte.Component<P> | Svelte.SvelteComponent<P>
7+
export type Component<
8+
P extends Record<string, any>,
9+
E extends Record<string, any>,
10+
> = IS_MODERN_SVELTE extends true
11+
? Svelte.Component<P, E> | Svelte.SvelteComponent<P>
912
: Svelte.SvelteComponent<P>
1013

1114
/**
@@ -19,7 +22,7 @@ export type ComponentType<C> = C extends Svelte.SvelteComponent
1922
: C
2023

2124
/** The props of a component. */
22-
export type Props<C> = Svelte.ComponentProps<C>
25+
export type Props<CextendsComponent<any,any>> = Svelte.ComponentProps<C>
2326

2427
/**
2528
* The exported fields of a component.
@@ -29,7 +32,7 @@ export type Props<C> = Svelte.ComponentProps<C>
2932
*/
3033
export type Exports<C> = C extends Svelte.SvelteComponent
3134
? C
32-
: C extends Svelte.Component<unknown, infer E>
35+
: C extends Svelte.Component<any, infer E>
3336
? E
3437
: never
3538

@@ -38,6 +41,7 @@ export type Exports<C> = C extends Svelte.SvelteComponent
3841
*
3942
* In Svelte 4, these are the options passed to the component constructor.
4043
*/
41-
export type MountOptions<C> = IS_MODERN_SVELTE extends true
42-
? Parameters<typeof Svelte.mount<Props<C>, Exports<C>>>[1]
43-
: Svelte.ComponentConstructorOptions<Props<C>>
44+
export type MountOptions<C extends Component<any, any>> =
45+
IS_MODERN_SVELTE extends true
46+
? Parameters<typeof Svelte.mount<Props<C>, Exports<C>>>[1]
47+
: Svelte.ComponentConstructorOptions<Props<C>>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /