-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mark exports as "can only bind to them"
- Loading branch information
1 parent
811b1ce
commit ade7c5b
Showing
12 changed files
with
149 additions
and
8 deletions.
There are no files selected for viewing
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
6 changes: 6 additions & 0 deletions
6
...guage-server/test/plugins/typescript/features/diagnostics/fixtures/bindings/Legacy.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,6 @@ | ||
<script lang="ts"> | ||
export let value = 'implicitly bindable'; | ||
export function bind_and_prop() { | ||
return true; | ||
} | ||
</script> |
7 changes: 7 additions & 0 deletions
7
...nguage-server/test/plugins/typescript/features/diagnostics/fixtures/bindings/Runes.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,7 @@ | ||
<script lang="ts"> | ||
let { readonly, can_bind = $bindable() }: { readonly?: string; can_bind?: string } = $props(); | ||
export function only_bind() { | ||
return true; | ||
} | ||
</script> |
36 changes: 36 additions & 0 deletions
36
...ver/test/plugins/typescript/features/diagnostics/fixtures/bindings/expected_svelte_5.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,36 @@ | ||
[ | ||
{ | ||
"code": 2322, | ||
"message": "Type 'Binding<string>' is not assignable to type 'string'.", | ||
"range": { | ||
"end": { | ||
"character": 20, | ||
"line": 23 | ||
}, | ||
"start": { | ||
"character": 12, | ||
"line": 23 | ||
} | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"tags": [] | ||
}, | ||
{ | ||
"code": 2322, | ||
"message": "Type '() => boolean' is not assignable to type 'Binding<() => boolean>'.", | ||
"range": { | ||
"end": { | ||
"character": 17, | ||
"line": 24 | ||
}, | ||
"start": { | ||
"character": 8, | ||
"line": 24 | ||
} | ||
}, | ||
"severity": 1, | ||
"source": "ts", | ||
"tags": [] | ||
} | ||
] |
1 change: 1 addition & 0 deletions
1
...age-server/test/plugins/typescript/features/diagnostics/fixtures/bindings/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 @@ | ||
[] |
25 changes: 25 additions & 0 deletions
25
...nguage-server/test/plugins/typescript/features/diagnostics/fixtures/bindings/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,25 @@ | ||
<script lang="ts"> | ||
import Legacy from './Legacy.svelte'; | ||
import Runes from './Runes.svelte'; | ||
let bind_and_prop: () => boolean; | ||
let value = ''; | ||
let only_bind: () => boolean; | ||
let can_bind = ''; | ||
let readonly = '' | ||
</script> | ||
|
||
<!-- ok --> | ||
<Legacy bind:bind_and_prop /> | ||
<Legacy bind:value /> | ||
<Legacy {value} /> | ||
<Legacy {bind_and_prop} /> | ||
<Runes bind:can_bind /> | ||
<Runes {can_bind} /> | ||
<Runes {readonly} /> | ||
<Runes bind:only_bind /> | ||
|
||
<!-- error in Svelte 5 --> | ||
<Runes bind:readonly /> | ||
<Runes {only_bind} /> |
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
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
15 changes: 15 additions & 0 deletions
15
...sx/test/svelte2tsx/samples/sveltekit-autotypes-$props-rune-no-changes/expected-svelte5.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,15 @@ | ||
///<reference types="svelte" /> | ||
;function render() { | ||
|
||
/** @typedef {{form: boolean, data: true }} $$ComponentProps *//** @type {$$ComponentProps} */ | ||
let { form, data } = $props(); | ||
/** @type {any} */ | ||
const snapshot = {}; | ||
; | ||
async () => {}; | ||
return { props: /** @type {{snapshot?: import("svelte").Binding<typeof snapshot>} & $$ComponentProps} */({}), slots: {}, events: {} }} | ||
|
||
export default class Page__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(['snapshot'], __sveltets_2_with_any_event(render()))) { | ||
constructor(options = __sveltets_2_runes_constructor(__sveltets_2_partial(['snapshot'], __sveltets_2_with_any_event(render())))) { super(options); } | ||
get snapshot() { return __sveltets_2_nonNullable(this.$$prop_def.snapshot) } | ||
} |
13 changes: 13 additions & 0 deletions
13
...es/svelte2tsx/test/svelte2tsx/samples/sveltekit-autotypes-$props-rune/expected-svelte5.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,13 @@ | ||
///<reference types="svelte" /> | ||
;function render() { | ||
|
||
let/** @typedef {{ form: import('./$types.js').ActionData, data: import('./$types.js').PageData }} $$ComponentProps *//** @type {$$ComponentProps} */ { form, data } = $props(); | ||
const snapshot/*Ωignore_startΩ*/: import('./$types.js').Snapshot/*Ωignore_endΩ*/ = {}; | ||
; | ||
async () => {}; | ||
return { props: /** @type {{snapshot?: import("svelte").Binding<typeof snapshot>} & $$ComponentProps} */({}), slots: {}, events: {} }} | ||
|
||
export default class Page__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_partial(['snapshot'], __sveltets_2_with_any_event(render()))) { | ||
constructor(options = __sveltets_2_runes_constructor(__sveltets_2_partial(['snapshot'], __sveltets_2_with_any_event(render())))) { super(options); } | ||
get snapshot() { return __sveltets_2_nonNullable(this.$$prop_def.snapshot) } | ||
} |
13 changes: 13 additions & 0 deletions
13
.../test/svelte2tsx/samples/ts-sveltekit-autotypes-$props-rune-unchanged/expected-svelte5.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,13 @@ | ||
///<reference types="svelte" /> | ||
;function render() { | ||
|
||
const snapshot: any = {};;type $$ComponentProps = {form: boolean, data: true }; | ||
let { form, data }:$$ComponentProps = $props(); | ||
; | ||
async () => {}; | ||
return { props: {} as any as $$ComponentProps & { snapshot?: import("svelte").Binding<any> }, slots: {}, events: {} }} | ||
|
||
export default class Page__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_with_any_event(render())) { | ||
constructor(options = __sveltets_2_runes_constructor(__sveltets_2_with_any_event(render()))) { super(options); } | ||
get snapshot() { return __sveltets_2_nonNullable(this.$$prop_def.snapshot) } | ||
} |
13 changes: 13 additions & 0 deletions
13
...svelte2tsx/test/svelte2tsx/samples/ts-sveltekit-autotypes-$props-rune/expected-svelte5.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,13 @@ | ||
///<reference types="svelte" /> | ||
;function render() { | ||
|
||
const snapshot/*Ωignore_startΩ*/: import('./$types.js').Snapshot/*Ωignore_endΩ*/ = {};/*Ωignore_startΩ*/;type $$ComponentProps = { form: import('./$types.js').ActionData, data: import('./$types.js').PageData };/*Ωignore_endΩ*/ | ||
let { form, data }: $$ComponentProps = $props(); | ||
; | ||
async () => {}; | ||
return { props: {} as any as $$ComponentProps & { snapshot?: import("svelte").Binding<typeof snapshot> }, slots: {}, events: {} }} | ||
|
||
export default class Page__SvelteComponent_ extends __sveltets_2_createSvelte2TsxComponent(__sveltets_2_with_any_event(render())) { | ||
constructor(options = __sveltets_2_runes_constructor(__sveltets_2_with_any_event(render()))) { super(options); } | ||
get snapshot() { return __sveltets_2_nonNullable(this.$$prop_def.snapshot) } | ||
} |