Skip to content

Commit 2133d7d

Browse files
authored
fix: support TS satisfies operator (#10068)
fixes #9606
1 parent fa8aa2d commit 2133d7d

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

.changeset/light-humans-hang.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: support TypeScript's `satisfies` operator

packages/svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"@ampproject/remapping": "^2.2.1",
118118
"@jridgewell/sourcemap-codec": "^1.4.15",
119119
"acorn": "^8.10.0",
120-
"acorn-typescript": "^1.4.11",
120+
"acorn-typescript": "^1.4.13",
121121
"aria-query": "^5.3.0",
122122
"axobject-query": "^4.0.0",
123123
"esm-env": "^1.0.0",

packages/svelte/src/compiler/phases/1-parse/acorn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as acorn from 'acorn';
22
import { walk } from 'zimmerframe';
33
import { tsPlugin } from 'acorn-typescript';
44

5-
const ParserWithTS = acorn.Parser.extend(tsPlugin());
5+
const ParserWithTS = acorn.Parser.extend(tsPlugin({ allowSatisfies: true }));
66

77
/**
88
* @param {string} source

packages/svelte/src/compiler/phases/3-transform/typescript.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ export const remove_types = {
4141
TSAsExpression(node, context) {
4242
return context.visit(node.expression);
4343
},
44+
TSSatisfiesExpression(node, context) {
45+
return context.visit(node.expression);
46+
},
4447
TSNonNullExpression(node, context) {
4548
return context.visit(node.expression);
4649
},
47-
TSInterfaceDeclaration(node, context) {
50+
TSInterfaceDeclaration() {
4851
return b.empty;
4952
},
50-
TSTypeAliasDeclaration(node, context) {
53+
TSTypeAliasDeclaration() {
5154
return b.empty;
5255
}
5356
};

packages/svelte/tests/runtime-runes/samples/typescript/main.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import { type Bar, type Baz } from './types';
1111
1212
let count = $state(0);
13+
const person = {
14+
message: 'goodbye'
15+
} satisfies Goodbye;
1316
</script>
1417

1518
<button

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)