-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(svelte2tsx): autotype
const load = ...
declarations (#2540)
- Loading branch information
Showing
6 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
.../plugins/typescript/features/diagnostics/fixtures/sveltekit-autotypings-arrow/$types.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface PageLoadEvent<> { | ||
test: { | ||
exists: boolean; | ||
}; | ||
} | ||
|
||
export type PageLoad<OutputData = Record<string, any>> = (event: PageLoadEvent) => OutputData; | ||
|
||
export type PageData = ReturnType<typeof import('./+page').load>; |
3 changes: 3 additions & 0 deletions
3
...plugins/typescript/features/diagnostics/fixtures/sveltekit-autotypings-arrow/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<script lang="ts"> | ||
export let data; | ||
</script> |
8 changes: 8 additions & 0 deletions
8
...est/plugins/typescript/features/diagnostics/fixtures/sveltekit-autotypings-arrow/+page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// In a real SvelteKit application, $types are autogenerated, for this test we manually create them to our liking | ||
// @ts-expect-error - to silence tsc | ||
export const load = decorator((event) => event.test); | ||
|
||
// Dummy decorator function, to open the door to SvelteKit extensions | ||
function decorator<T>(fn: T): T { | ||
return fn; | ||
} |
19 changes: 19 additions & 0 deletions
19
...gins/typescript/features/diagnostics/fixtures/sveltekit-autotypings-arrow/expectedv2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[ | ||
{ | ||
"range": { | ||
"start": { | ||
"line": 4, | ||
"character": 1 | ||
}, | ||
"end": { | ||
"line": 4, | ||
"character": 5 | ||
} | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"message": "Property 'data' is missing in type '{}' but required in type '{ data: { exists: boolean; }; }'.", | ||
"code": 2741, | ||
"tags": [] | ||
} | ||
] |
5 changes: 5 additions & 0 deletions
5
...plugins/typescript/features/diagnostics/fixtures/sveltekit-autotypings-arrow/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script lang="ts"> | ||
import Page from './+page.svelte'; | ||
</script> | ||
|
||
<Page /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters