diff --git a/.changeset/wise-mice-hang.md b/.changeset/wise-mice-hang.md new file mode 100644 index 00000000..58059db8 --- /dev/null +++ b/.changeset/wise-mice-hang.md @@ -0,0 +1,5 @@ +--- +"svelte-eslint-parser": patch +--- + +fix: error in snippets with type annotations diff --git a/src/parser/converts/block.ts b/src/parser/converts/block.ts index b1ab2931..274b2df6 100644 --- a/src/parser/converts/block.ts +++ b/src/parser/converts/block.ts @@ -651,13 +651,18 @@ export function convertSnippetBlock( ...ctx.getConvertLocation({ start: nodeStart, end: node.end }), }; + let beforeClosingParen: ESTree.Node; + if (node.parameters.length > 0) { + const lastParam = node.parameters[ + node.parameters.length - 1 + ] as ESTree.Pattern & { typeAnnotation?: ESTree.Node }; + beforeClosingParen = lastParam.typeAnnotation ?? lastParam; + } else { + beforeClosingParen = node.expression; + } const closeParenIndex = ctx.code.indexOf( ")", - getWithLoc( - node.parameters.length > 0 - ? node.parameters[node.parameters.length - 1] - : node.expression, - ).end, + getWithLoc(beforeClosingParen).end, ); const scopeKind = diff --git a/tests/fixtures/parser/ast/svelte5/ts-snippet03-input.svelte b/tests/fixtures/parser/ast/svelte5/ts-snippet03-input.svelte new file mode 100644 index 00000000..92522bda --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/ts-snippet03-input.svelte @@ -0,0 +1,11 @@ + + +{@render foo({ onclick: hello })} + +{#snippet foo(o: {onclick: () => void})} + +{/snippet} diff --git a/tests/fixtures/parser/ast/svelte5/ts-snippet03-output.json b/tests/fixtures/parser/ast/svelte5/ts-snippet03-output.json new file mode 100644 index 00000000..4a10b08f --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/ts-snippet03-output.json @@ -0,0 +1,2257 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteScriptElement", + "name": { + "type": "SvelteName", + "name": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "lang", + "range": [ + 8, + 12 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteLiteral", + "value": "ts", + "range": [ + 14, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + ], + "range": [ + 8, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 17 + } + } + } + ], + "selfClosing": false, + "range": [ + 0, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Literal", + "raw": "'Hello'", + "value": "Hello", + "range": [ + 53, + 60 + ], + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 21 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "console", + "range": [ + 41, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "log", + "range": [ + 49, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + "range": [ + 41, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + "optional": false, + "range": [ + 41, + 61 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + "range": [ + 41, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 23 + } + } + } + ], + "range": [ + 37, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 4, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "hello", + "range": [ + 29, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "params": [], + "range": [ + 20, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 66, + 75 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + } + }, + "range": [ + 0, + 75 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 75, + 77 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 7, + "column": 0 + } + } + }, + { + "type": "SvelteRenderTag", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "onclick", + "range": [ + 92, + 99 + ], + "loc": { + "start": { + "line": 7, + "column": 15 + }, + "end": { + "line": 7, + "column": 22 + } + } + }, + "method": false, + "shorthand": false, + "value": { + "type": "Identifier", + "name": "hello", + "range": [ + 101, + 106 + ], + "loc": { + "start": { + "line": 7, + "column": 24 + }, + "end": { + "line": 7, + "column": 29 + } + } + }, + "range": [ + 92, + 106 + ], + "loc": { + "start": { + "line": 7, + "column": 15 + }, + "end": { + "line": 7, + "column": 29 + } + } + } + ], + "range": [ + 90, + 108 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 31 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "foo", + "range": [ + 86, + 89 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "optional": false, + "range": [ + 86, + 109 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 32 + } + } + }, + "range": [ + 77, + 110 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 33 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 110, + 112 + ], + "loc": { + "start": { + "line": 7, + "column": 33 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 122, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "name": "onclick", + "range": [ + 130, + 137 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 25 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSVoidKeyword", + "range": [ + 145, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 33 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 142, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 139, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 27 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 137, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 130, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 37 + } + } + } + ], + "range": [ + 129, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 127, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 126, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 38 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "button", + "range": [ + 156, + 162 + ], + "loc": { + "start": { + "line": 10, + "column": 3 + }, + "end": { + "line": 10, + "column": 9 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteDirective", + "kind": "EventHandler", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "click", + "range": [ + 166, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 13 + }, + "end": { + "line": 10, + "column": 18 + } + } + }, + "modifiers": [], + "range": [ + 163, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 18 + } + } + }, + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "o", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 20 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "onclick", + "range": [ + 175, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 22 + }, + "end": { + "line": 10, + "column": 29 + } + } + }, + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 20 + }, + "end": { + "line": 10, + "column": 29 + } + } + }, + "range": [ + 163, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 30 + } + } + } + ], + "selfClosing": false, + "range": [ + 155, + 184 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 31 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "Click me", + "range": [ + 184, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 31 + }, + "end": { + "line": 10, + "column": 39 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 192, + 201 + ], + "loc": { + "start": { + "line": 10, + "column": 39 + }, + "end": { + "line": 10, + "column": 48 + } + } + }, + "range": [ + 155, + 201 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 48 + } + } + } + ], + "range": [ + 112, + 212 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "lang", + "range": [ + 8, + 12 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 12, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + } + }, + { + "type": "HTMLText", + "value": "ts", + "range": [ + 14, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 16, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + { + "type": "Keyword", + "value": "function", + "range": [ + 20, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "hello", + "range": [ + 29, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "Identifier", + "value": "console", + "range": [ + 41, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": ".", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 10 + } + } + }, + { + "type": "Identifier", + "value": "log", + "range": [ + 49, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 52, + 53 + ], + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + } + }, + { + "type": "String", + "value": "'Hello'", + "range": [ + 53, + 60 + ], + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 60, + 61 + ], + "loc": { + "start": { + "line": 3, + "column": 21 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 61, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 66, + 67 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 68, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 75, + 77 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 7, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": "@render", + "range": [ + 78, + 85 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 8 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 86, + 89 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "line": 7, + "column": 13 + }, + "end": { + "line": 7, + "column": 14 + } + } + }, + { + "type": "Identifier", + "value": "onclick", + "range": [ + 92, + 99 + ], + "loc": { + "start": { + "line": 7, + "column": 15 + }, + "end": { + "line": 7, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 7, + "column": 22 + }, + "end": { + "line": 7, + "column": 23 + } + } + }, + { + "type": "Identifier", + "value": "hello", + "range": [ + 101, + 106 + ], + "loc": { + "start": { + "line": 7, + "column": 24 + }, + "end": { + "line": 7, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 107, + 108 + ], + "loc": { + "start": { + "line": 7, + "column": 30 + }, + "end": { + "line": 7, + "column": 31 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 7, + "column": 31 + }, + "end": { + "line": 7, + "column": 32 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 7, + "column": 32 + }, + "end": { + "line": 7, + "column": 33 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 110, + 112 + ], + "loc": { + "start": { + "line": 7, + "column": 33 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": "#snippet", + "range": [ + 113, + 121 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 122, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 9, + "column": 13 + }, + "end": { + "line": 9, + "column": 14 + } + } + }, + { + "type": "Identifier", + "value": "o", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 129, + 130 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 18 + } + } + }, + { + "type": "Identifier", + "value": "onclick", + "range": [ + 130, + 137 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 26 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 9, + "column": 27 + }, + "end": { + "line": 9, + "column": 28 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 28 + }, + "end": { + "line": 9, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "=>", + "range": [ + 142, + 144 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 32 + } + } + }, + { + "type": "Keyword", + "value": "void", + "range": [ + 145, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 33 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 37 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 38 + }, + "end": { + "line": 9, + "column": 39 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 151, + 152 + ], + "loc": { + "start": { + "line": 9, + "column": 39 + }, + "end": { + "line": 9, + "column": 40 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 155, + 156 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 3 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 156, + 162 + ], + "loc": { + "start": { + "line": 10, + "column": 3 + }, + "end": { + "line": 10, + "column": 9 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "on", + "range": [ + 163, + 165 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 165, + 166 + ], + "loc": { + "start": { + "line": 10, + "column": 12 + }, + "end": { + "line": 10, + "column": 13 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "click", + "range": [ + 166, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 13 + }, + "end": { + "line": 10, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 10, + "column": 18 + }, + "end": { + "line": 10, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 20 + } + } + }, + { + "type": "Identifier", + "value": "o", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 20 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": ".", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 21 + }, + "end": { + "line": 10, + "column": 22 + } + } + }, + { + "type": "Identifier", + "value": "onclick", + "range": [ + 175, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 22 + }, + "end": { + "line": 10, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 29 + }, + "end": { + "line": 10, + "column": 30 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 10, + "column": 30 + }, + "end": { + "line": 10, + "column": 31 + } + } + }, + { + "type": "HTMLText", + "value": "Click", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 31 + }, + "end": { + "line": 10, + "column": 36 + } + } + }, + { + "type": "HTMLText", + "value": " ", + "range": [ + 189, + 190 + ], + "loc": { + "start": { + "line": 10, + "column": 36 + }, + "end": { + "line": 10, + "column": 37 + } + } + }, + { + "type": "HTMLText", + "value": "me", + "range": [ + 190, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 37 + }, + "end": { + "line": 10, + "column": 39 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 192, + 193 + ], + "loc": { + "start": { + "line": 10, + "column": 39 + }, + "end": { + "line": 10, + "column": 40 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 10, + "column": 40 + }, + "end": { + "line": 10, + "column": 41 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 194, + 200 + ], + "loc": { + "start": { + "line": 10, + "column": 41 + }, + "end": { + "line": 10, + "column": 47 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 200, + 201 + ], + "loc": { + "start": { + "line": 10, + "column": 47 + }, + "end": { + "line": 10, + "column": 48 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 202, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": "/snippet", + "range": [ + 203, + 211 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 211, + 212 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 10 + } + } + } + ], + "range": [ + 0, + 213 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 12, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/ts-snippet03-scope-output.json b/tests/fixtures/parser/ast/svelte5/ts-snippet03-scope-output.json new file mode 100644 index 00000000..599b3c7a --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/ts-snippet03-scope-output.json @@ -0,0 +1,2129 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$state", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$derived", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$effect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$bindable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$inspect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$host", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "hello", + "identifiers": [ + { + "type": "Identifier", + "name": "hello", + "range": [ + 29, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + ], + "defs": [ + { + "type": "FunctionName", + "name": { + "type": "Identifier", + "name": "hello", + "range": [ + 29, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "node": { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Literal", + "raw": "'Hello'", + "value": "Hello", + "range": [ + 53, + 60 + ], + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 21 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "console", + "range": [ + 41, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "log", + "range": [ + 49, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + "range": [ + 41, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + "optional": false, + "range": [ + 41, + 61 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + "range": [ + 41, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 23 + } + } + } + ], + "range": [ + 37, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 4, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "hello", + "range": [ + 29, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + "params": [], + "range": [ + 20, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "hello", + "range": [ + 101, + 106 + ], + "loc": { + "start": { + "line": 7, + "column": 24 + }, + "end": { + "line": 7, + "column": 29 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "hello", + "range": [ + 29, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + } + ] + }, + { + "name": "foo", + "identifiers": [ + { + "type": "Identifier", + "name": "foo", + "range": [ + 122, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 13 + } + } + } + ], + "defs": [ + { + "type": "FunctionName", + "name": { + "type": "Identifier", + "name": "foo", + "range": [ + 122, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "node": { + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 122, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "name": "onclick", + "range": [ + 130, + 137 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 25 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSVoidKeyword", + "range": [ + 145, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 33 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 142, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 139, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 27 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 137, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 130, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 37 + } + } + } + ], + "range": [ + 129, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 127, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 126, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 38 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "button", + "range": [ + 156, + 162 + ], + "loc": { + "start": { + "line": 10, + "column": 3 + }, + "end": { + "line": 10, + "column": 9 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteDirective", + "kind": "EventHandler", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "click", + "range": [ + 166, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 13 + }, + "end": { + "line": 10, + "column": 18 + } + } + }, + "modifiers": [], + "range": [ + 163, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 18 + } + } + }, + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "o", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 20 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "onclick", + "range": [ + 175, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 22 + }, + "end": { + "line": 10, + "column": 29 + } + } + }, + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 20 + }, + "end": { + "line": 10, + "column": 29 + } + } + }, + "range": [ + 163, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 30 + } + } + } + ], + "selfClosing": false, + "range": [ + 155, + 184 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 31 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "Click me", + "range": [ + 184, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 31 + }, + "end": { + "line": 10, + "column": 39 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 192, + 201 + ], + "loc": { + "start": { + "line": 10, + "column": 39 + }, + "end": { + "line": 10, + "column": 48 + } + } + }, + "range": [ + 155, + 201 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 48 + } + } + } + ], + "range": [ + 112, + 212 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "range": [ + 86, + 89 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "foo", + "range": [ + 122, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 13 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "range": [ + 86, + 89 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "foo", + "range": [ + 122, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "hello", + "range": [ + 101, + 106 + ], + "loc": { + "start": { + "line": 7, + "column": 24 + }, + "end": { + "line": 7, + "column": 29 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "hello", + "range": [ + 29, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "console", + "range": [ + 41, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "from": "function", + "init": null, + "resolved": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "console", + "range": [ + 41, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "from": "function", + "init": null, + "resolved": null + } + ] + }, + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "o", + "identifiers": [ + { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "name": "onclick", + "range": [ + 130, + 137 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 25 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSVoidKeyword", + "range": [ + 145, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 33 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 142, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 139, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 27 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 137, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 130, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 37 + } + } + } + ], + "range": [ + 129, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 127, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 126, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 38 + } + } + } + ], + "defs": [ + { + "type": "Parameter", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "name": "onclick", + "range": [ + 130, + 137 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 25 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSVoidKeyword", + "range": [ + 145, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 33 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 142, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 139, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 27 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 137, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 130, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 37 + } + } + } + ], + "range": [ + 129, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 127, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 126, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "node": { + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 122, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "name": "onclick", + "range": [ + 130, + 137 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 25 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSVoidKeyword", + "range": [ + 145, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 33 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 142, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 139, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 27 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 137, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 130, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 37 + } + } + } + ], + "range": [ + 129, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 127, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 126, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 38 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "button", + "range": [ + 156, + 162 + ], + "loc": { + "start": { + "line": 10, + "column": 3 + }, + "end": { + "line": 10, + "column": 9 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteDirective", + "kind": "EventHandler", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "click", + "range": [ + 166, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 13 + }, + "end": { + "line": 10, + "column": 18 + } + } + }, + "modifiers": [], + "range": [ + 163, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 18 + } + } + }, + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "o", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 20 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "onclick", + "range": [ + 175, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 22 + }, + "end": { + "line": 10, + "column": 29 + } + } + }, + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 20 + }, + "end": { + "line": 10, + "column": 29 + } + } + }, + "range": [ + 163, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 30 + } + } + } + ], + "selfClosing": false, + "range": [ + 155, + 184 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 31 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "Click me", + "range": [ + 184, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 31 + }, + "end": { + "line": 10, + "column": 39 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 192, + 201 + ], + "loc": { + "start": { + "line": 10, + "column": 39 + }, + "end": { + "line": 10, + "column": 48 + } + } + }, + "range": [ + 155, + 201 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 48 + } + } + } + ], + "range": [ + 112, + 212 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "o", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 20 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "name": "onclick", + "range": [ + 130, + 137 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 25 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSVoidKeyword", + "range": [ + 145, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 33 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 142, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 139, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 27 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 137, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 130, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 37 + } + } + } + ], + "range": [ + 129, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 127, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 126, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 38 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "o", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 20 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "name": "onclick", + "range": [ + 130, + 137 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 25 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSVoidKeyword", + "range": [ + 145, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 33 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 142, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 139, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 27 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 137, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 37 + } + } + }, + "range": [ + 130, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 37 + } + } + } + ], + "range": [ + 129, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 127, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 38 + } + } + }, + "range": [ + 126, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 38 + } + } + } + } + ], + "childScopes": [ + { + "type": "functionType", + "variables": [], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "console", + "range": [ + 41, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "from": "function", + "init": null, + "resolved": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "console", + "range": [ + 41, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "from": "function", + "init": null, + "resolved": null + } + ] +} \ No newline at end of file