fix: intellisense DX for $props, $inspect, $bindable, and $host (#14777)

* remove default function types for $props, $inspect, $bindable, and $host

* changeset

* regenerate types

* add helper message for type regeneration

* append a newline to generated types

* prettier

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/14776/head
ottomated 9 months ago committed by GitHub
parent 5bc4033421
commit 999b92d134
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: Improve typescript DX for $inspect, $props, $bindable, and $host

@ -59,7 +59,7 @@ jobs:
run: pnpm lint
- name: build and check generated types
if: (${{ success() }} || ${{ failure() }}) # ensures this step runs even if previous steps fail
run: pnpm build && { [ "`git status --porcelain=v1`" == "" ] || (echo "Generated types have changed — please regenerate types locally and commit the changes after you have reviewed them"; git diff; exit 1); }
run: pnpm build && { [ "`git status --porcelain=v1`" == "" ] || (echo "Generated types have changed — please regenerate types locally with `cd packages/svelte && pnpm generate:types` and commit the changes after you have reviewed them"; git diff; exit 1); }
Benchmarks:
runs-on: ubuntu-latest
timeout-minutes: 15

@ -33,7 +33,7 @@ jobs:
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build && { [ "`git status --porcelain=v1`" == "" ] || (echo "Generated types have changed — please regenerate types locally and commit the changes after you have reviewed them"; git diff; exit 1); }
run: pnpm build && { [ "`git status --porcelain=v1`" == "" ] || (echo "Generated types have changed — please regenerate types locally with `cd packages/svelte && pnpm generate:types` and commit the changes after you have reviewed them"; git diff; exit 1); }
- name: Create Release Pull Request or Publish to npm
id: changesets

@ -46,6 +46,8 @@ await createBundle({
}
});
fs.appendFileSync(`${dir}/types/index.d.ts`, '\n');
const types = fs.readFileSync(`${dir}/types/index.d.ts`, 'utf-8');
const bad_links = [...types.matchAll(/\]\((\/[^)]+)\)/g)];

@ -338,6 +338,29 @@ declare namespace $effect {
*/
declare function $props(): any;
declare namespace $props {
// prevent intellisense from being unhelpful
/** @deprecated */
export const apply: never;
/** @deprecated */
// @ts-ignore
export const arguments: never;
/** @deprecated */
export const bind: never;
/** @deprecated */
export const call: never;
/** @deprecated */
export const caller: never;
/** @deprecated */
export const length: never;
/** @deprecated */
export const name: never;
/** @deprecated */
export const prototype: never;
/** @deprecated */
export const toString: never;
}
/**
* Declares a prop as bindable, meaning the parent component can use `bind:propName={value}` to bind to it.
*
@ -349,6 +372,29 @@ declare function $props(): any;
*/
declare function $bindable<T>(fallback?: T): T;
declare namespace $bindable {
// prevent intellisense from being unhelpful
/** @deprecated */
export const apply: never;
/** @deprecated */
// @ts-ignore
export const arguments: never;
/** @deprecated */
export const bind: never;
/** @deprecated */
export const call: never;
/** @deprecated */
export const caller: never;
/** @deprecated */
export const length: never;
/** @deprecated */
export const name: never;
/** @deprecated */
export const prototype: never;
/** @deprecated */
export const toString: never;
}
/**
* Inspects one or more values whenever they, or the properties they contain, change. Example:
*
@ -388,6 +434,27 @@ declare namespace $inspect {
* </script>
*/
export function trace(name: string): void;
// prevent intellisense from being unhelpful
/** @deprecated */
export const apply: never;
/** @deprecated */
// @ts-ignore
export const arguments: never;
/** @deprecated */
export const bind: never;
/** @deprecated */
export const call: never;
/** @deprecated */
export const caller: never;
/** @deprecated */
export const length: never;
/** @deprecated */
export const name: never;
/** @deprecated */
export const prototype: never;
/** @deprecated */
export const toString: never;
}
/**
@ -410,3 +477,26 @@ declare namespace $inspect {
* https://svelte.dev/docs/svelte/$host
*/
declare function $host<El extends HTMLElement = HTMLElement>(): El;
declare namespace $host {
// prevent intellisense from being unhelpful
/** @deprecated */
export const apply: never;
/** @deprecated */
// @ts-ignore
export const arguments: never;
/** @deprecated */
export const bind: never;
/** @deprecated */
export const call: never;
/** @deprecated */
export const caller: never;
/** @deprecated */
export const length: never;
/** @deprecated */
export const name: never;
/** @deprecated */
export const prototype: never;
/** @deprecated */
export const toString: never;
}

@ -2996,6 +2996,29 @@ declare namespace $effect {
*/
declare function $props(): any;
declare namespace $props {
// prevent intellisense from being unhelpful
/** @deprecated */
export const apply: never;
/** @deprecated */
// @ts-ignore
export const arguments: never;
/** @deprecated */
export const bind: never;
/** @deprecated */
export const call: never;
/** @deprecated */
export const caller: never;
/** @deprecated */
export const length: never;
/** @deprecated */
export const name: never;
/** @deprecated */
export const prototype: never;
/** @deprecated */
export const toString: never;
}
/**
* Declares a prop as bindable, meaning the parent component can use `bind:propName={value}` to bind to it.
*
@ -3007,6 +3030,29 @@ declare function $props(): any;
*/
declare function $bindable<T>(fallback?: T): T;
declare namespace $bindable {
// prevent intellisense from being unhelpful
/** @deprecated */
export const apply: never;
/** @deprecated */
// @ts-ignore
export const arguments: never;
/** @deprecated */
export const bind: never;
/** @deprecated */
export const call: never;
/** @deprecated */
export const caller: never;
/** @deprecated */
export const length: never;
/** @deprecated */
export const name: never;
/** @deprecated */
export const prototype: never;
/** @deprecated */
export const toString: never;
}
/**
* Inspects one or more values whenever they, or the properties they contain, change. Example:
*
@ -3046,6 +3092,27 @@ declare namespace $inspect {
* </script>
*/
export function trace(name: string): void;
// prevent intellisense from being unhelpful
/** @deprecated */
export const apply: never;
/** @deprecated */
// @ts-ignore
export const arguments: never;
/** @deprecated */
export const bind: never;
/** @deprecated */
export const call: never;
/** @deprecated */
export const caller: never;
/** @deprecated */
export const length: never;
/** @deprecated */
export const name: never;
/** @deprecated */
export const prototype: never;
/** @deprecated */
export const toString: never;
}
/**
@ -3069,4 +3136,27 @@ declare namespace $inspect {
*/
declare function $host<El extends HTMLElement = HTMLElement>(): El;
declare namespace $host {
// prevent intellisense from being unhelpful
/** @deprecated */
export const apply: never;
/** @deprecated */
// @ts-ignore
export const arguments: never;
/** @deprecated */
export const bind: never;
/** @deprecated */
export const call: never;
/** @deprecated */
export const caller: never;
/** @deprecated */
export const length: never;
/** @deprecated */
export const name: never;
/** @deprecated */
export const prototype: never;
/** @deprecated */
export const toString: never;
}
//# sourceMappingURL=index.d.ts.map
Loading…
Cancel
Save