Skip to content

Commit

Permalink
fix: support TS satisfies operator (#10068)
Browse files Browse the repository at this point in the history
fixes #9606
  • Loading branch information
dummdidumm committed Jan 3, 2024
1 parent fa8aa2d commit 2133d7d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
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.

1 comment on commit 2133d7d

@vercel
Copy link

@vercel vercel bot commented on 2133d7d Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

svelte-5-preview – ./sites/svelte-5-preview

svelte-5-preview-git-main-svelte.vercel.app
svelte-octane.vercel.app
svelte-5-preview.vercel.app
svelte-5-preview-svelte.vercel.app

Please sign in to comment.