diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 537f1533..00000000 --- a/.eslintignore +++ /dev/null @@ -1,10 +0,0 @@ -/.nyc_output -/.temp -/coverage -node_modules -/src/external -/src/html/util -/test/fixtures -/test/temp -/index.d.ts -/index.js diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 9a375797..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,878 +0,0 @@ -plugins: - - prettier -extends: - - plugin:node-dependencies/recommended - - plugin:jsonc/recommended-with-jsonc -globals: - root: off -parserOptions: - ecmaFeatures: - globalReturn: false - sourceType: module - ecmaVersion: 2020 - loggerFn: false - project: tsconfig.json -rules: - prettier/prettier: - - error - - tabWidth: 4 - semi: false - trailingComma: all - - usePrettierrc: false -overrides: - - files: "*.json" - rules: - prettier/prettier: - - error - - tabWidth: 2 - semi: false - trailingComma: all - - usePrettierrc: false - - files: "**/*.ts" - plugins: - - "@typescript-eslint" - - eslint-comments - - node - parser: "@typescript-eslint/parser" - rules: - prettier/prettier: - - error - - tabWidth: 4 - semi: false - trailingComma: all - parser: typescript - - usePrettierrc: false - "@typescript-eslint/consistent-type-imports": error - no-duplicate-imports: off - "@typescript-eslint/no-duplicate-imports": error - "@typescript-eslint/no-var-requires": off - node/no-unsupported-features/es-syntax: - - off - - ignores: - - modules - - dynamicImport - node/no-extraneous-import: - - error - node/file-extension-in-import: - - error - - always - - .js: never - .ts: never - .tsx: never - node/no-missing-import: - - error - node/no-unpublished-import: - - error - node/exports-style: - - error - - module.exports - node/no-callback-literal: - - off - node/no-deprecated-api: - - error - node/no-exports-assign: - - error - node/no-extraneous-require: - - error - node/no-missing-require: - - error - node/no-unpublished-bin: - - error - node/no-unpublished-require: - - error - node/no-unsupported-features/es-builtins: - - error - node/no-unsupported-features/node-builtins: - - error - node/prefer-global/buffer: - - error - node/prefer-global/console: - - error - node/prefer-global/process: - - error - node/prefer-global/text-decoder: - - off - node/prefer-global/text-encoder: - - off - node/prefer-global/url-search-params: - - off - node/prefer-global/url: - - off - node/prefer-promises/dns: - - off - node/prefer-promises/fs: - - off - node/process-exit-as-throw: - - error - node/shebang: - - error - "@typescript-eslint/adjacent-overload-signatures": - - error - "@typescript-eslint/array-type": - - error - "@typescript-eslint/await-thenable": - - error - "@typescript-eslint/ban-ts-comment": - - error - "@typescript-eslint/consistent-type-assertions": - - error - "@typescript-eslint/explicit-member-accessibility": - - error - "@typescript-eslint/no-array-constructor": - - error - "@typescript-eslint/no-empty-interface": - - error - "@typescript-eslint/no-extraneous-class": - - error - "@typescript-eslint/no-floating-promises": - - error - "@typescript-eslint/no-for-in-array": - - error - "@typescript-eslint/no-inferrable-types": - - error - "@typescript-eslint/no-misused-new": - - error - "@typescript-eslint/no-misused-promises": - - error - "@typescript-eslint/no-parameter-properties": - - error - "@typescript-eslint/no-require-imports": - - error - "@typescript-eslint/no-this-alias": - - error - - allowDestructuring: true - "@typescript-eslint/no-unnecessary-qualifier": - - error - "@typescript-eslint/no-unnecessary-type-arguments": - - error - "@typescript-eslint/no-unnecessary-type-assertion": - - error - "@typescript-eslint/prefer-function-type": - - off - "@typescript-eslint/prefer-includes": - - error - "@typescript-eslint/prefer-namespace-keyword": - - error - "@typescript-eslint/prefer-readonly": - - off - "@typescript-eslint/prefer-regexp-exec": - - error - "@typescript-eslint/prefer-string-starts-ends-with": - - error - "@typescript-eslint/restrict-plus-operands": - - error - "@typescript-eslint/require-array-sort-compare": - - error - "@typescript-eslint/triple-slash-reference": - - error - "@typescript-eslint/unbound-method": - - off - - ignoreStatic: true - "@typescript-eslint/unified-signatures": - - off - camelcase: - - off - no-empty-function: - - off - "@typescript-eslint/no-empty-function": - - error - no-useless-constructor: - - off - "@typescript-eslint/no-useless-constructor": - - error - require-await: - - off - "@typescript-eslint/require-await": - - error - func-style: - - off - - declaration - init-declarations: - - off - lines-between-class-members: - - off - no-dupe-class-members: - - off - no-invalid-this: - - off - no-loop-func: - - off - no-redeclare: - - off - - builtinGlobals: true - no-undef: - - off - - typeof: true - no-unused-vars: - - off - - args: all - argsIgnorePattern: "^_(?:[^_].*)?$" - caughtErrors: all - vars: all - varsIgnorePattern: "^_(?:[^_].*)?$" - no-use-before-define: - - off - - nofunc - one-var: - - off - - initialized: never - uninitialized: always - "@typescript-eslint/ban-types": - - off - "@typescript-eslint/brace-style": - - off - "@typescript-eslint/consistent-type-definitions": - - off - "@typescript-eslint/explicit-function-return-type": - - off - "@typescript-eslint/func-call-spacing": - - off - "@typescript-eslint/generic-type-naming": - - off - "@typescript-eslint/indent": - - off - "@typescript-eslint/member-delimiter-style": - - off - "@typescript-eslint/member-ordering": - - off - "@typescript-eslint/no-explicit-any": - - off - "@typescript-eslint/no-extra-parens": - - off - "@typescript-eslint/no-magic-numbers": - - off - "@typescript-eslint/no-namespace": - - off - "@typescript-eslint/no-non-null-assertion": - - off - "@typescript-eslint/no-type-alias": - - off - "@typescript-eslint/no-unnecessary-condition": - - off - "@typescript-eslint/no-unused-vars": - - off - "@typescript-eslint/no-use-before-define": - - off - "@typescript-eslint/prefer-for-of": - - off - "@typescript-eslint/promise-function-async": - - off - "@typescript-eslint/quotes": - - off - "@typescript-eslint/semi": - - off - "@typescript-eslint/strict-boolean-expressions": - - off - "@typescript-eslint/type-annotation-spacing": - - off - "@typescript-eslint/typedef": - - off - arrow-body-style: - - error - constructor-super: - - error - default-param-last: - - error - no-class-assign: - - error - no-const-assign: - - error - no-import-assign: - - error - no-new-symbol: - - error - no-template-curly-in-string: - - error - no-this-before-super: - - error - no-useless-computed-key: - - error - no-useless-rename: - - error - no-var: - - error - object-shorthand: - - error - - always - - avoidExplicitReturnArrows: true - prefer-arrow-callback: - - error - prefer-const: - - error - prefer-numeric-literals: - - error - prefer-rest-params: - - error - prefer-spread: - - error - prefer-template: - - error - require-unicode-regexp: - - error - require-yield: - - error - symbol-description: - - error - class-methods-use-this: - - warn - arrow-parens: - - off - arrow-spacing: - - off - generator-star-spacing: - - off - no-confusing-arrow: - - off - rest-spread-spacing: - - off - template-curly-spacing: - - off - yield-star-spacing: - - off - no-inner-declarations: - - off - - functions - no-restricted-imports: - - off - prefer-destructuring: - - off - sort-imports: - - off - accessor-pairs: - - error - - enforceForClassMembers: true - getWithoutSet: false - setWithoutGet: true - array-callback-return: - - error - consistent-return: - - error - curly: - - error - default-case: - - error - dot-notation: - - error - eqeqeq: - - error - - always - - "null": ignore - for-direction: - - error - getter-return: - - error - linebreak-style: - - error - - unix - max-statements-per-line: - - error - - max: 1 - multiline-comment-style: - - error - - separate-lines - new-cap: - - error - no-alert: - - error - no-array-constructor: - - error - no-async-promise-executor: - - error - no-caller: - - error - no-case-declarations: - - error - no-compare-neg-zero: - - error - no-cond-assign: - - error - no-constant-condition: - - error - no-control-regex: - - error - no-debugger: - - error - no-delete-var: - - error - no-div-regex: - - error - no-dupe-args: - - error - no-dupe-keys: - - error - no-duplicate-case: - - error - no-else-return: - - error - no-empty: - - error - no-empty-character-class: - - error - no-empty-pattern: - - error - no-eval: - - error - no-ex-assign: - - error - no-extend-native: - - error - no-extra-bind: - - error - no-extra-boolean-cast: - - error - no-extra-label: - - error - no-fallthrough: - - error - no-func-assign: - - error - no-global-assign: - - error - no-implicit-coercion: - - error - no-implicit-globals: - - error - no-implied-eval: - - error - no-invalid-regexp: - - error - no-irregular-whitespace: - - error - - skipComments: false - skipRegExps: false - skipStrings: false - skipTemplates: false - no-iterator: - - error - no-label-var: - - error - no-lone-blocks: - - error - no-lonely-if: - - error - no-misleading-character-class: - - error - no-mixed-operators: - - error - - groups: - - - - "&" - - "|" - - ^ - - "~" - - << - - ">>" - - ">>>" - - - - "&&" - - "||" - allowSamePrecedence: true - no-new: - - error - no-new-object: - - error - no-new-require: - - error - no-new-wrappers: - - error - no-obj-calls: - - error - no-octal: - - error - no-octal-escape: - - error - no-param-reassign: - - error - - props: false - no-process-env: - - error - no-process-exit: - - error - no-prototype-builtins: - - error - no-regex-spaces: - - error - no-restricted-properties: - - error - - property: __count__ - - property: __noSuchMethod__ - - property: __parent__ - - property: __defineGetter__ - - property: __defineSetter__ - - property: __lookupGetter__ - - property: __lookupSetter__ - no-return-assign: - - error - no-return-await: - - error - no-script-url: - - error - no-self-assign: - - error - - props: true - no-self-compare: - - error - no-sequences: - - error - "@typescript-eslint/no-shadow": - - error - - builtinGlobals: true - hoist: functions - no-shadow-restricted-names: - - error - no-sparse-arrays: - - error - no-tabs: - - error - no-throw-literal: - - error - no-unexpected-multiline: - - error - no-unmodified-loop-condition: - - error - no-unneeded-ternary: - - error - no-unreachable: - - error - no-unsafe-finally: - - error - no-unsafe-negation: - - error - - enforceForOrderingRelations: true - no-unused-expressions: - - error - no-unused-labels: - - error - no-useless-call: - - error - no-useless-catch: - - error - no-useless-concat: - - error - no-useless-escape: - - error - no-useless-return: - - error - no-void: - - error - no-with: - - error - padding-line-between-statements: - - error - - blankLine: always - next: "*" - prev: directive - - blankLine: always - next: function - prev: "*" - - blankLine: always - next: "*" - prev: function - prefer-promise-reject-errors: - - error - prefer-regex-literals: - - error - quotes: - - error - - double - - avoidEscape: true - radix: - - error - require-atomic-updates: - - error - spaced-comment: - - error - - always - - block: - balanced: true - markers: - - eslint - - eslint-env - - eslint-disable - - eslint-enable - - exported - - globals - - istanbul - line: - exceptions: - - "-" - - = - markers: - - eslint-disable-line - - eslint-disable-next-line - - istanbul - - "TODO:" - - "FIXME:" - strict: - - error - - global - use-isnan: - - error - - enforceForIndexOf: true - enforceForSwitchCase: true - valid-typeof: - - error - - requireStringLiterals: true - yoda: - - error - - never - - exceptRange: true - onlyEquality: false - complexity: - - warn - - max: 16 - max-nested-callbacks: - - warn - - max: 4 - max-params: - - warn - - max: 8 - no-console: - - warn - - allow: - - assert - - error - array-bracket-newline: - - off - array-bracket-spacing: - - off - array-element-newline: - - off - block-spacing: - - off - brace-style: - - off - comma-dangle: - - off - comma-spacing: - - off - comma-style: - - off - computed-property-spacing: - - off - dot-location: - - off - eol-last: - - off - func-call-spacing: - - off - function-call-argument-newline: - - off - function-paren-newline: - - off - implicit-arrow-linebreak: - - off - indent: - - off - jsx-quotes: - - off - key-spacing: - - off - keyword-spacing: - - off - multiline-ternary: - - off - new-parens: - - off - newline-per-chained-call: - - off - no-extra-parens: - - off - no-extra-semi: - - off - no-floating-decimal: - - off - no-mixed-spaces-and-tabs: - - off - no-multi-spaces: - - off - no-multiple-empty-lines: - - off - no-trailing-spaces: - - off - no-whitespace-before-property: - - off - nonblock-statement-body-position: - - off - object-curly-newline: - - off - object-curly-spacing: - - off - object-property-newline: - - off - one-var-declaration-per-line: - - off - operator-linebreak: - - off - padded-blocks: - - off - quote-props: - - off - semi: - - off - semi-spacing: - - off - semi-style: - - off - space-before-blocks: - - off - space-before-function-paren: - - off - space-in-parens: - - off - space-infix-ops: - - off - space-unary-ops: - - off - switch-colon-spacing: - - off - template-tag-spacing: - - off - unicode-bom: - - off - wrap-iife: - - off - wrap-regex: - - off - block-scoped-var: - - off - callback-return: - - off - capitalized-comments: - - off - consistent-this: - - off - func-name-matching: - - off - func-names: - - off - global-require: - - off - guard-for-in: - - off - handle-callback-err: - - off - id-blacklist: - - off - id-length: - - off - id-match: - - off - line-comment-position: - - off - lines-around-comment: - - off - max-classes-per-file: - - off - max-depth: - - off - max-len: - - off - max-lines: - - off - max-lines-per-function: - - off - max-statements: - - off - no-await-in-loop: - - off - no-bitwise: - - off - no-buffer-constructor: - - off - no-continue: - - off - no-eq-null: - - off - no-inline-comments: - - off - no-labels: - - off - no-magic-numbers: - - off - no-mixed-requires: - - off - no-multi-assign: - - off - no-multi-str: - - off - no-negated-condition: - - off - no-nested-ternary: - - off - no-new-func: - - off - no-path-concat: - - off - no-plusplus: - - off - no-proto: - - off - no-restricted-globals: - - off - no-restricted-modules: - - off - no-restricted-syntax: - - off - no-sync: - - off - no-ternary: - - off - no-undef-init: - - off - no-undefined: - - off - no-underscore-dangle: - - off - no-warning-comments: - - off - operator-assignment: - - off - prefer-named-capture-group: - - off - prefer-object-spread: - - off - sort-keys: - - off - sort-vars: - - off - vars-on-top: - - off - eslint-comments/disable-enable-pair: - - error - eslint-comments/no-aggregating-enable: - - error - eslint-comments/no-duplicate-disable: - - error - eslint-comments/no-restricted-disable: - - off - eslint-comments/no-unlimited-disable: - - error - eslint-comments/no-unused-disable: - - error - eslint-comments/no-unused-enable: - - error - eslint-comments/no-use: - - error - - allow: - - eslint-disable - - eslint-disable-line - - eslint-disable-next-line - - eslint-enable - - eslint-env - - globals - - files: "typings/**" - rules: - node/no-missing-import: - - error - - allowModules: - - estree - - files: package.json - rules: - "@mysticatea/prettier": off -settings: - node: - tryExtensions: - - .ts - - .js - - .json diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index f5d3f904..2c55f6c5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -29,7 +29,7 @@ body: - type: textarea id: eslint-plugin-vue-version attributes: - label: What version of `eslint-plugin-vue` and ` vue-eslint-parser` are you using? + label: What version of `eslint-plugin-vue` and `vue-eslint-parser` are you using? value: | - vue-eslint-parser@0.0.0 - eslint-plugin-vue@0.0.0 diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a4f21980..e1d1e9de 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,15 +13,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init - name: Install Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 'lts/*' - name: Install Packages - run: npm install && cd test/fixtures/eslint && npm install + run: npm install - name: Lint run: npm run -s lint @@ -29,70 +29,57 @@ jobs: name: Test strategy: matrix: - eslint: [7, 8] - node: [16, 17] + eslint: [9] + node: [18, 20, 21, 'lts/*'] os: [ubuntu-latest] include: # On other platforms - - eslint: 7 - node: 16 + - eslint: 9 + node: 'lts/*' os: windows-latest - - eslint: 7 - node: 16 + - eslint: 9 + node: 'lts/*' os: macos-latest - # On old Node.js versions - - eslint: 7 - node: 14 - os: ubuntu-latest - # On old ESLint versions - - eslint: 6 - node: 16 - os: ubuntu-latest - # On the minimum supported ESLint/Node.js version - - eslint: 6 - node: 14 - os: ubuntu-latest runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init - name: Install Node.js v${{ matrix.node }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - name: Install Packages - run: npm install --legacy-peer-deps + run: npm install -f - name: Install ESLint v${{ matrix.eslint }} run: node scripts/ci-install-eslint ${{ matrix.eslint }} - name: Build run: npm run -s build - name: Test run: npm run -s test:mocha + test-for-old-eslint: + name: Test + strategy: + matrix: + eslint: [8] + node: ['lts/*'] + os: [ubuntu-latest] - test-cov: - name: Test and Send Coverage - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout submodules run: git submodule update --init - - name: Install Node.js v16 - uses: actions/setup-node@v3 + - name: Install Node.js v${{ matrix.node }} + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: ${{ matrix.node }} - name: Install Packages - run: npm install - - name: Install ESLint v8 - run: node scripts/ci-install-eslint 8.12.0 - - name: Build - run: npm run -s build + run: npm install -f + - name: Install ESLint v${{ matrix.eslint }} + run: node scripts/ci-install-eslint ${{ matrix.eslint }} - name: Test - run: npm run -s test:cover - - name: Send Coverage - run: npm run -s codecov - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: npm run -s test:debug diff --git a/.gitmodules b/.gitmodules index 45ed6b45..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "test/fixtures/eslint"] - path = test/fixtures/eslint - url = https://github.com/eslint/eslint.git diff --git a/.vscode/settings.json b/.vscode/settings.json index 72446f43..7ff99747 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,12 @@ { - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vue", + "json", + "jsonc" + ] } diff --git a/README.md b/README.md index c0f76f2f..57e0668f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![npm version](https://img.shields.io/npm/v/vue-eslint-parser.svg)](https://www.npmjs.com/package/vue-eslint-parser) [![Downloads/month](https://img.shields.io/npm/dm/vue-eslint-parser.svg)](http://www.npmtrends.com/vue-eslint-parser) [![Build Status](https://github.com/vuejs/vue-eslint-parser/workflows/CI/badge.svg)](https://github.com/vuejs/vue-eslint-parser/actions) -[![Coverage Status](https://codecov.io/gh/vuejs/vue-eslint-parser/branch/master/graph/badge.svg)](https://codecov.io/gh/vuejs/vue-eslint-parser) The ESLint custom parser for `.vue` files. @@ -17,25 +16,21 @@ This parser allows us to lint the ` diff --git a/test/fixtures/ast/mustache-without-open-in-textarea/token-ranges.json b/test/fixtures/ast/mustache-without-open-in-textarea/token-ranges.json new file mode 100644 index 00000000..8d08b5f6 --- /dev/null +++ b/test/fixtures/ast/mustache-without-open-in-textarea/token-ranges.json @@ -0,0 +1,22 @@ +[ + "", + "\n ", + "{{", + "123", + "}}", + "\n ", + "", + " ", + "}}", + " ", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/mustache-without-open-in-textarea/tree.json b/test/fixtures/ast/mustache-without-open-in-textarea/tree.json new file mode 100644 index 00000000..7312fcac --- /dev/null +++ b/test/fixtures/ast/mustache-without-open-in-textarea/tree.json @@ -0,0 +1,65 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/mustache/ast.json b/test/fixtures/ast/mustache/ast.json index 590d2632..0b1fbe13 100644 --- a/test/fixtures/ast/mustache/ast.json +++ b/test/fixtures/ast/mustache/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/no-filters/ast.json b/test/fixtures/ast/no-filters/ast.json index adcb6056..2f1ed4af 100644 --- a/test/fixtures/ast/no-filters/ast.json +++ b/test/fixtures/ast/no-filters/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/not-closing-elements/ast.json b/test/fixtures/ast/not-closing-elements/ast.json index 0ebf4ca1..0c68b5cb 100644 --- a/test/fixtures/ast/not-closing-elements/ast.json +++ b/test/fixtures/ast/not-closing-elements/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/parser-option-multiple-parsers-1/ast.json b/test/fixtures/ast/parser-option-multiple-parsers-1/ast.json index e4419dca..1225bef4 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-1/ast.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-1/ast.json @@ -1,64 +1,58 @@ { "type": "Program", + "range": [ + 60, + 70 + ], "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "a", - "range": [ - 60, - 61 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - } - }, "arguments": [ { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 67, 68 ], "loc": { - "start": { - "line": 5, - "column": 9 - }, "end": { "line": 5, "column": 10 + }, + "start": { + "line": 5, + "column": 9 } } } ], - "optional": false, - "range": [ - 60, - 69 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 11 + "callee": { + "type": "Identifier", + "decorators": [], + "name": "a", + "optional": false, + "range": [ + 60, + 61 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } } }, - "typeParameters": { + "optional": false, + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 61, @@ -72,19 +66,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "b", + "optional": false, "range": [ 62, 63 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 4 } } }, @@ -93,13 +89,13 @@ 63 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 4 } } }, @@ -107,19 +103,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "c", + "optional": false, "range": [ 64, 65 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -128,13 +126,13 @@ 65 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } } @@ -144,27 +142,41 @@ 65 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 4 } } } ], "loc": { - "start": { - "line": 5, - "column": 3 - }, "end": { "line": 5, "column": 8 + }, + "start": { + "line": 5, + "column": 3 } } + }, + "range": [ + 60, + 69 + ], + "loc": { + "end": { + "line": 5, + "column": 11 + }, + "start": { + "line": 5, + "column": 2 + } } }, "range": [ @@ -172,32 +184,19 @@ 69 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 11 + }, + "start": { + "line": 5, + "column": 2 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 60, - 70 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 6, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -219,165 +218,165 @@ }, { "type": "Identifier", - "value": "a", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, "range": [ 60, 61 ], + "value": "a" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 2 + "column": 4 }, - "end": { + "start": { "line": 5, "column": 3 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 61, 62 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 3 + "column": 5 }, - "end": { + "start": { "line": 5, "column": 4 } - } - }, - { - "type": "Identifier", - "value": "b", + }, "range": [ 62, 63 ], + "value": "b" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 5, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 63, 64 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 5, "column": 6 } - } - }, - { - "type": "Identifier", - "value": "c", + }, "range": [ 64, 65 ], + "value": "c" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 6 + "column": 8 }, - "end": { + "start": { "line": 5, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 65, 66 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 7 + "column": 9 }, - "end": { + "start": { "line": 5, "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 66, 67 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 8 + "column": 10 }, - "end": { + "start": { "line": 5, "column": 9 } - } - }, - { - "type": "Identifier", - "value": "d", + }, "range": [ 67, 68 ], + "value": "d" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 9 + "column": 11 }, - "end": { + "start": { "line": 5, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 68, 69 ], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 11 - } - } + "value": ")" }, { "type": "Punctuator", @@ -398,7 +397,16 @@ "value": "" } ], - "comments": [], + "loc": { + "end": { + "line": 6, + "column": 0 + }, + "start": { + "line": 5, + "column": 2 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -474,60 +482,50 @@ }, "expression": { "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "a", - "range": [ - 15, - 16 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 5 - } - } - }, "arguments": [ { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 22, 23 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 12 + }, + "start": { + "line": 2, + "column": 11 } } } ], - "optional": false, - "range": [ - 15, - 24 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 13 + "callee": { + "type": "Identifier", + "decorators": [], + "name": "a", + "optional": false, + "range": [ + 15, + 16 + ], + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 4 + } } }, - "typeParameters": { + "optional": false, + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 16, @@ -541,19 +539,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "b", + "optional": false, "range": [ 17, 18 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 7 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -562,13 +562,13 @@ 18 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 7 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -576,19 +576,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "c", + "optional": false, "range": [ 19, 20 ], "loc": { - "start": { - "line": 2, - "column": 8 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } }, @@ -597,13 +599,13 @@ 20 ], "loc": { - "start": { - "line": 2, - "column": 8 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } } @@ -613,46 +615,62 @@ 20 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 6 } } } ], "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 10 + }, + "start": { + "line": 2, + "column": 5 } } + }, + "range": [ + 15, + 24 + ], + "loc": { + "end": { + "line": 2, + "column": 13 + }, + "start": { + "line": 2, + "column": 4 + } } }, "references": [ { "id": { "type": "Identifier", + "decorators": [], "name": "a", + "optional": false, "range": [ 15, 16 ], "loc": { - "start": { - "line": 2, - "column": 4 - }, "end": { "line": 2, "column": 5 + }, + "start": { + "line": 2, + "column": 4 } } }, @@ -663,19 +681,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 22, 23 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 12 + }, + "start": { + "line": 2, + "column": 11 } } }, @@ -686,19 +706,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "b", + "optional": false, "range": [ 17, 18 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 7 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -709,19 +731,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "c", + "optional": false, "range": [ 19, 20 ], "loc": { - "start": { - "line": 2, - "column": 8 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } }, @@ -843,165 +867,165 @@ }, { "type": "Identifier", - "value": "a", + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 4 + } + }, "range": [ 15, 16 ], + "value": "a" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 2, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 16, 17 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 2, "column": 6 } - } - }, - { - "type": "Identifier", - "value": "b", + }, "range": [ 17, 18 ], + "value": "b" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 6 + "column": 8 }, - "end": { + "start": { "line": 2, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 18, 19 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 7 + "column": 9 }, - "end": { + "start": { "line": 2, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "c", + }, "range": [ 19, 20 ], + "value": "c" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 8 + "column": 10 }, - "end": { + "start": { "line": 2, "column": 9 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 20, 21 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 9 + "column": 11 }, - "end": { + "start": { "line": 2, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 21, 22 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 10 + "column": 12 }, - "end": { + "start": { "line": 2, "column": 11 } - } - }, - { - "type": "Identifier", - "value": "d", + }, "range": [ 22, 23 ], + "value": "d" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 11 + "column": 13 }, - "end": { + "start": { "line": 2, "column": 12 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 23, 24 ], - "loc": { - "start": { - "line": 2, - "column": 12 - }, - "end": { - "line": 2, - "column": 13 - } - } + "value": ")" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/ast/parser-option-multiple-parsers-1/services.json b/test/fixtures/ast/parser-option-multiple-parsers-1/services.json index 7159ba5a..7f661a33 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-1/services.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-1/services.json @@ -2,10 +2,12 @@ "defineCustomBlocksVisitor", "defineDocumentVisitor", "defineTemplateBodyVisitor", + "emitDecoratorMetadata", "esTreeNodeToTSNodeMap", + "experimentalDecorators", "getDocumentFragment", "getTemplateBodyTokenStore", - "hasFullTypeInformation", + "isolatedDeclarations", "program", "tsNodeToESTreeNodeMap" ] \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-3/ast.json b/test/fixtures/ast/parser-option-multiple-parsers-3/ast.json index b3dadbb8..83f26de3 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-3/ast.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-3/ast.json @@ -1,64 +1,58 @@ { "type": "Program", + "range": [ + 60, + 70 + ], "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "a", - "range": [ - 60, - 61 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - } - }, "arguments": [ { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 67, 68 ], "loc": { - "start": { - "line": 5, - "column": 9 - }, "end": { "line": 5, "column": 10 + }, + "start": { + "line": 5, + "column": 9 } } } ], - "optional": false, - "range": [ - 60, - 69 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 11 + "callee": { + "type": "Identifier", + "decorators": [], + "name": "a", + "optional": false, + "range": [ + 60, + 61 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } } }, - "typeParameters": { + "optional": false, + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 61, @@ -72,19 +66,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "b", + "optional": false, "range": [ 62, 63 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 4 } } }, @@ -93,13 +89,13 @@ 63 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 4 } } }, @@ -107,19 +103,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "c", + "optional": false, "range": [ 64, 65 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -128,13 +126,13 @@ 65 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } } @@ -144,27 +142,41 @@ 65 ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 4 } } } ], "loc": { - "start": { - "line": 5, - "column": 3 - }, "end": { "line": 5, "column": 8 + }, + "start": { + "line": 5, + "column": 3 } } + }, + "range": [ + 60, + 69 + ], + "loc": { + "end": { + "line": 5, + "column": 11 + }, + "start": { + "line": 5, + "column": 2 + } } }, "range": [ @@ -172,32 +184,19 @@ 69 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 11 + }, + "start": { + "line": 5, + "column": 2 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 60, - 70 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 6, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -219,165 +218,165 @@ }, { "type": "Identifier", - "value": "a", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, "range": [ 60, 61 ], + "value": "a" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 2 + "column": 4 }, - "end": { + "start": { "line": 5, "column": 3 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 61, 62 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 3 + "column": 5 }, - "end": { + "start": { "line": 5, "column": 4 } - } - }, - { - "type": "Identifier", - "value": "b", + }, "range": [ 62, 63 ], + "value": "b" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 5, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 63, 64 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 5, "column": 6 } - } - }, - { - "type": "Identifier", - "value": "c", + }, "range": [ 64, 65 ], + "value": "c" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 6 + "column": 8 }, - "end": { + "start": { "line": 5, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 65, 66 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 7 + "column": 9 }, - "end": { + "start": { "line": 5, "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 66, 67 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 8 + "column": 10 }, - "end": { + "start": { "line": 5, "column": 9 } - } - }, - { - "type": "Identifier", - "value": "d", + }, "range": [ 67, 68 ], + "value": "d" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 9 + "column": 11 }, - "end": { + "start": { "line": 5, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 68, 69 ], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 11 - } - } + "value": ")" }, { "type": "Punctuator", @@ -398,7 +397,16 @@ "value": "" } ], - "comments": [], + "loc": { + "end": { + "line": 6, + "column": 0 + }, + "start": { + "line": 5, + "column": 2 + } + }, "templateBody": { "type": "VElement", "range": [ diff --git a/test/fixtures/ast/parser-option-multiple-parsers-3/services.json b/test/fixtures/ast/parser-option-multiple-parsers-3/services.json index 7159ba5a..7f661a33 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-3/services.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-3/services.json @@ -2,10 +2,12 @@ "defineCustomBlocksVisitor", "defineDocumentVisitor", "defineTemplateBodyVisitor", + "emitDecoratorMetadata", "esTreeNodeToTSNodeMap", + "experimentalDecorators", "getDocumentFragment", "getTemplateBodyTokenStore", - "hasFullTypeInformation", + "isolatedDeclarations", "program", "tsNodeToESTreeNodeMap" ] \ No newline at end of file diff --git a/test/fixtures/ast/parser-option-multiple-parsers-without-script/ast.json b/test/fixtures/ast/parser-option-multiple-parsers-without-script/ast.json index 8ad44185..bfb9997e 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-without-script/ast.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-without-script/ast.json @@ -1,23 +1,23 @@ { "type": "Program", - "body": [], - "sourceType": "module", "range": [ 0, 0 ], + "body": [], + "comments": [], + "sourceType": "module", + "tokens": [], "loc": { - "start": { - "line": 1, - "column": 0 - }, "end": { - "line": 1, - "column": 0 + "column": 0, + "line": 1 + }, + "start": { + "column": 0, + "line": 1 } }, - "tokens": [], - "comments": [], "templateBody": { "type": "VElement", "range": [ @@ -93,60 +93,50 @@ }, "expression": { "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "a", - "range": [ - 15, - 16 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 5 - } - } - }, "arguments": [ { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 22, 23 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 12 + }, + "start": { + "line": 2, + "column": 11 } } } ], - "optional": false, - "range": [ - 15, - 24 - ], - "loc": { - "start": { - "line": 2, - "column": 4 - }, - "end": { - "line": 2, - "column": 13 + "callee": { + "type": "Identifier", + "decorators": [], + "name": "a", + "optional": false, + "range": [ + 15, + 16 + ], + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 4 + } } }, - "typeParameters": { + "optional": false, + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 16, @@ -160,19 +150,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "b", + "optional": false, "range": [ 17, 18 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 7 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -181,13 +173,13 @@ 18 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 7 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -195,19 +187,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "c", + "optional": false, "range": [ 19, 20 ], "loc": { - "start": { - "line": 2, - "column": 8 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } }, @@ -216,13 +210,13 @@ 20 ], "loc": { - "start": { - "line": 2, - "column": 8 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } } @@ -232,46 +226,62 @@ 20 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 6 } } } ], "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 10 + }, + "start": { + "line": 2, + "column": 5 } } + }, + "range": [ + 15, + 24 + ], + "loc": { + "end": { + "line": 2, + "column": 13 + }, + "start": { + "line": 2, + "column": 4 + } } }, "references": [ { "id": { "type": "Identifier", + "decorators": [], "name": "a", + "optional": false, "range": [ 15, 16 ], "loc": { - "start": { - "line": 2, - "column": 4 - }, "end": { "line": 2, "column": 5 + }, + "start": { + "line": 2, + "column": 4 } } }, @@ -282,19 +292,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "d", + "optional": false, "range": [ 22, 23 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 12 + }, + "start": { + "line": 2, + "column": 11 } } }, @@ -305,19 +317,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "b", + "optional": false, "range": [ 17, 18 ], "loc": { - "start": { - "line": 2, - "column": 6 - }, "end": { "line": 2, "column": 7 + }, + "start": { + "line": 2, + "column": 6 } } }, @@ -328,19 +342,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "c", + "optional": false, "range": [ 19, 20 ], "loc": { - "start": { - "line": 2, - "column": 8 - }, "end": { "line": 2, "column": 9 + }, + "start": { + "line": 2, + "column": 8 } } }, @@ -462,165 +478,165 @@ }, { "type": "Identifier", - "value": "a", + "loc": { + "end": { + "line": 2, + "column": 5 + }, + "start": { + "line": 2, + "column": 4 + } + }, "range": [ 15, 16 ], + "value": "a" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 4 + "column": 6 }, - "end": { + "start": { "line": 2, "column": 5 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 16, 17 ], + "value": "<" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 5 + "column": 7 }, - "end": { + "start": { "line": 2, "column": 6 } - } - }, - { - "type": "Identifier", - "value": "b", + }, "range": [ 17, 18 ], + "value": "b" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 6 + "column": 8 }, - "end": { + "start": { "line": 2, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 18, 19 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 7 + "column": 9 }, - "end": { + "start": { "line": 2, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "c", + }, "range": [ 19, 20 ], + "value": "c" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 8 + "column": 10 }, - "end": { + "start": { "line": 2, "column": 9 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 20, 21 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 9 + "column": 11 }, - "end": { + "start": { "line": 2, "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 21, 22 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 10 + "column": 12 }, - "end": { + "start": { "line": 2, "column": 11 } - } - }, - { - "type": "Identifier", - "value": "d", + }, "range": [ 22, 23 ], + "value": "d" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 11 + "column": 13 }, - "end": { + "start": { "line": 2, "column": 12 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 23, 24 ], - "loc": { - "start": { - "line": 2, - "column": 12 - }, - "end": { - "line": 2, - "column": 13 - } - } + "value": ")" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/ast/parser-option-multiple-parsers-without-script/services.json b/test/fixtures/ast/parser-option-multiple-parsers-without-script/services.json index 7159ba5a..7f661a33 100644 --- a/test/fixtures/ast/parser-option-multiple-parsers-without-script/services.json +++ b/test/fixtures/ast/parser-option-multiple-parsers-without-script/services.json @@ -2,10 +2,12 @@ "defineCustomBlocksVisitor", "defineDocumentVisitor", "defineTemplateBodyVisitor", + "emitDecoratorMetadata", "esTreeNodeToTSNodeMap", + "experimentalDecorators", "getDocumentFragment", "getTemplateBodyTokenStore", - "hasFullTypeInformation", + "isolatedDeclarations", "program", "tsNodeToESTreeNodeMap" ] \ No newline at end of file diff --git a/test/fixtures/ast/pug/ast.json b/test/fixtures/ast/pug/ast.json index 0905cb4d..a10daf83 100644 --- a/test/fixtures/ast/pug/ast.json +++ b/test/fixtures/ast/pug/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [] } \ No newline at end of file diff --git a/test/fixtures/ast/raw-names/ast.json b/test/fixtures/ast/raw-names/ast.json index de79e673..c8a2e087 100644 --- a/test/fixtures/ast/raw-names/ast.json +++ b/test/fixtures/ast/raw-names/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/rawtext/ast.json b/test/fixtures/ast/rawtext/ast.json index 290dd4ec..d0eea386 100644 --- a/test/fixtures/ast/rawtext/ast.json +++ b/test/fixtures/ast/rawtext/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/script-setup-example01/ast.json b/test/fixtures/ast/script-setup-example01/ast.json index e4d8d462..d9adadbf 100644 --- a/test/fixtures/ast/script-setup-example01/ast.json +++ b/test/fixtures/ast/script-setup-example01/ast.json @@ -96,7 +96,8 @@ ], "value": "./Foo.vue", "raw": "'./Foo.vue'" - } + }, + "attributes": [] }, { "type": "ImportDeclaration", @@ -197,7 +198,8 @@ ], "value": "vue", "raw": "'vue'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/script-setup-example05/ast.json b/test/fixtures/ast/script-setup-example05/ast.json index d179c1df..a187f101 100644 --- a/test/fixtures/ast/script-setup-example05/ast.json +++ b/test/fixtures/ast/script-setup-example05/ast.json @@ -96,7 +96,8 @@ ], "value": "./Foo.vue", "raw": "'./Foo.vue'" - } + }, + "attributes": [] }, { "type": "ImportDeclaration", @@ -177,7 +178,8 @@ ], "value": "./MyComponent.vue", "raw": "'./MyComponent.vue'" - } + }, + "attributes": [] } ], "sourceType": "module", diff --git a/test/fixtures/ast/script-setup-example06/ast.json b/test/fixtures/ast/script-setup-example06/ast.json index 9b8daba2..e07644fb 100644 --- a/test/fixtures/ast/script-setup-example06/ast.json +++ b/test/fixtures/ast/script-setup-example06/ast.json @@ -96,7 +96,8 @@ ], "value": "./Foo.vue", "raw": "'./Foo.vue'" - } + }, + "attributes": [] }, { "type": "ImportDeclaration", @@ -177,7 +178,8 @@ ], "value": "./Bar.vue", "raw": "'./Bar.vue'" - } + }, + "attributes": [] } ], "sourceType": "module", diff --git a/test/fixtures/ast/script-setup-example07/ast.json b/test/fixtures/ast/script-setup-example07/ast.json index 46ad7ed6..1f16bdb6 100644 --- a/test/fixtures/ast/script-setup-example07/ast.json +++ b/test/fixtures/ast/script-setup-example07/ast.json @@ -116,7 +116,8 @@ ], "value": "v-click-outside", "raw": "'v-click-outside'" - } + }, + "attributes": [] } ], "sourceType": "module", diff --git a/test/fixtures/ast/script-setup-example09/ast.json b/test/fixtures/ast/script-setup-example09/ast.json index 8cc45989..02ac7838 100644 --- a/test/fixtures/ast/script-setup-example09/ast.json +++ b/test/fixtures/ast/script-setup-example09/ast.json @@ -175,7 +175,8 @@ ], "value": "vue", "raw": "'vue'" - } + }, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/script-setup-example13/ast.json b/test/fixtures/ast/script-setup-example13/ast.json index 6a67da3b..8e2d4fe6 100644 --- a/test/fixtures/ast/script-setup-example13/ast.json +++ b/test/fixtures/ast/script-setup-example13/ast.json @@ -340,7 +340,6 @@ ], "name": "a" }, - "kind": "init", "value": { "type": "Identifier", "start": 62, @@ -360,7 +359,8 @@ 63 ], "name": "a" - } + }, + "kind": "init" }, { "type": "Property", @@ -403,7 +403,6 @@ ], "name": "b" }, - "kind": "init", "value": { "type": "Identifier", "start": 67, @@ -423,7 +422,8 @@ 68 ], "name": "b" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/script-setup-example14/ast.json b/test/fixtures/ast/script-setup-example14/ast.json index 03765608..288e20da 100644 --- a/test/fixtures/ast/script-setup-example14/ast.json +++ b/test/fixtures/ast/script-setup-example14/ast.json @@ -178,7 +178,8 @@ "kind": "const" }, "specifiers": [], - "source": null + "source": null, + "attributes": [] }, { "type": "VariableDeclaration", diff --git a/test/fixtures/ast/script-setup-with-export/ast.json b/test/fixtures/ast/script-setup-with-export/ast.json index 932e9dd3..f97586b0 100644 --- a/test/fixtures/ast/script-setup-with-export/ast.json +++ b/test/fixtures/ast/script-setup-with-export/ast.json @@ -118,7 +118,8 @@ "kind": "let" }, "specifiers": [], - "source": null + "source": null, + "attributes": [] } ], "sourceType": "module", diff --git a/test/fixtures/ast/self-closing-elements/ast.json b/test/fixtures/ast/self-closing-elements/ast.json index ff1cbfb7..68aecb41 100644 --- a/test/fixtures/ast/self-closing-elements/ast.json +++ b/test/fixtures/ast/self-closing-elements/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/slot-scope-default/ast.json b/test/fixtures/ast/slot-scope-default/ast.json index cb985254..1dadf2d4 100644 --- a/test/fixtures/ast/slot-scope-default/ast.json +++ b/test/fixtures/ast/slot-scope-default/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/slot-scope-destructuring/ast.json b/test/fixtures/ast/slot-scope-destructuring/ast.json index b7360160..9ef5942d 100644 --- a/test/fixtures/ast/slot-scope-destructuring/ast.json +++ b/test/fixtures/ast/slot-scope-destructuring/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -319,7 +319,6 @@ ], "name": "a" }, - "kind": "init", "value": { "type": "Identifier", "start": 58, @@ -339,7 +338,8 @@ 59 ], "name": "a" - } + }, + "kind": "init" }, { "type": "Property", @@ -382,7 +382,6 @@ ], "name": "b" }, - "kind": "init", "value": { "type": "Identifier", "start": 61, @@ -402,7 +401,8 @@ 62 ], "name": "b" - } + }, + "kind": "init" }, { "type": "RestElement", diff --git a/test/fixtures/ast/slot-scope-multi-parameters/ast.json b/test/fixtures/ast/slot-scope-multi-parameters/ast.json index 4fe53628..a34a8fca 100644 --- a/test/fixtures/ast/slot-scope-multi-parameters/ast.json +++ b/test/fixtures/ast/slot-scope-multi-parameters/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/slot-scope-rest-parameter/ast.json b/test/fixtures/ast/slot-scope-rest-parameter/ast.json index 9a9e0e0e..9a2ed552 100644 --- a/test/fixtures/ast/slot-scope-rest-parameter/ast.json +++ b/test/fixtures/ast/slot-scope-rest-parameter/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/slot-scope/ast.json b/test/fixtures/ast/slot-scope/ast.json index c888fc67..ecf8d2f1 100644 --- a/test/fixtures/ast/slot-scope/ast.json +++ b/test/fixtures/ast/slot-scope/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/svg-attrs-camel-case/ast.json b/test/fixtures/ast/svg-attrs-camel-case/ast.json index 1e3a6aa0..3a3a3927 100644 --- a/test/fixtures/ast/svg-attrs-camel-case/ast.json +++ b/test/fixtures/ast/svg-attrs-camel-case/ast.json @@ -138,7 +138,7 @@ } } ], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [ { diff --git a/test/fixtures/ast/svg-attrs-colon/ast.json b/test/fixtures/ast/svg-attrs-colon/ast.json index b5a4c622..46367cd4 100644 --- a/test/fixtures/ast/svg-attrs-colon/ast.json +++ b/test/fixtures/ast/svg-attrs-colon/ast.json @@ -138,7 +138,7 @@ } } ], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [ { diff --git a/test/fixtures/ast/svg-namespace/ast.json b/test/fixtures/ast/svg-namespace/ast.json index 68f9c796..ce6d4e1b 100644 --- a/test/fixtures/ast/svg-namespace/ast.json +++ b/test/fixtures/ast/svg-namespace/ast.json @@ -138,7 +138,7 @@ } } ], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [ { diff --git a/test/fixtures/ast/svg-upper/ast.json b/test/fixtures/ast/svg-upper/ast.json index 24ac6fb7..26e58850 100644 --- a/test/fixtures/ast/svg-upper/ast.json +++ b/test/fixtures/ast/svg-upper/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/table/ast.json b/test/fixtures/ast/table/ast.json index 5baa64c5..f0488a41 100644 --- a/test/fixtures/ast/table/ast.json +++ b/test/fixtures/ast/table/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/text-and-expression-container/ast.json b/test/fixtures/ast/text-and-expression-container/ast.json index 3983af11..233bcc06 100644 --- a/test/fixtures/ast/text-and-expression-container/ast.json +++ b/test/fixtures/ast/text-and-expression-container/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/text/ast.json b/test/fixtures/ast/text/ast.json index ffb6c8b5..d529f26e 100644 --- a/test/fixtures/ast/text/ast.json +++ b/test/fixtures/ast/text/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/textarea/ast.json b/test/fixtures/ast/textarea/ast.json index 8e1cd026..793c9979 100644 --- a/test/fixtures/ast/textarea/ast.json +++ b/test/fixtures/ast/textarea/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/ts-script-setup-with-use-global-var/ast.json b/test/fixtures/ast/ts-script-setup-with-use-global-var/ast.json index 6d83d037..5f70958e 100644 --- a/test/fixtures/ast/ts-script-setup-with-use-global-var/ast.json +++ b/test/fixtures/ast/ts-script-setup-with-use-global-var/ast.json @@ -1,21 +1,12 @@ { "type": "Program", - "body": [], - "sourceType": "module", "range": [ 116, 116 ], - "loc": { - "start": { - "line": 8, - "column": 0 - }, - "end": { - "line": 8, - "column": 0 - } - }, + "body": [], + "comments": [], + "sourceType": "module", "tokens": [ { "type": "Punctuator", @@ -54,7 +45,16 @@ "value": "" } ], - "comments": [], + "loc": { + "end": { + "line": 8, + "column": 0 + }, + "start": { + "line": 8, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -187,120 +187,68 @@ }, "expression": { "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "JSON", - "range": [ - 32, - 36 - ], - "loc": { - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 15 - } - } - }, - "property": { - "type": "Identifier", - "name": "stringify", - "range": [ - 37, - 46 - ], - "loc": { - "start": { - "line": 3, - "column": 16 - }, - "end": { - "line": 3, - "column": 25 - } - } - }, - "computed": false, - "optional": false, - "range": [ - 32, - 46 - ], - "loc": { - "start": { - "line": 3, - "column": 11 - }, - "end": { - "line": 3, - "column": 25 - } - } - }, "arguments": [ { "type": "ObjectExpression", "properties": [ { "type": "Property", + "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "test", + "optional": false, "range": [ 49, 53 ], "loc": { - "start": { - "line": 3, - "column": 28 - }, "end": { "line": 3, "column": 32 + }, + "start": { + "line": 3, + "column": 28 } } }, + "kind": "init", + "method": false, + "optional": false, + "shorthand": false, "value": { "type": "Literal", - "value": "test", "raw": "'test'", + "value": "test", "range": [ 55, 61 ], "loc": { - "start": { - "line": 3, - "column": 34 - }, "end": { "line": 3, "column": 40 + }, + "start": { + "line": 3, + "column": 34 } } }, - "computed": false, - "method": false, - "shorthand": false, - "kind": "init", "range": [ 49, 61 ], "loc": { - "start": { - "line": 3, - "column": 28 - }, "end": { "line": 3, "column": 40 + }, + "start": { + "line": 3, + "column": 28 } } } @@ -310,30 +258,89 @@ 62 ], "loc": { + "end": { + "line": 3, + "column": 41 + }, "start": { "line": 3, "column": 26 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "JSON", + "optional": false, + "range": [ + 32, + 36 + ], + "loc": { + "end": { + "line": 3, + "column": 15 }, + "start": { + "line": 3, + "column": 11 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "stringify", + "optional": false, + "range": [ + 37, + 46 + ], + "loc": { "end": { "line": 3, - "column": 41 + "column": 25 + }, + "start": { + "line": 3, + "column": 16 } } + }, + "range": [ + 32, + 46 + ], + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 11 + } } - ], + }, "optional": false, "range": [ 32, 63 ], "loc": { - "start": { - "line": 3, - "column": 11 - }, "end": { "line": 3, "column": 42 + }, + "start": { + "line": 3, + "column": 11 } } }, @@ -341,19 +348,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "JSON", + "optional": false, "range": [ 32, 36 ], "loc": { - "start": { - "line": 3, - "column": 11 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 3, + "column": 11 } } }, @@ -567,183 +576,183 @@ }, { "type": "Identifier", - "value": "JSON", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 11 + } + }, "range": [ 32, 36 ], + "value": "JSON" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 11 + "column": 16 }, - "end": { + "start": { "line": 3, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 36, 37 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 15 + "column": 25 }, - "end": { + "start": { "line": 3, "column": 16 } - } - }, - { - "type": "Identifier", - "value": "stringify", + }, "range": [ 37, 46 ], + "value": "stringify" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 16 + "column": 26 }, - "end": { + "start": { "line": 3, "column": 25 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 46, 47 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 25 + "column": 27 }, - "end": { + "start": { "line": 3, "column": 26 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 47, 48 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 26 + "column": 32 }, - "end": { + "start": { "line": 3, - "column": 27 + "column": 28 } - } - }, - { - "type": "Identifier", - "value": "test", + }, "range": [ 49, 53 ], + "value": "test" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 28 + "column": 33 }, - "end": { + "start": { "line": 3, "column": 32 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 53, 54 ], + "value": ":" + }, + { + "type": "String", "loc": { - "start": { + "end": { "line": 3, - "column": 32 + "column": 40 }, - "end": { + "start": { "line": 3, - "column": 33 + "column": 34 } - } - }, - { - "type": "String", - "value": "'test'", + }, "range": [ 55, 61 ], + "value": "'test'" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 34 + "column": 41 }, - "end": { + "start": { "line": 3, "column": 40 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 61, 62 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 40 + "column": 42 }, - "end": { + "start": { "line": 3, "column": 41 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 62, 63 ], - "loc": { - "start": { - "line": 3, - "column": 41 - }, - "end": { - "line": 3, - "column": 42 - } - } + "value": ")" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/ast/ts-script-setup-with-use-global-var/scope.json b/test/fixtures/ast/ts-script-setup-with-use-global-var/scope.json index d82fa33c..3849ae94 100644 --- a/test/fixtures/ast/ts-script-setup-with-use-global-var/scope.json +++ b/test/fixtures/ast/ts-script-setup-with-use-global-var/scope.json @@ -1,6 +1,210 @@ { "type": "global", "variables": [ + { + "name": "Intl", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SymbolConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Function", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Disposable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposable", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SuppressedError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SuppressedErrorConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DisposableStack", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DisposableStackConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposableStack", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncDisposableStackConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncIteratorObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySetLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Set", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReadonlySet", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Iterator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "IteratorObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float16Array", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Float16ArrayConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Math", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MapConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ObjectConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseWithResolvers", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RegExp", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Atomics", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBuffer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SharedArrayBufferConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "String", + "identifiers": [], + "defs": [], + "references": [] + }, { "name": "ClassMemberDecoratorContext", "identifiers": [], @@ -13,6 +217,18 @@ "defs": [], "references": [] }, + { + "name": "DecoratorMetadataObject", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DecoratorMetadata", + "identifiers": [], + "defs": [], + "references": [] + }, { "name": "ClassDecoratorContext", "identifiers": [], @@ -62,469 +278,499 @@ "references": [] }, { - "name": "ClassDecorator", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "name": "RegExpConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "FlatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGenerator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunction", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "AsyncGeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DateConstructor", "identifiers": [], "defs": [], "references": [] @@ -536,343 +782,373 @@ "references": [] }, { - "name": "ArrayBufferLike", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "ImportAttributes", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "EvalError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RangeError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "ReferenceError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "SyntaxError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "TypeError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "URIError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "ConcatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "TypedPropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "PromiseConstructorLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "Awaited", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "ArrayLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "Partial", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Required", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "Readonly", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "Pick", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "Record", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "Exclude", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "Extract", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "Omit", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "NonNullable", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "Parameters", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ConstructorParameters", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "ReturnType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "InstanceType", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "Uppercase", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Lowercase", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "Capitalize", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "Uncapitalize", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "NoInfer", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "ThisType", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "WeakKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "ArrayBufferLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "ArrayBufferView", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "DataViewConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "Generator", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "GeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ProxyHandler", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", "identifiers": [], "defs": [], "references": [] diff --git a/test/fixtures/ast/ts-script-setup-with-use-global-var/services.json b/test/fixtures/ast/ts-script-setup-with-use-global-var/services.json index 7159ba5a..7f661a33 100644 --- a/test/fixtures/ast/ts-script-setup-with-use-global-var/services.json +++ b/test/fixtures/ast/ts-script-setup-with-use-global-var/services.json @@ -2,10 +2,12 @@ "defineCustomBlocksVisitor", "defineDocumentVisitor", "defineTemplateBodyVisitor", + "emitDecoratorMetadata", "esTreeNodeToTSNodeMap", + "experimentalDecorators", "getDocumentFragment", "getTemplateBodyTokenStore", - "hasFullTypeInformation", + "isolatedDeclarations", "program", "tsNodeToESTreeNodeMap" ] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-prop-shorthand/ast.json b/test/fixtures/ast/v-bind-prop-shorthand/ast.json index ba515f2f..dc3c2610 100644 --- a/test/fixtures/ast/v-bind-prop-shorthand/ast.json +++ b/test/fixtures/ast/v-bind-prop-shorthand/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-bind-same-name-shorthand02-options/ast.json b/test/fixtures/ast/v-bind-same-name-shorthand02-options/ast.json index 84add60c..55f56637 100644 --- a/test/fixtures/ast/v-bind-same-name-shorthand02-options/ast.json +++ b/test/fixtures/ast/v-bind-same-name-shorthand02-options/ast.json @@ -95,7 +95,6 @@ ], "name": "data" }, - "kind": "init", "value": { "type": "FunctionExpression", "start": 33, @@ -244,7 +243,8 @@ } ] } - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/v-bind-same-name-shorthand02-options/scope.json b/test/fixtures/ast/v-bind-same-name-shorthand02-options/scope.json index 19cca0f2..66d2c7f4 100644 --- a/test/fixtures/ast/v-bind-same-name-shorthand02-options/scope.json +++ b/test/fixtures/ast/v-bind-same-name-shorthand02-options/scope.json @@ -4,25 +4,17 @@ "references": [], "childScopes": [ { - "type": "module", - "variables": [], - "references": [], - "childScopes": [ + "type": "function", + "variables": [ { - "type": "function", - "variables": [ - { - "name": "arguments", - "identifiers": [], - "defs": [], - "references": [] - } - ], - "references": [], - "childScopes": [], - "through": [] + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] } ], + "references": [], + "childScopes": [], "through": [] } ], diff --git a/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/ast.json b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/ast.json index 7a0ab7e5..05fdd689 100644 --- a/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/ast.json +++ b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/ast.json @@ -95,7 +95,6 @@ ], "name": "data" }, - "kind": "init", "value": { "type": "FunctionExpression", "start": 33, @@ -286,7 +285,8 @@ } ] } - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/scope.json b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/scope.json index 19cca0f2..66d2c7f4 100644 --- a/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/scope.json +++ b/test/fixtures/ast/v-bind-same-name-shorthand04-with-v-for/scope.json @@ -4,25 +4,17 @@ "references": [], "childScopes": [ { - "type": "module", - "variables": [], - "references": [], - "childScopes": [ + "type": "function", + "variables": [ { - "type": "function", - "variables": [ - { - "name": "arguments", - "identifiers": [], - "defs": [], - "references": [] - } - ], - "references": [], - "childScopes": [], - "through": [] + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] } ], + "references": [], + "childScopes": [], "through": [] } ], diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/ast.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/ast.json new file mode 100644 index 00000000..06d41c77 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/ast.json @@ -0,0 +1,968 @@ +{ + "type": "Program", + "start": 15, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "range": [ + 15, + 60 + ], + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "range": [ + 15, + 60 + ], + "declarations": [ + { + "type": "VariableDeclarator", + "start": 21, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "range": [ + 21, + 60 + ], + "id": { + "type": "Identifier", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "range": [ + 21, + 27 + ], + "name": "srcUrl" + }, + "init": { + "type": "Literal", + "start": 30, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "range": [ + 30, + 60 + ], + "value": "https://github.com/vuejs.png", + "raw": "\"https://github.com/vuejs.png\"" + } + } + ], + "kind": "const" + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + } + ], + "templateBody": { + "type": "VElement", + "range": [ + 72, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 72, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 82, + 85 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 85, + 98 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "name": "img", + "rawName": "img", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 85, + 98 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 90, + 97 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 90, + 97 + ], + "loc": { + "start": { + "line": 6, + "column": 7 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "column": 7, + "line": 6 + }, + "end": { + "column": 8, + "line": 6 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 91, + 97 + ], + "loc": { + "start": { + "column": 8, + "line": 6 + }, + "end": { + "column": 14, + "line": 6 + } + }, + "name": "srcurl", + "rawName": "srcUrl" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 91, + 97 + ], + "loc": { + "start": { + "column": 8, + "line": 6 + }, + "end": { + "column": 14, + "line": 6 + } + }, + "expression": { + "type": "Identifier", + "start": 91, + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "column": 14, + "line": 6 + } + }, + "range": [ + 91, + 97 + ], + "name": "srcUrl" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 91, + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "column": 14, + "line": 6 + } + }, + "range": [ + 91, + 97 + ], + "name": "srcUrl" + }, + "mode": "r", + "variable": null + } + ] + } + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 98, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 15 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 99, + 110 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "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": "HTMLTagClose", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 14, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 15, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 21, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "value": "srcUrl" + }, + { + "type": "HTMLWhitespace", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 30, + 60 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "value": "\"https://github.com/vuejs.png\"" + }, + { + "type": "HTMLWhitespace", + "range": [ + 60, + 61 + ], + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 61, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 70, + 72 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 72, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 82, + 85 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 85, + 89 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "img" + }, + { + "type": "Punctuator", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "column": 7, + "line": 6 + }, + "end": { + "column": 8, + "line": 6 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 91, + 97 + ], + "loc": { + "start": { + "column": 8, + "line": 6 + }, + "end": { + "column": 14, + "line": 6 + } + }, + "value": "srcUrl" + }, + { + "type": "HTMLTagClose", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "line": 6, + "column": 14 + }, + "end": { + "line": 6, + "column": 15 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 98, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 15 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 99, + 109 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/parser-options.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/parser-options.json new file mode 100644 index 00000000..2104ca43 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/parser-options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/requirements.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/requirements.json new file mode 100644 index 00000000..36659b1f --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/requirements.json @@ -0,0 +1,3 @@ +{ + "eslint": ">=8" +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/scope.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/scope.json new file mode 100644 index 00000000..ca436a8c --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/scope.json @@ -0,0 +1,154 @@ +{ + "type": "global", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "srcUrl", + "identifiers": [ + { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "node": { + "type": "VariableDeclarator", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 45 + } + } + }, + "name": "srcUrl" + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "init": true + }, + { + "identifier": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "init": null, + "vueUsedInTemplate": true + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "from": "module", + "resolved": { + "type": "Identifier", + "name": "srcUrl", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "init": true + } + ], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/source.vue b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/source.vue new file mode 100644 index 00000000..6888a5e6 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/source.vue @@ -0,0 +1,7 @@ + + + diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/token-ranges.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/token-ranges.json new file mode 100644 index 00000000..9fa6dc66 --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/token-ranges.json @@ -0,0 +1,34 @@ +[ + "", + "", + "\n", + "const", + " ", + "srcUrl", + " ", + "=", + " ", + "\"https://github.com/vuejs.png\"", + "\n", + "", + "\n\n", + "", + "\n ", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/tree.json b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/tree.json new file mode 100644 index 00000000..75a9fb2c --- /dev/null +++ b/test/fixtures/ast/v-bind-same-name-shorthand07-camelcase/tree.json @@ -0,0 +1,73 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/v-bind-sequence-expression/ast.json b/test/fixtures/ast/v-bind-sequence-expression/ast.json index 79cbf7a3..34ebd90b 100644 --- a/test/fixtures/ast/v-bind-sequence-expression/ast.json +++ b/test/fixtures/ast/v-bind-sequence-expression/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-bind-spread-element/ast.json b/test/fixtures/ast/v-bind-spread-element/ast.json index 8600e444..ab827027 100644 --- a/test/fixtures/ast/v-bind-spread-element/ast.json +++ b/test/fixtures/ast/v-bind-spread-element/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-for-directives-error-with-es5/parser-options.json b/test/fixtures/ast/v-for-directives-error-with-es5/parser-options.json index fcc8a62f..03c6610d 100644 --- a/test/fixtures/ast/v-for-directives-error-with-es5/parser-options.json +++ b/test/fixtures/ast/v-for-directives-error-with-es5/parser-options.json @@ -1,3 +1,4 @@ { - "ecmaVersion": 5 + "ecmaVersion": 5, + "sourceType": "script" } diff --git a/test/fixtures/ast/v-for-directives-error/ast.json b/test/fixtures/ast/v-for-directives-error/ast.json index a79f66fa..9c9bf3fd 100644 --- a/test/fixtures/ast/v-for-directives-error/ast.json +++ b/test/fixtures/ast/v-for-directives-error/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-for-directives-index/ast.json b/test/fixtures/ast/v-for-directives-index/ast.json index 36768789..df5c82af 100644 --- a/test/fixtures/ast/v-for-directives-index/ast.json +++ b/test/fixtures/ast/v-for-directives-index/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-for-directives-with-destructuring/ast.json b/test/fixtures/ast/v-for-directives-with-destructuring/ast.json index 6e5ebe7d..b6ede250 100644 --- a/test/fixtures/ast/v-for-directives-with-destructuring/ast.json +++ b/test/fixtures/ast/v-for-directives-with-destructuring/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -262,7 +262,6 @@ ], "name": "key" }, - "kind": "init", "value": { "type": "Identifier", "start": 28, @@ -282,7 +281,8 @@ 31 ], "name": "key" - } + }, + "kind": "init" }, { "type": "Property", @@ -325,7 +325,6 @@ ], "name": "name" }, - "kind": "init", "value": { "type": "Identifier", "start": 32, @@ -345,7 +344,8 @@ 36 ], "name": "name" - } + }, + "kind": "init" } ] } @@ -1460,7 +1460,6 @@ ], "name": "name" }, - "kind": "init", "value": { "type": "Identifier", "start": 163, @@ -1480,7 +1479,8 @@ 167 ], "name": "name" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/v-for-directives-with-es5-2/parser-options.json b/test/fixtures/ast/v-for-directives-with-es5-2/parser-options.json index fcc8a62f..03c6610d 100644 --- a/test/fixtures/ast/v-for-directives-with-es5-2/parser-options.json +++ b/test/fixtures/ast/v-for-directives-with-es5-2/parser-options.json @@ -1,3 +1,4 @@ { - "ecmaVersion": 5 + "ecmaVersion": 5, + "sourceType": "script" } diff --git a/test/fixtures/ast/v-for-directives-with-es5/parser-options.json b/test/fixtures/ast/v-for-directives-with-es5/parser-options.json index fcc8a62f..03c6610d 100644 --- a/test/fixtures/ast/v-for-directives-with-es5/parser-options.json +++ b/test/fixtures/ast/v-for-directives-with-es5/parser-options.json @@ -1,3 +1,4 @@ { - "ecmaVersion": 5 + "ecmaVersion": 5, + "sourceType": "script" } diff --git a/test/fixtures/ast/v-for-directives/ast.json b/test/fixtures/ast/v-for-directives/ast.json index 4672c8d4..eb74e84d 100644 --- a/test/fixtures/ast/v-for-directives/ast.json +++ b/test/fixtures/ast/v-for-directives/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-arrow-function-expression.1/ast.json b/test/fixtures/ast/v-on-arrow-function-expression.1/ast.json index 4ecfef08..e96836d7 100644 --- a/test/fixtures/ast/v-on-arrow-function-expression.1/ast.json +++ b/test/fixtures/ast/v-on-arrow-function-expression.1/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-arrow-function-expression.2/ast.json b/test/fixtures/ast/v-on-arrow-function-expression.2/ast.json index a4a43c5b..79b19281 100644 --- a/test/fixtures/ast/v-on-arrow-function-expression.2/ast.json +++ b/test/fixtures/ast/v-on-arrow-function-expression.2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-async-arrow-function-expression/ast.json b/test/fixtures/ast/v-on-async-arrow-function-expression/ast.json new file mode 100644 index 00000000..76c9ea47 --- /dev/null +++ b/test/fixtures/ast/v-on-async-arrow-function-expression/ast.json @@ -0,0 +1,829 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 77 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 10, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 15, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 54 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 56 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 23, + 55 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "name": "on", + "rawName": "@" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 24, + 29 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 18, + "line": 2 + } + }, + "name": "click", + "rawName": "click" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 30, + 55 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 31, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "range": [ + 31, + 54 + ], + "id": null, + "expression": true, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "AwaitExpression", + "start": 43, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "range": [ + 43, + 54 + ], + "argument": { + "type": "CallExpression", + "start": 49, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "range": [ + 49, + 54 + ], + "callee": { + "type": "Identifier", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "range": [ + 49, + 52 + ], + "name": "act" + }, + "arguments": [], + "optional": false + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "range": [ + 49, + 52 + ], + "name": "act" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 56, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 54 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 65, + 66 + ], + "loc": { + "start": { + "line": 2, + "column": 54 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 66, + 77 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 10, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 15, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "value": "@" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 29 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 18, + "line": 2 + } + }, + "value": "click" + }, + { + "type": "HTMLAssociation", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "async", + "start": 31, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 31, + 36 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 37, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "range": [ + 37, + 38 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "range": [ + 38, + 39 + ] + }, + { + "type": "Punctuator", + "value": "=>", + "start": 40, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 29 + }, + "end": { + "line": 2, + "column": 31 + } + }, + "range": [ + 40, + 42 + ] + }, + { + "type": "Identifier", + "value": "await", + "start": 43, + "end": 48, + "loc": { + "start": { + "line": 2, + "column": 32 + }, + "end": { + "line": 2, + "column": 37 + } + }, + "range": [ + 43, + 48 + ] + }, + { + "type": "Identifier", + "value": "act", + "start": 49, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 38 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "range": [ + 49, + 52 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 52, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 41 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "range": [ + 52, + 53 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 53, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 42 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "range": [ + 53, + 54 + ] + }, + { + "type": "Punctuator", + "range": [ + 54, + 55 + ], + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 55, + 56 + ], + "loc": { + "start": { + "line": 2, + "column": 44 + }, + "end": { + "line": 2, + "column": 45 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 56, + 64 + ], + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 53 + }, + "end": { + "line": 2, + "column": 54 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 65, + 66 + ], + "loc": { + "start": { + "line": 2, + "column": 54 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 66, + 76 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/v-on-async-arrow-function-expression/source.vue b/test/fixtures/ast/v-on-async-arrow-function-expression/source.vue new file mode 100644 index 00000000..9cdad449 --- /dev/null +++ b/test/fixtures/ast/v-on-async-arrow-function-expression/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/v-on-async-arrow-function-expression/token-ranges.json b/test/fixtures/ast/v-on-async-arrow-function-expression/token-ranges.json new file mode 100644 index 00000000..032294ca --- /dev/null +++ b/test/fixtures/ast/v-on-async-arrow-function-expression/token-ranges.json @@ -0,0 +1,26 @@ +[ + "", + "\n ", + "", + "await", + "act", + "(", + ")", + "\"", + ">", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-on-async-arrow-function-expression/tree.json b/test/fixtures/ast/v-on-async-arrow-function-expression/tree.json new file mode 100644 index 00000000..d272edfa --- /dev/null +++ b/test/fixtures/ast/v-on-async-arrow-function-expression/tree.json @@ -0,0 +1,96 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/v-on-async-function-expression/ast.json b/test/fixtures/ast/v-on-async-function-expression/ast.json new file mode 100644 index 00000000..af3d12eb --- /dev/null +++ b/test/fixtures/ast/v-on-async-function-expression/ast.json @@ -0,0 +1,909 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "module", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 86 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 10, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 15, + 74 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 63 + } + }, + "name": "button", + "rawName": "button", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 54 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 23, + 64 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "name": "on", + "rawName": "@" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 24, + 29 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 18, + "line": 2 + } + }, + "name": "click", + "rawName": "click" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 30, + 64 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "expression": { + "type": "FunctionExpression", + "start": 31, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "range": [ + 31, + 63 + ], + "id": null, + "expression": false, + "generator": false, + "async": true, + "params": [], + "body": { + "type": "BlockStatement", + "start": 48, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 37 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "range": [ + 48, + 63 + ], + "body": [ + { + "type": "ExpressionStatement", + "start": 50, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 39 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "range": [ + 50, + 61 + ], + "expression": { + "type": "AwaitExpression", + "start": 50, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 39 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "range": [ + 50, + 61 + ], + "argument": { + "type": "CallExpression", + "start": 56, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "range": [ + 56, + 61 + ], + "callee": { + "type": "Identifier", + "start": 56, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 48 + } + }, + "range": [ + 56, + 59 + ], + "name": "act" + }, + "arguments": [], + "optional": false + } + } + } + ] + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 56, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 48 + } + }, + "range": [ + 56, + 59 + ], + "name": "act" + }, + "mode": "r" + } + ] + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 65, + 74 + ], + "loc": { + "start": { + "line": 2, + "column": 54 + }, + "end": { + "line": 2, + "column": 63 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 2, + "column": 63 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 75, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 10, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 15, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "value": "button" + }, + { + "type": "Punctuator", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "column": 12, + "line": 2 + }, + "end": { + "column": 13, + "line": 2 + } + }, + "value": "@" + }, + { + "type": "HTMLIdentifier", + "range": [ + 24, + 29 + ], + "loc": { + "start": { + "column": 13, + "line": 2 + }, + "end": { + "column": 18, + "line": 2 + } + }, + "value": "click" + }, + { + "type": "HTMLAssociation", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "async", + "start": 31, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 31, + 36 + ] + }, + { + "type": "Keyword", + "value": "function", + "start": 37, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 34 + } + }, + "range": [ + 37, + 45 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 45, + "end": 46, + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 35 + } + }, + "range": [ + 45, + 46 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 46, + "end": 47, + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 36 + } + }, + "range": [ + 46, + 47 + ] + }, + { + "type": "Punctuator", + "value": "{", + "start": 48, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 37 + }, + "end": { + "line": 2, + "column": 38 + } + }, + "range": [ + 48, + 49 + ] + }, + { + "type": "Identifier", + "value": "await", + "start": 50, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 39 + }, + "end": { + "line": 2, + "column": 44 + } + }, + "range": [ + 50, + 55 + ] + }, + { + "type": "Identifier", + "value": "act", + "start": 56, + "end": 59, + "loc": { + "start": { + "line": 2, + "column": 45 + }, + "end": { + "line": 2, + "column": 48 + } + }, + "range": [ + 56, + 59 + ] + }, + { + "type": "Punctuator", + "value": "(", + "start": 59, + "end": 60, + "loc": { + "start": { + "line": 2, + "column": 48 + }, + "end": { + "line": 2, + "column": 49 + } + }, + "range": [ + 59, + 60 + ] + }, + { + "type": "Punctuator", + "value": ")", + "start": 60, + "end": 61, + "loc": { + "start": { + "line": 2, + "column": 49 + }, + "end": { + "line": 2, + "column": 50 + } + }, + "range": [ + 60, + 61 + ] + }, + { + "type": "Punctuator", + "value": "}", + "start": 62, + "end": 63, + "loc": { + "start": { + "line": 2, + "column": 51 + }, + "end": { + "line": 2, + "column": 52 + } + }, + "range": [ + 62, + 63 + ] + }, + { + "type": "Punctuator", + "range": [ + 63, + 64 + ], + "loc": { + "start": { + "line": 2, + "column": 52 + }, + "end": { + "line": 2, + "column": 53 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 2, + "column": 53 + }, + "end": { + "line": 2, + "column": 54 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 65, + 73 + ], + "loc": { + "start": { + "line": 2, + "column": 54 + }, + "end": { + "line": 2, + "column": 62 + } + }, + "value": "button" + }, + { + "type": "HTMLTagClose", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 2, + "column": 62 + }, + "end": { + "line": 2, + "column": 63 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 2, + "column": 63 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 75, + 85 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 85, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 86, + 87 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/v-on-async-function-expression/source.vue b/test/fixtures/ast/v-on-async-function-expression/source.vue new file mode 100644 index 00000000..fb86873b --- /dev/null +++ b/test/fixtures/ast/v-on-async-function-expression/source.vue @@ -0,0 +1,3 @@ + diff --git a/test/fixtures/ast/v-on-async-function-expression/token-ranges.json b/test/fixtures/ast/v-on-async-function-expression/token-ranges.json new file mode 100644 index 00000000..77fdd025 --- /dev/null +++ b/test/fixtures/ast/v-on-async-function-expression/token-ranges.json @@ -0,0 +1,28 @@ +[ + "", + "\n ", + "", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/v-on-async-function-expression/tree.json b/test/fixtures/ast/v-on-async-function-expression/tree.json new file mode 100644 index 00000000..5fdf6e87 --- /dev/null +++ b/test/fixtures/ast/v-on-async-function-expression/tree.json @@ -0,0 +1,108 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/v-on-function-expression/ast.json b/test/fixtures/ast/v-on-function-expression/ast.json index 24049e41..946439ac 100644 --- a/test/fixtures/ast/v-on-function-expression/ast.json +++ b/test/fixtures/ast/v-on-function-expression/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-multiple-statements/ast.json b/test/fixtures/ast/v-on-multiple-statements/ast.json index 03f0a0c4..9b285e71 100644 --- a/test/fixtures/ast/v-on-multiple-statements/ast.json +++ b/test/fixtures/ast/v-on-multiple-statements/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-object-expression/ast.json b/test/fixtures/ast/v-on-object-expression/ast.json index c8cbcb81..c6d4163a 100644 --- a/test/fixtures/ast/v-on-object-expression/ast.json +++ b/test/fixtures/ast/v-on-object-expression/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-simple-path.1/ast.json b/test/fixtures/ast/v-on-simple-path.1/ast.json index d580550e..8a1e525d 100644 --- a/test/fixtures/ast/v-on-simple-path.1/ast.json +++ b/test/fixtures/ast/v-on-simple-path.1/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-simple-path.2/ast.json b/test/fixtures/ast/v-on-simple-path.2/ast.json index 9f05e47b..71f7779c 100644 --- a/test/fixtures/ast/v-on-simple-path.2/ast.json +++ b/test/fixtures/ast/v-on-simple-path.2/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-simple-path.3/ast.json b/test/fixtures/ast/v-on-simple-path.3/ast.json index a9b40fae..1ac5a8d2 100644 --- a/test/fixtures/ast/v-on-simple-path.3/ast.json +++ b/test/fixtures/ast/v-on-simple-path.3/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-on-simple-path.4/ast.json b/test/fixtures/ast/v-on-simple-path.4/ast.json index 10bc3274..5dd52cb6 100644 --- a/test/fixtures/ast/v-on-simple-path.4/ast.json +++ b/test/fixtures/ast/v-on-simple-path.4/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-pre/ast.json b/test/fixtures/ast/v-pre/ast.json index baaa037c..04772d33 100644 --- a/test/fixtures/ast/v-pre/ast.json +++ b/test/fixtures/ast/v-pre/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { diff --git a/test/fixtures/ast/v-slot-default-shorthand/ast.json b/test/fixtures/ast/v-slot-default-shorthand/ast.json index c6ca641e..fc107094 100644 --- a/test/fixtures/ast/v-slot-default-shorthand/ast.json +++ b/test/fixtures/ast/v-slot-default-shorthand/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -280,7 +280,6 @@ ], "name": "foo" }, - "kind": "init", "value": { "type": "Identifier", "start": 43, @@ -300,7 +299,8 @@ 46 ], "name": "foo" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/v-slot-default/ast.json b/test/fixtures/ast/v-slot-default/ast.json index f1ce9aee..38fcf4da 100644 --- a/test/fixtures/ast/v-slot-default/ast.json +++ b/test/fixtures/ast/v-slot-default/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -262,7 +262,6 @@ ], "name": "foo" }, - "kind": "init", "value": { "type": "Identifier", "start": 41, @@ -282,7 +281,8 @@ 44 ], "name": "foo" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/v-slot-named-shorthand/ast.json b/test/fixtures/ast/v-slot-named-shorthand/ast.json index 4a94e5d4..f7004d68 100644 --- a/test/fixtures/ast/v-slot-named-shorthand/ast.json +++ b/test/fixtures/ast/v-slot-named-shorthand/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -337,7 +337,6 @@ ], "name": "foo" }, - "kind": "init", "value": { "type": "Identifier", "start": 61, @@ -357,7 +356,8 @@ 64 ], "name": "foo" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/v-slot-named/ast.json b/test/fixtures/ast/v-slot-named/ast.json index 60ab37e6..1c337d08 100644 --- a/test/fixtures/ast/v-slot-named/ast.json +++ b/test/fixtures/ast/v-slot-named/ast.json @@ -17,7 +17,7 @@ 0 ], "body": [], - "sourceType": "script", + "sourceType": "module", "comments": [], "tokens": [], "templateBody": { @@ -337,7 +337,6 @@ ], "name": "foo" }, - "kind": "init", "value": { "type": "Identifier", "start": 67, @@ -357,7 +356,8 @@ 70 ], "name": "foo" - } + }, + "kind": "init" } ] } diff --git a/test/fixtures/ast/vue3.3-generic-1/ast.json b/test/fixtures/ast/vue3.3-generic-1/ast.json index c00e934a..6c0f8f26 100644 --- a/test/fixtures/ast/vue3.3-generic-1/ast.json +++ b/test/fixtures/ast/vue3.3-generic-1/ast.json @@ -1,45 +1,37 @@ { "type": "Program", + "range": [ + 37, + 60 + ], "body": [ { "type": "ExpressionStatement", "expression": { "type": "CallExpression", + "arguments": [], "callee": { "type": "Identifier", + "decorators": [], "name": "defineProps", + "optional": false, "range": [ 37, 48 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 0 } } }, - "arguments": [], "optional": false, - "range": [ - 37, - 59 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 2, - "column": 22 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 48, @@ -54,32 +46,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 50, 53 ], "loc": { - "start": { - "line": 2, - "column": 13 - }, "end": { "line": 2, "column": 16 + }, + "start": { + "line": 2, + "column": 13 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 2, - "column": 16 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 16 } }, "range": [ @@ -90,19 +87,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 54, 55 ], "loc": { - "start": { - "line": 2, - "column": 17 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 17 } } }, @@ -111,13 +110,13 @@ 55 ], "loc": { - "start": { - "line": 2, - "column": 17 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 17 } } } @@ -127,13 +126,13 @@ 55 ], "loc": { - "start": { - "line": 2, - "column": 13 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 13 } } } @@ -143,27 +142,41 @@ 56 ], "loc": { - "start": { - "line": 2, - "column": 12 - }, "end": { "line": 2, "column": 19 + }, + "start": { + "line": 2, + "column": 12 } } } ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 20 + }, + "start": { + "line": 2, + "column": 11 } } + }, + "range": [ + 37, + 59 + ], + "loc": { + "end": { + "line": 2, + "column": 22 + }, + "start": { + "line": 2, + "column": 0 + } } }, "range": [ @@ -171,32 +184,19 @@ 59 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 22 + }, + "start": { + "line": 2, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 37, - 60 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 3, - "column": 0 - } - }, "tokens": [ { "type": "Punctuator", @@ -218,183 +218,183 @@ }, { "type": "Identifier", - "value": "defineProps", + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 0 + } + }, "range": [ 37, 48 ], + "value": "defineProps" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 0 + "column": 12 }, - "end": { + "start": { "line": 2, "column": 11 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 48, 49 ], + "value": "<" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 11 + "column": 13 }, - "end": { + "start": { "line": 2, "column": 12 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 49, 50 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 2, "column": 13 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 50, 53 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 13 + "column": 17 }, - "end": { + "start": { "line": 2, "column": 16 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 53, 54 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 16 + "column": 18 }, - "end": { + "start": { "line": 2, "column": 17 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 54, 55 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 17 + "column": 19 }, - "end": { + "start": { "line": 2, "column": 18 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 55, 56 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 18 + "column": 20 }, - "end": { + "start": { "line": 2, "column": 19 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 56, 57 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 19 + "column": 21 }, - "end": { + "start": { "line": 2, "column": 20 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 57, 58 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 20 + "column": 22 }, - "end": { + "start": { "line": 2, "column": 21 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 58, 59 ], - "loc": { - "start": { - "line": 2, - "column": 21 - }, - "end": { - "line": 2, - "column": 22 - } - } + "value": ")" }, { "type": "Punctuator", @@ -415,7 +415,16 @@ "value": "" } ], - "comments": [], + "loc": { + "end": { + "line": 3, + "column": 0 + }, + "start": { + "line": 2, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -491,19 +500,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 83, 86 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -511,19 +522,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 83, 86 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -717,21 +730,21 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 33, - 34 - ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } - } + }, + "range": [ + 33, + 34 + ], + "value": "T" }, { "type": "Punctuator", @@ -951,21 +964,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 83, - 86 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 83, + 86 + ], + "value": "foo" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/ast/vue3.3-generic-1/scope.json b/test/fixtures/ast/vue3.3-generic-1/scope.json index f67735c2..cdafa028 100644 --- a/test/fixtures/ast/vue3.3-generic-1/scope.json +++ b/test/fixtures/ast/vue3.3-generic-1/scope.json @@ -2,904 +2,1180 @@ "type": "global", "variables": [ { - "name": "ClassMemberDecoratorContext", + "name": "Intl", "identifiers": [], "defs": [], "references": [] }, { - "name": "DecoratorContext", + "name": "SymbolConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecoratorContext", + "name": "Function", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassMethodDecoratorContext", + "name": "Disposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassGetterDecoratorContext", + "name": "AsyncDisposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassSetterDecoratorContext", + "name": "SuppressedError", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorContext", + "name": "SuppressedErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorTarget", + "name": "DisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorResult", + "name": "DisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassFieldDecoratorContext", + "name": "AsyncDisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecorator", + "name": "AsyncDisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "AsyncIteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "ReadonlySetLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "Set", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "ReadonlySet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Iterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "IteratorObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "PromiseConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "Float16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Float16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "Math", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "DataView", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "ArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "ArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "MapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "ObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "PromiseWithResolvers", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "RegExp", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "Atomics", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "SharedArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "SharedArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "String", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "ClassMemberDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "DecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "DecoratorMetadataObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "DecoratorMetadata", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "ClassDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "ClassMethodDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "ClassGetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "ClassSetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "ClassAccessorDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "ClassAccessorDecoratorTarget", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "ClassAccessorDecoratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "ClassFieldDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferTypes", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferLike", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "RegExpConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "FlatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "AsyncGenerator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "AsyncGeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "AsyncGeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "DateConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ArrayBufferTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "const", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "defineProps", + "name": "ImportAttributes", "identifiers": [], "defs": [], - "references": [ - { - "identifier": { - "type": "Identifier", + "references": [] + }, + { + "name": "EvalError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConcatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypedPropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructorLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseLike", + "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": "NoInfer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataViewConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Generator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyHandler", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", + "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 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -918,13 +1194,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 2, - "column": 17 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 17 } } }, @@ -945,13 +1221,13 @@ "type": "Identifier", "name": "defineProps", "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -963,13 +1239,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 2, - "column": 17 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 17 } } }, @@ -984,13 +1260,13 @@ "type": "Identifier", "name": "defineProps", "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 11 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -1002,13 +1278,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 2, - "column": 17 - }, "end": { "line": 2, "column": 18 + }, + "start": { + "line": 2, + "column": 17 } } }, diff --git a/test/fixtures/ast/vue3.3-generic-2/ast.json b/test/fixtures/ast/vue3.3-generic-2/ast.json index 3685710d..6eab96ca 100644 --- a/test/fixtures/ast/vue3.3-generic-2/ast.json +++ b/test/fixtures/ast/vue3.3-generic-2/ast.json @@ -1,23 +1,30 @@ { "type": "Program", + "range": [ + 9, + 162 + ], "body": [ { "type": "TSTypeAliasDeclaration", + "declare": false, "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 14, 17 ], "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -31,13 +38,13 @@ 26 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 11 } } }, @@ -48,13 +55,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 20 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 20 } } } @@ -64,13 +71,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 11 } } }, @@ -79,13 +86,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -94,61 +101,52 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 101, 102 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, "init": { "type": "CallExpression", + "arguments": [], "callee": { "type": "Identifier", + "decorators": [], "name": "defineProps", + "optional": false, "range": [ 105, 116 ], "loc": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, - "arguments": [], "optional": false, - "range": [ - 105, - 127 - ], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 32 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 116, @@ -163,32 +161,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 118, 121 ], "loc": { - "start": { - "line": 5, - "column": 23 - }, "end": { "line": 5, "column": 26 + }, + "start": { + "line": 5, + "column": 23 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 5, - "column": 26 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 26 } }, "range": [ @@ -199,19 +202,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 122, 123 ], "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -220,13 +225,13 @@ 123 ], "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } } @@ -236,13 +241,13 @@ 123 ], "loc": { - "start": { - "line": 5, - "column": 23 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 23 } } } @@ -252,27 +257,41 @@ 124 ], "loc": { - "start": { - "line": 5, - "column": 22 - }, "end": { "line": 5, "column": 29 + }, + "start": { + "line": 5, + "column": 22 } } } ], "loc": { - "start": { - "line": 5, - "column": 21 - }, "end": { "line": 5, "column": 30 + }, + "start": { + "line": 5, + "column": 21 } } + }, + "range": [ + 105, + 127 + ], + "loc": { + "end": { + "line": 5, + "column": 32 + }, + "start": { + "line": 5, + "column": 10 + } } }, "range": [ @@ -280,30 +299,31 @@ 127 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 32 + }, + "start": { + "line": 5, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 95, 127 ], "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { "line": 5, "column": 32 + }, + "start": { + "line": 5, + "column": 0 } } }, @@ -312,76 +332,83 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 134, 137 ], "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, "init": { "type": "MemberExpression", + "computed": false, "object": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 140, 141 ], "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 142, 145 ], "loc": { - "start": { - "line": 6, - "column": 14 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 14 } } }, - "computed": false, - "optional": false, "range": [ 140, 145 ], "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -390,30 +417,31 @@ 145 ], "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 128, 145 ], "loc": { - "start": { - "line": 6, - "column": 0 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 0 } } }, @@ -421,94 +449,100 @@ "type": "ExpressionStatement", "expression": { "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 158, + 161 + ], + "loc": { + "end": { + "line": 7, + "column": 15 + }, + "start": { + "line": 7, + "column": 12 + } + } + } + ], "callee": { "type": "MemberExpression", + "computed": false, "object": { "type": "Identifier", + "decorators": [], "name": "console", + "optional": false, "range": [ 146, 153 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "log", + "optional": false, "range": [ 154, 157 ], "loc": { - "start": { - "line": 7, - "column": 8 - }, "end": { "line": 7, "column": 11 - } - } + }, + "start": { + "line": 7, + "column": 8 + } + } }, - "computed": false, - "optional": false, "range": [ 146, 157 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 11 + }, + "start": { + "line": 7, + "column": 0 } } }, - "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 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -517,32 +551,19 @@ 162 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 16 + }, + "start": { + "line": 7, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 9, - 162 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 7, - "column": 16 - } - }, "tokens": [ { "type": "Punctuator", @@ -564,111 +585,111 @@ }, { "type": "Identifier", - "value": "type", + "loc": { + "end": { + "line": 2, + "column": 4 + }, + "start": { + "line": 2, + "column": 0 + } + }, "range": [ 9, 13 ], + "value": "type" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 2, - "column": 4 + "column": 5 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 14, 17 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 5 + "column": 10 }, - "end": { + "start": { "line": 2, - "column": 8 + "column": 9 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 18, 19 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 9 + "column": 17 }, - "end": { + "start": { "line": 2, - "column": 10 + "column": 11 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 20, 26 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 11 + "column": 19 }, - "end": { + "start": { "line": 2, - "column": 17 + "column": 18 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 27, 28 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 18 + "column": 26 }, - "end": { + "start": { "line": 2, - "column": 19 + "column": 20 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 29, 35 ], - "loc": { - "start": { - "line": 2, - "column": 20 - }, - "end": { - "line": 2, - "column": 26 - } - } + "value": "string" }, { "type": "Punctuator", @@ -708,453 +729,453 @@ }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 0 + } + }, "range": [ 95, 100 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 0 + "column": 7 }, - "end": { + "start": { "line": 5, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 101, 102 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 6 + "column": 9 }, - "end": { + "start": { "line": 5, - "column": 7 + "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 103, 104 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 8 + "column": 21 }, - "end": { + "start": { "line": 5, - "column": 9 + "column": 10 } - } - }, - { - "type": "Identifier", - "value": "defineProps", + }, "range": [ 105, 116 ], + "value": "defineProps" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 10 + "column": 22 }, - "end": { + "start": { "line": 5, "column": 21 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 116, 117 ], + "value": "<" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 21 + "column": 23 }, - "end": { + "start": { "line": 5, "column": 22 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 117, 118 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 22 + "column": 26 }, - "end": { + "start": { "line": 5, "column": 23 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 118, 121 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 23 + "column": 27 }, - "end": { + "start": { "line": 5, "column": 26 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 121, 122 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 26 + "column": 28 }, - "end": { + "start": { "line": 5, "column": 27 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 122, 123 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 27 + "column": 29 }, - "end": { + "start": { "line": 5, "column": 28 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 123, 124 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 28 + "column": 30 }, - "end": { + "start": { "line": 5, "column": 29 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 124, 125 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 29 + "column": 31 }, - "end": { + "start": { "line": 5, "column": 30 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 125, 126 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 30 + "column": 32 }, - "end": { + "start": { "line": 5, "column": 31 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 126, 127 ], - "loc": { - "start": { - "line": 5, - "column": 31 - }, - "end": { - "line": 5, - "column": 32 - } - } + "value": ")" }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 6, + "column": 5 + }, + "start": { + "line": 6, + "column": 0 + } + }, "range": [ 128, 133 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 6, - "column": 0 + "column": 9 }, - "end": { + "start": { "line": 6, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 134, 137 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 6, - "column": 6 + "column": 11 }, - "end": { + "start": { "line": 6, - "column": 9 + "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 138, 139 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 6, - "column": 10 + "column": 13 }, - "end": { + "start": { "line": 6, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 140, 141 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 6, - "column": 12 + "column": 14 }, - "end": { + "start": { "line": 6, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 141, 142 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 6, - "column": 13 + "column": 17 }, - "end": { + "start": { "line": 6, "column": 14 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 142, 145 ], - "loc": { - "start": { - "line": 6, - "column": 14 - }, - "end": { - "line": 6, - "column": 17 - } - } + "value": "foo" }, { "type": "Identifier", - "value": "console", + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + }, "range": [ 146, 153 ], + "value": "console" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 7, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 153, 154 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 7 + "column": 11 }, - "end": { + "start": { "line": 7, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "log", + }, "range": [ 154, 157 ], + "value": "log" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 8 + "column": 12 }, - "end": { + "start": { "line": 7, "column": 11 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 157, 158 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 11 + "column": 15 }, - "end": { + "start": { "line": 7, "column": 12 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 158, 161 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 7, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 161, 162 ], - "loc": { - "start": { - "line": 7, - "column": 15 - }, - "end": { - "line": 7, - "column": 16 - } - } + "value": ")" }, { "type": "Punctuator", @@ -1175,7 +1196,16 @@ "value": "" } ], - "comments": [], + "loc": { + "end": { + "line": 7, + "column": 16 + }, + "start": { + "line": 2, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -1251,19 +1281,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 186, 189 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1271,19 +1303,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 186, 189 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1801,57 +1835,57 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], - "loc": { - "start": { - "line": 4, - "column": 43 - }, - "end": { - "line": 4, - "column": 46 - } - } + "value": "Foo" }, { "type": "Punctuator", @@ -2359,21 +2393,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 186, - 189 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 186, + 189 + ], + "value": "foo" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/ast/vue3.3-generic-2/scope.json b/test/fixtures/ast/vue3.3-generic-2/scope.json index 261ad368..df9d4a47 100644 --- a/test/fixtures/ast/vue3.3-generic-2/scope.json +++ b/test/fixtures/ast/vue3.3-generic-2/scope.json @@ -2,904 +2,1180 @@ "type": "global", "variables": [ { - "name": "ClassMemberDecoratorContext", + "name": "Intl", "identifiers": [], "defs": [], "references": [] }, { - "name": "DecoratorContext", + "name": "SymbolConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecoratorContext", + "name": "Function", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassMethodDecoratorContext", + "name": "Disposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassGetterDecoratorContext", + "name": "AsyncDisposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassSetterDecoratorContext", + "name": "SuppressedError", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorContext", + "name": "SuppressedErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorTarget", + "name": "DisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorResult", + "name": "DisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassFieldDecoratorContext", + "name": "AsyncDisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecorator", + "name": "AsyncDisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "AsyncIteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "ReadonlySetLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "Set", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "ReadonlySet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Iterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "IteratorObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "PromiseConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "Float16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Float16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "Math", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "DataView", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "ArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "ArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "MapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "ObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "PromiseWithResolvers", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "RegExp", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "Atomics", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "SharedArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "SharedArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "String", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "ClassMemberDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "DecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "DecoratorMetadataObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "DecoratorMetadata", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "ClassDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "ClassMethodDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "ClassGetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "ClassSetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "ClassAccessorDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "ClassAccessorDecoratorTarget", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "ClassAccessorDecoratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "ClassFieldDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferTypes", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferLike", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "RegExpConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "FlatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "AsyncGenerator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "AsyncGeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "AsyncGeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "DateConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ArrayBufferTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "const", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "defineProps", + "name": "ImportAttributes", "identifiers": [], "defs": [], - "references": [ - { - "identifier": { - "type": "Identifier", + "references": [] + }, + { + "name": "EvalError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConcatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypedPropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructorLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseLike", + "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": "NoInfer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataViewConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Generator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyHandler", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", + "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 + }, + "start": { + "line": 5, + "column": 10 } } }, @@ -918,13 +1194,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -946,13 +1222,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } } @@ -963,13 +1239,13 @@ "node": { "type": "TSTypeAliasDeclaration", "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -982,13 +1258,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -997,13 +1273,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -1019,13 +1295,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } } @@ -1036,13 +1312,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 32 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1055,13 +1331,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1070,13 +1346,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1087,13 +1363,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -1102,13 +1378,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1123,13 +1399,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } } @@ -1140,13 +1416,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1159,13 +1435,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1174,13 +1450,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1191,13 +1467,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 7, - "column": 12 - }, "end": { "line": 7, "column": 15 + }, + "start": { + "line": 7, + "column": 12 } } }, @@ -1206,13 +1482,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1223,13 +1499,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1238,13 +1514,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1260,13 +1536,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1275,13 +1551,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1292,13 +1568,13 @@ "type": "Identifier", "name": "defineProps", "loc": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, @@ -1310,13 +1586,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -1328,13 +1604,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1343,13 +1619,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1360,13 +1636,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -1375,13 +1651,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1392,13 +1668,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -1411,13 +1687,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 7, - "column": 12 - }, "end": { "line": 7, "column": 15 + }, + "start": { + "line": 7, + "column": 12 } } }, @@ -1426,13 +1702,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1446,13 +1722,13 @@ "type": "Identifier", "name": "defineProps", "loc": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, @@ -1464,13 +1740,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -1482,13 +1758,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -1505,13 +1781,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, diff --git a/test/fixtures/ast/vue3.3-generic-3/ast.json b/test/fixtures/ast/vue3.3-generic-3/ast.json index 8dbd9da4..cb599c07 100644 --- a/test/fixtures/ast/vue3.3-generic-3/ast.json +++ b/test/fixtures/ast/vue3.3-generic-3/ast.json @@ -1,23 +1,30 @@ { "type": "Program", + "range": [ + 9, + 183 + ], "body": [ { "type": "TSTypeAliasDeclaration", + "declare": false, "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 14, 17 ], "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -31,13 +38,13 @@ 26 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 17 + }, + "start": { + "line": 2, + "column": 11 } } }, @@ -48,13 +55,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 20 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 20 } } } @@ -64,13 +71,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 11 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 11 } } }, @@ -79,13 +86,13 @@ 35 ], "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -94,61 +101,52 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 114, 115 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, "init": { "type": "CallExpression", + "arguments": [], "callee": { "type": "Identifier", + "decorators": [], "name": "defineProps", + "optional": false, "range": [ 118, 129 ], "loc": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, - "arguments": [], "optional": false, - "range": [ - 118, - 148 - ], - "loc": { - "start": { - "line": 5, - "column": 10 - }, - "end": { - "line": 5, - "column": 40 - } - }, - "typeParameters": { + "typeArguments": { "type": "TSTypeParameterInstantiation", "range": [ 129, @@ -163,32 +161,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 131, 134 ], "loc": { - "start": { - "line": 5, - "column": 23 - }, "end": { "line": 5, "column": 26 + }, + "start": { + "line": 5, + "column": 23 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 5, - "column": 26 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 26 } }, "range": [ @@ -199,19 +202,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 135, 136 ], "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -220,13 +225,13 @@ 136 ], "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } } @@ -236,13 +241,13 @@ 137 ], "loc": { - "start": { - "line": 5, - "column": 23 - }, "end": { "line": 5, "column": 29 + }, + "start": { + "line": 5, + "column": 23 } } }, @@ -251,32 +256,37 @@ "computed": false, "key": { "type": "Identifier", + "decorators": [], "name": "bar", + "optional": false, "range": [ 138, 141 ], "loc": { - "start": { - "line": 5, - "column": 30 - }, "end": { "line": 5, "column": 33 + }, + "start": { + "line": 5, + "column": 30 } } }, + "optional": false, + "readonly": false, + "static": false, "typeAnnotation": { "type": "TSTypeAnnotation", "loc": { - "start": { - "line": 5, - "column": 33 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 33 } }, "range": [ @@ -287,19 +297,21 @@ "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 143, 144 ], "loc": { - "start": { - "line": 5, - "column": 35 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 35 } } }, @@ -308,13 +320,13 @@ 144 ], "loc": { - "start": { - "line": 5, - "column": 35 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 35 } } } @@ -324,13 +336,13 @@ 144 ], "loc": { - "start": { - "line": 5, - "column": 30 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 30 } } } @@ -340,27 +352,41 @@ 145 ], "loc": { - "start": { - "line": 5, - "column": 22 - }, "end": { "line": 5, "column": 37 + }, + "start": { + "line": 5, + "column": 22 } } } ], "loc": { - "start": { - "line": 5, - "column": 21 - }, "end": { "line": 5, "column": 38 + }, + "start": { + "line": 5, + "column": 21 } } + }, + "range": [ + 118, + 148 + ], + "loc": { + "end": { + "line": 5, + "column": 40 + }, + "start": { + "line": 5, + "column": 10 + } } }, "range": [ @@ -368,30 +394,31 @@ 148 ], "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 40 + }, + "start": { + "line": 5, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 108, 148 ], "loc": { - "start": { - "line": 5, - "column": 0 - }, "end": { "line": 5, "column": 40 + }, + "start": { + "line": 5, + "column": 0 } } }, @@ -400,76 +427,83 @@ "declarations": [ { "type": "VariableDeclarator", + "definite": false, "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 155, 158 ], "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, "init": { "type": "MemberExpression", + "computed": false, "object": { "type": "Identifier", + "decorators": [], "name": "p", + "optional": false, "range": [ 161, 162 ], "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 163, 166 ], "loc": { - "start": { - "line": 6, - "column": 14 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 14 } } }, - "computed": false, - "optional": false, "range": [ 161, 166 ], "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -478,125 +512,132 @@ 166 ], "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 6 } } } ], + "declare": false, "kind": "const", "range": [ 149, 166 ], "loc": { - "start": { - "line": 6, - "column": 0 - }, "end": { "line": 6, "column": 17 - } - } - }, + }, + "start": { + "line": 6, + "column": 0 + } + } + }, { "type": "ExpressionStatement", "expression": { "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 179, + 182 + ], + "loc": { + "end": { + "line": 7, + "column": 15 + }, + "start": { + "line": 7, + "column": 12 + } + } + } + ], "callee": { "type": "MemberExpression", + "computed": false, "object": { "type": "Identifier", + "decorators": [], "name": "console", + "optional": false, "range": [ 167, 174 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, + "optional": false, "property": { "type": "Identifier", + "decorators": [], "name": "log", + "optional": false, "range": [ 175, 178 ], "loc": { - "start": { - "line": 7, - "column": 8 - }, "end": { "line": 7, "column": 11 + }, + "start": { + "line": 7, + "column": 8 } } }, - "computed": false, - "optional": false, "range": [ 167, 178 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 11 + }, + "start": { + "line": 7, + "column": 0 } } }, - "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 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -605,32 +646,19 @@ 183 ], "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 16 + }, + "start": { + "line": 7, + "column": 0 } } } ], + "comments": [], "sourceType": "module", - "range": [ - 9, - 183 - ], - "loc": { - "start": { - "line": 2, - "column": 0 - }, - "end": { - "line": 7, - "column": 16 - } - }, "tokens": [ { "type": "Punctuator", @@ -652,111 +680,111 @@ }, { "type": "Identifier", - "value": "type", + "loc": { + "end": { + "line": 2, + "column": 4 + }, + "start": { + "line": 2, + "column": 0 + } + }, "range": [ 9, 13 ], + "value": "type" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 2, - "column": 4 + "column": 5 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 14, 17 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 5 + "column": 10 }, - "end": { + "start": { "line": 2, - "column": 8 + "column": 9 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 18, 19 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 9 + "column": 17 }, - "end": { + "start": { "line": 2, - "column": 10 + "column": 11 } - } - }, - { - "type": "Identifier", - "value": "number", + }, "range": [ 20, 26 ], + "value": "number" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 2, - "column": 11 + "column": 19 }, - "end": { + "start": { "line": 2, - "column": 17 + "column": 18 } - } - }, - { - "type": "Punctuator", - "value": "|", + }, "range": [ 27, 28 ], + "value": "|" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 2, - "column": 18 + "column": 26 }, - "end": { + "start": { "line": 2, - "column": 19 + "column": 20 } - } - }, - { - "type": "Identifier", - "value": "string", + }, "range": [ 29, 35 ], - "loc": { - "start": { - "line": 2, - "column": 20 - }, - "end": { - "line": 2, - "column": 26 - } - } + "value": "string" }, { "type": "Punctuator", @@ -796,525 +824,525 @@ }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 5, + "column": 5 + }, + "start": { + "line": 5, + "column": 0 + } + }, "range": [ 108, 113 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 0 + "column": 7 }, - "end": { + "start": { "line": 5, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 114, 115 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 6 + "column": 9 }, - "end": { + "start": { "line": 5, - "column": 7 + "column": 8 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 116, 117 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 8 + "column": 21 }, - "end": { + "start": { "line": 5, - "column": 9 + "column": 10 } - } - }, - { - "type": "Identifier", - "value": "defineProps", + }, "range": [ 118, 129 ], + "value": "defineProps" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 10 + "column": 22 }, - "end": { + "start": { "line": 5, "column": 21 } - } - }, - { - "type": "Punctuator", - "value": "<", + }, "range": [ 129, 130 ], + "value": "<" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 21 + "column": 23 }, - "end": { + "start": { "line": 5, "column": 22 } - } - }, - { - "type": "Punctuator", - "value": "{", + }, "range": [ 130, 131 ], + "value": "{" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 22 + "column": 26 }, - "end": { + "start": { "line": 5, "column": 23 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 131, 134 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 23 + "column": 27 }, - "end": { + "start": { "line": 5, "column": 26 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 134, 135 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 26 + "column": 28 }, - "end": { + "start": { "line": 5, "column": 27 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 135, 136 ], + "value": "T" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 27 + "column": 29 }, - "end": { + "start": { "line": 5, "column": 28 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 136, 137 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 28 + "column": 33 }, - "end": { + "start": { "line": 5, - "column": 29 + "column": 30 } - } - }, - { - "type": "Identifier", - "value": "bar", + }, "range": [ 138, 141 ], + "value": "bar" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 30 + "column": 34 }, - "end": { + "start": { "line": 5, "column": 33 } - } - }, - { - "type": "Punctuator", - "value": ":", + }, "range": [ 141, 142 ], + "value": ":" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 5, - "column": 33 + "column": 36 }, - "end": { + "start": { "line": 5, - "column": 34 + "column": 35 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 143, 144 ], + "value": "U" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 35 + "column": 37 }, - "end": { + "start": { "line": 5, "column": 36 } - } - }, - { - "type": "Punctuator", - "value": "}", + }, "range": [ 144, 145 ], + "value": "}" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 36 + "column": 38 }, - "end": { + "start": { "line": 5, "column": 37 } - } - }, - { - "type": "Punctuator", - "value": ">", + }, "range": [ 145, 146 ], + "value": ">" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 37 + "column": 39 }, - "end": { + "start": { "line": 5, "column": 38 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 146, 147 ], + "value": "(" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 5, - "column": 38 + "column": 40 }, - "end": { + "start": { "line": 5, "column": 39 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 147, 148 ], - "loc": { - "start": { - "line": 5, - "column": 39 - }, - "end": { - "line": 5, - "column": 40 - } - } + "value": ")" }, { "type": "Keyword", - "value": "const", + "loc": { + "end": { + "line": 6, + "column": 5 + }, + "start": { + "line": 6, + "column": 0 + } + }, "range": [ 149, 154 ], + "value": "const" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 6, - "column": 0 + "column": 9 }, - "end": { + "start": { "line": 6, - "column": 5 + "column": 6 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 155, 158 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 6, - "column": 6 + "column": 11 }, - "end": { + "start": { "line": 6, - "column": 9 + "column": 10 } - } - }, - { - "type": "Punctuator", - "value": "=", + }, "range": [ 159, 160 ], + "value": "=" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 6, - "column": 10 + "column": 13 }, - "end": { + "start": { "line": 6, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "p", + }, "range": [ 161, 162 ], + "value": "p" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 6, - "column": 12 + "column": 14 }, - "end": { + "start": { "line": 6, "column": 13 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 162, 163 ], - "loc": { - "start": { - "line": 6, - "column": 13 - }, - "end": { - "line": 6, - "column": 14 - } - } + "value": "." }, { "type": "Identifier", - "value": "foo", - "range": [ - 163, - 166 - ], "loc": { - "start": { - "line": 6, - "column": 14 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 14 } - } + }, + "range": [ + 163, + 166 + ], + "value": "foo" }, { "type": "Identifier", - "value": "console", + "loc": { + "end": { + "line": 7, + "column": 7 + }, + "start": { + "line": 7, + "column": 0 + } + }, "range": [ 167, 174 ], + "value": "console" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 0 + "column": 8 }, - "end": { + "start": { "line": 7, "column": 7 } - } - }, - { - "type": "Punctuator", - "value": ".", + }, "range": [ 174, 175 ], + "value": "." + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 7 + "column": 11 }, - "end": { + "start": { "line": 7, "column": 8 } - } - }, - { - "type": "Identifier", - "value": "log", + }, "range": [ 175, 178 ], + "value": "log" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 8 + "column": 12 }, - "end": { + "start": { "line": 7, "column": 11 } - } - }, - { - "type": "Punctuator", - "value": "(", + }, "range": [ 178, 179 ], + "value": "(" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 7, - "column": 11 + "column": 15 }, - "end": { + "start": { "line": 7, "column": 12 } - } - }, - { - "type": "Identifier", - "value": "foo", + }, "range": [ 179, 182 ], + "value": "foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 7, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 7, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ")", + }, "range": [ 182, 183 ], - "loc": { - "start": { - "line": 7, - "column": 15 - }, - "end": { - "line": 7, - "column": 16 - } - } + "value": ")" }, { "type": "Punctuator", @@ -1335,7 +1363,16 @@ "value": "" } ], - "comments": [], + "loc": { + "end": { + "line": 7, + "column": 16 + }, + "start": { + "line": 2, + "column": 0 + } + }, "templateBody": { "type": "VElement", "range": [ @@ -1411,19 +1448,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 207, 210 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1431,19 +1470,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 207, 210 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1961,129 +2002,129 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 43 + "column": 47 }, - "end": { + "start": { "line": 4, "column": 46 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 92, 93 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 46 + "column": 49 }, - "end": { + "start": { "line": 4, - "column": 47 + "column": 48 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 94, 95 ], + "value": "U" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 48 + "column": 57 }, - "end": { + "start": { "line": 4, - "column": 49 + "column": 50 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 96, 103 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 50 + "column": 59 }, - "end": { + "start": { "line": 4, - "column": 57 + "column": 58 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 104, 105 ], - "loc": { - "start": { - "line": 4, - "column": 58 - }, - "end": { - "line": 4, - "column": 59 - } - } + "value": "T" }, { "type": "Punctuator", @@ -2663,21 +2704,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 207, - 210 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 207, + 210 + ], + "value": "foo" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/ast/vue3.3-generic-3/scope.json b/test/fixtures/ast/vue3.3-generic-3/scope.json index 07bfd168..01a2cda1 100644 --- a/test/fixtures/ast/vue3.3-generic-3/scope.json +++ b/test/fixtures/ast/vue3.3-generic-3/scope.json @@ -2,904 +2,1180 @@ "type": "global", "variables": [ { - "name": "ClassMemberDecoratorContext", + "name": "Intl", "identifiers": [], "defs": [], "references": [] }, { - "name": "DecoratorContext", + "name": "SymbolConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecoratorContext", + "name": "Function", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassMethodDecoratorContext", + "name": "Disposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassGetterDecoratorContext", + "name": "AsyncDisposable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassSetterDecoratorContext", + "name": "SuppressedError", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorContext", + "name": "SuppressedErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorTarget", + "name": "DisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassAccessorDecoratorResult", + "name": "DisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassFieldDecoratorContext", + "name": "AsyncDisposableStack", "identifiers": [], "defs": [], "references": [] }, { - "name": "ClassDecorator", + "name": "AsyncDisposableStackConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDecorator", + "name": "IteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "MethodDecorator", + "name": "AsyncIteratorObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "ParameterDecorator", + "name": "ReadonlySetLike", "identifiers": [], "defs": [], "references": [] }, { - "name": "Symbol", + "name": "Set", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyKey", + "name": "ReadonlySet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptor", + "name": "ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PropertyDescriptorMap", + "name": "Iterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Object", + "name": "IteratorObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ObjectConstructor", + "name": "PromiseConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Function", + "name": "Float16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "FunctionConstructor", + "name": "Float16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisParameterType", + "name": "Math", "identifiers": [], "defs": [], "references": [] }, { - "name": "OmitThisParameter", + "name": "DataView", "identifiers": [], "defs": [], "references": [] }, { - "name": "CallableFunction", + "name": "ArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NewableFunction", + "name": "ArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IArguments", + "name": "MapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "String", + "name": "ObjectConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "StringConstructor", + "name": "PromiseWithResolvers", "identifiers": [], "defs": [], "references": [] }, { - "name": "Boolean", + "name": "RegExp", "identifiers": [], "defs": [], "references": [] }, { - "name": "BooleanConstructor", + "name": "Atomics", "identifiers": [], "defs": [], "references": [] }, { - "name": "Number", + "name": "SharedArrayBuffer", "identifiers": [], "defs": [], "references": [] }, { - "name": "NumberConstructor", + "name": "SharedArrayBufferConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TemplateStringsArray", + "name": "String", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportMeta", + "name": "ClassMemberDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportCallOptions", + "name": "DecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "ImportAssertions", + "name": "DecoratorMetadataObject", "identifiers": [], "defs": [], "references": [] }, { - "name": "Math", + "name": "DecoratorMetadata", "identifiers": [], "defs": [], "references": [] }, { - "name": "Date", + "name": "ClassDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "DateConstructor", + "name": "ClassMethodDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpMatchArray", + "name": "ClassGetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpExecArray", + "name": "ClassSetterDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExp", + "name": "ClassAccessorDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "RegExpConstructor", + "name": "ClassAccessorDecoratorTarget", "identifiers": [], "defs": [], "references": [] }, { - "name": "Error", + "name": "ClassAccessorDecoratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "ErrorConstructor", + "name": "ClassFieldDecoratorContext", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalError", + "name": "IteratorYieldResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "EvalErrorConstructor", + "name": "IteratorReturnResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeError", + "name": "IteratorResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "RangeErrorConstructor", + "name": "Iterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceError", + "name": "IterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReferenceErrorConstructor", + "name": "BuiltinIteratorReturn", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxError", + "name": "ArrayIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "SyntaxErrorConstructor", + "name": "Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeError", + "name": "ReadonlyArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypeErrorConstructor", + "name": "IArguments", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIError", + "name": "MapIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "URIErrorConstructor", + "name": "Map", "identifiers": [], "defs": [], "references": [] }, { - "name": "JSON", + "name": "ReadonlyMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyArray", + "name": "WeakMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConcatArray", + "name": "WeakMapConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Array", + "name": "SetIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayConstructor", + "name": "SetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "TypedPropertyDescriptor", + "name": "WeakSet", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructorLike", + "name": "WeakSetConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseLike", + "name": "Promise", "identifiers": [], "defs": [], "references": [] }, { - "name": "Promise", + "name": "StringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "Awaited", + "name": "Int8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayLike", + "name": "Int8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Partial", + "name": "Uint8Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Required", + "name": "Uint8ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Readonly", + "name": "Uint8ClampedArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Pick", + "name": "Uint8ClampedArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Record", + "name": "Int16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Exclude", + "name": "Int16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Extract", + "name": "Uint16Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Omit", + "name": "Uint16ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "NonNullable", + "name": "Int32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Parameters", + "name": "Int32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ConstructorParameters", + "name": "Uint32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReturnType", + "name": "Uint32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "InstanceType", + "name": "Float32Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uppercase", + "name": "Float32ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Lowercase", + "name": "Float64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "Capitalize", + "name": "Float64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uncapitalize", + "name": "AsyncIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ThisType", + "name": "AsyncIterable", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBuffer", + "name": "AsyncIterableIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferTypes", + "name": "BigInt64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferLike", + "name": "BigUint64Array", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferConstructor", + "name": "WeakKeyTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "ArrayBufferView", + "name": "BigIntToLocaleStringOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataView", + "name": "BigInt", "identifiers": [], "defs": [], "references": [] }, { - "name": "DataViewConstructor", + "name": "BigIntConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8Array", + "name": "BigInt64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int8ArrayConstructor", + "name": "BigUint64ArrayConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8Array", + "name": "ErrorOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ArrayConstructor", + "name": "Error", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArray", + "name": "ErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint8ClampedArrayConstructor", + "name": "EvalErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16Array", + "name": "RangeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int16ArrayConstructor", + "name": "ReferenceErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16Array", + "name": "SyntaxErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint16ArrayConstructor", + "name": "TypeErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32Array", + "name": "URIErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Int32ArrayConstructor", + "name": "AggregateErrorConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32Array", + "name": "RegExpMatchArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Uint32ArrayConstructor", + "name": "RegExpExecArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32Array", + "name": "RegExpIndicesArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float32ArrayConstructor", + "name": "AggregateError", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64Array", + "name": "WeakRef", "identifiers": [], "defs": [], "references": [] }, { - "name": "Float64ArrayConstructor", + "name": "WeakRefConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Intl", + "name": "FinalizationRegistry", "identifiers": [], "defs": [], "references": [] }, { - "name": "Map", + "name": "FinalizationRegistryConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "MapConstructor", + "name": "Date", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlyMap", + "name": "Number", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMap", + "name": "PromiseFulfilledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakMapConstructor", + "name": "PromiseRejectedResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "Set", + "name": "PromiseSettledResult", "identifiers": [], "defs": [], "references": [] }, { - "name": "SetConstructor", + "name": "RegExpStringIterator", "identifiers": [], "defs": [], "references": [] }, { - "name": "ReadonlySet", + "name": "Symbol", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSet", + "name": "JSON", "identifiers": [], "defs": [], "references": [] }, { - "name": "WeakSetConstructor", + "name": "GeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SymbolConstructor", + "name": "RegExpConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorYieldResult", + "name": "FlatArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorReturnResult", + "name": "AsyncGenerator", "identifiers": [], "defs": [], "references": [] }, { - "name": "IteratorResult", + "name": "AsyncGeneratorFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterator", + "name": "AsyncGeneratorFunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "Iterable", + "name": "DateConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "IterableIterator", + "name": "ArrayBufferTypes", "identifiers": [], "defs": [], "references": [] }, { - "name": "PromiseConstructor", + "name": "PropertyKey", "identifiers": [], "defs": [], "references": [] }, { - "name": "Generator", + "name": "PropertyDescriptor", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunction", + "name": "PropertyDescriptorMap", "identifiers": [], "defs": [], "references": [] }, { - "name": "GeneratorFunctionConstructor", + "name": "Object", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyHandler", + "name": "FunctionConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "ProxyConstructor", + "name": "ThisParameterType", "identifiers": [], "defs": [], "references": [] }, { - "name": "Reflect", + "name": "OmitThisParameter", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBuffer", + "name": "CallableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "SharedArrayBufferConstructor", + "name": "NewableFunction", "identifiers": [], "defs": [], "references": [] }, { - "name": "Atomics", + "name": "StringConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterator", + "name": "Boolean", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterable", + "name": "BooleanConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncIterableIterator", + "name": "NumberConstructor", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGenerator", + "name": "TemplateStringsArray", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunction", + "name": "ImportMeta", "identifiers": [], "defs": [], "references": [] }, { - "name": "AsyncGeneratorFunctionConstructor", + "name": "ImportCallOptions", "identifiers": [], "defs": [], "references": [] }, { - "name": "const", + "name": "ImportAssertions", "identifiers": [], "defs": [], "references": [] }, { - "name": "defineProps", + "name": "ImportAttributes", "identifiers": [], "defs": [], - "references": [ - { - "identifier": { - "type": "Identifier", + "references": [] + }, + { + "name": "EvalError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "RangeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ReferenceError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "SyntaxError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypeError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "URIError", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ConcatArray", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "TypedPropertyDescriptor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseConstructorLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PromiseLike", + "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": "NoInfer", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ThisType", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "WeakKey", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferLike", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ArrayBufferView", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "DataViewConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Generator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "GeneratorFunctionConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyHandler", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ProxyConstructor", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "Reflect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ClassDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "PropertyDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "MethodDecorator", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "ParameterDecorator", + "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 + }, + "start": { + "line": 5, + "column": 10 } } }, @@ -918,13 +1194,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -943,13 +1219,13 @@ "type": "Identifier", "name": "U", "loc": { - "start": { - "line": 5, - "column": 35 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 35 } } }, @@ -971,13 +1247,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } } @@ -988,13 +1264,13 @@ "node": { "type": "TSTypeAliasDeclaration", "loc": { - "start": { - "line": 2, - "column": 0 - }, "end": { "line": 2, "column": 26 + }, + "start": { + "line": 2, + "column": 0 } } }, @@ -1007,13 +1283,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -1022,13 +1298,13 @@ "type": "Identifier", "name": "Foo", "loc": { - "start": { - "line": 2, - "column": 5 - }, "end": { "line": 2, "column": 8 + }, + "start": { + "line": 2, + "column": 5 } } }, @@ -1044,13 +1320,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } } @@ -1061,13 +1337,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 40 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1080,13 +1356,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1095,13 +1371,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1112,13 +1388,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -1127,13 +1403,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1148,13 +1424,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } } @@ -1165,13 +1441,13 @@ "node": { "type": "VariableDeclarator", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 17 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1184,13 +1460,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1199,13 +1475,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1216,13 +1492,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 7, - "column": 12 - }, "end": { "line": 7, "column": 15 + }, + "start": { + "line": 7, + "column": 12 } } }, @@ -1231,13 +1507,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1248,13 +1524,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1263,13 +1539,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1285,13 +1561,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1300,13 +1576,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1317,13 +1593,13 @@ "type": "Identifier", "name": "defineProps", "loc": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, @@ -1335,13 +1611,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -1353,13 +1629,13 @@ "type": "Identifier", "name": "U", "loc": { - "start": { - "line": 5, - "column": 35 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 35 } } }, @@ -1371,13 +1647,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1386,13 +1662,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1403,13 +1679,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 6, - "column": 12 - }, "end": { "line": 6, "column": 13 + }, + "start": { + "line": 6, + "column": 12 } } }, @@ -1418,13 +1694,13 @@ "type": "Identifier", "name": "p", "loc": { - "start": { - "line": 5, - "column": 6 - }, "end": { "line": 5, "column": 7 + }, + "start": { + "line": 5, + "column": 6 } } }, @@ -1435,13 +1711,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -1454,13 +1730,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 7, - "column": 12 - }, "end": { "line": 7, "column": 15 + }, + "start": { + "line": 7, + "column": 12 } } }, @@ -1469,13 +1745,13 @@ "type": "Identifier", "name": "foo", "loc": { - "start": { - "line": 6, - "column": 6 - }, "end": { "line": 6, "column": 9 + }, + "start": { + "line": 6, + "column": 6 } } }, @@ -1489,13 +1765,13 @@ "type": "Identifier", "name": "defineProps", "loc": { - "start": { - "line": 5, - "column": 10 - }, "end": { "line": 5, "column": 21 + }, + "start": { + "line": 5, + "column": 10 } } }, @@ -1507,13 +1783,13 @@ "type": "Identifier", "name": "T", "loc": { - "start": { - "line": 5, - "column": 27 - }, "end": { "line": 5, "column": 28 + }, + "start": { + "line": 5, + "column": 27 } } }, @@ -1525,13 +1801,13 @@ "type": "Identifier", "name": "U", "loc": { - "start": { - "line": 5, - "column": 35 - }, "end": { "line": 5, "column": 36 + }, + "start": { + "line": 5, + "column": 35 } } }, @@ -1543,13 +1819,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, @@ -1566,13 +1842,13 @@ "type": "Identifier", "name": "console", "loc": { - "start": { - "line": 7, - "column": 0 - }, "end": { "line": 7, "column": 7 + }, + "start": { + "line": 7, + "column": 0 } } }, diff --git a/test/fixtures/ast/vue3.3-generic-4-with-spaces/ast.json b/test/fixtures/ast/vue3.3-generic-4-with-spaces/ast.json new file mode 100644 index 00000000..6efed59a --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-4-with-spaces/ast.json @@ -0,0 +1,2674 @@ +{ + "type": "Program", + "range": [ + 92, + 195 + ], + "body": [ + { + "type": "TSTypeAliasDeclaration", + "declare": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 97, + 100 + ], + "loc": { + "end": { + "line": 8, + "column": 8 + }, + "start": { + "line": 8, + "column": 5 + } + } + }, + "typeAnnotation": { + "type": "TSUnionType", + "types": [ + { + "type": "TSNumberKeyword", + "range": [ + 103, + 109 + ], + "loc": { + "end": { + "line": 8, + "column": 17 + }, + "start": { + "line": 8, + "column": 11 + } + } + }, + { + "type": "TSStringKeyword", + "range": [ + 112, + 118 + ], + "loc": { + "end": { + "line": 8, + "column": 26 + }, + "start": { + "line": 8, + "column": 20 + } + } + } + ], + "range": [ + 103, + 118 + ], + "loc": { + "end": { + "line": 8, + "column": 26 + }, + "start": { + "line": 8, + "column": 11 + } + } + }, + "range": [ + 92, + 118 + ], + "loc": { + "end": { + "line": 8, + "column": 26 + }, + "start": { + "line": 8, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 125, + 126 + ], + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineProps", + "optional": false, + "range": [ + 129, + 140 + ], + "loc": { + "end": { + "line": 9, + "column": 21 + }, + "start": { + "line": 9, + "column": 10 + } + } + }, + "optional": false, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 140, + 157 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 142, + 145 + ], + "loc": { + "end": { + "line": 9, + "column": 26 + }, + "start": { + "line": 9, + "column": 23 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 9, + "column": 28 + }, + "start": { + "line": 9, + "column": 26 + } + }, + "range": [ + 145, + 147 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 146, + 147 + ], + "loc": { + "end": { + "line": 9, + "column": 28 + }, + "start": { + "line": 9, + "column": 27 + } + } + }, + "range": [ + 146, + 147 + ], + "loc": { + "end": { + "line": 9, + "column": 28 + }, + "start": { + "line": 9, + "column": 27 + } + } + } + }, + "range": [ + 142, + 148 + ], + "loc": { + "end": { + "line": 9, + "column": 29 + }, + "start": { + "line": 9, + "column": 23 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "bar", + "optional": false, + "range": [ + 149, + 152 + ], + "loc": { + "end": { + "line": 9, + "column": 33 + }, + "start": { + "line": 9, + "column": 30 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 9, + "column": 36 + }, + "start": { + "line": 9, + "column": 33 + } + }, + "range": [ + 152, + 155 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 154, + 155 + ], + "loc": { + "end": { + "line": 9, + "column": 36 + }, + "start": { + "line": 9, + "column": 35 + } + } + }, + "range": [ + 154, + 155 + ], + "loc": { + "end": { + "line": 9, + "column": 36 + }, + "start": { + "line": 9, + "column": 35 + } + } + } + }, + "range": [ + 149, + 155 + ], + "loc": { + "end": { + "line": 9, + "column": 36 + }, + "start": { + "line": 9, + "column": 30 + } + } + } + ], + "range": [ + 141, + 156 + ], + "loc": { + "end": { + "line": 9, + "column": 37 + }, + "start": { + "line": 9, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 9, + "column": 38 + }, + "start": { + "line": 9, + "column": 21 + } + } + }, + "range": [ + 129, + 159 + ], + "loc": { + "end": { + "line": 9, + "column": 40 + }, + "start": { + "line": 9, + "column": 10 + } + } + }, + "range": [ + 125, + 159 + ], + "loc": { + "end": { + "line": 9, + "column": 40 + }, + "start": { + "line": 9, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 119, + 159 + ], + "loc": { + "end": { + "line": 9, + "column": 40 + }, + "start": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 166, + 169 + ], + "loc": { + "end": { + "line": 10, + "column": 9 + }, + "start": { + "line": 10, + "column": 6 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 172, + 173 + ], + "loc": { + "end": { + "line": 10, + "column": 13 + }, + "start": { + "line": 10, + "column": 12 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 174, + 177 + ], + "loc": { + "end": { + "line": 10, + "column": 17 + }, + "start": { + "line": 10, + "column": 14 + } + } + }, + "range": [ + 172, + 177 + ], + "loc": { + "end": { + "line": 10, + "column": 17 + }, + "start": { + "line": 10, + "column": 12 + } + } + }, + "range": [ + 166, + 177 + ], + "loc": { + "end": { + "line": 10, + "column": 17 + }, + "start": { + "line": 10, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 160, + 177 + ], + "loc": { + "end": { + "line": 10, + "column": 17 + }, + "start": { + "line": 10, + "column": 0 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 190, + 193 + ], + "loc": { + "end": { + "line": 11, + "column": 15 + }, + "start": { + "line": 11, + "column": 12 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "console", + "optional": false, + "range": [ + 178, + 185 + ], + "loc": { + "end": { + "line": 11, + "column": 7 + }, + "start": { + "line": 11, + "column": 0 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "log", + "optional": false, + "range": [ + 186, + 189 + ], + "loc": { + "end": { + "line": 11, + "column": 11 + }, + "start": { + "line": 11, + "column": 8 + } + } + }, + "range": [ + 178, + 189 + ], + "loc": { + "end": { + "line": 11, + "column": 11 + }, + "start": { + "line": 11, + "column": 0 + } + } + }, + "optional": false, + "range": [ + 178, + 194 + ], + "loc": { + "end": { + "line": 11, + "column": 16 + }, + "start": { + "line": 11, + "column": 0 + } + } + }, + "range": [ + 178, + 194 + ], + "loc": { + "end": { + "line": 11, + "column": 16 + }, + "start": { + "line": 11, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 91 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 12, + "column": 0 + }, + "start": { + "line": 8, + "column": 0 + } + }, + "templateBody": { + "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", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 218, + 221 + ], + "loc": { + "end": { + "line": 14, + "column": 5 + }, + "start": { + "line": 14, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 218, + 221 + ], + "loc": { + "end": { + "line": 14, + "column": 5 + }, + "start": { + "line": 14, + "column": 2 + } + } + }, + "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", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 42, + 49 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 50, + 53 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 16 + }, + "start": { + "line": 3, + "column": 15 + } + }, + "range": [ + 53, + 54 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 73, + 74 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 5, + "column": 11 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 75, + 82 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 6, + "column": 5 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 87, + 88 + ], + "value": "T" + }, + { + "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", + "loc": { + "end": { + "line": 14, + "column": 5 + }, + "start": { + "line": 14, + "column": 2 + } + }, + "range": [ + 218, + 221 + ], + "value": "foo" + }, + { + "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", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 59, + 70 + ], + "value": " Comments" + } + ], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-4-with-spaces/parser-options.json b/test/fixtures/ast/vue3.3-generic-4-with-spaces/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/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/ast/vue3.3-generic-4-with-spaces/source.vue b/test/fixtures/ast/vue3.3-generic-4-with-spaces/source.vue new file mode 100644 index 00000000..7b4d167f --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-4-with-spaces/source.vue @@ -0,0 +1,15 @@ + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-4-with-spaces/token-ranges.json b/test/fixtures/ast/vue3.3-generic-4-with-spaces/token-ranges.json new file mode 100644 index 00000000..66951b9a --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-4-with-spaces/token-ranges.json @@ -0,0 +1,104 @@ +[ + "", + "", + "\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/ast/vue3.3-generic-4-with-spaces/tree.json b/test/fixtures/ast/vue3.3-generic-4-with-spaces/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-4-with-spaces/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-5-with-spaces/ast.json b/test/fixtures/ast/vue3.3-generic-5-with-spaces/ast.json new file mode 100644 index 00000000..b2319f0c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-5-with-spaces/ast.json @@ -0,0 +1,2800 @@ +{ + "type": "Program", + "range": [ + 142, + 245 + ], + "body": [ + { + "type": "TSTypeAliasDeclaration", + "declare": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 147, + 150 + ], + "loc": { + "end": { + "line": 9, + "column": 8 + }, + "start": { + "line": 9, + "column": 5 + } + } + }, + "typeAnnotation": { + "type": "TSUnionType", + "types": [ + { + "type": "TSNumberKeyword", + "range": [ + 153, + 159 + ], + "loc": { + "end": { + "line": 9, + "column": 17 + }, + "start": { + "line": 9, + "column": 11 + } + } + }, + { + "type": "TSStringKeyword", + "range": [ + 162, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 26 + }, + "start": { + "line": 9, + "column": 20 + } + } + } + ], + "range": [ + 153, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 26 + }, + "start": { + "line": 9, + "column": 11 + } + } + }, + "range": [ + 142, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 26 + }, + "start": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 175, + 176 + ], + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineProps", + "optional": false, + "range": [ + 179, + 190 + ], + "loc": { + "end": { + "line": 10, + "column": 21 + }, + "start": { + "line": 10, + "column": 10 + } + } + }, + "optional": false, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 190, + 207 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 192, + 195 + ], + "loc": { + "end": { + "line": 10, + "column": 26 + }, + "start": { + "line": 10, + "column": 23 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 10, + "column": 28 + }, + "start": { + "line": 10, + "column": 26 + } + }, + "range": [ + 195, + 197 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 196, + 197 + ], + "loc": { + "end": { + "line": 10, + "column": 28 + }, + "start": { + "line": 10, + "column": 27 + } + } + }, + "range": [ + 196, + 197 + ], + "loc": { + "end": { + "line": 10, + "column": 28 + }, + "start": { + "line": 10, + "column": 27 + } + } + } + }, + "range": [ + 192, + 198 + ], + "loc": { + "end": { + "line": 10, + "column": 29 + }, + "start": { + "line": 10, + "column": 23 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "bar", + "optional": false, + "range": [ + 199, + 202 + ], + "loc": { + "end": { + "line": 10, + "column": 33 + }, + "start": { + "line": 10, + "column": 30 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 10, + "column": 36 + }, + "start": { + "line": 10, + "column": 33 + } + }, + "range": [ + 202, + 205 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 204, + 205 + ], + "loc": { + "end": { + "line": 10, + "column": 36 + }, + "start": { + "line": 10, + "column": 35 + } + } + }, + "range": [ + 204, + 205 + ], + "loc": { + "end": { + "line": 10, + "column": 36 + }, + "start": { + "line": 10, + "column": 35 + } + } + } + }, + "range": [ + 199, + 205 + ], + "loc": { + "end": { + "line": 10, + "column": 36 + }, + "start": { + "line": 10, + "column": 30 + } + } + } + ], + "range": [ + 191, + 206 + ], + "loc": { + "end": { + "line": 10, + "column": 37 + }, + "start": { + "line": 10, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 10, + "column": 38 + }, + "start": { + "line": 10, + "column": 21 + } + } + }, + "range": [ + 179, + 209 + ], + "loc": { + "end": { + "line": 10, + "column": 40 + }, + "start": { + "line": 10, + "column": 10 + } + } + }, + "range": [ + 175, + 209 + ], + "loc": { + "end": { + "line": 10, + "column": 40 + }, + "start": { + "line": 10, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 169, + 209 + ], + "loc": { + "end": { + "line": 10, + "column": 40 + }, + "start": { + "line": 10, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 216, + 219 + ], + "loc": { + "end": { + "line": 11, + "column": 9 + }, + "start": { + "line": 11, + "column": 6 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 222, + 223 + ], + "loc": { + "end": { + "line": 11, + "column": 13 + }, + "start": { + "line": 11, + "column": 12 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 224, + 227 + ], + "loc": { + "end": { + "line": 11, + "column": 17 + }, + "start": { + "line": 11, + "column": 14 + } + } + }, + "range": [ + 222, + 227 + ], + "loc": { + "end": { + "line": 11, + "column": 17 + }, + "start": { + "line": 11, + "column": 12 + } + } + }, + "range": [ + 216, + 227 + ], + "loc": { + "end": { + "line": 11, + "column": 17 + }, + "start": { + "line": 11, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 210, + 227 + ], + "loc": { + "end": { + "line": 11, + "column": 17 + }, + "start": { + "line": 11, + "column": 0 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 240, + 243 + ], + "loc": { + "end": { + "line": 12, + "column": 15 + }, + "start": { + "line": 12, + "column": 12 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "console", + "optional": false, + "range": [ + 228, + 235 + ], + "loc": { + "end": { + "line": 12, + "column": 7 + }, + "start": { + "line": 12, + "column": 0 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "log", + "optional": false, + "range": [ + 236, + 239 + ], + "loc": { + "end": { + "line": 12, + "column": 11 + }, + "start": { + "line": 12, + "column": 8 + } + } + }, + "range": [ + 228, + 239 + ], + "loc": { + "end": { + "line": 12, + "column": 11 + }, + "start": { + "line": 12, + "column": 0 + } + } + }, + "optional": false, + "range": [ + 228, + 244 + ], + "loc": { + "end": { + "line": 12, + "column": 16 + }, + "start": { + "line": 12, + "column": 0 + } + } + }, + "range": [ + 228, + 244 + ], + "loc": { + "end": { + "line": 12, + "column": 16 + }, + "start": { + "line": 12, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 141 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 13, + "column": 0 + }, + "start": { + "line": 9, + "column": 0 + } + }, + "templateBody": { + "type": "VElement", + "range": [ + 255, + 285 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 255, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 265, + 266 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 266, + 273 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 268, + 271 + ], + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 268, + 271 + ], + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 273, + 274 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 274, + 285 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "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", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 54, + 61 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 62, + 65 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 16 + }, + "start": { + "line": 3, + "column": 15 + } + }, + "range": [ + 65, + 66 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 85, + 86 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 106, + 113 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 118, + 124 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 124, + 128 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 20 + }, + "start": { + "line": 7, + "column": 14 + } + }, + "range": [ + 128, + 134 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 21 + }, + "start": { + "line": 7, + "column": 20 + } + }, + "range": [ + 134, + 135 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 23 + }, + "start": { + "line": 7, + "column": 22 + } + }, + "range": [ + 136, + 137 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 7, + "column": 23 + } + }, + "range": [ + 137, + 138 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 141, + 142 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 142, + 146 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 146, + 147 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 147, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 151, + 152 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 152, + 153 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 153, + 159 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 161 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 161, + 162 + ], + "loc": { + "start": { + "line": 9, + "column": 19 + }, + "end": { + "line": 9, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 162, + 168 + ], + "loc": { + "start": { + "line": 9, + "column": 20 + }, + "end": { + "line": 9, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 168, + 169 + ], + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 169, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 175, + 176 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 178, + 179 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 179, + 198 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 198, + 199 + ], + "loc": { + "start": { + "line": 10, + "column": 29 + }, + "end": { + "line": 10, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 199, + 203 + ], + "loc": { + "start": { + "line": 10, + "column": 30 + }, + "end": { + "line": 10, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 10, + "column": 34 + }, + "end": { + "line": 10, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 204, + 209 + ], + "loc": { + "start": { + "line": 10, + "column": 35 + }, + "end": { + "line": 10, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 209, + 210 + ], + "loc": { + "start": { + "line": 10, + "column": 40 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 210, + 215 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 215, + 216 + ], + "loc": { + "start": { + "line": 11, + "column": 5 + }, + "end": { + "line": 11, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 216, + 219 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 219, + 220 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 220, + 221 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 221, + 222 + ], + "loc": { + "start": { + "line": 11, + "column": 11 + }, + "end": { + "line": 11, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 222, + 227 + ], + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 227, + 228 + ], + "loc": { + "start": { + "line": 11, + "column": 17 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 228, + 244 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 244, + 245 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 245, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 253, + 254 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 254, + 255 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 255, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 265, + 266 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 266, + 268 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + }, + "range": [ + 268, + 271 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 271, + 273 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 273, + 274 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 274, + 284 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 15 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 71, + 82 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 18 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 87, + 101 + ], + "value": " Comments " + } + ], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-5-with-spaces/parser-options.json b/test/fixtures/ast/vue3.3-generic-5-with-spaces/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-5-with-spaces/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-5-with-spaces/source.vue b/test/fixtures/ast/vue3.3-generic-5-with-spaces/source.vue new file mode 100644 index 00000000..1ce43570 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-5-with-spaces/source.vue @@ -0,0 +1,16 @@ + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-5-with-spaces/token-ranges.json b/test/fixtures/ast/vue3.3-generic-5-with-spaces/token-ranges.json new file mode 100644 index 00000000..1af7d0bd --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-5-with-spaces/token-ranges.json @@ -0,0 +1,111 @@ +[ + "", + "", + "\"", + ">", + "\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", + "// Comments", + "/* Comments */" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-5-with-spaces/tree.json b/test/fixtures/ast/vue3.3-generic-5-with-spaces/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-5-with-spaces/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-6-with-default/ast.json b/test/fixtures/ast/vue3.3-generic-6-with-default/ast.json new file mode 100644 index 00000000..df9f6fee --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-6-with-default/ast.json @@ -0,0 +1,3016 @@ +{ + "type": "Program", + "range": [ + 228, + 331 + ], + "body": [ + { + "type": "TSTypeAliasDeclaration", + "declare": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 233, + 236 + ], + "loc": { + "end": { + "line": 14, + "column": 8 + }, + "start": { + "line": 14, + "column": 5 + } + } + }, + "typeAnnotation": { + "type": "TSUnionType", + "types": [ + { + "type": "TSNumberKeyword", + "range": [ + 239, + 245 + ], + "loc": { + "end": { + "line": 14, + "column": 17 + }, + "start": { + "line": 14, + "column": 11 + } + } + }, + { + "type": "TSStringKeyword", + "range": [ + 248, + 254 + ], + "loc": { + "end": { + "line": 14, + "column": 26 + }, + "start": { + "line": 14, + "column": 20 + } + } + } + ], + "range": [ + 239, + 254 + ], + "loc": { + "end": { + "line": 14, + "column": 26 + }, + "start": { + "line": 14, + "column": 11 + } + } + }, + "range": [ + 228, + 254 + ], + "loc": { + "end": { + "line": 14, + "column": 26 + }, + "start": { + "line": 14, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 261, + 262 + ], + "loc": { + "end": { + "line": 15, + "column": 7 + }, + "start": { + "line": 15, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineProps", + "optional": false, + "range": [ + 265, + 276 + ], + "loc": { + "end": { + "line": 15, + "column": 21 + }, + "start": { + "line": 15, + "column": 10 + } + } + }, + "optional": false, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 276, + 293 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 278, + 281 + ], + "loc": { + "end": { + "line": 15, + "column": 26 + }, + "start": { + "line": 15, + "column": 23 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 15, + "column": 28 + }, + "start": { + "line": 15, + "column": 26 + } + }, + "range": [ + 281, + 283 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 282, + 283 + ], + "loc": { + "end": { + "line": 15, + "column": 28 + }, + "start": { + "line": 15, + "column": 27 + } + } + }, + "range": [ + 282, + 283 + ], + "loc": { + "end": { + "line": 15, + "column": 28 + }, + "start": { + "line": 15, + "column": 27 + } + } + } + }, + "range": [ + 278, + 284 + ], + "loc": { + "end": { + "line": 15, + "column": 29 + }, + "start": { + "line": 15, + "column": 23 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "bar", + "optional": false, + "range": [ + 285, + 288 + ], + "loc": { + "end": { + "line": 15, + "column": 33 + }, + "start": { + "line": 15, + "column": 30 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 15, + "column": 36 + }, + "start": { + "line": 15, + "column": 33 + } + }, + "range": [ + 288, + 291 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 290, + 291 + ], + "loc": { + "end": { + "line": 15, + "column": 36 + }, + "start": { + "line": 15, + "column": 35 + } + } + }, + "range": [ + 290, + 291 + ], + "loc": { + "end": { + "line": 15, + "column": 36 + }, + "start": { + "line": 15, + "column": 35 + } + } + } + }, + "range": [ + 285, + 291 + ], + "loc": { + "end": { + "line": 15, + "column": 36 + }, + "start": { + "line": 15, + "column": 30 + } + } + } + ], + "range": [ + 277, + 292 + ], + "loc": { + "end": { + "line": 15, + "column": 37 + }, + "start": { + "line": 15, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 15, + "column": 38 + }, + "start": { + "line": 15, + "column": 21 + } + } + }, + "range": [ + 265, + 295 + ], + "loc": { + "end": { + "line": 15, + "column": 40 + }, + "start": { + "line": 15, + "column": 10 + } + } + }, + "range": [ + 261, + 295 + ], + "loc": { + "end": { + "line": 15, + "column": 40 + }, + "start": { + "line": 15, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 255, + 295 + ], + "loc": { + "end": { + "line": 15, + "column": 40 + }, + "start": { + "line": 15, + "column": 0 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 302, + 305 + ], + "loc": { + "end": { + "line": 16, + "column": 9 + }, + "start": { + "line": 16, + "column": 6 + } + } + }, + "init": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 308, + 309 + ], + "loc": { + "end": { + "line": 16, + "column": 13 + }, + "start": { + "line": 16, + "column": 12 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 310, + 313 + ], + "loc": { + "end": { + "line": 16, + "column": 17 + }, + "start": { + "line": 16, + "column": 14 + } + } + }, + "range": [ + 308, + 313 + ], + "loc": { + "end": { + "line": 16, + "column": 17 + }, + "start": { + "line": 16, + "column": 12 + } + } + }, + "range": [ + 302, + 313 + ], + "loc": { + "end": { + "line": 16, + "column": 17 + }, + "start": { + "line": 16, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 296, + 313 + ], + "loc": { + "end": { + "line": 16, + "column": 17 + }, + "start": { + "line": 16, + "column": 0 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 326, + 329 + ], + "loc": { + "end": { + "line": 17, + "column": 15 + }, + "start": { + "line": 17, + "column": 12 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "console", + "optional": false, + "range": [ + 314, + 321 + ], + "loc": { + "end": { + "line": 17, + "column": 7 + }, + "start": { + "line": 17, + "column": 0 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "log", + "optional": false, + "range": [ + 322, + 325 + ], + "loc": { + "end": { + "line": 17, + "column": 11 + }, + "start": { + "line": 17, + "column": 8 + } + } + }, + "range": [ + 314, + 325 + ], + "loc": { + "end": { + "line": 17, + "column": 11 + }, + "start": { + "line": 17, + "column": 0 + } + } + }, + "optional": false, + "range": [ + 314, + 330 + ], + "loc": { + "end": { + "line": 17, + "column": 16 + }, + "start": { + "line": 17, + "column": 0 + } + } + }, + "range": [ + 314, + 330 + ], + "loc": { + "end": { + "line": 17, + "column": 16 + }, + "start": { + "line": 17, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 227 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 13, + "column": 2 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 18, + "column": 0 + }, + "start": { + "line": 14, + "column": 0 + } + }, + "templateBody": { + "type": "VElement", + "range": [ + 341, + 371 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 341, + 351 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 351, + 352 + ], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 20, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 352, + 359 + ], + "loc": { + "start": { + "line": 20, + "column": 0 + }, + "end": { + "line": 20, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 354, + 357 + ], + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 354, + 357 + ], + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 359, + 360 + ], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 360, + 371 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "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", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 54, + 61 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + }, + "range": [ + 70, + 73 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 24 + } + }, + "range": [ + 74, + 75 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 76, + 82 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 32 + } + }, + "range": [ + 82, + 83 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 102, + 103 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 122, + 129 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 134, + 140 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 140, + 144 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 12 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 165, + 171 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 13 + }, + "start": { + "line": 9, + "column": 12 + } + }, + "range": [ + 171, + 172 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 184, + 185 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 11, + "column": 5 + }, + "start": { + "line": 11, + "column": 4 + } + }, + "range": [ + 190, + 191 + ], + "value": ">" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 6 + }, + "start": { + "line": 12, + "column": 5 + } + }, + "range": [ + 197, + 198 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 13 + }, + "start": { + "line": 12, + "column": 7 + } + }, + "range": [ + 199, + 205 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 14 + }, + "start": { + "line": 12, + "column": 13 + } + }, + "range": [ + 205, + 206 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 20 + }, + "start": { + "line": 12, + "column": 14 + } + }, + "range": [ + 206, + 212 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 21 + }, + "start": { + "line": 12, + "column": 20 + } + }, + "range": [ + 212, + 213 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 28 + }, + "start": { + "line": 12, + "column": 22 + } + }, + "range": [ + 214, + 220 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 12, + "column": 28 + } + }, + "range": [ + 220, + 224 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 225, + 226 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 226, + 227 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 227, + 228 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 228, + 232 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 232, + 233 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 233, + 236 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 236, + 237 + ], + "loc": { + "start": { + "line": 14, + "column": 8 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 237, + 238 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 238, + 239 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 14, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 239, + 245 + ], + "loc": { + "start": { + "line": 14, + "column": 11 + }, + "end": { + "line": 14, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 245, + 246 + ], + "loc": { + "start": { + "line": 14, + "column": 17 + }, + "end": { + "line": 14, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 246, + 247 + ], + "loc": { + "start": { + "line": 14, + "column": 18 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 247, + 248 + ], + "loc": { + "start": { + "line": 14, + "column": 19 + }, + "end": { + "line": 14, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 248, + 254 + ], + "loc": { + "start": { + "line": 14, + "column": 20 + }, + "end": { + "line": 14, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 254, + 255 + ], + "loc": { + "start": { + "line": 14, + "column": 26 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 255, + 260 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 260, + 261 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 261, + 262 + ], + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 262, + 263 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 15, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 15, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 15, + "column": 9 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 265, + 284 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 15, + "column": 29 + }, + "end": { + "line": 15, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 285, + 289 + ], + "loc": { + "start": { + "line": 15, + "column": 30 + }, + "end": { + "line": 15, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 289, + 290 + ], + "loc": { + "start": { + "line": 15, + "column": 34 + }, + "end": { + "line": 15, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 290, + 295 + ], + "loc": { + "start": { + "line": 15, + "column": 35 + }, + "end": { + "line": 15, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 295, + 296 + ], + "loc": { + "start": { + "line": 15, + "column": 40 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 296, + 301 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 301, + 302 + ], + "loc": { + "start": { + "line": 16, + "column": 5 + }, + "end": { + "line": 16, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 302, + 305 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 305, + 306 + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 306, + 307 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 307, + 308 + ], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 308, + 313 + ], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 313, + 314 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 314, + 330 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 330, + 331 + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 331, + 339 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 339, + 340 + ], + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 340, + 341 + ], + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 19, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 341, + 350 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 350, + 351 + ], + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 351, + 352 + ], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 20, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 352, + 354 + ], + "loc": { + "start": { + "line": 20, + "column": 0 + }, + "end": { + "line": 20, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + }, + "range": [ + 354, + 357 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 357, + 359 + ], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 359, + 360 + ], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 360, + 370 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 370, + 371 + ], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 15 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 3, + "column": 19 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 62, + 69 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 88, + 99 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 17 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 104, + 117 + ], + "value": " extends " + }, + { + "type": "Block", + "loc": { + "end": { + "line": 8, + "column": 13 + }, + "start": { + "line": 8, + "column": 6 + } + }, + "range": [ + 151, + 158 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 9, + "column": 18 + }, + "start": { + "line": 9, + "column": 14 + } + }, + "range": [ + 173, + 177 + ], + "value": " =" + } + ], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-6-with-default/parser-options.json b/test/fixtures/ast/vue3.3-generic-6-with-default/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-6-with-default/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-6-with-default/source.vue b/test/fixtures/ast/vue3.3-generic-6-with-default/source.vue new file mode 100644 index 00000000..a0ad29c8 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-6-with-default/source.vue @@ -0,0 +1,21 @@ + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-6-with-default/token-ranges.json b/test/fixtures/ast/vue3.3-generic-6-with-default/token-ranges.json new file mode 100644 index 00000000..25735e17 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-6-with-default/token-ranges.json @@ -0,0 +1,123 @@ +[ + "", + "", + "=", + "Record", + "<", + "string", + ",", + "number", + ">", + "\"", + ">", + "\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", + "/* = */", + "// Comments", + "/* extends */", + "/* = */", + "// =" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-6-with-default/tree.json b/test/fixtures/ast/vue3.3-generic-6-with-default/tree.json new file mode 100644 index 00000000..eea3840c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-6-with-default/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-7-with-arrow/ast.json b/test/fixtures/ast/vue3.3-generic-7-with-arrow/ast.json new file mode 100644 index 00000000..f79be40c --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-7-with-arrow/ast.json @@ -0,0 +1,2258 @@ +{ + "type": "Program", + "range": [ + 103, + 141 + ], + "body": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "definite": false, + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 109, + 110 + ], + "loc": { + "end": { + "line": 5, + "column": 7 + }, + "start": { + "line": 5, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "decorators": [], + "name": "defineProps", + "optional": false, + "range": [ + 113, + 124 + ], + "loc": { + "end": { + "line": 5, + "column": 21 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "optional": false, + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 124, + 138 + ], + "params": [ + { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "t", + "optional": false, + "range": [ + 126, + 127 + ], + "loc": { + "end": { + "line": 5, + "column": 24 + }, + "start": { + "line": 5, + "column": 23 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 5, + "column": 27 + }, + "start": { + "line": 5, + "column": 24 + } + }, + "range": [ + 127, + 130 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 129, + 130 + ], + "loc": { + "end": { + "line": 5, + "column": 27 + }, + "start": { + "line": 5, + "column": 26 + } + } + }, + "range": [ + 129, + 130 + ], + "loc": { + "end": { + "line": 5, + "column": 27 + }, + "start": { + "line": 5, + "column": 26 + } + } + } + }, + "range": [ + 126, + 131 + ], + "loc": { + "end": { + "line": 5, + "column": 28 + }, + "start": { + "line": 5, + "column": 23 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "key": { + "type": "Identifier", + "decorators": [], + "name": "u", + "optional": false, + "range": [ + 132, + 133 + ], + "loc": { + "end": { + "line": 5, + "column": 30 + }, + "start": { + "line": 5, + "column": 29 + } + } + }, + "optional": false, + "readonly": false, + "static": false, + "typeAnnotation": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 5, + "column": 33 + }, + "start": { + "line": 5, + "column": 30 + } + }, + "range": [ + 133, + 136 + ], + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 135, + 136 + ], + "loc": { + "end": { + "line": 5, + "column": 33 + }, + "start": { + "line": 5, + "column": 32 + } + } + }, + "range": [ + 135, + 136 + ], + "loc": { + "end": { + "line": 5, + "column": 33 + }, + "start": { + "line": 5, + "column": 32 + } + } + } + }, + "range": [ + 132, + 136 + ], + "loc": { + "end": { + "line": 5, + "column": 33 + }, + "start": { + "line": 5, + "column": 29 + } + } + } + ], + "range": [ + 125, + 137 + ], + "loc": { + "end": { + "line": 5, + "column": 34 + }, + "start": { + "line": 5, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 5, + "column": 35 + }, + "start": { + "line": 5, + "column": 21 + } + } + }, + "range": [ + 113, + 140 + ], + "loc": { + "end": { + "line": 5, + "column": 37 + }, + "start": { + "line": 5, + "column": 10 + } + } + }, + "range": [ + 109, + 140 + ], + "loc": { + "end": { + "line": 5, + "column": 37 + }, + "start": { + "line": 5, + "column": 6 + } + } + } + ], + "declare": false, + "kind": "const", + "range": [ + 103, + 140 + ], + "loc": { + "end": { + "line": 5, + "column": 37 + }, + "start": { + "line": 5, + "column": 0 + } + } + } + ], + "comments": [], + "sourceType": "module", + "tokens": [ + { + "type": "Punctuator", + "range": [ + 0, + 102 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "value": "" + } + ], + "loc": { + "end": { + "line": 6, + "column": 0 + }, + "start": { + "line": 5, + "column": 0 + } + }, + "templateBody": { + "type": "VElement", + "range": [ + 152, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 152, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 163, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 165, + 166 + ], + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "t", + "optional": false, + "range": [ + 167, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 4 + } + } + }, + "range": [ + 165, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "optional": false, + "range": [ + 165, + 170 + ], + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 165, + 166 + ], + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 175, + 176 + ], + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "u", + "optional": false, + "range": [ + 177, + 178 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 4 + } + } + }, + "range": [ + 175, + 178 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "optional": false, + "range": [ + 175, + 180 + ], + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 175, + 176 + ], + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 183, + 194 + ], + "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": "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", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 45 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 13 + }, + "start": { + "line": 2, + "column": 12 + } + }, + "range": [ + 46, + 47 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 14 + }, + "start": { + "line": 2, + "column": 13 + } + }, + "range": [ + 47, + 48 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 17 + }, + "start": { + "line": 2, + "column": 15 + } + }, + "range": [ + 49, + 51 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 18 + } + }, + "range": [ + 52, + 58 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 25 + }, + "start": { + "line": 2, + "column": 24 + } + }, + "range": [ + 58, + 59 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + }, + "range": [ + 62, + 63 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 12 + }, + "start": { + "line": 3, + "column": 5 + } + }, + "range": [ + 65, + 72 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 14 + }, + "start": { + "line": 3, + "column": 13 + } + }, + "range": [ + 73, + 74 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 14 + } + }, + "range": [ + 74, + 75 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 18 + }, + "start": { + "line": 3, + "column": 16 + } + }, + "range": [ + 76, + 78 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 19 + } + }, + "range": [ + 79, + 85 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 27 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 86, + 87 + ], + "value": "=" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 29 + }, + "start": { + "line": 3, + "column": 28 + } + }, + "range": [ + 88, + 89 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 30 + }, + "start": { + "line": 3, + "column": 29 + } + }, + "range": [ + 89, + 90 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 31 + } + }, + "range": [ + 91, + 93 + ], + "value": "=>" + }, + { + "type": "String", + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 34 + } + }, + "range": [ + 94, + 99 + ], + "value": "'abc'" + }, + { + "type": "Punctuator", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 108 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 113, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "value": "defineProps<{t:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 129, + 131 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "value": "T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 131, + 132 + ], + "loc": { + "start": { + "line": 5, + "column": 28 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 132, + 134 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "value": "u:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 135, + 140 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 37 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 5, + "column": 37 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 141, + 149 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 152 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 152, + 161 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 161, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 163, + 165 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + }, + "range": [ + 165, + 166 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 4 + }, + "start": { + "line": 9, + "column": 3 + } + }, + "range": [ + 166, + 167 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 4 + } + }, + "range": [ + 167, + 168 + ], + "value": "t" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 6 + }, + "start": { + "line": 9, + "column": 5 + } + }, + "range": [ + 168, + 169 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 169, + 170 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 170, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 173, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 175, + 176 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 4 + }, + "start": { + "line": 10, + "column": 3 + } + }, + "range": [ + 176, + 177 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 4 + } + }, + "range": [ + 177, + 178 + ], + "value": "u" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 6 + }, + "start": { + "line": 10, + "column": 5 + } + }, + "range": [ + 178, + 179 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 179, + 180 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 180, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 183, + 193 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 193, + 194 + ], + "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-7-with-arrow/parser-options.json b/test/fixtures/ast/vue3.3-generic-7-with-arrow/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-7-with-arrow/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/ast/vue3.3-generic-7-with-arrow/source.vue b/test/fixtures/ast/vue3.3-generic-7-with-arrow/source.vue new file mode 100644 index 00000000..d1a84af7 --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-7-with-arrow/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-7-with-arrow/token-ranges.json b/test/fixtures/ast/vue3.3-generic-7-with-arrow/token-ranges.json new file mode 100644 index 00000000..6ae5ff6d --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-7-with-arrow/token-ranges.json @@ -0,0 +1,88 @@ +[ + "", + "", + "string", + ",", + "U", + "extends", + "(", + ")", + "=>", + "string", + "=", + "(", + ")", + "=>", + "'abc'", + "\"", + ">", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{t:", + " ", + "T,", + " ", + "u:", + " ", + "U}>()", + "\n", + "", + "\n\n", + "", + "\n", + "{{", + "p", + ".", + "t", + "(", + ")", + "}}", + "\n", + "{{", + "p", + ".", + "u", + "(", + ")", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/vue3.3-generic-7-with-arrow/tree.json b/test/fixtures/ast/vue3.3-generic-7-with-arrow/tree.json new file mode 100644 index 00000000..bd27ee7b --- /dev/null +++ b/test/fixtures/ast/vue3.3-generic-7-with-arrow/tree.json @@ -0,0 +1,89 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/style-variables-edge-cases/document-fragment.json b/test/fixtures/document-fragment/style-variables-edge-cases/document-fragment.json index 9d703376..8616cb4e 100644 --- a/test/fixtures/document-fragment/style-variables-edge-cases/document-fragment.json +++ b/test/fixtures/document-fragment/style-variables-edge-cases/document-fragment.json @@ -226,7 +226,8 @@ ], "name": "size" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { @@ -348,7 +349,8 @@ "value": "color", "raw": "'color'" } - ] + ], + "optional": false }, "references": [ { @@ -468,7 +470,8 @@ ], "name": "color" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { diff --git a/test/fixtures/document-fragment/style-variables-ignores02/document-fragment.json b/test/fixtures/document-fragment/style-variables-ignores02/document-fragment.json index 187cd4d5..06625d92 100644 --- a/test/fixtures/document-fragment/style-variables-ignores02/document-fragment.json +++ b/test/fixtures/document-fragment/style-variables-ignores02/document-fragment.json @@ -283,7 +283,8 @@ "value": 42, "raw": "42" }, - "computed": true + "computed": true, + "optional": false }, "references": [ { @@ -383,7 +384,8 @@ ], "name": "getColor" }, - "arguments": [] + "arguments": [], + "optional": false }, "references": [ { diff --git a/test/fixtures/document-fragment/style-variables01/document-fragment.json b/test/fixtures/document-fragment/style-variables01/document-fragment.json index 1812ac76..e920516a 100644 --- a/test/fixtures/document-fragment/style-variables01/document-fragment.json +++ b/test/fixtures/document-fragment/style-variables01/document-fragment.json @@ -2361,7 +2361,8 @@ ], "name": "size" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { diff --git a/test/fixtures/document-fragment/style-variables02/document-fragment.json b/test/fixtures/document-fragment/style-variables02/document-fragment.json index 167b24f4..10654bb7 100644 --- a/test/fixtures/document-fragment/style-variables02/document-fragment.json +++ b/test/fixtures/document-fragment/style-variables02/document-fragment.json @@ -244,7 +244,8 @@ ], "name": "font" }, - "computed": false + "computed": false, + "optional": false }, "property": { "type": "Identifier", @@ -266,7 +267,8 @@ ], "name": "size" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { diff --git a/test/fixtures/document-fragment/style-variables05/document-fragment.json b/test/fixtures/document-fragment/style-variables05/document-fragment.json index 58b12495..6c733b31 100644 --- a/test/fixtures/document-fragment/style-variables05/document-fragment.json +++ b/test/fixtures/document-fragment/style-variables05/document-fragment.json @@ -226,7 +226,8 @@ ], "name": "size" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { @@ -348,7 +349,8 @@ "value": "color", "raw": "'color'" } - ] + ], + "optional": false }, "references": [ { @@ -468,7 +470,8 @@ ], "name": "color" }, - "computed": false + "computed": false, + "optional": false }, "references": [ { 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 index b354feda..13c2a968 100644 --- a/test/fixtures/document-fragment/vue3.3-generic-1/document-fragment.json +++ b/test/fixtures/document-fragment/vue3.3-generic-1/document-fragment.json @@ -235,39 +235,41 @@ "params": [ { "type": "TSTypeParameter", + "const": false, + "in": false, "name": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 33, 34 ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } } }, - "in": false, "out": false, - "const": false, "range": [ 33, 34 ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } } } @@ -322,19 +324,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 33, 34 ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } } }, @@ -435,19 +439,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 83, 86 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -455,19 +461,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 83, 86 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -661,21 +669,21 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 33, - 34 - ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } - } + }, + "range": [ + 33, + 34 + ], + "value": "T" }, { "type": "Punctuator", @@ -895,21 +903,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 83, - 86 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 83, + 86 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -1135,21 +1143,21 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 33, - 34 - ], "loc": { - "start": { - "line": 1, - "column": 33 - }, "end": { "line": 1, "column": 34 + }, + "start": { + "line": 1, + "column": 33 } - } + }, + "range": [ + 33, + 34 + ], + "value": "T" }, { "type": "Punctuator", @@ -1369,21 +1377,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 83, - 86 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 83, + 86 + ], + "value": "foo" }, { "type": "VExpressionEnd", 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 index efd5dc1c..370d495c 100644 --- a/test/fixtures/document-fragment/vue3.3-generic-2/document-fragment.json +++ b/test/fixtures/document-fragment/vue3.3-generic-2/document-fragment.json @@ -330,41 +330,26 @@ "params": [ { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "T", - "range": [ - 79, - 80 - ], - "loc": { - "start": { - "line": 4, - "column": 33 - }, - "end": { - "line": 4, - "column": 34 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 89, 92 ], "loc": { - "start": { - "line": 4, - "column": 43 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 43 } } }, @@ -373,31 +358,50 @@ 92 ], "loc": { + "end": { + "line": 4, + "column": 46 + }, "start": { "line": 4, "column": 43 - }, + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 79, + 80 + ], + "loc": { "end": { "line": 4, - "column": 46 + "column": 34 + }, + "start": { + "line": 4, + "column": 33 } } }, - "in": false, "out": false, - "const": false, "range": [ 79, 92 ], "loc": { - "start": { - "line": 4, - "column": 33 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 33 } } } @@ -410,19 +414,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 89, 92 ], "loc": { - "start": { - "line": 4, - "column": 43 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 43 } } }, @@ -476,19 +482,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 79, 80 ], "loc": { - "start": { - "line": 4, - "column": 33 - }, "end": { "line": 4, "column": 34 + }, + "start": { + "line": 4, + "column": 33 } } }, @@ -589,19 +597,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 186, 189 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -609,19 +619,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 186, 189 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1139,57 +1151,57 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], - "loc": { - "start": { - "line": 4, - "column": 43 - }, - "end": { - "line": 4, - "column": 46 - } - } + "value": "Foo" }, { "type": "Punctuator", @@ -1697,21 +1709,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 186, - 189 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 186, + 189 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -2261,57 +2273,57 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], - "loc": { - "start": { - "line": 4, - "column": 43 - }, - "end": { - "line": 4, - "column": 46 - } - } + "value": "Foo" }, { "type": "Punctuator", @@ -2819,21 +2831,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 186, - 189 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 186, + 189 + ], + "value": "foo" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/document-fragment/vue3.3-generic-2/tree.json b/test/fixtures/document-fragment/vue3.3-generic-2/tree.json index c55894cd..02563812 100644 --- a/test/fixtures/document-fragment/vue3.3-generic-2/tree.json +++ b/test/fixtures/document-fragment/vue3.3-generic-2/tree.json @@ -91,11 +91,6 @@ "type": "TSTypeParameter", "text": "T extends Foo", "children": [ - { - "type": "Identifier", - "text": "T", - "children": [] - }, { "type": "TSTypeReference", "text": "Foo", @@ -106,6 +101,11 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "T", + "children": [] } ] } 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 index f3bedad1..352fa378 100644 --- a/test/fixtures/document-fragment/vue3.3-generic-3/document-fragment.json +++ b/test/fixtures/document-fragment/vue3.3-generic-3/document-fragment.json @@ -330,41 +330,26 @@ "params": [ { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "T", - "range": [ - 79, - 80 - ], - "loc": { - "start": { - "line": 4, - "column": 33 - }, - "end": { - "line": 4, - "column": 34 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 89, 92 ], "loc": { - "start": { - "line": 4, - "column": 43 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 43 } } }, @@ -373,71 +358,75 @@ 92 ], "loc": { + "end": { + "line": 4, + "column": 46 + }, "start": { "line": 4, "column": 43 - }, + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 79, + 80 + ], + "loc": { "end": { "line": 4, - "column": 46 + "column": 34 + }, + "start": { + "line": 4, + "column": 33 } } }, - "in": false, "out": false, - "const": false, "range": [ 79, 92 ], "loc": { - "start": { - "line": 4, - "column": 33 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 33 } } }, { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "U", - "range": [ - 94, - 95 - ], - "loc": { - "start": { - "line": 4, - "column": 48 - }, - "end": { - "line": 4, - "column": 49 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 104, 105 ], "loc": { - "start": { - "line": 4, - "column": 58 - }, "end": { "line": 4, "column": 59 + }, + "start": { + "line": 4, + "column": 58 } } }, @@ -446,31 +435,50 @@ 105 ], "loc": { + "end": { + "line": 4, + "column": 59 + }, "start": { "line": 4, "column": 58 - }, + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 94, + 95 + ], + "loc": { "end": { "line": 4, - "column": 59 + "column": 49 + }, + "start": { + "line": 4, + "column": 48 } } }, - "in": false, "out": false, - "const": false, "range": [ 94, 105 ], "loc": { - "start": { - "line": 4, - "column": 48 - }, "end": { "line": 4, "column": 59 + }, + "start": { + "line": 4, + "column": 48 } } } @@ -484,19 +492,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 89, 92 ], "loc": { - "start": { - "line": 4, - "column": 43 - }, "end": { "line": 4, "column": 46 + }, + "start": { + "line": 4, + "column": 43 } } }, @@ -550,19 +560,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 79, 80 ], "loc": { - "start": { - "line": 4, - "column": 33 - }, "end": { "line": 4, "column": 34 + }, + "start": { + "line": 4, + "column": 33 } } }, @@ -571,19 +583,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 94, 95 ], "loc": { - "start": { - "line": 4, - "column": 48 - }, "end": { "line": 4, "column": 49 + }, + "start": { + "line": 4, + "column": 48 } } }, @@ -684,19 +698,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 207, 210 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -704,19 +720,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 207, 210 ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } } }, @@ -1234,129 +1252,129 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 43 + "column": 47 }, - "end": { + "start": { "line": 4, "column": 46 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 92, 93 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 46 + "column": 49 }, - "end": { + "start": { "line": 4, - "column": 47 + "column": 48 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 94, 95 ], + "value": "U" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 48 + "column": 57 }, - "end": { + "start": { "line": 4, - "column": 49 + "column": 50 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 96, 103 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 50 + "column": 59 }, - "end": { + "start": { "line": 4, - "column": 57 + "column": 58 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 104, 105 ], - "loc": { - "start": { - "line": 4, - "column": 58 - }, - "end": { - "line": 4, - "column": 59 - } - } + "value": "T" }, { "type": "Punctuator", @@ -1936,21 +1954,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 207, - 210 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 207, + 210 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -2500,129 +2518,129 @@ }, { "type": "Identifier", - "value": "T", + "loc": { + "end": { + "line": 4, + "column": 34 + }, + "start": { + "line": 4, + "column": 33 + } + }, "range": [ 79, 80 ], + "value": "T" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 33 + "column": 42 }, - "end": { + "start": { "line": 4, - "column": 34 + "column": 35 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 81, 88 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 35 + "column": 46 }, - "end": { + "start": { "line": 4, - "column": 42 + "column": 43 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 89, 92 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 4, - "column": 43 + "column": 47 }, - "end": { + "start": { "line": 4, "column": 46 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 92, 93 ], + "value": "," + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 46 + "column": 49 }, - "end": { + "start": { "line": 4, - "column": 47 + "column": 48 } - } - }, - { - "type": "Identifier", - "value": "U", + }, "range": [ 94, 95 ], + "value": "U" + }, + { + "type": "Keyword", "loc": { - "start": { + "end": { "line": 4, - "column": 48 + "column": 57 }, - "end": { + "start": { "line": 4, - "column": 49 + "column": 50 } - } - }, - { - "type": "Keyword", - "value": "extends", + }, "range": [ 96, 103 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 4, - "column": 50 + "column": 59 }, - "end": { + "start": { "line": 4, - "column": 57 + "column": 58 } - } - }, - { - "type": "Identifier", - "value": "T", + }, "range": [ 104, 105 ], - "loc": { - "start": { - "line": 4, - "column": 58 - }, - "end": { - "line": 4, - "column": 59 - } - } + "value": "T" }, { "type": "Punctuator", @@ -3202,21 +3220,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 207, - 210 - ], "loc": { - "start": { - "line": 10, - "column": 2 - }, "end": { "line": 10, "column": 5 + }, + "start": { + "line": 10, + "column": 2 } - } + }, + "range": [ + 207, + 210 + ], + "value": "foo" }, { "type": "VExpressionEnd", diff --git a/test/fixtures/document-fragment/vue3.3-generic-3/tree.json b/test/fixtures/document-fragment/vue3.3-generic-3/tree.json index 39979906..098b5927 100644 --- a/test/fixtures/document-fragment/vue3.3-generic-3/tree.json +++ b/test/fixtures/document-fragment/vue3.3-generic-3/tree.json @@ -91,11 +91,6 @@ "type": "TSTypeParameter", "text": "T extends Foo", "children": [ - { - "type": "Identifier", - "text": "T", - "children": [] - }, { "type": "TSTypeReference", "text": "Foo", @@ -106,6 +101,11 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "T", + "children": [] } ] }, @@ -113,11 +113,6 @@ "type": "TSTypeParameter", "text": "U extends T", "children": [ - { - "type": "Identifier", - "text": "U", - "children": [] - }, { "type": "TSTypeReference", "text": "T", @@ -128,6 +123,11 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "U", + "children": [] } ] } 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 index 23514a87..fd104f1b 100644 --- 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 @@ -235,41 +235,26 @@ "params": [ { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "T", - "range": [ - 36, - 37 - ], - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 3 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 50, 53 ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 3, + "column": 12 } } }, @@ -278,71 +263,75 @@ 53 ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 3, + "column": 12 } } }, "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, "out": false, - "const": false, "range": [ 36, 53 ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 2, + "column": 2 } } }, { "type": "TSTypeParameter", - "name": { - "type": "Identifier", - "name": "U", - "range": [ - 73, - 74 - ], - "loc": { - "start": { - "line": 5, - "column": 2 - }, - "end": { - "line": 5, - "column": 3 - } - } - }, + "const": false, "constraint": { "type": "TSTypeReference", "typeName": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 87, 88 ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 6, + "column": 4 } } }, @@ -351,31 +340,50 @@ 88 ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 6, + "column": 4 } } }, "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 73, + 74 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, "out": false, - "const": false, "range": [ 73, 88 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 5, + "column": 2 } } } @@ -389,19 +397,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "Foo", + "optional": false, "range": [ 50, 53 ], "loc": { - "start": { - "line": 3, - "column": 12 - }, "end": { "line": 3, "column": 15 + }, + "start": { + "line": 3, + "column": 12 } } }, @@ -455,19 +465,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "T", + "optional": false, "range": [ 36, 37 ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } } }, @@ -476,19 +488,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "U", + "optional": false, "range": [ 73, 74 ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } } }, @@ -589,19 +603,21 @@ }, "expression": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 218, 221 ], "loc": { - "start": { - "line": 14, - "column": 2 - }, "end": { "line": 14, "column": 5 + }, + "start": { + "line": 14, + "column": 2 } } }, @@ -609,19 +625,21 @@ { "id": { "type": "Identifier", + "decorators": [], "name": "foo", + "optional": false, "range": [ 218, 221 ], "loc": { - "start": { - "line": 14, - "column": 2 - }, "end": { "line": 14, "column": 5 + }, + "start": { + "line": 14, + "column": 2 } } }, @@ -815,129 +833,129 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 36, - 37 - ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } - } + }, + "range": [ + 36, + 37 + ], + "value": "T" }, { "type": "Keyword", - "value": "extends", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, "range": [ 42, 49 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 4 + "column": 15 }, - "end": { + "start": { "line": 3, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 50, 53 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 3, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 53, 54 ], - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", - "range": [ - 73, - 74 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 73, + 74 + ], + "value": "U" }, { "type": "Keyword", - "value": "extends", - "range": [ - 75, - 82 - ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 11 + }, + "start": { + "line": 5, + "column": 4 } - } + }, + "range": [ + 75, + 82 + ], + "value": "extends" }, { "type": "Identifier", - "value": "T", - "range": [ - 87, - 88 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 87, + 88 + ], + "value": "T" }, { "type": "Punctuator", @@ -1733,21 +1751,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 218, - 221 - ], "loc": { - "start": { - "line": 14, - "column": 2 - }, "end": { "line": 14, "column": 5 + }, + "start": { + "line": 14, + "column": 2 } - } + }, + "range": [ + 218, + 221 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -1825,21 +1843,21 @@ "comments": [ { "type": "Line", - "value": " Comments", - "range": [ - 59, - 70 - ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 4, "column": 15 + }, + "start": { + "line": 4, + "column": 4 } - } + }, + "range": [ + 59, + 70 + ], + "value": " Comments" } ], "errors": [] @@ -1992,129 +2010,129 @@ }, { "type": "Identifier", - "value": "T", - "range": [ - 36, - 37 - ], "loc": { - "start": { - "line": 2, - "column": 2 - }, "end": { "line": 2, "column": 3 + }, + "start": { + "line": 2, + "column": 2 } - } + }, + "range": [ + 36, + 37 + ], + "value": "T" }, { "type": "Keyword", - "value": "extends", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, "range": [ 42, 49 ], + "value": "extends" + }, + { + "type": "Identifier", "loc": { - "start": { + "end": { "line": 3, - "column": 4 + "column": 15 }, - "end": { + "start": { "line": 3, - "column": 11 + "column": 12 } - } - }, - { - "type": "Identifier", - "value": "Foo", + }, "range": [ 50, 53 ], + "value": "Foo" + }, + { + "type": "Punctuator", "loc": { - "start": { + "end": { "line": 3, - "column": 12 + "column": 16 }, - "end": { + "start": { "line": 3, "column": 15 } - } - }, - { - "type": "Punctuator", - "value": ",", + }, "range": [ 53, 54 ], - "loc": { - "start": { - "line": 3, - "column": 15 - }, - "end": { - "line": 3, - "column": 16 - } - } + "value": "," }, { "type": "Identifier", - "value": "U", - "range": [ - 73, - 74 - ], "loc": { - "start": { - "line": 5, - "column": 2 - }, "end": { "line": 5, "column": 3 + }, + "start": { + "line": 5, + "column": 2 } - } + }, + "range": [ + 73, + 74 + ], + "value": "U" }, { "type": "Keyword", - "value": "extends", - "range": [ - 75, - 82 - ], "loc": { - "start": { - "line": 5, - "column": 4 - }, "end": { "line": 5, "column": 11 + }, + "start": { + "line": 5, + "column": 4 } - } + }, + "range": [ + 75, + 82 + ], + "value": "extends" }, { "type": "Identifier", - "value": "T", - "range": [ - 87, - 88 - ], "loc": { - "start": { - "line": 6, - "column": 4 - }, "end": { "line": 6, "column": 5 + }, + "start": { + "line": 6, + "column": 4 } - } + }, + "range": [ + 87, + 88 + ], + "value": "T" }, { "type": "Punctuator", @@ -2910,21 +2928,21 @@ }, { "type": "Identifier", - "value": "foo", - "range": [ - 218, - 221 - ], "loc": { - "start": { - "line": 14, - "column": 2 - }, "end": { "line": 14, "column": 5 + }, + "start": { + "line": 14, + "column": 2 } - } + }, + "range": [ + 218, + 221 + ], + "value": "foo" }, { "type": "VExpressionEnd", @@ -3002,21 +3020,21 @@ "comments": [ { "type": "Line", - "value": " Comments", - "range": [ - 59, - 70 - ], "loc": { - "start": { - "line": 4, - "column": 4 - }, "end": { "line": 4, "column": 15 + }, + "start": { + "line": 4, + "column": 4 } - } + }, + "range": [ + 59, + 70 + ], + "value": " Comments" } ], "errors": [] 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 index 7e5efdcf..8ccbd3bd 100644 --- 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 @@ -65,11 +65,6 @@ "type": "TSTypeParameter", "text": "T\n extends Foo", "children": [ - { - "type": "Identifier", - "text": "T", - "children": [] - }, { "type": "TSTypeReference", "text": "Foo", @@ -80,6 +75,11 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "T", + "children": [] } ] }, @@ -87,11 +87,6 @@ "type": "TSTypeParameter", "text": "U extends\n T", "children": [ - { - "type": "Identifier", - "text": "U", - "children": [] - }, { "type": "TSTypeReference", "text": "T", @@ -102,6 +97,11 @@ "children": [] } ] + }, + { + "type": "Identifier", + "text": "U", + "children": [] } ] } diff --git a/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/document-fragment.json new file mode 100644 index 00000000..6ead8821 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/document-fragment.json @@ -0,0 +1,3366 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 283 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 252 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 139 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "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, + 138 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 8, + "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, + 138 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 36, + 136 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 7, + "column": 24 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 61, + 64 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + } + }, + "range": [ + 61, + 64 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "out": false, + "range": [ + 36, + 64 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 122, + 136 + ], + "params": [ + { + "type": "TSStringKeyword", + "range": [ + 126, + 132 + ], + "loc": { + "end": { + "line": 7, + "column": 20 + }, + "start": { + "line": 7, + "column": 14 + } + } + }, + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 134, + 135 + ], + "loc": { + "end": { + "line": 7, + "column": 23 + }, + "start": { + "line": 7, + "column": 22 + } + } + }, + "range": [ + 134, + 135 + ], + "loc": { + "end": { + "line": 7, + "column": 23 + }, + "start": { + "line": 7, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 7, + "column": 10 + } + } + }, + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Record", + "optional": false, + "range": [ + 116, + 122 + ], + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + } + }, + "range": [ + 116, + 136 + ], + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 7, + "column": 4 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 84, + 85 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "out": false, + "range": [ + 84, + 136 + ], + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 5, + "column": 2 + } + } + } + ], + "rawParams": [ + "T // extends\n extends Foo", + "U /* extends */\n extends\n Record" + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 61, + 64 + ], + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + } + ] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 139, + 243 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 13, + "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": [ + 243, + 252 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "kind": "generic" + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 84, + 85 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 252, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 253, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 253, + 263 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 264, + 271 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 266, + 269 + ], + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 266, + 269 + ], + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 271, + 272 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 272, + 283 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "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", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 53, + 60 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 61, + 64 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 16 + }, + "start": { + "line": 3, + "column": 15 + } + }, + "range": [ + 64, + 65 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 84, + 85 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 104, + 111 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 116, + 122 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 122, + 126 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 20 + }, + "start": { + "line": 7, + "column": 14 + } + }, + "range": [ + 126, + 132 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 21 + }, + "start": { + "line": 7, + "column": 20 + } + }, + "range": [ + 132, + 133 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 23 + }, + "start": { + "line": 7, + "column": 22 + } + }, + "range": [ + 134, + 135 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 7, + "column": 23 + } + }, + "range": [ + 135, + 136 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 144 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 145, + 148 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 151, + 157 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 157, + 158 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 158, + 159 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 9, + "column": 19 + }, + "end": { + "line": 9, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 166 + ], + "loc": { + "start": { + "line": 9, + "column": 20 + }, + "end": { + "line": 9, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 167, + 172 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 175, + 176 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 177, + 196 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 10, + "column": 29 + }, + "end": { + "line": 10, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 197, + 201 + ], + "loc": { + "start": { + "line": 10, + "column": 30 + }, + "end": { + "line": 10, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 201, + 202 + ], + "loc": { + "start": { + "line": 10, + "column": 34 + }, + "end": { + "line": 10, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 202, + 207 + ], + "loc": { + "start": { + "line": 10, + "column": 35 + }, + "end": { + "line": 10, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 207, + 208 + ], + "loc": { + "start": { + "line": 10, + "column": 40 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 208, + 213 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 213, + 214 + ], + "loc": { + "start": { + "line": 11, + "column": 5 + }, + "end": { + "line": 11, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 214, + 217 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 217, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 218, + 219 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 219, + 220 + ], + "loc": { + "start": { + "line": 11, + "column": 11 + }, + "end": { + "line": 11, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 220, + 225 + ], + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 225, + 226 + ], + "loc": { + "start": { + "line": 11, + "column": 17 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 226, + 242 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 242, + 243 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 243, + 251 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 251, + 252 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 252, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 253, + 262 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 262, + 263 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 264, + 266 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + }, + "range": [ + 266, + 269 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 269, + 271 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 271, + 272 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 272, + 282 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 282, + 283 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 14 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 48 + ], + "value": " extends" + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 70, + 81 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 17 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 86, + 99 + ], + "value": " extends " + } + ], + "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", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 53, + 60 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 61, + 64 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 16 + }, + "start": { + "line": 3, + "column": 15 + } + }, + "range": [ + 64, + 65 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 84, + 85 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 104, + 111 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 116, + 122 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 122, + 126 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 20 + }, + "start": { + "line": 7, + "column": 14 + } + }, + "range": [ + 126, + 132 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 21 + }, + "start": { + "line": 7, + "column": 20 + } + }, + "range": [ + 132, + 133 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 23 + }, + "start": { + "line": 7, + "column": 22 + } + }, + "range": [ + 134, + 135 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 24 + }, + "start": { + "line": 7, + "column": 23 + } + }, + "range": [ + 135, + 136 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 140, + 144 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 144, + 145 + ], + "loc": { + "start": { + "line": 9, + "column": 4 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 145, + 148 + ], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 148, + 149 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 151, + 157 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 157, + 158 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 158, + 159 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 9, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 9, + "column": 19 + }, + "end": { + "line": 9, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 160, + 166 + ], + "loc": { + "start": { + "line": 9, + "column": 20 + }, + "end": { + "line": 9, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 166, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 26 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 167, + 172 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 175, + 176 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 177, + 196 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 10, + "column": 29 + }, + "end": { + "line": 10, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 197, + 201 + ], + "loc": { + "start": { + "line": 10, + "column": 30 + }, + "end": { + "line": 10, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 201, + 202 + ], + "loc": { + "start": { + "line": 10, + "column": 34 + }, + "end": { + "line": 10, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 202, + 207 + ], + "loc": { + "start": { + "line": 10, + "column": 35 + }, + "end": { + "line": 10, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 207, + 208 + ], + "loc": { + "start": { + "line": 10, + "column": 40 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 208, + 213 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 213, + 214 + ], + "loc": { + "start": { + "line": 11, + "column": 5 + }, + "end": { + "line": 11, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 214, + 217 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 217, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 218, + 219 + ], + "loc": { + "start": { + "line": 11, + "column": 10 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 219, + 220 + ], + "loc": { + "start": { + "line": 11, + "column": 11 + }, + "end": { + "line": 11, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 220, + 225 + ], + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 225, + 226 + ], + "loc": { + "start": { + "line": 11, + "column": 17 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 226, + 242 + ], + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 242, + 243 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 243, + 251 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 251, + 252 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 252, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 253, + 262 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 262, + 263 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 264, + 266 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 15, + "column": 5 + }, + "start": { + "line": 15, + "column": 2 + } + }, + "range": [ + 266, + 269 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 269, + 271 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 271, + 272 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 272, + 282 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 282, + 283 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 14 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 48 + ], + "value": " extends" + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 70, + 81 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 17 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 86, + 99 + ], + "value": " extends " + } + ], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-5-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-5-with-spaces/source.vue b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/source.vue new file mode 100644 index 00000000..a5a1b5eb --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/source.vue @@ -0,0 +1,16 @@ + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/token-ranges.json new file mode 100644 index 00000000..a58b113b --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/token-ranges.json @@ -0,0 +1,74 @@ +[ + "", + "\"", + ">", + "\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", + "", + "// extends", + "// Comments", + "/* extends */" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/tree.json b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/tree.json new file mode 100644 index 00000000..eb531362 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-5-with-spaces/tree.json @@ -0,0 +1,194 @@ +[ + { + "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-6-with-default/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/document-fragment.json new file mode 100644 index 00000000..36290861 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/document-fragment.json @@ -0,0 +1,3905 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 371 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 340 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 18, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 227 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 13, + "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, + 226 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 13, + "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, + 226 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 13, + "column": 1 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 36, + 224 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 12, + "column": 32 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 70, + 73 + ], + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + } + }, + "range": [ + 70, + 73 + ], + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + } + }, + "default": { + "type": "TSNumberKeyword", + "range": [ + 76, + 82 + ], + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 3, + "column": 26 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "out": false, + "range": [ + 36, + 82 + ], + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSTypeReference", + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 140, + 191 + ], + "params": [ + { + "type": "TSStringKeyword", + "range": [ + 165, + 171 + ], + "loc": { + "end": { + "line": 9, + "column": 12 + }, + "start": { + "line": 9, + "column": 6 + } + } + }, + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 184, + 185 + ], + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + } + }, + "range": [ + 184, + 185 + ], + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + } + } + ], + "loc": { + "end": { + "line": 11, + "column": 5 + }, + "start": { + "line": 7, + "column": 10 + } + } + }, + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Record", + "optional": false, + "range": [ + 134, + 140 + ], + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + } + }, + "range": [ + 134, + 191 + ], + "loc": { + "end": { + "line": 11, + "column": 5 + }, + "start": { + "line": 7, + "column": 4 + } + } + }, + "default": { + "type": "TSTypeReference", + "typeArguments": { + "type": "TSTypeParameterInstantiation", + "range": [ + 205, + 224 + ], + "params": [ + { + "type": "TSStringKeyword", + "range": [ + 206, + 212 + ], + "loc": { + "end": { + "line": 12, + "column": 20 + }, + "start": { + "line": 12, + "column": 14 + } + } + }, + { + "type": "TSNumberKeyword", + "range": [ + 214, + 220 + ], + "loc": { + "end": { + "line": 12, + "column": 28 + }, + "start": { + "line": 12, + "column": 22 + } + } + } + ], + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 12, + "column": 13 + } + } + }, + "typeName": { + "type": "Identifier", + "decorators": [], + "name": "Record", + "optional": false, + "range": [ + 199, + 205 + ], + "loc": { + "end": { + "line": 12, + "column": 13 + }, + "start": { + "line": 12, + "column": 7 + } + } + }, + "range": [ + 199, + 224 + ], + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 12, + "column": 7 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 102, + 103 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "out": false, + "range": [ + 102, + 224 + ], + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 5, + "column": 2 + } + } + } + ], + "rawParams": [ + "T // Comments\n extends /* = */ Foo = number", + "U /* extends */\n extends\n Record<\n /* = */\n string, // =\n T\n >\n = Record" + ] + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "Foo", + "optional": false, + "range": [ + 70, + 73 + ], + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + } + }, + "mode": "r", + "isValueReference": false, + "isTypeReference": true + } + ] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 227, + 331 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 18, + "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": [ + 331, + 340 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "kind": "generic" + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 102, + 103 + ], + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 340, + 341 + ], + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 19, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VElement", + "range": [ + 341, + 371 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 341, + 351 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 351, + 352 + ], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 20, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 352, + 359 + ], + "loc": { + "start": { + "line": 20, + "column": 0 + }, + "end": { + "line": 20, + "column": 7 + } + }, + "expression": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 354, + 357 + ], + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "foo", + "optional": false, + "range": [ + 354, + 357 + ], + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 359, + 360 + ], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 360, + 371 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "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", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 54, + 61 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + }, + "range": [ + 70, + 73 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 24 + } + }, + "range": [ + 74, + 75 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 76, + 82 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 32 + } + }, + "range": [ + 82, + 83 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 102, + 103 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 122, + 129 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 134, + 140 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 140, + 144 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 12 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 165, + 171 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 13 + }, + "start": { + "line": 9, + "column": 12 + } + }, + "range": [ + 171, + 172 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 184, + 185 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 11, + "column": 5 + }, + "start": { + "line": 11, + "column": 4 + } + }, + "range": [ + 190, + 191 + ], + "value": ">" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 6 + }, + "start": { + "line": 12, + "column": 5 + } + }, + "range": [ + 197, + 198 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 13 + }, + "start": { + "line": 12, + "column": 7 + } + }, + "range": [ + 199, + 205 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 14 + }, + "start": { + "line": 12, + "column": 13 + } + }, + "range": [ + 205, + 206 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 20 + }, + "start": { + "line": 12, + "column": 14 + } + }, + "range": [ + 206, + 212 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 21 + }, + "start": { + "line": 12, + "column": 20 + } + }, + "range": [ + 212, + 213 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 28 + }, + "start": { + "line": 12, + "column": 22 + } + }, + "range": [ + 214, + 220 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 12, + "column": 28 + } + }, + "range": [ + 220, + 224 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 225, + 226 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 226, + 227 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 227, + 228 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 228, + 232 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 232, + 233 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 233, + 236 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 236, + 237 + ], + "loc": { + "start": { + "line": 14, + "column": 8 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 237, + 238 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 238, + 239 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 14, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 239, + 245 + ], + "loc": { + "start": { + "line": 14, + "column": 11 + }, + "end": { + "line": 14, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 245, + 246 + ], + "loc": { + "start": { + "line": 14, + "column": 17 + }, + "end": { + "line": 14, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 246, + 247 + ], + "loc": { + "start": { + "line": 14, + "column": 18 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 247, + 248 + ], + "loc": { + "start": { + "line": 14, + "column": 19 + }, + "end": { + "line": 14, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 248, + 254 + ], + "loc": { + "start": { + "line": 14, + "column": 20 + }, + "end": { + "line": 14, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 254, + 255 + ], + "loc": { + "start": { + "line": 14, + "column": 26 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 255, + 260 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 260, + 261 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 261, + 262 + ], + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 262, + 263 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 15, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 15, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 15, + "column": 9 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 265, + 284 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 15, + "column": 29 + }, + "end": { + "line": 15, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 285, + 289 + ], + "loc": { + "start": { + "line": 15, + "column": 30 + }, + "end": { + "line": 15, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 289, + 290 + ], + "loc": { + "start": { + "line": 15, + "column": 34 + }, + "end": { + "line": 15, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 290, + 295 + ], + "loc": { + "start": { + "line": 15, + "column": 35 + }, + "end": { + "line": 15, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 295, + 296 + ], + "loc": { + "start": { + "line": 15, + "column": 40 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 296, + 301 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 301, + 302 + ], + "loc": { + "start": { + "line": 16, + "column": 5 + }, + "end": { + "line": 16, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 302, + 305 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 305, + 306 + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 306, + 307 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 307, + 308 + ], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 308, + 313 + ], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 313, + 314 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 314, + 330 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 330, + 331 + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 331, + 339 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 339, + 340 + ], + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 340, + 341 + ], + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 19, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 341, + 350 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 350, + 351 + ], + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 351, + 352 + ], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 20, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 352, + 354 + ], + "loc": { + "start": { + "line": 20, + "column": 0 + }, + "end": { + "line": 20, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + }, + "range": [ + 354, + 357 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 357, + 359 + ], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 359, + 360 + ], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 360, + 370 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 370, + 371 + ], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 15 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 3, + "column": 19 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 62, + 69 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 88, + 99 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 17 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 104, + 117 + ], + "value": " extends " + }, + { + "type": "Block", + "loc": { + "end": { + "line": 8, + "column": 13 + }, + "start": { + "line": 8, + "column": 6 + } + }, + "range": [ + 151, + 158 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 9, + "column": 18 + }, + "start": { + "line": 9, + "column": 14 + } + }, + "range": [ + 173, + 177 + ], + "value": " =" + } + ], + "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", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 11 + }, + "start": { + "line": 3, + "column": 4 + } + }, + "range": [ + 54, + 61 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 23 + }, + "start": { + "line": 3, + "column": 20 + } + }, + "range": [ + 70, + 73 + ], + "value": "Foo" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 24 + } + }, + "range": [ + 74, + 75 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 32 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 76, + 82 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 32 + } + }, + "range": [ + 82, + 83 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 5, + "column": 3 + }, + "start": { + "line": 5, + "column": 2 + } + }, + "range": [ + 102, + 103 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 6, + "column": 11 + }, + "start": { + "line": 6, + "column": 4 + } + }, + "range": [ + 122, + 129 + ], + "value": "extends" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 7, + "column": 10 + }, + "start": { + "line": 7, + "column": 4 + } + }, + "range": [ + 134, + 140 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 7, + "column": 14 + }, + "start": { + "line": 7, + "column": 10 + } + }, + "range": [ + 140, + 144 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 12 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 165, + 171 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 13 + }, + "start": { + "line": 9, + "column": 12 + } + }, + "range": [ + 171, + 172 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 184, + 185 + ], + "value": "T" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 11, + "column": 5 + }, + "start": { + "line": 11, + "column": 4 + } + }, + "range": [ + 190, + 191 + ], + "value": ">" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 6 + }, + "start": { + "line": 12, + "column": 5 + } + }, + "range": [ + 197, + 198 + ], + "value": "=" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 13 + }, + "start": { + "line": 12, + "column": 7 + } + }, + "range": [ + 199, + 205 + ], + "value": "Record" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 14 + }, + "start": { + "line": 12, + "column": 13 + } + }, + "range": [ + 205, + 206 + ], + "value": "<" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 20 + }, + "start": { + "line": 12, + "column": 14 + } + }, + "range": [ + 206, + 212 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 21 + }, + "start": { + "line": 12, + "column": 20 + } + }, + "range": [ + 212, + 213 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 12, + "column": 28 + }, + "start": { + "line": 12, + "column": 22 + } + }, + "range": [ + 214, + 220 + ], + "value": "number" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 12, + "column": 32 + }, + "start": { + "line": 12, + "column": 28 + } + }, + "range": [ + 220, + 224 + ], + "value": ">" + }, + { + "type": "Punctuator", + "range": [ + 225, + 226 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 226, + 227 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 227, + 228 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 228, + 232 + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 4 + } + }, + "value": "type" + }, + { + "type": "HTMLWhitespace", + "range": [ + 232, + 233 + ], + "loc": { + "start": { + "line": 14, + "column": 4 + }, + "end": { + "line": 14, + "column": 5 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 233, + 236 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 8 + } + }, + "value": "Foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 236, + 237 + ], + "loc": { + "start": { + "line": 14, + "column": 8 + }, + "end": { + "line": 14, + "column": 9 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 237, + 238 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 238, + 239 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 14, + "column": 11 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 239, + 245 + ], + "loc": { + "start": { + "line": 14, + "column": 11 + }, + "end": { + "line": 14, + "column": 17 + } + }, + "value": "number" + }, + { + "type": "HTMLWhitespace", + "range": [ + 245, + 246 + ], + "loc": { + "start": { + "line": 14, + "column": 17 + }, + "end": { + "line": 14, + "column": 18 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 246, + 247 + ], + "loc": { + "start": { + "line": 14, + "column": 18 + }, + "end": { + "line": 14, + "column": 19 + } + }, + "value": "|" + }, + { + "type": "HTMLWhitespace", + "range": [ + 247, + 248 + ], + "loc": { + "start": { + "line": 14, + "column": 19 + }, + "end": { + "line": 14, + "column": 20 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 248, + 254 + ], + "loc": { + "start": { + "line": 14, + "column": 20 + }, + "end": { + "line": 14, + "column": 26 + } + }, + "value": "string" + }, + { + "type": "HTMLWhitespace", + "range": [ + 254, + 255 + ], + "loc": { + "start": { + "line": 14, + "column": 26 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 255, + 260 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 260, + 261 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 261, + 262 + ], + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 262, + 263 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 15, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 15, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 15, + "column": 9 + }, + "end": { + "line": 15, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 265, + 284 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 29 + } + }, + "value": "defineProps<{foo:T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 15, + "column": 29 + }, + "end": { + "line": 15, + "column": 30 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 285, + 289 + ], + "loc": { + "start": { + "line": 15, + "column": 30 + }, + "end": { + "line": 15, + "column": 34 + } + }, + "value": "bar:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 289, + 290 + ], + "loc": { + "start": { + "line": 15, + "column": 34 + }, + "end": { + "line": 15, + "column": 35 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 290, + 295 + ], + "loc": { + "start": { + "line": 15, + "column": 35 + }, + "end": { + "line": 15, + "column": 40 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 295, + 296 + ], + "loc": { + "start": { + "line": 15, + "column": 40 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 296, + 301 + ], + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 301, + 302 + ], + "loc": { + "start": { + "line": 16, + "column": 5 + }, + "end": { + "line": 16, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 302, + 305 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 9 + } + }, + "value": "foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 305, + 306 + ], + "loc": { + "start": { + "line": 16, + "column": 9 + }, + "end": { + "line": 16, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 306, + 307 + ], + "loc": { + "start": { + "line": 16, + "column": 10 + }, + "end": { + "line": 16, + "column": 11 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 307, + 308 + ], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 12 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 308, + 313 + ], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 17 + } + }, + "value": "p.foo" + }, + { + "type": "HTMLWhitespace", + "range": [ + 313, + 314 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 314, + 330 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 16 + } + }, + "value": "console.log(foo)" + }, + { + "type": "HTMLWhitespace", + "range": [ + 330, + 331 + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 331, + 339 + ], + "loc": { + "start": { + "line": 18, + "column": 0 + }, + "end": { + "line": 18, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 339, + 340 + ], + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 340, + 341 + ], + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 19, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 341, + 350 + ], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 350, + 351 + ], + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 351, + 352 + ], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 20, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 352, + 354 + ], + "loc": { + "start": { + "line": 20, + "column": 0 + }, + "end": { + "line": 20, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 20, + "column": 5 + }, + "start": { + "line": 20, + "column": 2 + } + }, + "range": [ + 354, + 357 + ], + "value": "foo" + }, + { + "type": "VExpressionEnd", + "range": [ + 357, + 359 + ], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 7 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 359, + 360 + ], + "loc": { + "start": { + "line": 20, + "column": 7 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 360, + 370 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 370, + 371 + ], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 11 + } + }, + "value": "" + } + ], + "comments": [ + { + "type": "Line", + "loc": { + "end": { + "line": 2, + "column": 15 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 49 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 3, + "column": 19 + }, + "start": { + "line": 3, + "column": 12 + } + }, + "range": [ + 62, + 69 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 4, + "column": 15 + }, + "start": { + "line": 4, + "column": 4 + } + }, + "range": [ + 88, + 99 + ], + "value": " Comments" + }, + { + "type": "Block", + "loc": { + "end": { + "line": 5, + "column": 17 + }, + "start": { + "line": 5, + "column": 4 + } + }, + "range": [ + 104, + 117 + ], + "value": " extends " + }, + { + "type": "Block", + "loc": { + "end": { + "line": 8, + "column": 13 + }, + "start": { + "line": 8, + "column": 6 + } + }, + "range": [ + 151, + 158 + ], + "value": " = " + }, + { + "type": "Line", + "loc": { + "end": { + "line": 9, + "column": 18 + }, + "start": { + "line": 9, + "column": 14 + } + }, + "range": [ + 173, + 177 + ], + "value": " =" + } + ], + "errors": [] +} \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-6-with-default/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-6-with-default/source.vue b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/source.vue new file mode 100644 index 00000000..a0ad29c8 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/source.vue @@ -0,0 +1,21 @@ + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-6-with-default/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/token-ranges.json new file mode 100644 index 00000000..38d59219 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/token-ranges.json @@ -0,0 +1,86 @@ +[ + "", + "=", + "Record", + "<", + "string", + ",", + "number", + ">", + "\"", + ">", + "\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", + "/* = */", + "// Comments", + "/* extends */", + "/* = */", + "// =" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-6-with-default/tree.json b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/tree.json new file mode 100644 index 00000000..ab3eb2d9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-6-with-default/tree.json @@ -0,0 +1,226 @@ +[ + { + "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-7-with-arrow/document-fragment.json b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/document-fragment.json new file mode 100644 index 00000000..15d9ad50 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/document-fragment.json @@ -0,0 +1,3384 @@ +{ + "type": "VDocumentFragment", + "range": [ + 0, + 194 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "children": [ + { + "type": "VElement", + "range": [ + 0, + 150 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "name": "script", + "rawName": "script", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 102 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "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, + 101 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 4, + "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, + 101 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "expression": { + "type": "VGenericExpression", + "range": [ + 36, + 99 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 39 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 15 + } + }, + "range": [ + 49, + 58 + ], + "typeAnnotation": { + "type": "TSStringKeyword", + "range": [ + 52, + 58 + ], + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 18 + } + } + } + }, + "range": [ + 46, + 58 + ], + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 12 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "out": false, + "range": [ + 36, + 58 + ], + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + { + "type": "TSTypeParameter", + "const": false, + "constraint": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 16 + } + }, + "range": [ + 76, + 85 + ], + "typeAnnotation": { + "type": "TSStringKeyword", + "range": [ + 79, + 85 + ], + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 19 + } + } + } + }, + "range": [ + 73, + 85 + ], + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 13 + } + } + }, + "default": { + "type": "TSFunctionType", + "params": [], + "returnType": { + "type": "TSTypeAnnotation", + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 31 + } + }, + "range": [ + 91, + 99 + ], + "typeAnnotation": { + "type": "TSLiteralType", + "literal": { + "type": "Literal", + "raw": "'abc'", + "value": "abc", + "range": [ + 94, + 99 + ], + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 34 + } + } + }, + "range": [ + 94, + 99 + ], + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 34 + } + } + } + }, + "range": [ + 88, + 99 + ], + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 28 + } + } + }, + "in": false, + "name": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 62, + 63 + ], + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + } + }, + "out": false, + "range": [ + 62, + 99 + ], + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 2 + } + } + } + ], + "rawParams": [ + "T extends () => string", + "U extends () => string = () => 'abc'" + ] + }, + "references": [] + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 102, + 141 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\nconst p = defineProps<{t: T, u: U}>()\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 141, + 150 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + "variables": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "T", + "optional": false, + "range": [ + 36, + 37 + ], + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + } + }, + "kind": "generic" + }, + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "U", + "optional": false, + "range": [ + 62, + 63 + ], + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + } + }, + "kind": "generic" + } + ] + }, + { + "type": "VText", + "range": [ + 150, + 152 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "VElement", + "range": [ + 152, + 194 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 11, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 152, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 163, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 165, + 166 + ], + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "t", + "optional": false, + "range": [ + 167, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 4 + } + } + }, + "range": [ + 165, + 168 + ], + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "optional": false, + "range": [ + 165, + 170 + ], + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 165, + 166 + ], + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionContainer", + "range": [ + 173, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 175, + 176 + ], + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "decorators": [], + "name": "u", + "optional": false, + "range": [ + 177, + 178 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 4 + } + } + }, + "range": [ + 175, + 178 + ], + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "optional": false, + "range": [ + 175, + 180 + ], + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "decorators": [], + "name": "p", + "optional": false, + "range": [ + 175, + 176 + ], + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + } + }, + "mode": "r", + "isValueReference": true, + "isTypeReference": false + } + ] + }, + { + "type": "VText", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 183, + 194 + ], + "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": "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", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 45 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 13 + }, + "start": { + "line": 2, + "column": 12 + } + }, + "range": [ + 46, + 47 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 14 + }, + "start": { + "line": 2, + "column": 13 + } + }, + "range": [ + 47, + 48 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 17 + }, + "start": { + "line": 2, + "column": 15 + } + }, + "range": [ + 49, + 51 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 18 + } + }, + "range": [ + 52, + 58 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 25 + }, + "start": { + "line": 2, + "column": 24 + } + }, + "range": [ + 58, + 59 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + }, + "range": [ + 62, + 63 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 12 + }, + "start": { + "line": 3, + "column": 5 + } + }, + "range": [ + 65, + 72 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 14 + }, + "start": { + "line": 3, + "column": 13 + } + }, + "range": [ + 73, + 74 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 14 + } + }, + "range": [ + 74, + 75 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 18 + }, + "start": { + "line": 3, + "column": 16 + } + }, + "range": [ + 76, + 78 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 19 + } + }, + "range": [ + 79, + 85 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 27 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 86, + 87 + ], + "value": "=" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 29 + }, + "start": { + "line": 3, + "column": 28 + } + }, + "range": [ + 88, + 89 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 30 + }, + "start": { + "line": 3, + "column": 29 + } + }, + "range": [ + 89, + 90 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 31 + } + }, + "range": [ + 91, + 93 + ], + "value": "=>" + }, + { + "type": "String", + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 34 + } + }, + "range": [ + 94, + 99 + ], + "value": "'abc'" + }, + { + "type": "Punctuator", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 108 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 113, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "value": "defineProps<{t:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 129, + 131 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "value": "T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 131, + 132 + ], + "loc": { + "start": { + "line": 5, + "column": 28 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 132, + 134 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "value": "u:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 135, + 140 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 37 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 5, + "column": 37 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 141, + 149 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 152 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 152, + 161 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 161, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 163, + 165 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + }, + "range": [ + 165, + 166 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 4 + }, + "start": { + "line": 9, + "column": 3 + } + }, + "range": [ + 166, + 167 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 4 + } + }, + "range": [ + 167, + 168 + ], + "value": "t" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 6 + }, + "start": { + "line": 9, + "column": 5 + } + }, + "range": [ + 168, + 169 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 169, + 170 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 170, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 173, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 175, + 176 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 4 + }, + "start": { + "line": 10, + "column": 3 + } + }, + "range": [ + 176, + 177 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 4 + } + }, + "range": [ + 177, + 178 + ], + "value": "u" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 6 + }, + "start": { + "line": 10, + "column": 5 + } + }, + "range": [ + 178, + 179 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 179, + 180 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 180, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 183, + 193 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 193, + 194 + ], + "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": "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", + "loc": { + "end": { + "line": 2, + "column": 3 + }, + "start": { + "line": 2, + "column": 2 + } + }, + "range": [ + 36, + 37 + ], + "value": "T" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 2, + "column": 11 + }, + "start": { + "line": 2, + "column": 4 + } + }, + "range": [ + 38, + 45 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 13 + }, + "start": { + "line": 2, + "column": 12 + } + }, + "range": [ + 46, + 47 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 14 + }, + "start": { + "line": 2, + "column": 13 + } + }, + "range": [ + 47, + 48 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 17 + }, + "start": { + "line": 2, + "column": 15 + } + }, + "range": [ + 49, + 51 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 2, + "column": 24 + }, + "start": { + "line": 2, + "column": 18 + } + }, + "range": [ + 52, + 58 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 2, + "column": 25 + }, + "start": { + "line": 2, + "column": 24 + } + }, + "range": [ + 58, + 59 + ], + "value": "," + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 3 + }, + "start": { + "line": 3, + "column": 2 + } + }, + "range": [ + 62, + 63 + ], + "value": "U" + }, + { + "type": "Keyword", + "loc": { + "end": { + "line": 3, + "column": 12 + }, + "start": { + "line": 3, + "column": 5 + } + }, + "range": [ + 65, + 72 + ], + "value": "extends" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 14 + }, + "start": { + "line": 3, + "column": 13 + } + }, + "range": [ + 73, + 74 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 15 + }, + "start": { + "line": 3, + "column": 14 + } + }, + "range": [ + 74, + 75 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 18 + }, + "start": { + "line": 3, + "column": 16 + } + }, + "range": [ + 76, + 78 + ], + "value": "=>" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 3, + "column": 25 + }, + "start": { + "line": 3, + "column": 19 + } + }, + "range": [ + 79, + 85 + ], + "value": "string" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 27 + }, + "start": { + "line": 3, + "column": 26 + } + }, + "range": [ + 86, + 87 + ], + "value": "=" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 29 + }, + "start": { + "line": 3, + "column": 28 + } + }, + "range": [ + 88, + 89 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 30 + }, + "start": { + "line": 3, + "column": 29 + } + }, + "range": [ + 89, + 90 + ], + "value": ")" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 3, + "column": 33 + }, + "start": { + "line": 3, + "column": 31 + } + }, + "range": [ + 91, + 93 + ], + "value": "=>" + }, + { + "type": "String", + "loc": { + "end": { + "line": 3, + "column": 39 + }, + "start": { + "line": 3, + "column": 34 + } + }, + "range": [ + 94, + 99 + ], + "value": "'abc'" + }, + { + "type": "Punctuator", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "value": "\"" + }, + { + "type": "HTMLTagClose", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLRawText", + "range": [ + 103, + 108 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 5 + } + }, + "value": "const" + }, + { + "type": "HTMLWhitespace", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLWhitespace", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "=" + }, + { + "type": "HTMLWhitespace", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 113, + 128 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "value": "defineProps<{t:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 129, + 131 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 28 + } + }, + "value": "T," + }, + { + "type": "HTMLWhitespace", + "range": [ + 131, + 132 + ], + "loc": { + "start": { + "line": 5, + "column": 28 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 132, + 134 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "value": "u:" + }, + { + "type": "HTMLWhitespace", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": " " + }, + { + "type": "HTMLRawText", + "range": [ + 135, + 140 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 37 + } + }, + "value": "U}>()" + }, + { + "type": "HTMLWhitespace", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 5, + "column": 37 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 141, + 149 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 8 + } + }, + "value": "script" + }, + { + "type": "HTMLTagClose", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 150, + 152 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 8, + "column": 0 + } + }, + "value": "\n\n" + }, + { + "type": "HTMLTagOpen", + "range": [ + 152, + 161 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 161, + 162 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 163, + 165 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 3 + }, + "start": { + "line": 9, + "column": 2 + } + }, + "range": [ + 165, + 166 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 4 + }, + "start": { + "line": 9, + "column": 3 + } + }, + "range": [ + 166, + 167 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 9, + "column": 5 + }, + "start": { + "line": 9, + "column": 4 + } + }, + "range": [ + 167, + 168 + ], + "value": "t" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 6 + }, + "start": { + "line": 9, + "column": 5 + } + }, + "range": [ + 168, + 169 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 9, + "column": 7 + }, + "start": { + "line": 9, + "column": 6 + } + }, + "range": [ + 169, + 170 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 170, + 172 + ], + "loc": { + "start": { + "line": 9, + "column": 7 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 172, + 173 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "VExpressionStart", + "range": [ + 173, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 2 + } + }, + "value": "{{" + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 3 + }, + "start": { + "line": 10, + "column": 2 + } + }, + "range": [ + 175, + 176 + ], + "value": "p" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 4 + }, + "start": { + "line": 10, + "column": 3 + } + }, + "range": [ + 176, + 177 + ], + "value": "." + }, + { + "type": "Identifier", + "loc": { + "end": { + "line": 10, + "column": 5 + }, + "start": { + "line": 10, + "column": 4 + } + }, + "range": [ + 177, + 178 + ], + "value": "u" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 6 + }, + "start": { + "line": 10, + "column": 5 + } + }, + "range": [ + 178, + 179 + ], + "value": "(" + }, + { + "type": "Punctuator", + "loc": { + "end": { + "line": 10, + "column": 7 + }, + "start": { + "line": 10, + "column": 6 + } + }, + "range": [ + 179, + 180 + ], + "value": ")" + }, + { + "type": "VExpressionEnd", + "range": [ + 180, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 9 + } + }, + "value": "}}" + }, + { + "type": "HTMLWhitespace", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 183, + 193 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 193, + 194 + ], + "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-7-with-arrow/parser-options.json b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/parser-options.json new file mode 100644 index 00000000..0ead30e9 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/parser-options.json @@ -0,0 +1,6 @@ +{ + "sourceType": "module", + "parser": { + "ts": "@typescript-eslint/parser" + } +} diff --git a/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/source.vue b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/source.vue new file mode 100644 index 00000000..d1a84af7 --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/source.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/token-ranges.json b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/token-ranges.json new file mode 100644 index 00000000..19b7461d --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/token-ranges.json @@ -0,0 +1,69 @@ +[ + "", + "string", + ",", + "U", + "extends", + "(", + ")", + "=>", + "string", + "=", + "(", + ")", + "=>", + "'abc'", + "\"", + ">", + "\n", + "const", + " ", + "p", + " ", + "=", + " ", + "defineProps<{t:", + " ", + "T,", + " ", + "u:", + " ", + "U}>()", + "\n", + "", + "\n\n", + "", + "\n", + "{{", + "p", + ".", + "t", + "(", + ")", + "}}", + "\n", + "{{", + "p", + ".", + "u", + "(", + ")", + "}}", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/tree.json b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/tree.json new file mode 100644 index 00000000..64d30e2d --- /dev/null +++ b/test/fixtures/document-fragment/vue3.3-generic-7-with-arrow/tree.json @@ -0,0 +1,257 @@ +[ + { + "type": "VDocumentFragment", + "text": "\n\n", + "children": [ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + }, + { + "type": "VText", + "text": "\n\n", + "children": [] + }, + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/eslint b/test/fixtures/eslint deleted file mode 160000 index 8bb52766..00000000 --- a/test/fixtures/eslint +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8bb527660ffddc122204fb5bf59076687aaa78b8 diff --git a/test/index.js b/test/index.js index 8f8c9a19..e4d898b3 100644 --- a/test/index.js +++ b/test/index.js @@ -12,12 +12,9 @@ const assert = require("assert") const path = require("path") const fs = require("fs-extra") -const semver = require("semver") const parse = require("../src").parse const parseForESLint = require("../src").parseForESLint -const eslint = require("./lib/eslint-compat")(require("./fixtures/eslint")) -const ESLint = eslint.ESLint -const Linter = eslint.Linter +const eslint = require("eslint") //------------------------------------------------------------------------------ // Helpers @@ -25,7 +22,7 @@ const Linter = eslint.Linter const ORIGINAL_FIXTURE_DIR = path.join(__dirname, "fixtures") const FIXTURE_DIR = path.join(__dirname, "temp") -const PARSER_PATH = path.resolve(__dirname, "../src/index.ts") +const parser = require("../src/index.ts") const BABEL_PARSER_OPTIONS = { parser: "@babel/eslint-parser", @@ -46,7 +43,13 @@ const BABEL_PARSER_OPTIONS = { // Tests //------------------------------------------------------------------------------ -describe("Basic tests", () => { +describe("Basic tests", async () => { + const ESLint = await eslint.loadESLint({ useFlatConfig: true }) + const Linter = class extends eslint.Linter { + constructor() { + super({ configType: "flat" }) + } + } beforeEach(() => { fs.emptyDirSync(FIXTURE_DIR) for (const fileName of fs.readdirSync(ORIGINAL_FIXTURE_DIR)) { @@ -67,11 +70,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["hello.vue"]) const messages = report[0].messages @@ -90,11 +96,14 @@ describe("Basic tests", () => { cwd: FIXTURE_DIR, fix: true, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) await ESLint.outputFixes(await cli.lintFiles(["hello.vue"])) @@ -116,11 +125,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["empty.vue"]) const messages = report[0].messages @@ -134,11 +146,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["no-script.vue"]) const messages = report[0].messages @@ -152,11 +167,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["empty-script.vue"]) const messages = report[0].messages @@ -170,11 +188,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["no-end-script-tag.vue"]) const messages = report[0].messages @@ -188,11 +209,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.js"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["notvue.js"]) const messages = report[0].messages @@ -208,11 +232,14 @@ describe("Basic tests", () => { cwd: FIXTURE_DIR, fix: true, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.js"], + languageOptions: { + parser, + globals: {}, + }, rules: { semi: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) await ESLint.outputFixes(await cli.lintFiles(["notvue.js"])) @@ -225,7 +252,7 @@ describe("Basic tests", () => { "utf8", ) - assert(actual === expected) + assert.strictEqual(actual, expected) }) }) @@ -234,11 +261,14 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, rules: { indent: "error" }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["crlf.vue"]) const messages = report[0].messages @@ -252,15 +282,18 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, - parserOptions: { - ...BABEL_PARSER_OPTIONS, - sourceType: "module", + files: ["*.js"], + languageOptions: { + parser, + globals: {}, + parserOptions: { + ...BABEL_PARSER_OPTIONS, + sourceType: "module", + }, }, rules: { semi: ["error", "never"] }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["typed.js"]) const messages = report[0].messages @@ -268,87 +301,97 @@ describe("Basic tests", () => { assert.deepStrictEqual(messages, []) }) - if (semver.gte(process.version, "10.0.0")) { - it("should notify no error with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + it("should notify no error with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.js"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: "@typescript-eslint/parser", }, - rules: { semi: ["error", "never"] }, }, - useEslintrc: false, - }) - const report = await cli.lintFiles(["typed.js"]) - const messages = report[0].messages - - assert.deepStrictEqual(messages, []) + rules: { semi: ["error", "never"] }, + }, + overrideConfigFile: true, }) + const report = await cli.lintFiles(["typed.js"]) + const messages = report[0].messages - it("should notify no error with multiple parser with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + assert.deepStrictEqual(messages, []) + }) + + it("should notify no error with multiple parser with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.ts", "*.tsx"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: { ts: "@typescript-eslint/parser", }, }, - rules: { semi: ["error", "never"] }, }, - useEslintrc: false, - }) - const report = await cli.lintFiles(["typed.ts", "typed.tsx"]) - - assert.deepStrictEqual(report[0].messages, []) - assert.deepStrictEqual(report[1].messages, []) + rules: { semi: ["error", "never"] }, + }, + overrideConfigFile: true, }) + const report = await cli.lintFiles(["typed.ts", "typed.tsx"]) + + assert.deepStrictEqual(report[0].messages, []) + assert.deepStrictEqual(report[1].messages, []) + }) - it("should notify no error with parser object with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + it("should notify no error with parser object with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.js"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: require("@typescript-eslint/parser"), }, - rules: { semi: ["error", "never"] }, }, - useEslintrc: false, - }) - const report = await cli.lintFiles(["typed.js"]) - const messages = report[0].messages - - assert.deepStrictEqual(messages, []) + rules: { semi: ["error", "never"] }, + }, + overrideConfigFile: true, }) + const report = await cli.lintFiles(["typed.js"]) + const messages = report[0].messages + + assert.deepStrictEqual(messages, []) + }) - it("should notify no error with multiple parser object with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + it("should notify no error with multiple parser object with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.ts", "*.tsx"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: { ts: require("@typescript-eslint/parser"), }, }, - rules: { semi: ["error", "never"] }, }, - useEslintrc: false, - }) - const report = await cli.lintFiles(["typed.ts", "typed.tsx"]) - - assert.deepStrictEqual(report[0].messages, []) - assert.deepStrictEqual(report[1].messages, []) + rules: { semi: ["error", "never"] }, + }, + overrideConfigFile: true, }) - } + const report = await cli.lintFiles(["typed.ts", "typed.tsx"]) + + assert.deepStrictEqual(report[0].messages, []) + assert.deepStrictEqual(report[1].messages, []) + }) }) describe("About fixtures/typed.vue", () => { @@ -356,15 +399,17 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, - parserOptions: { - ...BABEL_PARSER_OPTIONS, - sourceType: "module", + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + parserOptions: { + ...BABEL_PARSER_OPTIONS, + }, }, rules: { semi: ["error", "never"] }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["typed.vue"]) const messages = report[0].messages @@ -372,41 +417,44 @@ describe("Basic tests", () => { assert.deepStrictEqual(messages, []) }) - if (semver.gte(process.version, "10.0.0")) { - it("should notify no error with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + it("should notify no error with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: "@typescript-eslint/parser", }, - rules: { semi: ["error", "never"] }, }, - useEslintrc: false, - }) - const report = await cli.lintFiles(["typed.vue"]) - const messages = report[0].messages - - assert.deepStrictEqual(messages, []) + rules: { semi: ["error", "never"] }, + }, + overrideConfigFile: true, }) - } + const report = await cli.lintFiles(["typed.vue"]) + const messages = report[0].messages + + assert.deepStrictEqual(messages, []) + }) it("should fix 'semi' errors with --fix option with '@babel/eslint-parser'", async () => { const cli = new ESLint({ cwd: FIXTURE_DIR, fix: true, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, - parserOptions: { - ...BABEL_PARSER_OPTIONS, - sourceType: "module", + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + parserOptions: { + ...BABEL_PARSER_OPTIONS, + }, }, rules: { semi: ["error", "always"] }, }, - useEslintrc: false, + overrideConfigFile: true, }) await ESLint.outputFixes(await cli.lintFiles(["typed.vue"])) @@ -422,73 +470,78 @@ describe("Basic tests", () => { assert(actual === expected) }) - if (semver.gte(process.version, "10.0.0")) { - it("should fix 'semi' errors with --fix option with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - fix: true, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + it("should fix 'semi' errors with --fix option with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + fix: true, + overrideConfig: { + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: "@typescript-eslint/parser", }, - rules: { semi: ["error", "always"] }, }, - useEslintrc: false, - }) - await ESLint.outputFixes(await cli.lintFiles(["typed.vue"])) - - const actual = fs.readFileSync( - path.join(FIXTURE_DIR, "typed.vue"), - "utf8", - ) - const expected = fs.readFileSync( - path.join(FIXTURE_DIR, "typed.vue.fixed"), - "utf8", - ) - - assert(actual === expected) + rules: { semi: ["error", "always"] }, + }, + overrideConfigFile: true, }) - } + await ESLint.outputFixes(await cli.lintFiles(["typed.vue"])) + + const actual = fs.readFileSync( + path.join(FIXTURE_DIR, "typed.vue"), + "utf8", + ) + const expected = fs.readFileSync( + path.join(FIXTURE_DIR, "typed.vue.fixed"), + "utf8", + ) + + assert.strictEqual(actual, expected) + }) }) - if (semver.gte(process.version, "10.0.0")) { - describe("About fixtures/ts-scope-manager.vue", () => { - it("should calculate the correct location with '@typescript-eslint/parser'", async () => { - const cli = new ESLint({ - cwd: FIXTURE_DIR, - overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + describe("About fixtures/ts-scope-manager.vue", () => { + it("should calculate the correct location with '@typescript-eslint/parser'", async () => { + const cli = new ESLint({ + cwd: FIXTURE_DIR, + overrideConfig: { + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, parserOptions: { parser: "@typescript-eslint/parser", }, - rules: { "no-unused-vars": ["error"] }, }, - useEslintrc: false, - }) - const report = await cli.lintFiles(["ts-scope-manager.vue"]) - const messages = report[0].messages - - assert.strictEqual(messages.length, 1) - assert.deepStrictEqual(messages[0].line, 8) - assert.deepStrictEqual(messages[0].column, 8) - assert.deepStrictEqual(messages[0].endLine, 8) - assert.deepStrictEqual(messages[0].endColumn, 14) + rules: { "no-unused-vars": ["error"] }, + }, + overrideConfigFile: true, }) + const report = await cli.lintFiles(["ts-scope-manager.vue"]) + const messages = report[0].messages + + assert.strictEqual(messages.length, 1) + assert.deepStrictEqual(messages[0].line, 8) + assert.deepStrictEqual(messages[0].column, 8) + assert.deepStrictEqual(messages[0].endLine, 8) + assert.deepStrictEqual(messages[0].endColumn, 14) }) - } + }) describe("About fixtures/svg-attrs.vue", () => { it("parses attributes with colons", async () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["svg-attrs-colon.vue"]) const messages = report[0].messages @@ -500,10 +553,13 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { es6: true, node: true }, - parser: PARSER_PATH, + files: ["*.vue"], + languageOptions: { + parser, + globals: {}, + }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles(["svg-attrs-camel-case.vue"]) const messages = report[0].messages @@ -517,18 +573,21 @@ describe("Basic tests", () => { const cli = new ESLint({ cwd: FIXTURE_DIR, overrideConfig: { - env: { browser: true, node: true }, - parser: PARSER_PATH, - parserOptions: { - ...BABEL_PARSER_OPTIONS, - sourceType: "module", - ecmaVersion: 2017, + files: ["*.vue"], + languageOptions: { + parser, + parserOptions: { + ...BABEL_PARSER_OPTIONS, + sourceType: "module", + ecmaVersion: "latest", + }, + globals: {}, }, rules: { "no-use-before-define": "error", }, }, - useEslintrc: false, + overrideConfigFile: true, }) const report = await cli.lintFiles([ "location-issue-with-babel-eslint.vue", @@ -684,7 +743,7 @@ describe("Basic tests", () => { const indexOfDecorator = code.indexOf("@Component") const ast = parse(code, { ...BABEL_PARSER_OPTIONS, - ecmaVersion: 2017, + ecmaVersion: "latest", sourceType: "module", // Implicit parserOptions to detect whether the current ESLint supports `result.scopeManager` and `result.visitorKeys`. @@ -704,22 +763,25 @@ describe("Basic tests", () => { it("should work even if AST object was reused.", () => { const code = "" const config = { - parser: PARSER_PATH, + languageOptions: { + parser, + }, + plugins: buildPlugins({ + create(context) { + return context.sourceCode.parserServices.defineTemplateBodyVisitor( + { + "VElement[name='div']"(node) { + context.report({ node, message: "OK" }) + }, + }, + ) + }, + }), rules: { - "test-rule": "error", + "test/test-rule": "error", }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - linter.defineRule("test-rule", (context) => - context.parserServices.defineTemplateBodyVisitor({ - "VElement[name='div']"(node) { - context.report({ node, message: "OK" }) - }, - }), - ) - const messages1 = linter.verify(code, config) const messages2 = linter.verify(linter.getSourceCode(), config) @@ -732,22 +794,28 @@ describe("Basic tests", () => { it("should work even if used sibling selector.", () => { const code = "" const config = { - parser: PARSER_PATH, + languageOptions: { + parser, + }, + plugins: buildPlugins({ + create(context) { + return context.sourceCode.parserServices.defineTemplateBodyVisitor( + { + "* ~ *"(node) { + context.report({ + node, + message: "OK", + }) + }, + }, + ) + }, + }), rules: { - "test-rule": "error", + "test/test-rule": "error", }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - linter.defineRule("test-rule", (context) => - context.parserServices.defineTemplateBodyVisitor({ - "* ~ *"(node) { - context.report({ node, message: "OK" }) - }, - }), - ) - const messages1 = linter.verify(code, config) const messages2 = linter.verify(linter.getSourceCode(), config) @@ -763,12 +831,11 @@ describe("Basic tests", () => { const code = '' const config = { - parser: PARSER_PATH, + languageOptions: { + parser, + }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - const messages = linter.verify(code, config) assert.strictEqual(messages.length, 1) @@ -780,15 +847,14 @@ describe("Basic tests", () => { it("should notify parsing error #2", () => { const code = "" const config = { - parser: PARSER_PATH, - parserOptions: { - ecmaVersion: 2015, + languageOptions: { + parser, + parserOptions: { + ecmaVersion: "latest", + }, }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - const messages = linter.verify(code, config) assert.strictEqual(messages.length, 1) @@ -800,12 +866,11 @@ describe("Basic tests", () => { it("should notify parsing error #3", () => { const code = '' const config = { - parser: PARSER_PATH, + languageOptions: { + parser, + }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - const messages = linter.verify(code, config) assert.strictEqual(messages.length, 1) @@ -818,15 +883,14 @@ describe("Basic tests", () => { const code = "" const config = { - parser: PARSER_PATH, + languageOptions: { + parser, + }, rules: { "no-undef": "error", }, } const linter = new Linter() - - linter.defineParser(PARSER_PATH, require(PARSER_PATH)) - const messages = linter.verify(code, config) assert.strictEqual(messages.length, 1) @@ -834,3 +898,13 @@ describe("Basic tests", () => { }) }) }) + +function buildPlugins(rule) { + return { + test: { + rules: { + "test-rule": rule, + }, + }, + } +} diff --git a/test/integrations.js b/test/integrations.js index 1f230e95..88e9c501 100644 --- a/test/integrations.js +++ b/test/integrations.js @@ -6,7 +6,6 @@ const assert = require("assert") const path = require("path") const fs = require("fs-extra") const cp = require("child_process") -const semver = require("semver") const eslintCompat = require("./lib/eslint-compat") //------------------------------------------------------------------------------ @@ -20,9 +19,6 @@ const FIXTURE_DIR = path.join(__dirname, "fixtures/integrations") //------------------------------------------------------------------------------ describe("Integration tests", () => { - if (!semver.gte(process.version, "14.0.0")) { - return - } for (const target of fs.readdirSync(FIXTURE_DIR)) { it(target, async () => { let ESLint = eslintCompat(require("eslint")).ESLint @@ -32,11 +28,13 @@ describe("Integration tests", () => { process.chdir(path.join(FIXTURE_DIR, target)) cp.execSync("npm i", { stdio: "inherit" }) ESLint = eslintCompat( - require(path.join( - FIXTURE_DIR, - target, - "node_modules/eslint", - )), + require( + path.join( + FIXTURE_DIR, + target, + "node_modules/eslint", + ), + ), ).ESLint } finally { process.chdir(originalCwd) @@ -94,8 +92,8 @@ describe("Integration tests", () => { a.filePath < b.filePath ? -1 : a.filePath < b.filePath - ? 1 - : 0, + ? 1 + : 0, ) } }) diff --git a/test/lib/eslint-compat.js b/test/lib/eslint-compat.js index 041807f3..9077ec55 100644 --- a/test/lib/eslint-compat.js +++ b/test/lib/eslint-compat.js @@ -80,7 +80,6 @@ function getESLintClassForV6(eslint) { * @param {Parameters} params * @returns {ReturnType} */ - // eslint-disable-next-line require-await -- ignore async lintText(...params) { const result = this.engine.executeOnText( params[0], @@ -93,7 +92,6 @@ function getESLintClassForV6(eslint) { * @param {Parameters} params * @returns {ReturnType} */ - // eslint-disable-next-line require-await -- ignore async lintFiles(...params) { const result = this.engine.executeOnFiles( Array.isArray(params[0]) ? params[0] : [params[0]], @@ -105,7 +103,6 @@ function getESLintClassForV6(eslint) { * @param {Parameters} params * @returns {ReturnType} */ - // eslint-disable-next-line require-await -- ignore static async outputFixes(...params) { return eslint.CLIEngine.outputFixes({ results: params[0], diff --git a/test/parser-options-project.js b/test/parser-options-project.js new file mode 100644 index 00000000..1fc3b12a --- /dev/null +++ b/test/parser-options-project.js @@ -0,0 +1,134 @@ +"use strict" + +const assert = require("assert") +const { parseForESLint } = require("../src") +const espree = require("espree") + +describe("use `project: undefined` when parsing template script-let", () => { + it("should be the project option is defined only once in Simple SFC.", () => { + let projectCount = 0 + parseForESLint( + ` + + `, + { + project: true, + sourceType: "module", + ecmaVersion: "latest", + parser: { + parseForESLint(code, options) { + if (options.project) { + projectCount++ + } + + return { + ast: espree.parse(code, options), + } + }, + }, + }, + ) + assert.strictEqual(projectCount, 1) + }) + it("should be the project option is defined only once in + + + `, + { + project: true, + sourceType: "module", + ecmaVersion: "latest", + parser: { + parseForESLint(code, options) { + if (options.project) { + projectCount++ + } + + return { + ast: espree.parse(code, options), + } + }, + }, + }, + ) + assert.strictEqual(projectCount, 1) + }) + + it("should be the project option is defined only once in + + + `, + { + project: true, + sourceType: "module", + ecmaVersion: "latest", + parser: { + parseForESLint(code, options) { + if (options.project) { + projectCount++ + } + + return { + ast: espree.parse(code, options), + } + }, + }, + }, + ) + assert.strictEqual(projectCount, 1) + }) +}) diff --git a/test/parser-options.js b/test/parser-options.js index 2c7f26eb..3c7e4e1b 100644 --- a/test/parser-options.js +++ b/test/parser-options.js @@ -6,33 +6,43 @@ const assert = require("assert") const { parseForESLint } = require("../src") -const eslint = require("./fixtures/eslint") +const eslint = require("eslint") const Linter = eslint.Linter describe("parserOptions", () => { describe("parser", () => { - const linter = new Linter() - linter.defineParser("vue-eslint-parser", { parseForESLint }) - linter.defineRule("vue/template-test", { - create(context) { - return { - Program(node) { - const element = node.templateBody - if (element != null) { - context.report({ node, message: "test" }) + const linter = new Linter({ configType: "flat" }) + const parser = { parseForESLint } + const plugin = { + rules: { + "template-test": { + create(context) { + return { + Program(node) { + const element = node.templateBody + if (element != null) { + context.report({ node, message: "test" }) + } + }, } }, - } + }, }, - }) + } it("false then skip parsing '` const config = { - parser: "vue-eslint-parser", - parserOptions: { - parser: false, + files: ["*.vue"], + plugins: { + vue: plugin, + }, + languageOptions: { + parser, + parserOptions: { + parser: false, + }, }, rules: { "vue/template-test": "error", @@ -44,12 +54,19 @@ describe("parserOptions", () => { assert.strictEqual(messages[0].ruleId, "vue/template-test") }) - it("Fail in ` const config = { - parser: "vue-eslint-parser", - parserOptions: {}, + files: ["*.vue"], + plugins: { + vue: plugin, + }, + languageOptions: { + parser, + sourceType: "script", + parserOptions: {}, + }, rules: {}, } const messages = linter.verify(code, config, "test.vue") diff --git a/test/test-utils.js b/test/test-utils.js new file mode 100644 index 00000000..8ea0b760 --- /dev/null +++ b/test/test-utils.js @@ -0,0 +1,140 @@ +const escope = require("eslint-scope") + +module.exports = { replacer, getAllTokens, scopeToJSON, analyze } + +/** + * Remove `parent` properties from the given AST. + * @param {string} key The key. + * @param {any} value The value of the key. + * @returns {any} The value of the key to output. + */ +function replacer(key, value) { + if (key === "parent") { + return undefined + } + if (key === "errors" && Array.isArray(value)) { + return value.map((e) => ({ + message: e.message, + index: e.index, + lineNumber: e.lineNumber, + column: e.column, + })) + } + return value +} + +/** + * Get all tokens of the given AST. + * @param {ASTNode} ast The root node of AST. + * @returns {Token[]} Tokens. + */ +function getAllTokens(ast) { + const tokenArrays = [ast.tokens, ast.comments] + if (ast.templateBody != null) { + tokenArrays.push(ast.templateBody.tokens, ast.templateBody.comments) + } + return Array.prototype.concat.apply([], tokenArrays) +} + +function scopeToJSON(scopeManager) { + return JSON.stringify(normalizeScope(scopeManager.globalScope), replacer, 4) + + function normalizeScope(scope) { + return { + type: scope.type, + variables: scope.variables.map(normalizeVar), + references: scope.references.map(normalizeReference), + childScopes: scope.childScopes.map(normalizeScope), + through: scope.through.map(normalizeReference), + } + } + + function normalizeVar(v) { + return { + name: v.name, + identifiers: v.identifiers.map(normalizeId), + defs: v.defs.map(normalizeDef), + references: v.references.map(normalizeReference), + } + } + + function normalizeReference(reference) { + return { + identifier: normalizeId(reference.identifier), + from: reference.from.type, + resolved: normalizeId( + reference.resolved && + reference.resolved.defs && + reference.resolved.defs[0] && + reference.resolved.defs[0].name, + ), + init: reference.init ?? null, + vueUsedInTemplate: reference.vueUsedInTemplate + ? reference.vueUsedInTemplate + : undefined, + } + } + + function normalizeDef(def) { + return { + type: def.type, + node: normalizeDefNode(def.node), + name: def.name.name, + } + } + + function normalizeId(identifier) { + return ( + identifier && { + type: identifier.type, + name: identifier.name, + loc: identifier.loc, + } + ) + } + + function normalizeDefNode(node) { + return { + type: node.type, + loc: node.loc, + } + } +} + +/** + * Analyze scope + */ +function analyze(ast, parserOptions) { + const ecmaVersion = parserOptions.ecmaVersion ?? 2022 + const ecmaFeatures = parserOptions.ecmaFeatures ?? {} + const sourceType = parserOptions.sourceType ?? "script" + const result = escope.analyze(ast, { + ignoreEval: true, + nodejsScope: false, + impliedStrict: ecmaFeatures.impliedStrict, + ecmaVersion, + sourceType, + fallback: getFallbackKeys, + }) + + return result + + function getFallbackKeys(node) { + return Object.keys(node).filter(fallbackKeysFilter, node) + } + + function fallbackKeysFilter(key) { + const value = null + return ( + key !== "comments" && + key !== "leadingComments" && + key !== "loc" && + key !== "parent" && + key !== "range" && + key !== "tokens" && + key !== "trailingComments" && + typeof value === "object" && + (typeof value.type === "string" || Array.isArray(value)) + ) + } +} diff --git a/test/tokens.js b/test/tokens.js index 09cc4a2c..de370298 100644 --- a/test/tokens.js +++ b/test/tokens.js @@ -52,10 +52,7 @@ describe("services.getTemplateBodyTokenStore", () => { let tokens = null before(() => { - const result = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ) + const result = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }) ast = result.ast tokens = result.services.getTemplateBodyTokenStore() }) @@ -288,4 +285,19 @@ describe("services.getTemplateBodyTokenStore", () => { assert.deepStrictEqual(actual, ["div", ">"]) }) }) + + describe("TokenStore#get{Range,Loc}()", () => { + it("should return loc and range.", () => { + const { + templateBody: { + children: [node], + tokens: [token], + }, + } = ast + assert.equal(typeof tokens.getRange(node)[0], "number") + assert.equal(typeof tokens.getRange(token)[1], "number") + assert.equal(typeof tokens.getLoc(node).start.line, "number") + assert.equal(typeof tokens.getLoc(node).end.column, "number") + }) + }) }) diff --git a/test/variables-references.js b/test/variables-references.js index 8a43d0a3..4e6a590b 100644 --- a/test/variables-references.js +++ b/test/variables-references.js @@ -34,10 +34,7 @@ describe("[references] expression containers", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should have references", () => { @@ -62,10 +59,7 @@ describe("[references] expression containers", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should have references", () => { @@ -83,10 +77,7 @@ describe("[references] expression containers", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should not include $event references.", () => { @@ -110,10 +101,7 @@ describe("[variables] elements", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should have references", () => { @@ -138,10 +126,7 @@ describe("[variables] elements", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should have references", () => { @@ -169,10 +154,7 @@ describe("[variables] elements", () => { let ast = null before(() => { - ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast }) it("should have variables", () => { @@ -204,10 +186,7 @@ describe("Variables of v-for and references", () => { let mustacheReferences3 = null before(() => { - const ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + const ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast variables = ast.templateBody.children[0].variables vForReferences = ast.templateBody.children[0].startTag.attributes[0].value.references @@ -274,10 +253,7 @@ describe("Variables of template-scope and references", () => { let mustacheReferences3 = null before(() => { - const ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + const ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast variables = ast.templateBody.children[0].variables vBindKeyReferences = ast.templateBody.children[0].startTag.attributes[1].value.references @@ -336,10 +312,7 @@ describe("Variables of v-for and references of dynamic arguments", () => { let vBindKeyReferences = null before(() => { - const ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + const ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast variables = ast.templateBody.children[0].variables vForReferences = ast.templateBody.children[0].startTag.attributes[0].value.references @@ -366,10 +339,7 @@ describe("Variables of v-for and references of v-bind same-name shorthand", () = let vBindReferences = null before(() => { - const ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + const ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast variables = ast.templateBody.children[0].variables vForReferences = ast.templateBody.children[0].startTag.attributes[0].value.references @@ -395,10 +365,7 @@ describe("Variables of v-for and references of v-bind same-name shorthand with k let vBindReferences = null before(() => { - const ast = parse( - code, - Object.assign({ filePath: "test.vue" }, PARSER_OPTIONS), - ).ast + const ast = parse(code, { filePath: "test.vue", ...PARSER_OPTIONS }).ast variables = ast.templateBody.children[0].variables vForReferences = ast.templateBody.children[0].startTag.attributes[0].value.references diff --git a/tsconfig.json b/tsconfig.json index e4397962..e4cbfcc2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,41 +1,41 @@ { - "compileOnSave": true, - "compilerOptions": { - "allowJs": false, - "allowSyntheticDefaultImports": true, - "allowUnreachableCode": false, - "allowUnusedLabels": false, - "alwaysStrict": true, - "baseUrl": ".", - "checkJs": false, - "declaration": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "inlineSources": true, - "lib": ["es2015"], - "module": "commonjs", - "moduleResolution": "node", - "newLine": "LF", - "noEmitOnError": true, - "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "outDir": ".temp", - "paths": { - "*": ["typings/*"] - }, - "pretty": true, - "removeComments": true, - "sourceMap": true, - "sourceRoot": "src", - "strict": true, - "strictNullChecks": true, - "target": "es2015", - - "skipLibCheck": true, + "compileOnSave": true, + "compilerOptions": { + "allowJs": false, + "allowSyntheticDefaultImports": true, + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "alwaysStrict": true, + "baseUrl": ".", + "checkJs": false, + "declaration": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "inlineSources": true, + "lib": ["es2015"], + "module": "commonjs", + "moduleResolution": "node", + "newLine": "LF", + "noEmitOnError": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "outDir": ".temp", + "paths": { + "*": ["typings/*"] }, - "include": ["src/**/*.ts"] + "pretty": true, + "removeComments": true, + "sourceMap": true, + "sourceRoot": "src", + "strict": true, + "strictNullChecks": true, + "target": "ES2024", + + "skipLibCheck": true + }, + "include": ["src/**/*.ts"] } diff --git a/typings/esquery/index.d.ts b/typings/esquery/index.d.ts index 2e4d0fac..1861f0bb 100644 --- a/typings/esquery/index.d.ts +++ b/typings/esquery/index.d.ts @@ -4,9 +4,8 @@ * See LICENSE file in root directory for full license. */ -import type { Node } from "../../src/ast" -// eslint-disable-next-line @mysticatea/node/no-missing-import -import type { VisitorKeys } from "../eslint-visitor-keys" +import type { Node } from "../../src/ast/index" +import type { VisitorKeys } from "eslint-visitor-keys" export type Selector = | AdjacentSelector