From 21fe5e9810d49d52fd0765b7efbf095099623578 Mon Sep 17 00:00:00 2001 From: Puru Vijay Date: Wed, 12 Apr 2023 16:57:57 +0530 Subject: [PATCH] Fix, add disclaimer for svelte/internal --- .../docs/05-misc/03-svelte-internal.md | 4 ++++ sites/svelte.dev/scripts/type-gen/index.js | 23 ++++++++++--------- .../svelte.dev/src/lib/server/docs/render.js | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/site/content/docs/05-misc/03-svelte-internal.md b/site/content/docs/05-misc/03-svelte-internal.md index e02537def4..c7d51aac05 100644 --- a/site/content/docs/05-misc/03-svelte-internal.md +++ b/site/content/docs/05-misc/03-svelte-internal.md @@ -2,6 +2,10 @@ title: svelte/internal --- +`svelte/internal` module gives you all the mthods and types internally used. + +> WARNING: This API may change without warning. Use exports from this module with caution. + ## Exports > EXPORTS: svelte/internal diff --git a/sites/svelte.dev/scripts/type-gen/index.js b/sites/svelte.dev/scripts/type-gen/index.js index 9e62779743..37a95f9c97 100644 --- a/sites/svelte.dev/scripts/type-gen/index.js +++ b/sites/svelte.dev/scripts/type-gen/index.js @@ -180,19 +180,20 @@ function munge_type_element(member, depth = 1) { }; } -/** - * Type declarations include fully qualified URLs so that they become links when - * you hover over names in an editor with TypeScript enabled. We need to remove - * the origin so that they become root-relative, so that they work in preview - * deployments and when developing locally - * @param {string} str - */ -function strip_origin(str) { - return str.replace(/https:\/\/svelte\.dev/g, ''); -} - const bundled_types = await get_bundled_types(); +{ + const module = bundled_types.get('svelte'); + + if (!module) throw new Error('Could not find svelte'); + + modules.push({ + name: 'svelte', + comment: '', + ...get_types(module.code, module.ts_source_file.statements) + }); +} + { const module = bundled_types.get('svelte/compiler'); diff --git a/sites/svelte.dev/src/lib/server/docs/render.js b/sites/svelte.dev/src/lib/server/docs/render.js index 0f0207f047..c5b638490d 100644 --- a/sites/svelte.dev/src/lib/server/docs/render.js +++ b/sites/svelte.dev/src/lib/server/docs/render.js @@ -66,7 +66,7 @@ export function replace_placeholders(content) { }) .replace(/> EXPORT_SNIPPET: (.+?)#(.+)?$/gm, (_, name, id) => { const module = modules.find((module) => module.name === name); - if (!module) throw new Error(`Could not find module ${name}`); + if (!module) throw new Error(`Could not find module ${name} for EXPORT_SNIPPET clause`); if (!id) { throw new Error(`id is required for module ${name}`);