Skip to content

update type generation script #8712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
15bdadb
chore: playground (#8648)
gtm-nayan Jun 7, 2023
1046dab
Generate type declarations with `dts-buddy` (#8702)
Rich-Harris Jun 8, 2023
0b15bb6
fix: export ComponentType (#8694)
gtm-nayan Jun 8, 2023
264da48
fix: derived types (#8700)
gtm-nayan Jun 8, 2023
5963b6f
Version Packages (next) (#8709)
github-actions[bot] Jun 8, 2023
3d6dbdc
update type generation script
Jun 8, 2023
7a46f2e
remove unused stuff
Jun 8, 2023
ba58327
fix: changeset publish script isn't called release anymore (#8711)
dominikg Jun 8, 2023
0c6f172
chore: remove prepare script (#8713)
benmccann Jun 8, 2023
8bd9021
chore: fix release workflow (#8716)
gtm-nayan Jun 9, 2023
b8f7bf6
More readable, Fix $$_attributes
PuruVJ Jun 10, 2023
3a614c2
Merge branch 'sites' into type-gen
benmccann Jun 12, 2023
d6f0b7b
Fix types (#8727)
Rich-Harris Jun 13, 2023
3ab6292
merge version-4 -> type-gen
Jun 13, 2023
564bdff
build types
Jun 13, 2023
9dc3498
add svelte/compiler types
Jun 13, 2023
be4e4ab
remove prepare script
Jun 13, 2023
8e0c1ad
fix
Jun 13, 2023
c317313
typo
Jun 13, 2023
d17be5a
squelch errors
Jun 13, 2023
c1c8085
Add svelte and kit to twoslash's types field
PuruVJ Jun 13, 2023
c39a989
Merge remote-tracking branch 'origin/type-gen' into type-gen
PuruVJ Jun 13, 2023
0f1e42a
squelch more stuff
Jun 13, 2023
2e19792
Add errors to account for new types
PuruVJ Jun 13, 2023
757109f
Merge branch 'type-gen' of github.com:sveltejs/svelte into type-gen
Jun 13, 2023
82422c3
Remove deps
PuruVJ Jun 13, 2023
a02ba7b
formatting tweak
Jun 13, 2023
1bb7f74
fix linting, maybe
Jun 13, 2023
4635d4a
the hell
Jun 13, 2023
a7971e0
gah
Jun 13, 2023
1a14528
Fix types a bit
PuruVJ Jun 13, 2023
ae5b546
bump dts-buddy
Jun 13, 2023
a0c38b4
Merge branch 'type-gen' of github.com:sveltejs/svelte into type-gen
Jun 13, 2023
91bc371
pnpm generate in dev mode
PuruVJ Jun 14, 2023
1bf098f
Cache again
PuruVJ Jun 14, 2023
d0568b9
reduce index
PuruVJ Jun 14, 2023
a3a9478
bump dts-buddy
Jun 14, 2023
3be9924
remove comment
Jun 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/docs/03-runtime/02-svelte-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ declare global {
export {};

// @filename: index.ts
// @errors: 18046
// @errors: 18046 2769 7006
// ---cut---
import { derived } from 'svelte/store';

Expand Down
3 changes: 2 additions & 1 deletion documentation/docs/03-runtime/07-svelte-action.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ Sometimes actions emit custom events and apply custom attributes to the element
<!--- file: App.svelte --->
<script>
/**
* @type {import('svelte/action').Action<HTMLDivElement, { prop: any }, { 'on:emit': (e: CustomEvent<string>) => void }>} */
* @type {import('svelte/action').Action<HTMLDivElement, { prop: any }, { 'on:emit': (e: CustomEvent<string>) => void }>}
*/
function foo(node, { prop }) {
// the node has been mounted in the DOM

Expand Down
5 changes: 5 additions & 0 deletions documentation/docs/04-compiler-and-api/01-svelte-compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ Multiple preprocessors can be used together. The output of the first becomes the
> In Svelte 3, all `markup` functions ran first, then all `script` and then all `style` preprocessors. This order was changed in Svelte 4.

```js
// @errors: 2322
// @filename: ambient.d.ts
declare global {
var source: string;
Expand Down Expand Up @@ -398,3 +399,7 @@ The current version, as set in package.json.
import { VERSION } from 'svelte/compiler';
console.log(`running svelte version ${VERSION}`);
```

## Types

> TYPES: svelte/compiler
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ title: 'Client-side component API'
## Creating a component

```ts
// @filename: ambiend.d.ts
// @errors: 2554
// @filename: ambient.d.ts
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';

declare global {
Expand All @@ -14,14 +15,16 @@ declare global {
}

// @filename: index.ts
// @errors: 2554
// ---cut---
const component = new Component(options);
```

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

```ts
// @filename: ambiend.d.ts
// @errors: 2554
// @filename: ambient.d.ts
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';

declare module './App.svelte' {
Expand All @@ -30,6 +33,7 @@ declare module './App.svelte' {
}

// @filename: index.ts
// @errors: 2554
// ---cut---
import App from './App.svelte';

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

```ts
// @filename: ambiend.d.ts
// @filename: ambient.d.ts
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';

declare module './App.svelte' {
Expand All @@ -72,7 +76,7 @@ declare module './App.svelte' {
}

// @filename: index.ts
// @errors: 2322
// @errors: 2322 2554
// ---cut---
import App from './App.svelte';

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

```ts
// @filename: ambiend.d.ts
// @filename: ambient.d.ts
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';

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

```ts
// @filename: ambiend.d.ts
// @filename: ambient.d.ts
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';

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

```ts
// @filename: ambiend.d.ts
// @filename: ambient.d.ts
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';

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

```ts
// @filename: ambiend.d.ts
// @filename: ambient.d.ts
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';

declare global {
Expand All @@ -168,7 +172,7 @@ off();
## `$destroy`

```js
// @filename: ambiend.d.ts
// @filename: ambient.d.ts
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';

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

```js
// @filename: ambiend.d.ts
// @filename: ambient.d.ts
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';

declare global {
Expand All @@ -199,12 +203,13 @@ declare global {
export {}

// @filename: index.ts
// @errors: 2339
// ---cut---
component.prop;
```

```js
// @filename: ambiend.d.ts
// @filename: ambient.d.ts
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';

declare global {
Expand All @@ -216,6 +221,7 @@ declare global {
export {}

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

```js
// @filename: ambiend.d.ts
// @filename: ambient.d.ts
import { SvelteComponent, ComponentConstructorOptions } from 'svelte';

declare global {
Expand All @@ -237,6 +243,7 @@ declare global {
export {}

// @filename: index.ts
// @errors: 2339
// ---cut---
console.log(component.count);
component.count += 1;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"test": "pnpm test -r --filter=./packages/*",
"build": "pnpm -r build",
"check": "pnpm -r check",
"check": "cd packages/svelte && pnpm build && cd ../../ && pnpm -r check",
"lint": "pnpm -r lint",
"format": "pnpm -r format",
"changeset:version": "changeset version && pnpm -r generate:version && git add --all",
Expand All @@ -30,4 +30,4 @@
"prettier-plugin-svelte": "^2.10.0"
},
"packageManager": "[email protected]"
}
}
4 changes: 2 additions & 2 deletions packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"@types/node": "^14.14.31",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"agadoo": "^3.0.0",
"dts-buddy": "^0.1.2",
"dts-buddy": "^0.1.6",
"esbuild": "^0.17.19",
"happy-dom": "^9.18.3",
"jsdom": "^21.1.1",
Expand All @@ -137,4 +137,4 @@
"util": "^0.12.5",
"vitest": "^0.31.1"
}
}
}
12 changes: 6 additions & 6 deletions packages/svelte/src/runtime/action/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
* ```ts
* interface Attributes {
* newprop?: string;
* 'on:event': (e: CustomEvent<boolean>) => void;
* 'on:event': (e: CustomEvent<boolean>) => void;
* }
*
* export function myAction(node: HTMLElement, parameter: Parameter): ActionReturn<Parameter, Attributes> {
* // ...
* return {
* update: (updatedParameter) => {...},
* destroy: () => {...}
* };
* // ...
* return {
* update: (updatedParameter) => {...},
* destroy: () => {...}
* };
* }
* ```
*
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/runtime/internal/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export function construct_svelte_component_dev(component, props) {
*
* Can be used to create strongly typed Svelte components.
*
* ### Example:
* #### Example:
*
* You have component library on npm called `component-library`, from which
* you export a component called `MyComponent`. For Svelte+TypeScript users,
Expand Down
1 change: 1 addition & 0 deletions packages/svelte/src/runtime/internal/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export function subscribe(store, ...callbacks) {
}

/**
* Get the current value from a store by subscribing and immediately unsubscribing.
* @template T
* @param {import('../store/public.js').Readable<T>} store
* @returns {T}
Expand Down
6 changes: 0 additions & 6 deletions packages/svelte/src/runtime/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,4 @@ export function readonly(store) {
};
}

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