fix: support TS satisfies operator (#10068)

fixes #9606
pull/10071/head
Simon H 2 years ago committed by GitHub
parent fa8aa2d481
commit 2133d7d67a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: support TypeScript's `satisfies` operator

@ -117,7 +117,7 @@
"@ampproject/remapping": "^2.2.1", "@ampproject/remapping": "^2.2.1",
"@jridgewell/sourcemap-codec": "^1.4.15", "@jridgewell/sourcemap-codec": "^1.4.15",
"acorn": "^8.10.0", "acorn": "^8.10.0",
"acorn-typescript": "^1.4.11", "acorn-typescript": "^1.4.13",
"aria-query": "^5.3.0", "aria-query": "^5.3.0",
"axobject-query": "^4.0.0", "axobject-query": "^4.0.0",
"esm-env": "^1.0.0", "esm-env": "^1.0.0",

@ -2,7 +2,7 @@ import * as acorn from 'acorn';
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';
import { tsPlugin } from 'acorn-typescript'; import { tsPlugin } from 'acorn-typescript';
const ParserWithTS = acorn.Parser.extend(tsPlugin()); const ParserWithTS = acorn.Parser.extend(tsPlugin({ allowSatisfies: true }));
/** /**
* @param {string} source * @param {string} source

@ -41,13 +41,16 @@ export const remove_types = {
TSAsExpression(node, context) { TSAsExpression(node, context) {
return context.visit(node.expression); return context.visit(node.expression);
}, },
TSSatisfiesExpression(node, context) {
return context.visit(node.expression);
},
TSNonNullExpression(node, context) { TSNonNullExpression(node, context) {
return context.visit(node.expression); return context.visit(node.expression);
}, },
TSInterfaceDeclaration(node, context) { TSInterfaceDeclaration() {
return b.empty; return b.empty;
}, },
TSTypeAliasDeclaration(node, context) { TSTypeAliasDeclaration() {
return b.empty; return b.empty;
} }
}; };

@ -10,6 +10,9 @@
import { type Bar, type Baz } from './types'; import { type Bar, type Baz } from './types';
let count = $state(0); let count = $state(0);
const person = {
message: 'goodbye'
} satisfies Goodbye;
</script> </script>
<button <button

@ -69,8 +69,8 @@ importers:
specifier: ^8.10.0 specifier: ^8.10.0
version: 8.11.2 version: 8.11.2
acorn-typescript: acorn-typescript:
specifier: ^1.4.11 specifier: ^1.4.13
version: 1.4.11(acorn@8.11.2) version: 1.4.13(acorn@8.11.2)
aria-query: aria-query:
specifier: ^5.3.0 specifier: ^5.3.0
version: 5.3.0 version: 5.3.0
@ -2748,8 +2748,8 @@ packages:
acorn: 8.11.2 acorn: 8.11.2
dev: true dev: true
/acorn-typescript@1.4.11(acorn@8.11.2): /acorn-typescript@1.4.13(acorn@8.11.2):
resolution: {integrity: sha512-cRGgp+4HMxMZAiMS61ZmQ3iuU/+A4g4ZYZsyLZdmvrEVN/TOwfJ40rPWcLqi3H5ut75SYAdOOJj6QGCcrkK57w==} resolution: {integrity: sha512-xsc9Xv0xlVfwp2o7sQ+GCQ1PgbkdcpWdTzrwXxO3xDMTAywVS3oXVOcOHuRjAPkS4P9b+yc/qNF15460v+jp4Q==}
peerDependencies: peerDependencies:
acorn: '>=8.9.0' acorn: '>=8.9.0'
dependencies: dependencies:

Loading…
Cancel
Save