@testing-library/svelte 5.2.2 → 5.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/svelte",
3
- "version": "5.2.2",
3
+ "version": "5.2.3",
4
4
  "description": "Simple and complete Svelte testing utilities that encourage good testing practices.",
5
5
  "main": "src/index.js",
6
6
  "exports": {
@@ -72,7 +72,7 @@
72
72
  "types": "svelte-check",
73
73
  "types:legacy": "svelte-check --tsconfig tsconfig.legacy.json",
74
74
  "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",
76
76
  "contributors:add": "all-contributors add",
77
77
  "contributors:generate": "all-contributors generate",
78
78
  "preview-release": "./scripts/preview-release"
@@ -120,7 +120,7 @@
120
120
  "prettier": "^3.3.3",
121
121
  "prettier-plugin-svelte": "^3.2.5",
122
122
  "svelte": "^3 || ^4 || ^5 || ^5.0.0-next.0",
123
- "svelte-check": "^3.8.4",
123
+ "svelte-check": "^4.0.4",
124
124
  "svelte-jester": "^5.0.0",
125
125
  "typescript": "^5.5.3",
126
126
  "vite": "^5.3.3",
@@ -1,11 +1,14 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import type * as Svelte from 'svelte'
2
3
 
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
4
  type IS_MODERN_SVELTE = any extends Svelte.Component ? false : true
5
5
 
6
6
  /** 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>
9
12
  : Svelte.SvelteComponent<P>
10
13
 
11
14
  /**
@@ -19,7 +22,7 @@ export type ComponentType<C> = C extends Svelte.SvelteComponent
19
22
  : C
20
23
 
21
24
  /** The props of a component. */
22
- export type Props<C> = Svelte.ComponentProps<C>
25
+ export type Props<C extends Component<any, any>> = Svelte.ComponentProps<C>
23
26
 
24
27
  /**
25
28
  * The exported fields of a component.
@@ -29,7 +32,7 @@ export type Props<C> = Svelte.ComponentProps<C>
29
32
  */
30
33
  export type Exports<C> = C extends Svelte.SvelteComponent
31
34
  ? C
32
- : C extends Svelte.Component<unknown, infer E>
35
+ : C extends Svelte.Component<any, infer E>
33
36
  ? E
34
37
  : never
35
38
 
@@ -38,6 +41,7 @@ export type Exports<C> = C extends Svelte.SvelteComponent
38
41
  *
39
42
  * In Svelte 4, these are the options passed to the component constructor.
40
43
  */
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,0 +1,47 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import type * as Svelte from 'svelte'
3
+
4
+ type IS_MODERN_SVELTE = any extends Svelte.Component ? false : true
5
+
6
+ /** A compiled, imported Svelte component. */
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>
12
+ : Svelte.SvelteComponent<P>
13
+
14
+ /**
15
+ * The type of an imported, compiled Svelte component.
16
+ *
17
+ * In Svelte 4, this was the Svelte component class' type.
18
+ * In Svelte 5, this distinction no longer matters.
19
+ */
20
+ export type ComponentType<C> = C extends Svelte.SvelteComponent
21
+ ? Svelte.ComponentType<C>
22
+ : C
23
+
24
+ /** The props of a component. */
25
+ export type Props<C extends Component<any, any>> = Svelte.ComponentProps<C>
26
+
27
+ /**
28
+ * The exported fields of a component.
29
+ *
30
+ * In Svelte 4, this is simply the instance of the component class.
31
+ * In Svelte 5, this is the set of variables marked as `export`'d.
32
+ */
33
+ export type Exports<C> = C extends Svelte.SvelteComponent
34
+ ? C
35
+ : C extends Svelte.Component<any, infer E>
36
+ ? E
37
+ : never
38
+
39
+ /**
40
+ * Options that may be passed to `mount` when rendering the component.
41
+ *
42
+ * In Svelte 4, these are the options passed to the component constructor.
43
+ */
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>>