Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm authored Oct 28, 2024
1 parent eafb082 commit ab57c7b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export const load = (async () => {

const scriptTemplate: ReadonlyMap<ProjectType, string> = 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]
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const tsSv5ScriptTemplate = `
<script lang="ts">
import type { LayoutData } from './$types';
let data: LayoutData = $props();
let { data }: LayoutData = $props();
</script>
`;

Expand All @@ -26,7 +26,7 @@ const tsScriptTemplate = `
const jsSv5ScriptTemplate = `
<script>
/** @type {import('./$types').LayoutData} */
let data = $props();
let { data } = $props();
</script>
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export const load = (async () => {

const scriptTemplate: ReadonlyMap<ProjectType, string> = 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]
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export const load = (async () => {

const scriptTemplate: ReadonlyMap<ProjectType, string> = 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]
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const tsSv5ScriptTemplate = `
<script lang="ts">
import type { PageData } from './$types';
let data: PageData = $props();
let { data }: PageData = $props();
</script>
`;

Expand All @@ -26,7 +26,7 @@ const tsScriptTemplate = `
const jsSv5ScriptTemplate = `
<script>
/** @type {import('./$types').PageData} */
let data = $props();
let { data } = $props();
</script>
`;

Expand Down
8 changes: 4 additions & 4 deletions packages/svelte-vscode/src/sveltekit/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TextDecoder } from 'util';
import * as path from 'path';
import { Uri, workspace } from 'vscode';
import { IsSvelte5Plus, ProjectType } from './generateFiles/types'
Expand Down Expand Up @@ -57,12 +58,11 @@ export function isSvelte5Plus(version: string | undefined): IsSvelte5Plus {
return version.split('.')[0] >= '5';
}

export async function getSvelteVersionFromPackageJson(): Promise<string> {
export async function getSvelteVersionFromPackageJson(): Promise<string | undefined> {
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) {
Expand All @@ -79,5 +79,5 @@ export async function getSvelteVersionFromPackageJson(): Promise<string> {
}
}

throw new Error('No svelte version found');
return undefined;
}

0 comments on commit ab57c7b

Please sign in to comment.