Skip to content

Commit

Permalink
fix: use correct semantic tokens for $props types (#2379)
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloricciuti authored May 21, 2024
1 parent 7409890 commit cf00f03
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/svelte2tsx/src/svelte2tsx/nodes/ExportedNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ export class ExportedNames {
generic_arg.end + this.astOffset,
node.parent.pos + this.astOffset
);
this.str.appendRight(generic_arg.end + this.astOffset, this.$props.type);
this.str.appendRight(
generic_arg.end + this.astOffset,
// so that semantic tokens ignore it, preventing an overlap of tokens
surroundWithIgnoreComments(this.$props.type)
);
}
} else {
if (!this.isTsFile) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///<reference types="svelte" />
;function render<T>() {
;type $$ComponentProps = { a: T, b: string };
let { a, b }:$$ComponentProps = $props();
let { a, b }:/*Ωignore_startΩ*/$$ComponentProps/*Ωignore_endΩ*/ = $props();
let x = $state<T>(0);
let y = $derived(x * 2);
;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///<reference types="svelte" />
;function render() {
;type $$ComponentProps = { a: number, b: string };
let { a, b }:$$ComponentProps = $props();
let { a, b }:/*Ωignore_startΩ*/$$ComponentProps/*Ωignore_endΩ*/ = $props();
let x = $state(0);
let y = $derived(x * 2);
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
;function render() {

const snapshot: any = {};;type $$ComponentProps = {form: boolean, data: true };
let { form, data }:$$ComponentProps = $props();
let { form, data }:/*Ωignore_startΩ*/$$ComponentProps/*Ωignore_endΩ*/ = $props();
;
async () => {};
return { props: {} as any as $$ComponentProps, exports: {} as any as { snapshot: any }, slots: {}, events: {} }}
Expand Down

0 comments on commit cf00f03

Please sign in to comment.