-
-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: detect shadowed variables/types during type hoisting (#2590)
- Loading branch information
1 parent
bf2e459
commit fba28b2
Showing
9 changed files
with
158 additions
and
11 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
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
34 changes: 34 additions & 0 deletions
34
...ages/svelte2tsx/test/svelte2tsx/samples/ts-runes-hoistable-props-false-3.v5/expectedv2.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,34 @@ | ||
///<reference types="svelte" /> | ||
; | ||
type SomeType<T extends boolean> = T; | ||
type T = unknown; | ||
;;function render<T extends boolean>() { | ||
;type $$ComponentProps = { someProp: SomeType<T>; }; | ||
let { someProp }:/*Ωignore_startΩ*/$$ComponentProps/*Ωignore_endΩ*/ = $props(); | ||
; | ||
async () => { | ||
|
||
}; | ||
return { props: {} as any as $$ComponentProps, exports: {}, bindings: __sveltets_$$bindings(''), slots: {}, events: {} }} | ||
class __sveltets_Render<T extends boolean> { | ||
props() { | ||
return render<T>().props; | ||
} | ||
events() { | ||
return render<T>().events; | ||
} | ||
slots() { | ||
return render<T>().slots; | ||
} | ||
bindings() { return __sveltets_$$bindings(''); } | ||
exports() { return {}; } | ||
} | ||
|
||
interface $$IsomorphicComponent { | ||
new <T extends boolean>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & { $$bindings?: ReturnType<__sveltets_Render<T>['bindings']> } & ReturnType<__sveltets_Render<T>['exports']>; | ||
<T extends boolean>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>; | ||
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>; | ||
} | ||
const Input__SvelteComponent_: $$IsomorphicComponent = null as any; | ||
/*Ωignore_startΩ*/type Input__SvelteComponent_<T extends boolean> = InstanceType<typeof Input__SvelteComponent_<T>>; | ||
/*Ωignore_endΩ*/export default Input__SvelteComponent_; |
8 changes: 8 additions & 0 deletions
8
packages/svelte2tsx/test/svelte2tsx/samples/ts-runes-hoistable-props-false-3.v5/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,8 @@ | ||
<script lang="ts" module> | ||
type SomeType<T extends boolean> = T; | ||
type T = unknown; | ||
</script> | ||
|
||
<script lang="ts" generics="T extends boolean"> | ||
let { someProp }: { someProp: SomeType<T>; } = $props(); | ||
</script> |
15 changes: 15 additions & 0 deletions
15
...ages/svelte2tsx/test/svelte2tsx/samples/ts-runes-hoistable-props-false-4.v5/expectedv2.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" /> | ||
; | ||
let a = ''; | ||
;;function render() { | ||
|
||
let a = true;;type $$ComponentProps = { someProp: typeof a }; | ||
let { someProp }:/*Ωignore_startΩ*/$$ComponentProps/*Ωignore_endΩ*/ = $props(); | ||
; | ||
async () => { | ||
|
||
}; | ||
return { props: {} as any as $$ComponentProps, exports: {}, bindings: __sveltets_$$bindings(''), slots: {}, events: {} }} | ||
const Input__SvelteComponent_ = __sveltets_2_fn_component(render()); | ||
type Input__SvelteComponent_ = ReturnType<typeof Input__SvelteComponent_>; | ||
export default Input__SvelteComponent_; |
8 changes: 8 additions & 0 deletions
8
packages/svelte2tsx/test/svelte2tsx/samples/ts-runes-hoistable-props-false-4.v5/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,8 @@ | ||
<script lang="ts" module> | ||
let a = ''; | ||
</script> | ||
|
||
<script lang="ts"> | ||
let a = true; | ||
let { someProp }: { someProp: typeof a } = $props(); | ||
</script> |
15 changes: 15 additions & 0 deletions
15
...ages/svelte2tsx/test/svelte2tsx/samples/ts-runes-hoistable-props-false-5.v5/expectedv2.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" /> | ||
; | ||
type Shadowed = string; | ||
;;function render() { | ||
|
||
type Shadowed = boolean;;type $$ComponentProps = { someProp: Shadowed }; | ||
let { someProp }:/*Ωignore_startΩ*/$$ComponentProps/*Ωignore_endΩ*/ = $props(); | ||
; | ||
async () => { | ||
|
||
}; | ||
return { props: {} as any as $$ComponentProps, exports: {}, bindings: __sveltets_$$bindings(''), slots: {}, events: {} }} | ||
const Input__SvelteComponent_ = __sveltets_2_fn_component(render()); | ||
type Input__SvelteComponent_ = ReturnType<typeof Input__SvelteComponent_>; | ||
export default Input__SvelteComponent_; |
8 changes: 8 additions & 0 deletions
8
packages/svelte2tsx/test/svelte2tsx/samples/ts-runes-hoistable-props-false-5.v5/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,8 @@ | ||
<script lang="ts" module> | ||
type Shadowed = string; | ||
</script> | ||
|
||
<script lang="ts"> | ||
type Shadowed = boolean; | ||
let { someProp }: { someProp: Shadowed } = $props(); | ||
</script> |