From 2ea2be3324c52c15840d66f1960ebc9cfe3a7dd9 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:53:25 +0200 Subject: [PATCH] docs: explain `runes` compiler option behavior (#12578) closes #11523 --- packages/svelte/src/compiler/types/index.d.ts | 2 ++ packages/svelte/src/index.d.ts | 1 - packages/svelte/types/index.d.ts | 10 +++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/svelte/src/compiler/types/index.d.ts b/packages/svelte/src/compiler/types/index.d.ts index f3ca084d5e..c0adbdaa7b 100644 --- a/packages/svelte/src/compiler/types/index.d.ts +++ b/packages/svelte/src/compiler/types/index.d.ts @@ -129,6 +129,8 @@ export interface CompileOptions extends ModuleCompileOptions { * Set to `undefined` (the default) to infer runes mode from the component code. * Is always `true` for JS/TS modules compiled with Svelte. * Will be `true` by default in Svelte 6. + * Note that setting this to `true` in your `svelte.config.js` will force runes mode for your entire project, including components in `node_modules`, + * which is likely not what you want. If you're using Vite, consider using [dynamicCompileOptions](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#dynamiccompileoptions) instead. * @default undefined */ runes?: boolean | undefined; diff --git a/packages/svelte/src/index.d.ts b/packages/svelte/src/index.d.ts index 5a052e3c12..897d468ebc 100644 --- a/packages/svelte/src/index.d.ts +++ b/packages/svelte/src/index.d.ts @@ -1,6 +1,5 @@ // This should contain all the public interfaces (not all of them are actually importable, check current Svelte for which ones are). -import type { Getters } from '#shared'; import './ambient.js'; /** diff --git a/packages/svelte/types/index.d.ts b/packages/svelte/types/index.d.ts index b36af178df..62705db8c6 100644 --- a/packages/svelte/types/index.d.ts +++ b/packages/svelte/types/index.d.ts @@ -303,9 +303,6 @@ declare module 'svelte' { : [type: Type, parameter: EventMap[Type], options?: DispatchOptions] ): boolean; } - type Getters = { - [K in keyof T]: () => T[K]; - }; /** * The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM. * It must be called during the component's initialisation (but doesn't need to live *inside* the component; @@ -470,6 +467,9 @@ declare module 'svelte' { * https://svelte.dev/docs/svelte#getallcontexts * */ export function getAllContexts = Map>(): T; + type Getters = { + [K in keyof T]: () => T[K]; + }; export {}; } @@ -810,6 +810,8 @@ declare module 'svelte/compiler' { * Set to `undefined` (the default) to infer runes mode from the component code. * Is always `true` for JS/TS modules compiled with Svelte. * Will be `true` by default in Svelte 6. + * Note that setting this to `true` in your `svelte.config.js` will force runes mode for your entire project, including components in `node_modules`, + * which is likely not what you want. If you're using Vite, consider using [dynamicCompileOptions](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#dynamiccompileoptions) instead. * @default undefined */ runes?: boolean | undefined; @@ -2628,6 +2630,8 @@ declare module 'svelte/types/compiler/interfaces' { * Set to `undefined` (the default) to infer runes mode from the component code. * Is always `true` for JS/TS modules compiled with Svelte. * Will be `true` by default in Svelte 6. + * Note that setting this to `true` in your `svelte.config.js` will force runes mode for your entire project, including components in `node_modules`, + * which is likely not what you want. If you're using Vite, consider using [dynamicCompileOptions](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#dynamiccompileoptions) instead. * @default undefined */ runes?: boolean | undefined;