Skip to content

Commit b1cafc4

Browse files
Rich-Harrisgtm-nayanRich Harrisgithub-actions[bot]dominikg
authored
update type generation script (#8712)
* chore: playground (#8648) * initialize playground * pnpm up * tidy up git ignore * remove fluff * format * rm readme * fix jsconfig error * add skip-worktree instructions * reload hack * simplify * use rollup * ughh * add flag for SSR * ... * simplify further * configure launch.json * add debugger info to readme * remove vm modules flag * use replaceAll instead of replace * tidy up * fix: make it run * add watch to launch config * Generate type declarations with `dts-buddy` (#8702) * use dts-buddy * remove debug output * remove existing type generation script * fix package.json * update gitignore * bump dts-buddy * remove unused action entry point * add svelte/compiler and svelte/types/compiler/preprocess modules * bump dts-buddy * annoying * changeset * bump dts-buddy * get rid of .d.ts files * another one * Update packages/svelte/package.json Co-authored-by: gtmnayan <[email protected]> --------- Co-authored-by: Rich Harris <[email protected]> Co-authored-by: gtmnayan <[email protected]> * fix: export ComponentType (#8694) * fix: export ComponentType * ughh * changeset * fix: derived types (#8700) * fix: derived store types * changeset * Version Packages (next) (#8709) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * update type generation script * remove unused stuff * fix: changeset publish script isn't called release anymore (#8711) * chore: remove prepare script (#8713) * chore: fix release workflow (#8716) * More readable, Fix $$_attributes * Fix types (#8727) * put comment in right place * bump dts-buddy --------- Co-authored-by: Rich Harris <[email protected]> * build types * add svelte/compiler types * remove prepare script * fix * typo * squelch errors * Add svelte and kit to twoslash's types field * squelch more stuff * Add errors to account for new types * Remove deps * formatting tweak * fix linting, maybe * the hell * gah * Fix types a bit * bump dts-buddy * pnpm generate in dev mode * Cache again * reduce index * bump dts-buddy * remove comment --------- Co-authored-by: gtmnayan <[email protected]> Co-authored-by: Rich Harris <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Dominik G <[email protected]> Co-authored-by: Ben McCann <[email protected]> Co-authored-by: Puru Vijay <[email protected]>
1 parent 744c596 commit b1cafc4

File tree

25 files changed

+104
-353
lines changed

25 files changed

+104
-353
lines changed

documentation/docs/03-runtime/02-svelte-store.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ declare global {
124124
export {};
125125

126126
// @filename: index.ts
127-
// @errors: 18046
127+
// @errors: 18046 2769 7006
128128
// ---cut---
129129
import { derived } from 'svelte/store';
130130

documentation/docs/03-runtime/07-svelte-action.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Sometimes actions emit custom events and apply custom attributes to the element
5858
<!--- file: App.svelte --->
5959
<script>
6060
/**
61-
* @type {import('svelte/action').Action<HTMLDivElement, { prop: any }, { 'on:emit': (e: CustomEvent<string>) => void }>} */
61+
* @type {import('svelte/action').Action<HTMLDivElement, { prop: any }, { 'on:emit': (e: CustomEvent<string>) => void }>}
62+
*/
6263
function foo(node, { prop }) {
6364
// the node has been mounted in the DOM
6465

documentation/docs/04-compiler-and-api/01-svelte-compiler.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ Multiple preprocessors can be used together. The output of the first becomes the
310310
> In Svelte 3, all `markup` functions ran first, then all `script` and then all `style` preprocessors. This order was changed in Svelte 4.
311311
312312
```js
313+
// @errors: 2322
313314
// @filename: ambient.d.ts
314315
declare global {
315316
var source: string;
@@ -398,3 +399,7 @@ The current version, as set in package.json.
398399
import { VERSION } from 'svelte/compiler';
399400
console.log(`running svelte version ${VERSION}`);
400401
```
402+
403+
## Types
404+
405+
> TYPES: svelte/compiler

documentation/docs/04-compiler-and-api/02-client-side-component-api.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ title: 'Client-side component API'
55
## Creating a component
66

77
```ts
8-
// @filename: ambiend.d.ts
8+
// @errors: 2554
9+
// @filename: ambient.d.ts
910
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';
1011

1112
declare global {
@@ -14,14 +15,16 @@ declare global {
1415
}
1516

1617
// @filename: index.ts
18+
// @errors: 2554
1719
// ---cut---
1820
const component = new Component(options);
1921
```
2022

2123
A client-side component — that is, a component compiled with `generate: 'dom'` (or the `generate` option left unspecified) is a JavaScript class.
2224

2325
```ts
24-
// @filename: ambiend.d.ts
26+
// @errors: 2554
27+
// @filename: ambient.d.ts
2528
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';
2629

2730
declare module './App.svelte' {
@@ -30,6 +33,7 @@ declare module './App.svelte' {
3033
}
3134

3235
// @filename: index.ts
36+
// @errors: 2554
3337
// ---cut---
3438
import App from './App.svelte';
3539

@@ -63,7 +67,7 @@ Whereas children of `target` are normally left alone, `hydrate: true` will cause
6367
The existing DOM doesn't need to match the component — Svelte will 'repair' the DOM as it goes.
6468

6569
```ts
66-
// @filename: ambiend.d.ts
70+
// @filename: ambient.d.ts
6771
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';
6872

6973
declare module './App.svelte' {
@@ -72,7 +76,7 @@ declare module './App.svelte' {
7276
}
7377

7478
// @filename: index.ts
75-
// @errors: 2322
79+
// @errors: 2322 2554
7680
// ---cut---
7781
import App from './App.svelte';
7882

@@ -85,7 +89,7 @@ const app = new App({
8589
## `$set`
8690

8791
```ts
88-
// @filename: ambiend.d.ts
92+
// @filename: ambient.d.ts
8993
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';
9094

9195
declare global {
@@ -106,7 +110,7 @@ Programmatically sets props on an instance. `component.$set({ x: 1 })` is equiva
106110
Calling this method schedules an update for the next microtask — the DOM is _not_ updated synchronously.
107111

108112
```ts
109-
// @filename: ambiend.d.ts
113+
// @filename: ambient.d.ts
110114
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';
111115

112116
declare global {
@@ -124,7 +128,7 @@ component.$set({ answer: 42 });
124128
## `$on`
125129

126130
```ts
127-
// @filename: ambiend.d.ts
131+
// @filename: ambient.d.ts
128132
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';
129133

130134
declare global {
@@ -146,7 +150,7 @@ Causes the `callback` function to be called whenever the component dispatches an
146150
A function is returned that will remove the event listener when called.
147151

148152
```ts
149-
// @filename: ambiend.d.ts
153+
// @filename: ambient.d.ts
150154
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';
151155

152156
declare global {
@@ -168,7 +172,7 @@ off();
168172
## `$destroy`
169173

170174
```js
171-
// @filename: ambiend.d.ts
175+
// @filename: ambient.d.ts
172176
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';
173177

174178
declare global {
@@ -188,7 +192,7 @@ Removes a component from the DOM and triggers any `onDestroy` handlers.
188192
## Component props
189193

190194
```js
191-
// @filename: ambiend.d.ts
195+
// @filename: ambient.d.ts
192196
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';
193197

194198
declare global {
@@ -199,12 +203,13 @@ declare global {
199203
export {}
200204

201205
// @filename: index.ts
206+
// @errors: 2339
202207
// ---cut---
203208
component.prop;
204209
```
205210

206211
```js
207-
// @filename: ambiend.d.ts
212+
// @filename: ambient.d.ts
208213
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';
209214

210215
declare global {
@@ -216,6 +221,7 @@ declare global {
216221
export {}
217222

218223
// @filename: index.ts
224+
// @errors: 2339
219225
// ---cut---
220226
component.prop = value;
221227
```
@@ -225,7 +231,7 @@ If a component is compiled with `accessors: true`, each instance will have gette
225231
By default, `accessors` is `false`, unless you're compiling as a custom element.
226232

227233
```js
228-
// @filename: ambiend.d.ts
234+
// @filename: ambient.d.ts
229235
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';
230236

231237
declare global {
@@ -237,6 +243,7 @@ declare global {
237243
export {}
238244

239245
// @filename: index.ts
246+
// @errors: 2339
240247
// ---cut---
241248
console.log(component.count);
242249
component.count += 1;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"test": "pnpm test -r --filter=./packages/*",
99
"build": "pnpm -r build",
10-
"check": "pnpm -r check",
10+
"check": "cd packages/svelte && pnpm build && cd ../../ && pnpm -r check",
1111
"lint": "pnpm -r lint",
1212
"format": "pnpm -r format",
1313
"changeset:version": "changeset version && pnpm -r generate:version && git add --all",
@@ -30,4 +30,4 @@
3030
"prettier-plugin-svelte": "^2.10.0"
3131
},
3232
"packageManager": "[email protected]"
33-
}
33+
}

packages/svelte/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"@types/node": "^14.14.31",
126126
"@typescript-eslint/eslint-plugin": "^5.58.0",
127127
"agadoo": "^3.0.0",
128-
"dts-buddy": "^0.1.2",
128+
"dts-buddy": "^0.1.6",
129129
"esbuild": "^0.17.19",
130130
"happy-dom": "^9.18.3",
131131
"jsdom": "^21.1.1",
@@ -137,4 +137,4 @@
137137
"util": "^0.12.5",
138138
"vitest": "^0.31.1"
139139
}
140-
}
140+
}

packages/svelte/src/runtime/action/public.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
* ```ts
1313
* interface Attributes {
1414
* newprop?: string;
15-
* 'on:event': (e: CustomEvent<boolean>) => void;
15+
* 'on:event': (e: CustomEvent<boolean>) => void;
1616
* }
1717
*
1818
* export function myAction(node: HTMLElement, parameter: Parameter): ActionReturn<Parameter, Attributes> {
19-
* // ...
20-
* return {
21-
* update: (updatedParameter) => {...},
22-
* destroy: () => {...}
23-
* };
19+
* // ...
20+
* return {
21+
* update: (updatedParameter) => {...},
22+
* destroy: () => {...}
23+
* };
2424
* }
2525
* ```
2626
*

packages/svelte/src/runtime/internal/dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export function construct_svelte_component_dev(component, props) {
274274
*
275275
* Can be used to create strongly typed Svelte components.
276276
*
277-
* ### Example:
277+
* #### Example:
278278
*
279279
* You have component library on npm called `component-library`, from which
280280
* you export a component called `MyComponent`. For Svelte+TypeScript users,

packages/svelte/src/runtime/internal/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export function subscribe(store, ...callbacks) {
106106
}
107107

108108
/**
109+
* Get the current value from a store by subscribing and immediately unsubscribing.
109110
* @template T
110111
* @param {import('../store/public.js').Readable<T>} store
111112
* @returns {T}

packages/svelte/src/runtime/store/index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,4 @@ export function readonly(store) {
189189
};
190190
}
191191

192-
/**
193-
* Get the current value from a store by subscribing and immediately unsubscribing.
194-
* @template T
195-
* @param {import('./public.js').Readable<T>} store readable
196-
* @returns {T}
197-
*/
198192
export { get_store_value as get };

0 commit comments

Comments
 (0)