diff --git a/package.json b/package.json index c47fc2a1..fca2a8ca 100644 --- a/package.json +++ b/package.json @@ -76,8 +76,7 @@ "test:mocha": "mocha --require ts-node/register \"test/*.js\" --reporter dot --timeout 60000", "test:cover": "nyc mocha \"test/*.js\" --reporter dot --timeout 60000", "test:debug": "mocha --require ts-node/register/transpile-only \"test/*.js\" --reporter dot --timeout 60000", - "preupdate-fixtures": "npm run -s build", - "update-fixtures": "node scripts/update-fixtures-ast.js && node scripts/update-fixtures-document-fragment.js", + "update-fixtures": "ts-node --transpile-only scripts/update-fixtures-ast.js && ts-node --transpile-only scripts/update-fixtures-document-fragment.js", "preversion": "npm test", "version": "npm run -s build", "postversion": "git push && git push --tags", diff --git a/scripts/update-fixtures-ast.js b/scripts/update-fixtures-ast.js index 23aa1c56..89905747 100644 --- a/scripts/update-fixtures-ast.js +++ b/scripts/update-fixtures-ast.js @@ -11,7 +11,7 @@ const fs = require("fs") const path = require("path") -const parser = require("../") +const parser = require("../src") const escope = require("eslint-scope") const semver = require("semver") @@ -222,16 +222,17 @@ for (const name of TARGETS) { continue } const sourcePath = path.join(ROOT, `${name}/source.vue`) - const optionsPath = path.join(ROOT, `${name}/parser-options.json`) + const optionsPath = [ + path.join(ROOT, `${name}/parser-options.json`), + path.join(ROOT, `${name}/parser-options.js`), + ].find((fp) => fs.existsSync(fp)) const astPath = path.join(ROOT, `${name}/ast.json`) const tokenRangesPath = path.join(ROOT, `${name}/token-ranges.json`) const treePath = path.join(ROOT, `${name}/tree.json`) const scopePath = path.join(ROOT, `${name}/scope.json`) const servicesPath = path.join(ROOT, `${name}/services.json`) const source = fs.readFileSync(sourcePath, "utf8") - const parserOptions = fs.existsSync(optionsPath) - ? JSON.parse(fs.readFileSync(optionsPath, "utf8")) - : {} + const parserOptions = optionsPath ? require(optionsPath) : {} const options = Object.assign( { filePath: sourcePath }, PARSER_OPTIONS, diff --git a/scripts/update-fixtures-document-fragment.js b/scripts/update-fixtures-document-fragment.js index 605c3d45..ef8c4110 100644 --- a/scripts/update-fixtures-document-fragment.js +++ b/scripts/update-fixtures-document-fragment.js @@ -6,7 +6,7 @@ const fs = require("fs") const path = require("path") -const parser = require("../") +const parser = require("../src") //------------------------------------------------------------------------------ // Helpers @@ -53,14 +53,15 @@ for (const name of TARGETS) { .readdirSync(path.join(ROOT, name)) .find((f) => f.startsWith("source.")) const sourcePath = path.join(ROOT, `${name}/${sourceFileName}`) - const optionsPath = path.join(ROOT, `${name}/parser-options.json`) + const optionsPath = [ + path.join(ROOT, `${name}/parser-options.json`), + path.join(ROOT, `${name}/parser-options.js`), + ].find((fp) => fs.existsSync(fp)) const source = fs.readFileSync(sourcePath, "utf8") const options = Object.assign( { filePath: sourcePath }, PARSER_OPTIONS, - fs.existsSync(optionsPath) - ? JSON.parse(fs.readFileSync(optionsPath, "utf8")) - : {} + optionsPath ? require(optionsPath) : {}, ) const result = parser.parseForESLint(source, options) const actual = result.services.getDocumentFragment() @@ -72,7 +73,7 @@ for (const name of TARGETS) { console.log("Update:", name) const tokenRanges = getAllTokens(actual).map((t) => - source.slice(t.range[0], t.range[1]) + source.slice(t.range[0], t.range[1]), ) const tree = getTree(source, actual) @@ -106,7 +107,7 @@ function getTree(source, fgAst) { type: node.type, text: source.slice(node.range[0], node.range[1]), children: [], - }) + }), ) }, leaveNode() { diff --git a/src/ast/nodes.ts b/src/ast/nodes.ts index 104255fe..090f8573 100644 --- a/src/ast/nodes.ts +++ b/src/ast/nodes.ts @@ -7,6 +7,8 @@ import type { ScopeManager } from "eslint-scope" import type { ParseError } from "./errors" import type { HasLocation } from "./locations" import type { Token } from "./tokens" +// eslint-disable-next-line node/no-extraneous-import -- ignore +import type { TSESTree } from "@typescript-eslint/utils" //------------------------------------------------------------------------------ // Common @@ -28,6 +30,7 @@ export type Node = | VForExpression | VOnExpression | VSlotScopeExpression + | VGenericExpression | VFilterSequenceExpression | VFilter @@ -742,7 +745,7 @@ export type Namespace = */ export interface Variable { id: ESLintIdentifier - kind: "v-for" | "scope" + kind: "v-for" | "scope" | "generic" references: Reference[] } @@ -787,6 +790,16 @@ export interface VSlotScopeExpression extends HasLocation, HasParent { params: ESLintPattern[] } +/** + * The node of `generic` directives. + */ +export interface VGenericExpression extends HasLocation, HasParent { + type: "VGenericExpression" + parent: VExpressionContainer + params: TSESTree.TSTypeParameterDeclaration["params"] + rawParams: string[] +} + /** * The node of a filter sequence which is separated by `|`. */ @@ -845,6 +858,7 @@ export interface VExpressionContainer extends HasLocation, HasParent { | VForExpression | VOnExpression | VSlotScopeExpression + | VGenericExpression | null references: Reference[] } diff --git a/src/common/ast-utils.ts b/src/common/ast-utils.ts index a97a1970..e87b8365 100644 --- a/src/common/ast-utils.ts +++ b/src/common/ast-utils.ts @@ -3,6 +3,8 @@ import type { VDirective, VDocumentFragment, VElement, + VExpressionContainer, + VGenericExpression, VNode, } from "../ast" @@ -80,3 +82,34 @@ export function getLang(element: VElement | undefined): string | null { const lang = langAttr && langAttr.value && langAttr.value.value return lang || null } +/** + * Check whether the given script element has `lang="ts"`. + * @param element The element to check. + * @returns The given script element has `lang="ts"`. + */ +export function isTSLang(element: VElement | undefined): boolean { + const lang = getLang(element) + // See https://github.com/vuejs/core/blob/28e30c819df5e4fc301c98f7be938fa13e8be3bc/packages/compiler-sfc/src/compileScript.ts#L179 + return lang === "ts" || lang === "tsx" +} + +export type GenericDirective = VDirective & { + value: VExpressionContainer & { + expression: VGenericExpression + } +} + +/** + * Find `generic` directive from given `" + } + ], + "comments": [], + "templateBody": { + "type": "VElement", + "range": [ + 70, + 100 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 70, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 81, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "name": "foo", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 89, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + } + } + }, + { + "type": "Punctuator", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 37, + 59 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 60, + 68 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 70, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 81, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 86, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 89, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-1/parser-options.json b/test/fixtures/ast/vue3.3-generic-1/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-1/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-1/scope.json b/test/fixtures/ast/vue3.3-generic-1/scope.json new file mode 100644 index 00000000..f67735c2 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-1/scope.json @@ -0,0 +1,1022 @@ +{ + "type": "global", + "variables": [ + { + "name": "ClassMemberDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassMethodDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassGetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassSetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorTarget", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassFieldDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Symbol", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptorMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Object", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Function", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisParameterType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "OmitThisParameter", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "CallableFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NewableFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IArguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "String", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "StringConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Boolean", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BooleanConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Number", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NumberConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TemplateStringsArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportMeta", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportCallOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportAssertions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Math", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Date", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DateConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpMatchArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpExecArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExp", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Error", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "JSON", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConcatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypedPropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructorLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Promise", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Awaited", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Partial", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Required", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Readonly", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Pick", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Record", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Exclude", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Extract", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Omit", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NonNullable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Parameters", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConstructorParameters", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReturnType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "InstanceType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uppercase", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Lowercase", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Capitalize", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uncapitalize", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataViewConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int8Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int8ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ClampedArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ClampedArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Intl", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Map", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Set", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SymbolConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorYieldResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorReturnResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Generator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyHandler", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Atomics", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGenerator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "const", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "defineProps", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + "from": "module", + "init": null + } + ] + }, + { + "name": "T", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + } + }, + "from": "module", + "init": null + } + ] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + } + }, + "from": "module", + "init": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + } + }, + "from": "module", + "init": null + } + ] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-1/source.vue b/test/fixtures/ast/vue3.3-generic-1/source.vue new file mode 100644 index 00000000..fc54be37 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-1/source.vue @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-1/token-ranges.json b/test/fixtures/ast/vue3.3-generic-1/token-ranges.json new file mode 100644 index 00000000..debb41a2 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-1/token-ranges.json @@ -0,0 +1,40 @@ +[ + "", + "", + "\n", + "defineProps<{foo:T}>()", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-1/tree.json b/test/fixtures/ast/vue3.3-generic-1/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-1/tree.json @@ -0,0 +1,39 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-2/ast.json b/test/fixtures/ast/vue3.3-generic-2/ast.json new file mode 100644 index 00000000..3685710d --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/ast.json @@ -0,0 +1,2454 @@ +{ + "type": "Program", + "body": [ + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "Foo", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "typeAnnotation": { + "type": "TSUnionType", + "types": [ + { + "type": "TSNumberKeyword", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "TSStringKeyword", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + } + } + ], + "range": [ + 20, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 26 + } + } + }, + "range": [ + 9, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 26 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "p", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "defineProps", + "range": [ + 105, + 116 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "arguments": [], + "optional": false, + "range": [ + 105, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "range": [ + 116, + 125 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "name": "foo", + "range": [ + 118, + 121 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 26 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "range": [ + 121, + 123 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "T", + "range": [ + 122, + 123 + ], + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "range": [ + 122, + 123 + ], + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 28 + } + } + } + }, + "range": [ + 118, + 123 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 28 + } + } + } + ], + "range": [ + 117, + 124 + ], + "loc": { + "start": { + "line": 5, + "column": 22 + }, + "end": { + "line": 5, + "column": 29 + } + } + } + ], + "loc": { + "start": { + "line": 5, + "column": 21 + }, + "end": { + "line": 5, + "column": 30 + } + } + } + }, + "range": [ + 101, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 32 + } + } + } + ], + "kind": "const", + "range": [ + 95, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 32 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 134, + 137 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "p", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "foo", + "range": [ + 142, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + "computed": false, + "optional": false, + "range": [ + 140, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + "range": [ + 134, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + } + } + ], + "kind": "const", + "range": [ + 128, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "console", + "range": [ + 146, + 153 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "property": { + "type": "Identifier", + "name": "log", + "range": [ + 154, + 157 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + "computed": false, + "optional": false, + "range": [ + 146, + 157 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "foo", + "range": [ + 158, + 161 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 15 + } + } + } + ], + "optional": false, + "range": [ + 146, + 162 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + } + }, + "range": [ + 146, + 162 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + } + } + ], + "sourceType": "module", + "range": [ + 9, + 162 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 46, + 94 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 48 + } + }, + "value": "" + } + ], + "comments": [], + "templateBody": { + "type": "VElement", + "range": [ + 173, + 203 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 173, + 183 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 184, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "name": "foo", + "range": [ + 186, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 186, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 192, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 34 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 81, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 35 + }, + "end": { + "line": 4, + "column": 42 + } + } + }, + { + "type": "Identifier", + "value": "Foo", + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + { + "type": "Punctuator", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 46 + }, + "end": { + "line": 4, + "column": 47 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 93, + 94 + ], + "loc": { + "start": { + "line": 4, + "column": 47 + }, + "end": { + "line": 4, + "column": 48 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 95, + 100 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 105, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 128, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 134, + 137 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 146, + 162 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 163, + 171 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 184, + 186 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 186, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 189, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 192, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 202, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-2/parser-options.json b/test/fixtures/ast/vue3.3-generic-2/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-2/scope.json b/test/fixtures/ast/vue3.3-generic-2/scope.json new file mode 100644 index 00000000..9629ab05 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/scope.json @@ -0,0 +1,1519 @@ +{ + "type": "global", + "variables": [ + { + "name": "ClassMemberDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassMethodDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassGetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassSetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorTarget", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassFieldDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Symbol", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptorMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Object", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Function", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisParameterType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "OmitThisParameter", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "CallableFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NewableFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IArguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "String", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "StringConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Boolean", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BooleanConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Number", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NumberConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TemplateStringsArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportMeta", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportCallOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportAssertions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Math", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Date", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DateConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpMatchArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpExecArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExp", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Error", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "JSON", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConcatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypedPropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructorLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Promise", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Awaited", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Partial", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Required", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Readonly", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Pick", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Record", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Exclude", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Extract", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Omit", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NonNullable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Parameters", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConstructorParameters", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReturnType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "InstanceType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uppercase", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Lowercase", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Capitalize", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uncapitalize", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataViewConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int8Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int8ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ClampedArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ClampedArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Intl", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Map", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Set", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SymbolConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorYieldResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorReturnResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Generator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyHandler", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Atomics", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGenerator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "const", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "defineProps", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "from": "module", + "init": null + } + ] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "Foo", + "identifiers": [ + { + "type": "Identifier", + "name": "Foo", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + } + } + ], + "defs": [ + { + "type": "Type", + "node": { + "type": "TSTypeAliasDeclaration", + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 26 + } + } + }, + "name": "Foo" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "Foo", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "Foo", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + }, + { + "name": "p", + "identifiers": [ + { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 32 + } + } + }, + "name": "p" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "init": null + } + ] + }, + { + "name": "foo", + "identifiers": [ + { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + "name": "foo" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 15 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 15 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-2/source.vue b/test/fixtures/ast/vue3.3-generic-2/source.vue new file mode 100644 index 00000000..e42bea85 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-2/token-ranges.json b/test/fixtures/ast/vue3.3-generic-2/token-ranges.json new file mode 100644 index 00000000..8c7613a8 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/token-ranges.json @@ -0,0 +1,99 @@ +[ + "", + "", + "", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "", + "\n", + "", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-2/tree.json b/test/fixtures/ast/vue3.3-generic-2/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-2/tree.json @@ -0,0 +1,39 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-3/ast.json b/test/fixtures/ast/vue3.3-generic-3/ast.json new file mode 100644 index 00000000..8dbd9da4 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/ast.json @@ -0,0 +1,2758 @@ +{ + "type": "Program", + "body": [ + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "Foo", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "typeAnnotation": { + "type": "TSUnionType", + "types": [ + { + "type": "TSNumberKeyword", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "TSStringKeyword", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + } + } + ], + "range": [ + 20, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 26 + } + } + }, + "range": [ + 9, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 26 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "p", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "defineProps", + "range": [ + 118, + 129 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "arguments": [], + "optional": false, + "range": [ + 118, + 148 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 40 + } + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "range": [ + 129, + 146 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "name": "foo", + "range": [ + 131, + 134 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 26 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "range": [ + 134, + 136 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "T", + "range": [ + 135, + 136 + ], + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "range": [ + 135, + 136 + ], + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 28 + } + } + } + }, + "range": [ + 131, + 137 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 29 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "name": "bar", + "range": [ + 138, + 141 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 33 + } + } + }, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "start": { + "line": 5, + "column": 33 + }, + "end": { + "line": 5, + "column": 36 + } + }, + "range": [ + 141, + 144 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "U", + "range": [ + 143, + 144 + ], + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 36 + } + } + }, + "range": [ + 143, + 144 + ], + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 36 + } + } + } + }, + "range": [ + 138, + 144 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 36 + } + } + } + ], + "range": [ + 130, + 145 + ], + "loc": { + "start": { + "line": 5, + "column": 22 + }, + "end": { + "line": 5, + "column": 37 + } + } + } + ], + "loc": { + "start": { + "line": 5, + "column": 21 + }, + "end": { + "line": 5, + "column": 38 + } + } + } + }, + "range": [ + 114, + 148 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 40 + } + } + } + ], + "kind": "const", + "range": [ + 108, + 148 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 40 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 155, + 158 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "p", + "range": [ + 161, + 162 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + } + }, + "property": { + "type": "Identifier", + "name": "foo", + "range": [ + 163, + 166 + ], + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + "computed": false, + "optional": false, + "range": [ + 161, + 166 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + "range": [ + 155, + 166 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + } + } + ], + "kind": "const", + "range": [ + 149, + 166 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "console", + "range": [ + 167, + 174 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "property": { + "type": "Identifier", + "name": "log", + "range": [ + 175, + 178 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + "computed": false, + "optional": false, + "range": [ + 167, + 178 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "foo", + "range": [ + 179, + 182 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 15 + } + } + } + ], + "optional": false, + "range": [ + 167, + 183 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + } + }, + "range": [ + 167, + 183 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + } + } + ], + "sourceType": "module", + "range": [ + 9, + 183 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 46, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 61 + } + }, + "value": "" + } + ], + "comments": [], + "templateBody": { + "type": "VElement", + "range": [ + 194, + 224 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 194, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 205, + 212 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "name": "foo", + "range": [ + 207, + 210 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 207, + 210 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 213, + 224 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 34 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 81, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 35 + }, + "end": { + "line": 4, + "column": 42 + } + } + }, + { + "type": "Identifier", + "value": "Foo", + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 46 + }, + "end": { + "line": 4, + "column": 47 + } + } + }, + { + "type": "Identifier", + "value": "U", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 4, + "column": 49 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 96, + 103 + ], + "loc": { + "start": { + "line": 4, + "column": 50 + }, + "end": { + "line": 4, + "column": 57 + } + } + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 4, + "column": 58 + }, + "end": { + "line": 4, + "column": 59 + } + } + }, + { + "type": "Punctuator", + "range": [ + 105, + 106 + ], + "loc": { + "start": { + "line": 4, + "column": 59 + }, + "end": { + "line": 4, + "column": 60 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 60 + }, + "end": { + "line": 4, + "column": 61 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 107, + 108 + ], + "loc": { + "start": { + "line": 4, + "column": 61 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 115, + 116 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 116, + 117 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 118, + 137 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 142 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 142, + 143 + ], + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 5, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 143, + 148 + ], + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 5, + "column": 40 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 154 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 154, + 155 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 155, + 158 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 158, + 159 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 160, + 161 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 161, + 166 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 167, + 183 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 184, + 192 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 192, + 193 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 194, + 203 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 205, + 207 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 207, + 210 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 210, + 212 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 213, + 223 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-3/parser-options.json b/test/fixtures/ast/vue3.3-generic-3/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-3/scope.json b/test/fixtures/ast/vue3.3-generic-3/scope.json new file mode 100644 index 00000000..7deedb76 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/scope.json @@ -0,0 +1,1576 @@ +{ + "type": "global", + "variables": [ + { + "name": "ClassMemberDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassMethodDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassGetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassSetterDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorTarget", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassAccessorDecoratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassFieldDecoratorContext", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Symbol", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDescriptorMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Object", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Function", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisParameterType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "OmitThisParameter", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "CallableFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NewableFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IArguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "String", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "StringConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Boolean", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "BooleanConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Number", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NumberConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TemplateStringsArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportMeta", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportCallOptions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ImportAssertions", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Math", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Date", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DateConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpMatchArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpExecArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExp", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExpConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Error", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "EvalErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "JSON", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConcatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypedPropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructorLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Promise", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Awaited", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Partial", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Required", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Readonly", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Pick", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Record", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Exclude", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Extract", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Omit", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "NonNullable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Parameters", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConstructorParameters", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReturnType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "InstanceType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uppercase", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Lowercase", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Capitalize", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uncapitalize", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferTypes", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataViewConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int8Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int8ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ClampedArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint8ClampedArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Int32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Uint32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float32Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float32ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float64Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float64ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Intl", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Map", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlyMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMap", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakMapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Set", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakSetConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SymbolConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorYieldResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorReturnResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorResult", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Generator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyHandler", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Atomics", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIterableIterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGenerator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "const", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "defineProps", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "from": "module", + "init": null + } + ] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "Foo", + "identifiers": [ + { + "type": "Identifier", + "name": "Foo", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + } + } + ], + "defs": [ + { + "type": "Type", + "node": { + "type": "TSTypeAliasDeclaration", + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 26 + } + } + }, + "name": "Foo" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "Foo", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "Foo", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + }, + { + "name": "p", + "identifiers": [ + { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 40 + } + } + }, + "name": "p" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "init": null + } + ] + }, + { + "name": "foo", + "identifiers": [ + { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + "name": "foo" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 15 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "U", + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 36 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "p", + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 7, + "column": 15 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "foo", + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "init": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "defineProps", + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "from": "module", + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "U", + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 36 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "T", + "loc": { + "start": { + "line": 5, + "column": 27 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "U", + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 36 + } + } + }, + "from": "module", + "resolved": null, + "init": null + }, + { + "identifier": { + "type": "Identifier", + "name": "console", + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "from": "module", + "resolved": null, + "init": null + } + ] +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-3/source.vue b/test/fixtures/ast/vue3.3-generic-3/source.vue new file mode 100644 index 00000000..5d3590d2 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-3/token-ranges.json b/test/fixtures/ast/vue3.3-generic-3/token-ranges.json new file mode 100644 index 00000000..cec12a2a --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/token-ranges.json @@ -0,0 +1,111 @@ +[ + "", + "", + "", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "", + "\n", + "", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T,", + " ", + "bar:", + " ", + "U}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-3/tree.json b/test/fixtures/ast/vue3.3-generic-3/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-3/tree.json @@ -0,0 +1,39 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-1/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-1/document-fragment.json new file mode 100644 index 00000000..b354feda --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-1/document-fragment.json @@ -0,0 +1,1463 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 100 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 69 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "name": "setup", + "rawName": "setup" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 14, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": "lang", + "rawName": "lang" + }, + "value": { + "type": "VLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + } + }, + { + "type": "VAttribute", + "range": [ + 24, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "name": "generic", + "rawName": "generic" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "name": { + "type": "Identifier", + "name": "T", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + } + } + }, + "in": false, + "out": false, + "const": false, + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + } + } + } + ], + "rawParams": [ + "T" + ] + }, + "references": [] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 36, + 60 + ], + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\ndefineProps<{foo:T}>()\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 60, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "name": "T", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 70, + 100 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 70, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 81, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "name": "foo", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 89, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + } + } + }, + { + "type": "Punctuator", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 37, + 59 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 60, + 68 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 70, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 81, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 86, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 89, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } + ], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 34 + } + } + }, + { + "type": "Punctuator", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 35 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 37, + 59 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 60, + 68 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 70, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 81, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 86, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 89, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-1/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-1/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-1/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-1/source.vue b/test/fixtures/document-fragment/vue3.3-generic-1/source.vue new file mode 100644 index 00000000..fc54be37 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-1/source.vue @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-1/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-1/token-ranges.json new file mode 100644 index 00000000..80b1a7d7 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-1/token-ranges.json @@ -0,0 +1,28 @@ +[ + "", + "\n", + "defineProps<{foo:T}>()", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-1/tree.json b/test/fixtures/document-fragment/vue3.3-generic-1/tree.json new file mode 100644 index 00000000..0c0a767a --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-1/tree.json @@ -0,0 +1,139 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-2/document-fragment.json new file mode 100644 index 00000000..efd5dc1c --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-2/document-fragment.json @@ -0,0 +1,2913 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 203 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 45 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 8, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\ntype Foo = number | string\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 36, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 46, + 172 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 46, + 94 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 48 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "name": "setup", + "rawName": "setup" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 60, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "name": "lang", + "rawName": "lang" + }, + "value": { + "type": "VLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + } + }, + { + "type": "VAttribute", + "range": [ + 70, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 47 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "name": "generic", + "rawName": "generic" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 78, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 47 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 79, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 46 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "name": { + "type": "Identifier", + "name": "T", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 34 + } + } + }, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "Foo", + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + "in": false, + "out": false, + "const": false, + "range": [ + 79, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 46 + } + } + } + ], + "rawParams": [ + "T extends Foo" + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "Foo", + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + } + ] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 94, + 163 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\nconst p = defineProps<{foo:T}>()\nconst foo = p.foo\nconsole.log(foo)\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 163, + 172 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "name": "T", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 34 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 173, + 203 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 173, + 183 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 184, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "name": "foo", + "range": [ + 186, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 186, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 192, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 34 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 81, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 35 + }, + "end": { + "line": 4, + "column": 42 + } + } + }, + { + "type": "Identifier", + "value": "Foo", + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + { + "type": "Punctuator", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 46 + }, + "end": { + "line": 4, + "column": 47 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 93, + 94 + ], + "loc": { + "start": { + "line": 4, + "column": 47 + }, + "end": { + "line": 4, + "column": 48 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 95, + 100 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 105, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 128, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 134, + 137 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 146, + 162 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 163, + 171 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 184, + 186 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 186, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 189, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 192, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 202, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } + ], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 34 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 81, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 35 + }, + "end": { + "line": 4, + "column": 42 + } + } + }, + { + "type": "Identifier", + "value": "Foo", + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + { + "type": "Punctuator", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 46 + }, + "end": { + "line": 4, + "column": 47 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 93, + 94 + ], + "loc": { + "start": { + "line": 4, + "column": 47 + }, + "end": { + "line": 4, + "column": 48 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 95, + 100 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 105, + 127 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": "defineProps<{foo:T}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 128, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 134, + 137 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 145 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 145, + 146 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 146, + 162 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 163, + 171 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 184, + 186 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 186, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 189, + 191 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 191, + 192 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 192, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 202, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-2/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-2/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/source.vue b/test/fixtures/document-fragment/vue3.3-generic-2/source.vue new file mode 100644 index 00000000..e42bea85 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-2/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-2/token-ranges.json new file mode 100644 index 00000000..0f21efc8 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-2/token-ranges.json @@ -0,0 +1,64 @@ +[ + "", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "", + "\n", + "", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/tree.json b/test/fixtures/document-fragment/vue3.3-generic-2/tree.json new file mode 100644 index 00000000..c55894cd --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-2/tree.json @@ -0,0 +1,176 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-3/document-fragment.json new file mode 100644 index 00000000..f3bedad1 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-3/document-fragment.json @@ -0,0 +1,3296 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 224 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 45 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 8, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\ntype Foo = number | string\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 36, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 46, + 193 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 46, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 61 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "name": "setup", + "rawName": "setup" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 60, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "name": "lang", + "rawName": "lang" + }, + "value": { + "type": "VLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + } + }, + { + "type": "VAttribute", + "range": [ + 70, + 106 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 60 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 4, + "column": 31 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "name": "generic", + "rawName": "generic" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 78, + 106 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 60 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 79, + 105 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 59 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "name": { + "type": "Identifier", + "name": "T", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 34 + } + } + }, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "Foo", + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + "in": false, + "out": false, + "const": false, + "range": [ + 79, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + { + "type": "TSTypeParameter", + "name": { + "type": "Identifier", + "name": "U", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 4, + "column": 49 + } + } + }, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "T", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 4, + "column": 58 + }, + "end": { + "line": 4, + "column": 59 + } + } + }, + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 4, + "column": 58 + }, + "end": { + "line": 4, + "column": 59 + } + } + }, + "in": false, + "out": false, + "const": false, + "range": [ + 94, + 105 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 4, + "column": 59 + } + } + } + ], + "rawParams": [ + "T extends Foo", + "U extends T" + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "Foo", + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + } + ] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 107, + 184 + ], + "loc": { + "start": { + "line": 4, + "column": 61 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\nconst p = defineProps<{foo:T, bar: U}>()\nconst foo = p.foo\nconsole.log(foo)\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 184, + 193 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "name": "T", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 34 + } + } + }, + "kind": "generic" + }, + { + "id": { + "type": "Identifier", + "name": "U", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 4, + "column": 49 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 194, + 224 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 194, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 205, + 212 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "name": "foo", + "range": [ + 207, + 210 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 207, + 210 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 213, + 224 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 34 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 81, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 35 + }, + "end": { + "line": 4, + "column": 42 + } + } + }, + { + "type": "Identifier", + "value": "Foo", + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 46 + }, + "end": { + "line": 4, + "column": 47 + } + } + }, + { + "type": "Identifier", + "value": "U", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 4, + "column": 49 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 96, + 103 + ], + "loc": { + "start": { + "line": 4, + "column": 50 + }, + "end": { + "line": 4, + "column": 57 + } + } + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 4, + "column": 58 + }, + "end": { + "line": 4, + "column": 59 + } + } + }, + { + "type": "Punctuator", + "range": [ + 105, + 106 + ], + "loc": { + "start": { + "line": 4, + "column": 59 + }, + "end": { + "line": 4, + "column": 60 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 60 + }, + "end": { + "line": 4, + "column": 61 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 107, + 108 + ], + "loc": { + "start": { + "line": 4, + "column": 61 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 115, + 116 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 116, + 117 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 118, + 137 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 142 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 142, + 143 + ], + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 5, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 143, + 148 + ], + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 5, + "column": 40 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 154 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 154, + 155 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 155, + 158 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 158, + 159 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 160, + 161 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 161, + 166 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 167, + 183 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 184, + 192 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 192, + 193 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 194, + 203 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 205, + 207 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 207, + 210 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 210, + 212 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 213, + 223 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] + } + ], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 8, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 9, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 14, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 20, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 36, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 46, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 60, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 77 + ], + "loc": { + "start": { + "column": 24, + "line": 4 + }, + "end": { + "column": 31, + "line": 4 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 4, + "column": 32 + }, + "end": { + "line": 4, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 4, + "column": 33 + }, + "end": { + "line": 4, + "column": 34 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 81, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 35 + }, + "end": { + "line": 4, + "column": 42 + } + } + }, + { + "type": "Identifier", + "value": "Foo", + "range": [ + 89, + 92 + ], + "loc": { + "start": { + "line": 4, + "column": 43 + }, + "end": { + "line": 4, + "column": 46 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 4, + "column": 46 + }, + "end": { + "line": 4, + "column": 47 + } + } + }, + { + "type": "Identifier", + "value": "U", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 4, + "column": 48 + }, + "end": { + "line": 4, + "column": 49 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 96, + 103 + ], + "loc": { + "start": { + "line": 4, + "column": 50 + }, + "end": { + "line": 4, + "column": 57 + } + } + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 104, + 105 + ], + "loc": { + "start": { + "line": 4, + "column": 58 + }, + "end": { + "line": 4, + "column": 59 + } + } + }, + { + "type": "Punctuator", + "range": [ + 105, + 106 + ], + "loc": { + "start": { + "line": 4, + "column": 59 + }, + "end": { + "line": 4, + "column": 60 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 60 + }, + "end": { + "line": 4, + "column": 61 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 107, + 108 + ], + "loc": { + "start": { + "line": 4, + "column": 61 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 115, + 116 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 116, + 117 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 118, + 137 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 138, + 142 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 142, + 143 + ], + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 5, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 143, + 148 + ], + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 5, + "column": 40 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 154 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 154, + 155 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 155, + 158 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 158, + 159 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 160, + 161 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 161, + 166 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 167, + 183 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 184, + 192 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 192, + 193 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 193, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 194, + 203 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 205, + 207 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 207, + 210 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 210, + 212 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 212, + 213 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 213, + 223 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-3/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-3/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/source.vue b/test/fixtures/document-fragment/vue3.3-generic-3/source.vue new file mode 100644 index 00000000..5d3590d2 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-3/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-3/token-ranges.json new file mode 100644 index 00000000..2c199c64 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-3/token-ranges.json @@ -0,0 +1,72 @@ +[ + "", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "", + "\n", + "", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T,", + " ", + "bar:", + " ", + "U}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/tree.json b/test/fixtures/document-fragment/vue3.3-generic-3/tree.json new file mode 100644 index 00000000..39979906 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-3/tree.json @@ -0,0 +1,198 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/document-fragment.json new file mode 100644 index 00000000..23514a87 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/document-fragment.json @@ -0,0 +1,3023 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 235 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 204 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 91 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "name": "setup", + "rawName": "setup" + }, + "value": null + }, + { + "type": "VAttribute", + "range": [ + 14, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": "lang", + "rawName": "lang" + }, + "value": { + "type": "VLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + } + }, + { + "type": "VAttribute", + "range": [ + 24, + 90 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "name": "generic", + "rawName": "generic" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 32, + 90 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 36, + 88 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 6, + "column": 5 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "name": { + "type": "Identifier", + "name": "T", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + } + }, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "Foo", + "range": [ + 50, + 53 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + } + }, + "range": [ + 50, + 53 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + } + }, + "in": false, + "out": false, + "const": false, + "range": [ + 36, + 53 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 15 + } + } + }, + { + "type": "TSTypeParameter", + "name": { + "type": "Identifier", + "name": "U", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } + } + }, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "T", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 5 + } + } + }, + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 5 + } + } + }, + "in": false, + "out": false, + "const": false, + "range": [ + 73, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 6, + "column": 5 + } + } + } + ], + "rawParams": [ + "T\n extends Foo", + "U extends\n T" + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "Foo", + "range": [ + 50, + 53 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + } + ] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 91, + 195 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\ntype Foo = number | string\nconst p = defineProps<{foo:T, bar: U}>()\nconst foo = p.foo\nconsole.log(foo)\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 195, + 204 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "name": "T", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + } + }, + "kind": "generic" + }, + { + "id": { + "type": "Identifier", + "name": "U", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 205, + 235 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 205, + 215 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 215, + 216 + ], + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 216, + 223 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "name": "foo", + "range": [ + 218, + 221 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 5 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 218, + 221 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 5 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 224, + 235 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 42, + 49 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + } + }, + { + "type": "Identifier", + "value": "Foo", + "range": [ + 50, + 53 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 53, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + } + }, + { + "type": "Identifier", + "value": "U", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 75, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 11 + } + } + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 91, + 92 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 92, + 96 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 96, + 97 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 97, + 100 + ], + "loc": { + "start": { + "line": 8, + "column": 5 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 109 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 8, + "column": 17 + }, + "end": { + "line": 8, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 8, + "column": 18 + }, + "end": { + "line": 8, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 8, + "column": 19 + }, + "end": { + "line": 8, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 112, + 118 + ], + "loc": { + "start": { + "line": 8, + "column": 20 + }, + "end": { + "line": 8, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 118, + 119 + ], + "loc": { + "start": { + "line": 8, + "column": 26 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 119, + 124 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 124, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 129, + 148 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 9, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 153 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 153, + 154 + ], + "loc": { + "start": { + "line": 9, + "column": 34 + }, + "end": { + "line": 9, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 154, + 159 + ], + "loc": { + "start": { + "line": 9, + "column": 35 + }, + "end": { + "line": 9, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 9, + "column": 40 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 165 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 165, + 166 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 166, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 169, + 170 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 170, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 172, + 177 + ], + "loc": { + "start": { + "line": 10, + "column": 12 + }, + "end": { + "line": 10, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 10, + "column": 17 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 178, + 194 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 194, + 195 + ], + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 195, + 203 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 12, + "column": 8 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 205, + 214 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 214, + 215 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 215, + 216 + ], + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 216, + 218 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 218, + 221 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 5 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 221, + 223 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 224, + 234 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 234, + 235 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "value": " Comments", + "range": [ + 59, + 70 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 15 + } + } + } + ], + "errors": [] + } + ], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "value": "script" + }, + { + "type": "HTMLIdentifier", + "range": [ + 8, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "value": "setup" + }, + { + "type": "HTMLIdentifier", + "range": [ + 14, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "value": "lang" + }, + { + "type": "HTMLAssociation", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "value": "ts" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "column": 24, + "line": 1 + }, + "end": { + "column": 31, + "line": 1 + } + }, + "value": "generic" + }, + { + "type": "HTMLAssociation", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 42, + 49 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + } + }, + { + "type": "Identifier", + "value": "Foo", + "range": [ + 50, + 53 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 53, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + } + }, + { + "type": "Identifier", + "value": "U", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } + } + }, + { + "type": "Keyword", + "value": "extends", + "range": [ + 75, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 11 + } + } + }, + { + "type": "Identifier", + "value": "T", + "range": [ + 87, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 91, + 92 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 92, + 96 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 96, + 97 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 97, + 100 + ], + "loc": { + "start": { + "line": 8, + "column": 5 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 109 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 8, + "column": 17 + }, + "end": { + "line": 8, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 8, + "column": 18 + }, + "end": { + "line": 8, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 8, + "column": 19 + }, + "end": { + "line": 8, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 112, + 118 + ], + "loc": { + "start": { + "line": 8, + "column": 20 + }, + "end": { + "line": 8, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 118, + 119 + ], + "loc": { + "start": { + "line": 8, + "column": 26 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 119, + 124 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 124, + 125 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 9, + "column": 6 + }, + "end": { + "line": 9, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 127, + 128 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 129, + 148 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 9, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 153 + ], + "loc": { + "start": { + "line": 9, + "column": 30 + }, + "end": { + "line": 9, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 153, + 154 + ], + "loc": { + "start": { + "line": 9, + "column": 34 + }, + "end": { + "line": 9, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 154, + 159 + ], + "loc": { + "start": { + "line": 9, + "column": 35 + }, + "end": { + "line": 9, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 9, + "column": 40 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 165 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 165, + 166 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 166, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 169, + 170 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 170, + 171 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 172, + 177 + ], + "loc": { + "start": { + "line": 10, + "column": 12 + }, + "end": { + "line": 10, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 10, + "column": 17 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 178, + 194 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 194, + 195 + ], + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 195, + 203 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 12, + "column": 8 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 205, + 214 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 214, + 215 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 13, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 215, + 216 + ], + "loc": { + "start": { + "line": 13, + "column": 10 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 216, + 218 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 218, + 221 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 5 + } + } + }, + { + "type": "VExpressionEnd", + "range": [ + 221, + 223 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 224, + 234 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 234, + 235 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "value": " Comments", + "range": [ + 59, + 70 + ], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 15 + } + } + } + ], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/source.vue b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/source.vue new file mode 100644 index 00000000..7b4d167f --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/source.vue @@ -0,0 +1,15 @@ + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/token-ranges.json new file mode 100644 index 00000000..37ed0210 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/token-ranges.json @@ -0,0 +1,67 @@ +[ + "", + "\n", + "type", + " ", + "Foo", + " ", + "=", + " ", + "number", + " ", + "|", + " ", + "string", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{foo:T,", + " ", + "bar:", + " ", + "U}>()", + "\n", + "const", + " ", + "foo", + " ", + "=", + " ", + "p.foo", + "\n", + "console.log(foo)", + "\n", + "", + "\n", + "", + "\n", + "{{", + "foo", + "}}", + "\n", + "", + "// Comments" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/tree.json b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/tree.json new file mode 100644 index 00000000..7e5efdcf --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-4-with-spaces/tree.json @@ -0,0 +1,172 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/.eslintrc.js b/test/fixtures/integrations/script-setup-with-typescript-eslint/.eslintrc.js new file mode 100644 index 00000000..ef47614d --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/.eslintrc.js @@ -0,0 +1,14 @@ +"use strict"; + +module.exports = { + root: true, + parser: require.resolve("../../../../src/index.ts"), + parserOptions: { + ecmaVersion: 2020, + sourceType: "module", + parser: "@typescript-eslint/parser", + project: require.resolve("./tsconfig.test.json"), + extraFileExtensions: ['.vue'] + }, + plugins: ["@typescript-eslint"], +}; diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/.eslintrc.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/.eslintrc.json deleted file mode 100644 index 54de939a..00000000 --- a/test/fixtures/integrations/script-setup-with-typescript-eslint/.eslintrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "root": true, - "parser": "../../../../src/index.ts", - "parserOptions": { - "ecmaVersion": 2020, - "sourceType": "module", - "parser": "@typescript-eslint/parser" - }, - "plugins": ["@typescript-eslint"] -} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/invalid/generic.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/invalid/generic.vue new file mode 100644 index 00000000..f5752f73 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/invalid/generic.vue @@ -0,0 +1,11 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic-with-spaces.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic-with-spaces.vue new file mode 100644 index 00000000..8eecb84d --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic-with-spaces.vue @@ -0,0 +1,13 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic.vue new file mode 100644 index 00000000..fce7db53 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/no-undef/valid/generic.vue @@ -0,0 +1,10 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/output.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/output.json index 1a7e639e..af72fcf4 100644 --- a/test/fixtures/integrations/script-setup-with-typescript-eslint/output.json +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/output.json @@ -1,4 +1,14 @@ [ + { + "filePath": "/no-undef/invalid/generic.vue", + "messages": [ + { + "ruleId": "no-undef", + "line": 6, + "message": "'U' is not defined." + } + ] + }, { "filePath": "/no-undef/invalid/with-defaults.vue", "messages": [ @@ -13,5 +23,15 @@ "message": "'defineProps' is not defined." } ] + }, + { + "filePath": "/ts-no-unused-vars/invalid/generic.vue", + "messages": [ + { + "ruleId": "@typescript-eslint/no-unused-vars", + "line": 4, + "message": "'Baz' is defined but never used." + } + ] } ] diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/package.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/package.json index c158dd6f..f16b529e 100644 --- a/test/fixtures/integrations/script-setup-with-typescript-eslint/package.json +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/package.json @@ -1,7 +1,9 @@ { "devDependencies": { "eslint": "^8.8.0", - "@typescript-eslint/parser": "^5.10.2", - "@typescript-eslint/eslint-plugin": "^5.10.2" + "@typescript-eslint/parser": "^5.57.0", + "@typescript-eslint/eslint-plugin": "^5.57.0", + "vue": "^3.2.47", + "typescript": "^5.0.2" } } diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/.eslintrc.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/.eslintrc.json new file mode 100644 index 00000000..3b7392e3 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "@typescript-eslint/no-unsafe-assignment": "error" + } +} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic1.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic1.vue new file mode 100644 index 00000000..1f064003 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic1.vue @@ -0,0 +1,9 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic2.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic2.vue new file mode 100644 index 00000000..0937cd44 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic2.vue @@ -0,0 +1,9 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic3.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic3.vue new file mode 100644 index 00000000..d440fe0c --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unsafe-assignment/valid-generic3.vue @@ -0,0 +1,12 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/.eslintrc.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/.eslintrc.json new file mode 100644 index 00000000..7592b0b5 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "@typescript-eslint/no-unused-vars": "error" + } +} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/invalid/generic.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/invalid/generic.vue new file mode 100644 index 00000000..5449949b --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/invalid/generic.vue @@ -0,0 +1,11 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/valid/generic.vue b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/valid/generic.vue new file mode 100644 index 00000000..fce7db53 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/ts-no-unused-vars/valid/generic.vue @@ -0,0 +1,10 @@ + diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/tsconfig.test.json b/test/fixtures/integrations/script-setup-with-typescript-eslint/tsconfig.test.json new file mode 100644 index 00000000..eed31ea8 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/tsconfig.test.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "jsx": "preserve", + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "lib": ["ESNext", "DOM"], + "skipLibCheck": true, + "noEmit": true, + "checkJs": true, + "allowJs": true + }, + "include": ["./vue.d.ts", "**/*.ts", "**/*.vue"] +} diff --git a/test/fixtures/integrations/script-setup-with-typescript-eslint/vue.d.ts b/test/fixtures/integrations/script-setup-with-typescript-eslint/vue.d.ts new file mode 100644 index 00000000..be556739 --- /dev/null +++ b/test/fixtures/integrations/script-setup-with-typescript-eslint/vue.d.ts @@ -0,0 +1 @@ +/// \ No newline at end of file