fix: ignore generic type arguments while creating AST (#15659)

* fix: ignore generic type arguments while creating AST

bumps esrap and fixes a resulting error: because esrap now uses a more compliant TSESTree AST, it has `typeArguments` instead of `typeParameters` in some places - those were not deleted while stripping types, which caused an error.

* fix $$render_inner declaration
pull/15650/head
Simon H 5 months ago committed by GitHub
parent 3682371fb6
commit 959f593487
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ignore generic type arguments while creating AST

@ -156,7 +156,7 @@
"axobject-query": "^4.1.0", "axobject-query": "^4.1.0",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"esm-env": "^1.2.1", "esm-env": "^1.2.1",
"esrap": "^1.4.3", "esrap": "^1.4.6",
"is-reference": "^3.0.3", "is-reference": "^3.0.3",
"locate-character": "^3.0.0", "locate-character": "^3.0.0",
"magic-string": "^0.30.11", "magic-string": "^0.30.11",

@ -24,6 +24,7 @@ const visitors = {
// until that day comes, we just delete them so they don't confuse esrap // until that day comes, we just delete them so they don't confuse esrap
delete n.typeAnnotation; delete n.typeAnnotation;
delete n.typeParameters; delete n.typeParameters;
delete n.typeArguments;
delete n.returnType; delete n.returnType;
delete n.accessibility; delete n.accessibility;
}, },

@ -186,12 +186,10 @@ export function server_component(analysis, options) {
...snippets, ...snippets,
b.let('$$settled', b.true), b.let('$$settled', b.true),
b.let('$$inner_payload'), b.let('$$inner_payload'),
b.stmt( b.function_declaration(
b.function( b.id('$$render_inner'),
b.id('$$render_inner'), [b.id('$$payload')],
[b.id('$$payload')], b.block(/** @type {Statement[]} */ (rest))
b.block(/** @type {Statement[]} */ (rest))
)
), ),
b.do_while( b.do_while(
b.unary('!', b.id('$$settled')), b.unary('!', b.id('$$settled')),

@ -8,7 +8,7 @@
console.log(this); console.log(this);
} }
function foo(): string { function foo<T>(): string {
return ""!; return ""!;
} }
@ -46,6 +46,7 @@
const TypedFoo = Foo<true>; const TypedFoo = Foo<true>;
const typeAssertion = <boolean>true; const typeAssertion = <boolean>true;
const x = foo<true>();
</script> </script>
<script> <script>

@ -23,7 +23,7 @@ export default function Bind_component_snippet($$payload) {
}); });
$$payload.out += `<!----> value: ${$.escape(value)}`; $$payload.out += `<!----> value: ${$.escape(value)}`;
}; }
do { do {
$$settled = true; $$settled = true;

@ -87,8 +87,8 @@ importers:
specifier: ^1.2.1 specifier: ^1.2.1
version: 1.2.1 version: 1.2.1
esrap: esrap:
specifier: ^1.4.3 specifier: ^1.4.6
version: 1.4.3 version: 1.4.6
is-reference: is-reference:
specifier: ^3.0.3 specifier: ^3.0.3
version: 3.0.3 version: 3.0.3
@ -1261,8 +1261,8 @@ packages:
resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==}
engines: {node: '>=0.10'} engines: {node: '>=0.10'}
esrap@1.4.3: esrap@1.4.6:
resolution: {integrity: sha512-Xddc1RsoFJ4z9nR7W7BFaEPIp4UXoeQ0+077UdWLxbafMQFyU79sQJMk7kxNgRwQ9/aVgaKacCHC2pUACGwmYw==} resolution: {integrity: sha512-F/D2mADJ9SHY3IwksD4DAXjTt7qt7GWUf3/8RhCNWmC/67tyb55dpimHmy7EplakFaflV0R/PC+fdSPqrRHAQw==}
esrecurse@4.3.0: esrecurse@4.3.0:
resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==}
@ -3617,7 +3617,7 @@ snapshots:
dependencies: dependencies:
estraverse: 5.3.0 estraverse: 5.3.0
esrap@1.4.3: esrap@1.4.6:
dependencies: dependencies:
'@jridgewell/sourcemap-codec': 1.5.0 '@jridgewell/sourcemap-codec': 1.5.0

Loading…
Cancel
Save