Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/light-humans-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: support TypeScript's `satisfies` operator
2 changes: 1 addition & 1 deletion packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"@ampproject/remapping": "^2.2.1",
"@jridgewell/sourcemap-codec": "^1.4.15",
"acorn": "^8.10.0",
"acorn-typescript": "^1.4.11",
"acorn-typescript": "^1.4.13",
"aria-query": "^5.3.0",
"axobject-query": "^4.0.0",
"esm-env": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/phases/1-parse/acorn.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as acorn from 'acorn';
import { walk } from 'zimmerframe';
import { tsPlugin } from 'acorn-typescript';

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

/**
* @param {string} source
Expand Down
7 changes: 5 additions & 2 deletions packages/svelte/src/compiler/phases/3-transform/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ export const remove_types = {
TSAsExpression(node, context) {
return context.visit(node.expression);
},
TSSatisfiesExpression(node, context) {
return context.visit(node.expression);
},
TSNonNullExpression(node, context) {
return context.visit(node.expression);
},
TSInterfaceDeclaration(node, context) {
TSInterfaceDeclaration() {
return b.empty;
},
TSTypeAliasDeclaration(node, context) {
TSTypeAliasDeclaration() {
return b.empty;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import { type Bar, type Baz } from './types';

let count = $state(0);
const person = {
message: 'goodbye'
} satisfies Goodbye;
</script>

<button
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.