diff --git a/packages/svelte-vscode/src/sveltekit/generateFiles/templates/layout-server.ts b/packages/svelte-vscode/src/sveltekit/generateFiles/templates/layout-server.ts index 24bb14fec..0954b5e65 100644 --- a/packages/svelte-vscode/src/sveltekit/generateFiles/templates/layout-server.ts +++ b/packages/svelte-vscode/src/sveltekit/generateFiles/templates/layout-server.ts @@ -26,10 +26,10 @@ export const load = (async () => { const scriptTemplate: ReadonlyMap = new Map([ [ProjectType.TS_SV5, tsScriptTemplate], - [ProjectType.TS_SATISFIES_SV5, tsScriptTemplate], + [ProjectType.TS_SATISFIES_SV5, tsSatisfiesScriptTemplate], [ProjectType.JS_SV5, defaultScriptTemplate], [ProjectType.TS, tsScriptTemplate], - [ProjectType.TS_SATISFIES, tsScriptTemplate], + [ProjectType.TS_SATISFIES, tsSatisfiesScriptTemplate], [ProjectType.JS, defaultScriptTemplate] ]) diff --git a/packages/svelte-vscode/src/sveltekit/generateFiles/templates/layout.ts b/packages/svelte-vscode/src/sveltekit/generateFiles/templates/layout.ts index 3e1fa4ce1..11651dbbf 100644 --- a/packages/svelte-vscode/src/sveltekit/generateFiles/templates/layout.ts +++ b/packages/svelte-vscode/src/sveltekit/generateFiles/templates/layout.ts @@ -11,7 +11,7 @@ const tsSv5ScriptTemplate = ` `; @@ -26,7 +26,7 @@ const tsScriptTemplate = ` const jsSv5ScriptTemplate = ` `; diff --git a/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page-load.ts b/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page-load.ts index 5d24854ff..c604e2495 100644 --- a/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page-load.ts +++ b/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page-load.ts @@ -26,10 +26,10 @@ export const load = (async () => { const scriptTemplate: ReadonlyMap = new Map([ [ProjectType.TS_SV5, tsScriptTemplate], - [ProjectType.TS_SATISFIES_SV5, tsScriptTemplate], + [ProjectType.TS_SATISFIES_SV5, tsSatisfiesScriptTemplate], [ProjectType.JS_SV5, defaultScriptTemplate], [ProjectType.TS, tsScriptTemplate], - [ProjectType.TS_SATISFIES, tsScriptTemplate], + [ProjectType.TS_SATISFIES, tsSatisfiesScriptTemplate], [ProjectType.JS, defaultScriptTemplate] ]) diff --git a/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page-server.ts b/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page-server.ts index 41ae7ad55..56d1c5bdf 100644 --- a/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page-server.ts +++ b/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page-server.ts @@ -26,10 +26,10 @@ export const load = (async () => { const scriptTemplate: ReadonlyMap = new Map([ [ProjectType.TS_SV5, tsScriptTemplate], - [ProjectType.TS_SATISFIES_SV5, tsScriptTemplate], + [ProjectType.TS_SATISFIES_SV5, tsSatisfiesScriptTemplate], [ProjectType.JS_SV5, defaultScriptTemplate], [ProjectType.TS, tsScriptTemplate], - [ProjectType.TS_SATISFIES, tsScriptTemplate], + [ProjectType.TS_SATISFIES, tsSatisfiesScriptTemplate], [ProjectType.JS, defaultScriptTemplate] ]) diff --git a/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page.ts b/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page.ts index b67e0df8e..910493a35 100644 --- a/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page.ts +++ b/packages/svelte-vscode/src/sveltekit/generateFiles/templates/page.ts @@ -11,7 +11,7 @@ const tsSv5ScriptTemplate = ` `; @@ -26,7 +26,7 @@ const tsScriptTemplate = ` const jsSv5ScriptTemplate = ` `; diff --git a/packages/svelte-vscode/src/sveltekit/utils.ts b/packages/svelte-vscode/src/sveltekit/utils.ts index 83904f668..7eeef64bc 100644 --- a/packages/svelte-vscode/src/sveltekit/utils.ts +++ b/packages/svelte-vscode/src/sveltekit/utils.ts @@ -1,3 +1,4 @@ +import { TextDecoder } from 'util'; import * as path from 'path'; import { Uri, workspace } from 'vscode'; import { IsSvelte5Plus, ProjectType } from './generateFiles/types' @@ -57,12 +58,11 @@ export function isSvelte5Plus(version: string | undefined): IsSvelte5Plus { return version.split('.')[0] >= '5'; } -export async function getSvelteVersionFromPackageJson(): Promise { +export async function getSvelteVersionFromPackageJson(): Promise { const packageJsonList = await workspace.findFiles('**/package.json', '**/node_modules/**'); if (packageJsonList.length === 0) { - // We assume that the user has not setup their project yet - throw new Error('No package.json found'); + return undefined; } for (const fileUri of packageJsonList) { @@ -79,5 +79,5 @@ export async function getSvelteVersionFromPackageJson(): Promise { } } - throw new Error('No svelte version found'); + return undefined; }