diff --git a/.cspell.json b/.cspell.json index 2d939d1b4a3..daf674b70f3 100644 --- a/.cspell.json +++ b/.cspell.json @@ -12,7 +12,8 @@ "**/*.{json,snap}", ".cspell.json", "yarn.lock", - ".github/workflows/**" + ".github/workflows/**", + ".vscode/*.json" ], "dictionaries": [ "typescript", @@ -57,6 +58,7 @@ "ESLint", "ESLint's", "espree", + "esrecurse", "estree", "IDE's", "IIFE", @@ -75,11 +77,13 @@ "Premade", "prettier's", "recurse", + "redeclared", "reimplement", "resync", "ROADMAP", "ruleset", "rulesets", + "serializers", "superset", "thenables", "transpiles", diff --git a/.eslintrc.js b/.eslintrc.js index 2c69c6ecfed..6ce31fc7cbd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -55,6 +55,11 @@ module.exports = { '@typescript-eslint/prefer-nullish-coalescing': 'error', '@typescript-eslint/prefer-optional-chain': 'error', '@typescript-eslint/unbound-method': 'off', + '@typescript-eslint/prefer-as-const': 'error', + '@typescript-eslint/no-unused-vars': [ + 'warn', + { varsIgnorePattern: '^_', argsIgnorePattern: '^_' }, + ], // TODO - enable these new recommended rules '@typescript-eslint/no-floating-promises': 'off', @@ -224,5 +229,18 @@ module.exports = { 'no-console': 'off', }, }, + // generated files + { + files: [ + 'packages/scope-manager/src/lib/*.ts', + 'packages/eslint-plugin/src/configs/*.ts', + ], + rules: { + // allow console logs in tools and tests + '@typescript-eslint/internal/no-poorly-typed-ts-props': 'off', + '@typescript-eslint/internal/no-typescript-default-import': 'off', + '@typescript-eslint/internal/prefer-ast-types-enum': 'off', + }, + }, ], }; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b60c976543f..cfc7a1ea39e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,8 +4,6 @@ on: push: branches: - master - # TODO - delete this before merging v3 into master - - v3 pull_request: branches: - '**' @@ -103,6 +101,12 @@ jobs: env: CI: true + - name: Run unit tests for scope-manager + run: yarn test + working-directory: packages/scope-manager + env: + CI: true + - name: Run unit tests for experimental-utils run: yarn test working-directory: packages/experimental-utils @@ -269,6 +273,12 @@ jobs: env: CI: true + - name: Run unit tests for scope-manager + run: yarn test + working-directory: packages/scope-manager + env: + CI: true + - name: Run unit tests for experimental-utils run: yarn test working-directory: packages/experimental-utils diff --git a/.prettierignore b/.prettierignore index 5155a78aa50..048e552b38b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,5 @@ **/tests/fixtures/**/* +!packages/scope-manager/tests/fixtures/**/* **/tests/fixture-project/**/* **/dist **/coverage diff --git a/.vscode/extensions.json b/.vscode/extensions.json index d91eb64d0d4..3c84af70cc5 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,10 +1,11 @@ { "recommendations": [ - "esbenp.prettier-vscode", + "davidanson.vscode-markdownlint", "dbaeumer.vscode-eslint", "editorconfig.editorconfig", + "esbenp.prettier-vscode", "streetsidesoftware.code-spell-checker", - "davidanson.vscode-markdownlint" + "tlent.jest-snapshot-language-support" ], "unwantedRecommendations": ["hookyqr.beautify", "dbaeumer.jshint"] } diff --git a/.vscode/launch.json b/.vscode/launch.json index ff1507f8c3a..5ad1e226457 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -32,6 +32,8 @@ "${workspaceFolder}/packages/types/dist/index.js", "${workspaceFolder}/packages/visitor-keys/src/index.ts", "${workspaceFolder}/packages/visitor-keys/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", ], }, { @@ -62,6 +64,8 @@ "${workspaceFolder}/packages/types/dist/index.js", "${workspaceFolder}/packages/visitor-keys/src/index.ts", "${workspaceFolder}/packages/visitor-keys/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", ], }, { @@ -92,6 +96,8 @@ "${workspaceFolder}/packages/types/dist/index.js", "${workspaceFolder}/packages/visitor-keys/src/index.ts", "${workspaceFolder}/packages/visitor-keys/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", ], }, { @@ -122,6 +128,8 @@ "${workspaceFolder}/packages/types/dist/index.js", "${workspaceFolder}/packages/visitor-keys/src/index.ts", "${workspaceFolder}/packages/visitor-keys/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", ], }, { @@ -152,7 +160,41 @@ "${workspaceFolder}/packages/types/dist/index.js", "${workspaceFolder}/packages/visitor-keys/src/index.ts", "${workspaceFolder}/packages/visitor-keys/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", ], - } + }, + { + "type": "node", + "request": "launch", + "name": "Run currently opened scope-manager test", + "cwd": "${workspaceFolder}/packages/scope-manager/", + "program": "${workspaceFolder}/node_modules/jest/bin/jest.js", + "args": [ + "--runInBand", + "--no-cache", + "--no-coverage", + "${fileBasename}" + ], + "sourceMaps": true, + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "skipFiles": [ + "${workspaceFolder}/packages/experimental-utils/src/index.ts", + "${workspaceFolder}/packages/experimental-utils/dist/index.js", + "${workspaceFolder}/packages/experimental-utils/src/ts-estree.ts", + "${workspaceFolder}/packages/experimental-utils/dist/ts-estree.js", + "${workspaceFolder}/packages/parser/src/index.ts", + "${workspaceFolder}/packages/parser/dist/index.js", + "${workspaceFolder}/packages/typescript-estree/src/index.ts", + "${workspaceFolder}/packages/typescript-estree/dist/index.js", + "${workspaceFolder}/packages/types/src/index.ts", + "${workspaceFolder}/packages/types/dist/index.js", + "${workspaceFolder}/packages/visitor-keys/src/index.ts", + "${workspaceFolder}/packages/visitor-keys/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", + "${workspaceFolder}/packages/scope-manager/dist/index.js", + ], + }, ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index dc6744448f3..20830a2fa0b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,4 +18,21 @@ "javascript.preferences.quoteStyle": "single", "typescript.preferences.quoteStyle": "single", "editor.defaultFormatter": "esbenp.prettier-vscode", + + // make the .shot files from jest-specific-snapshot act like normal snapshots + "files.associations": { + "*.shot": "jest-snapshot" + }, + "vsicons.associations.files": [ + { + "icon": "jest_snapshot", + "extensions": [ + ".ts.shot", + ".tsx.shot", + ".js.shot", + ".jsx.shot", + ], + "extends": "jest_snapshot" + }, + ], } diff --git a/package.json b/package.json index e01a0ed0c89..197f31c38df 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "@types/jest": "^25.2.1", "@types/node": "^13.13.5", "@types/prettier": "^2.0.0", + "@types/rimraf": "^3.0.0", "all-contributors-cli": "^6.14.2", "cspell": "^4.0.61", "cz-conventional-changelog": "^3.2.0", diff --git a/packages/eslint-plugin-internal/jest.config.js b/packages/eslint-plugin-internal/jest.config.js index 1123e5ab8ad..cce8d6c61ba 100644 --- a/packages/eslint-plugin-internal/jest.config.js +++ b/packages/eslint-plugin-internal/jest.config.js @@ -1,5 +1,7 @@ 'use strict'; +// @ts-check +/** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { globals: { 'ts-jest': { diff --git a/packages/eslint-plugin-tslint/jest.config.js b/packages/eslint-plugin-tslint/jest.config.js index 2cc2459cf65..76cf7150459 100644 --- a/packages/eslint-plugin-tslint/jest.config.js +++ b/packages/eslint-plugin-tslint/jest.config.js @@ -1,5 +1,7 @@ 'use strict'; +// @ts-check +/** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { globals: { 'ts-jest': { diff --git a/packages/eslint-plugin/jest.config.js b/packages/eslint-plugin/jest.config.js index 1123e5ab8ad..cce8d6c61ba 100644 --- a/packages/eslint-plugin/jest.config.js +++ b/packages/eslint-plugin/jest.config.js @@ -1,5 +1,7 @@ 'use strict'; +// @ts-check +/** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { globals: { 'ts-jest': { diff --git a/packages/eslint-plugin/src/configs/all.ts b/packages/eslint-plugin/src/configs/all.ts index 642d6f736d0..68923e26e8a 100644 --- a/packages/eslint-plugin/src/configs/all.ts +++ b/packages/eslint-plugin/src/configs/all.ts @@ -1,3 +1,7 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:configs + export = { extends: ['./configs/base', './configs/eslint-recommended'], rules: { diff --git a/packages/eslint-plugin/src/configs/base.ts b/packages/eslint-plugin/src/configs/base.ts index 652bf9db1ee..528e00c7778 100644 --- a/packages/eslint-plugin/src/configs/base.ts +++ b/packages/eslint-plugin/src/configs/base.ts @@ -1,3 +1,7 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:configs + export = { parser: '@typescript-eslint/parser', parserOptions: { sourceType: 'module' }, diff --git a/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts b/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts index 57e29f3e401..40872fa72f3 100644 --- a/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts +++ b/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts @@ -1,3 +1,7 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:configs + export = { extends: ['./configs/base', './configs/eslint-recommended'], rules: { diff --git a/packages/eslint-plugin/src/configs/recommended.ts b/packages/eslint-plugin/src/configs/recommended.ts index 8aac1a8a3b0..d9450197c41 100644 --- a/packages/eslint-plugin/src/configs/recommended.ts +++ b/packages/eslint-plugin/src/configs/recommended.ts @@ -1,3 +1,7 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:configs + export = { extends: ['./configs/base', './configs/eslint-recommended'], rules: { diff --git a/packages/eslint-plugin/tools/generate-configs.ts b/packages/eslint-plugin/tools/generate-configs.ts index 6830d266e99..e78808aa4b1 100644 --- a/packages/eslint-plugin/tools/generate-configs.ts +++ b/packages/eslint-plugin/tools/generate-configs.ts @@ -5,6 +5,16 @@ import path from 'path'; import { format, resolveConfig } from 'prettier'; import rules from '../src/rules'; +function addAutoGeneratedComment(code: string): string { + return [ + '// THIS CODE WAS AUTOMATICALLY GENERATED', + '// DO NOT EDIT THIS CODE BY HAND', + '// YOU CAN REGENERATE IT USING yarn generate:configs', + '', + code, + ].join('\n'); +} + const prettierConfig = resolveConfig.sync(__dirname); interface LinterConfigRules { @@ -117,8 +127,9 @@ function reducer( * Helper function writes configuration. */ function writeConfig(config: LinterConfig, filePath: string): void { + // note: we use `export =` because ESLint will import these configs via a commonjs import const code = `export = ${JSON.stringify(config)};`; - const configStr = format(code, { + const configStr = format(addAutoGeneratedComment(code), { parser: 'typescript', ...prettierConfig, }); diff --git a/packages/experimental-utils/jest.config.js b/packages/experimental-utils/jest.config.js index 1123e5ab8ad..cce8d6c61ba 100644 --- a/packages/experimental-utils/jest.config.js +++ b/packages/experimental-utils/jest.config.js @@ -1,5 +1,7 @@ 'use strict'; +// @ts-check +/** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { globals: { 'ts-jest': { diff --git a/packages/scope-manager/LICENSE b/packages/scope-manager/LICENSE new file mode 100644 index 00000000000..7e7370143b2 --- /dev/null +++ b/packages/scope-manager/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 TypeScript ESLint and other contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/scope-manager/README.md b/packages/scope-manager/README.md new file mode 100644 index 00000000000..6d389a32f31 --- /dev/null +++ b/packages/scope-manager/README.md @@ -0,0 +1,98 @@ +

TypeScript Scope Manager

+ +

+ CI + NPM Version + NPM Downloads +

+ +This is a fork of [`eslint-scope`](https://github.com/eslint/eslint-scope), enhanced to support TypeScript functionality. +[You can view the original licence for the code here](https://github.com/eslint/eslint-scope/blob/dbddf14d5771b21b5da704213e4508c660ca1c64/LICENSE). + +This package is consumed automatically by [`@typescript-eslint/parser`](../parser). +You probably don't want to use it directly. + +## Getting Started + +**[You can find our Getting Started docs here](../../docs/getting-started/linting/README.md)** + +## Installation + +```bash +$ yarn add -D typescript @typescript-eslint/scope-manager +$ npm i --save-dev typescript @typescript-eslint/scope-manager +``` + +## API + +### `analyze(tree, options)` + +Analyses a given AST and returns the resulting `ScopeManager`. + +```ts +interface AnalyzeOptions { + /** + * Known visitor keys. + */ + childVisitorKeys?: Record | null; + + /** + * Which ECMAScript version is considered. + * Defaults to `2018`. + */ + ecmaVersion?: EcmaVersion; + + /** + * Whether the whole script is executed under node.js environment. + * When enabled, the scope manager adds a function scope immediately following the global scope. + * Defaults to `false`. + */ + globalReturn?: boolean; + + /** + * Implied strict mode (if ecmaVersion >= 5). + * Defaults to `false`. + */ + impliedStrict?: boolean; + + /** + * The lib used by the project. + * This automatically defines a type variable for any types provided by the configured TS libs. + * For more information, see https://www.typescriptlang.org/tsconfig#lib + * + * Defaults to the lib for the provided `ecmaVersion`. + */ + lib?: Lib[]; + + /** + * The source type of the script. + */ + sourceType?: 'script' | 'module'; +} +``` + +Example usage: + +```ts +import { analyze } from '@typescript-eslint/scope-manager'; +import { parse } from '@typescript-eslint/typescript-estree'; + +const code = `const hello: string = 'world';`; +const ast = parse(code, { + // note that scope-manager requires ranges on the AST + range: true, +}); +const scope = analyze(ast, { + ecmaVersion: 2020, + sourceType: 'module', +}); +``` + +## References + +- https://eslint.org/docs/developer-guide/scope-manager-interface +- https://github.com/eslint/eslint-scope + +## Contributing + +[See the contributing guide here](../../CONTRIBUTING.md) diff --git a/packages/scope-manager/jest.config.js b/packages/scope-manager/jest.config.js new file mode 100644 index 00000000000..3e3bcb726ed --- /dev/null +++ b/packages/scope-manager/jest.config.js @@ -0,0 +1,24 @@ +'use strict'; + +// @ts-check +/** @type {import('@jest/types').Config.InitialOptions} */ +module.exports = { + globals: { + 'ts-jest': { + isolatedModules: true, + }, + }, + testEnvironment: 'node', + transform: { + [/^.+\.tsx?$/.source]: 'ts-jest', + }, + testRegex: [ + /.\/tests\/.+\.test\.ts$/.source, + /.\/tests\/eslint-scope\/[^/]+\.test\.ts$/.source, + ], + collectCoverage: false, + collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'], + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], + coverageReporters: ['text-summary', 'lcov'], + setupFilesAfterEnv: ['./tests/util/serializers/index.ts'], +}; diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json new file mode 100644 index 00000000000..e23d18d0401 --- /dev/null +++ b/packages/scope-manager/package.json @@ -0,0 +1,67 @@ +{ + "name": "@typescript-eslint/scope-manager", + "version": "3.4.0", + "description": "TypeScript scope analyser for ESLint", + "keywords": [ + "eslint", + "typescript", + "estree" + ], + "engines": { + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "files": [ + "dist", + "package.json", + "README.md", + "LICENSE" + ], + "repository": { + "type": "git", + "url": "https://github.com/typescript-eslint/typescript-eslint.git", + "directory": "packages/scope-manager" + }, + "bugs": { + "url": "https://github.com/typescript-eslint/typescript-eslint/issues" + }, + "license": "MIT", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "scripts": { + "build": "tsc -b tsconfig.build.json", + "postbuild": "downlevel-dts dist _ts3.4/dist", + "clean": "tsc -b tsconfig.build.json --clean", + "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", + "generate:lib": "../../node_modules/.bin/ts-node --files --transpile-only tools/generate-lib.ts", + "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", + "test": "jest --coverage", + "typecheck": "tsc -p tsconfig.json --noEmit" + }, + "dependencies": { + "@typescript-eslint/types": "3.4.0", + "@typescript-eslint/visitor-keys": "3.4.0" + }, + "devDependencies": { + "@types/jest-specific-snapshot": "^0.5.4", + "@types/mkdirp": "^1.0.0", + "@typescript-eslint/typescript-estree": "3.4.0", + "glob": "^7.1.6", + "jest-specific-snapshot": "^3.0.0", + "make-dir": "^3.1.0", + "prettier": "*", + "pretty-format": "^25.5.0", + "rimraf": "*", + "typescript": "*" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "typesVersions": { + "<3.8": { + "*": [ + "_ts3.4/*" + ] + } + } +} diff --git a/packages/scope-manager/src/ID.ts b/packages/scope-manager/src/ID.ts new file mode 100644 index 00000000000..1595c2a137d --- /dev/null +++ b/packages/scope-manager/src/ID.ts @@ -0,0 +1,20 @@ +const ID_CACHE = new Map(); +let NEXT_KEY = 0; + +function createIdGenerator(): () => number { + const key = (NEXT_KEY += 1); + ID_CACHE.set(key, 0); + + return (): number => { + const current = ID_CACHE.get(key) ?? 0; + const next = current + 1; + ID_CACHE.set(key, next); + return next; + }; +} + +function resetIds(): void { + ID_CACHE.clear(); +} + +export { createIdGenerator, resetIds }; diff --git a/packages/scope-manager/src/ScopeManager.ts b/packages/scope-manager/src/ScopeManager.ts new file mode 100644 index 00000000000..e4c9b4d3cdc --- /dev/null +++ b/packages/scope-manager/src/ScopeManager.ts @@ -0,0 +1,251 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { assert } from './assert'; +import { + BlockScope, + CatchScope, + ClassScope, + ConditionalTypeScope, + ForScope, + FunctionExpressionNameScope, + FunctionScope, + FunctionTypeScope, + GlobalScope, + MappedTypeScope, + ModuleScope, + Scope, + SwitchScope, + TSEnumScope, + TSModuleScope, + TypeScope, + WithScope, +} from './scope'; + +import { Variable } from './variable'; + +interface ScopeManagerOptions { + globalReturn?: boolean; + sourceType?: 'module' | 'script'; + impliedStrict?: boolean; + ecmaVersion?: number; +} + +class ScopeManager { + public currentScope: Scope | null; + public readonly declaredVariables: WeakMap; + /** + * The root scope + * @public + */ + public globalScope: GlobalScope | null; + public readonly nodeToScope: WeakMap; + readonly #options: ScopeManagerOptions; + /** + * All scopes + * @public + */ + public readonly scopes: Scope[]; + + public get variables(): Variable[] { + const variables = new Set(); + function recurse(scope: Scope): void { + scope.variables.forEach(v => variables.add(v)); + scope.childScopes.forEach(recurse); + } + this.scopes.forEach(recurse); + return Array.from(variables).sort((a, b) => a.$id - b.$id); + } + + constructor(options: ScopeManagerOptions) { + this.scopes = []; + this.globalScope = null; + this.nodeToScope = new WeakMap(); + this.currentScope = null; + this.#options = options; + this.declaredVariables = new WeakMap(); + } + + public isGlobalReturn(): boolean { + return this.#options.globalReturn === true; + } + + public isModule(): boolean { + return this.#options.sourceType === 'module'; + } + + public isImpliedStrict(): boolean { + return this.#options.impliedStrict === true; + } + public isStrictModeSupported(): boolean { + return this.#options.ecmaVersion != null && this.#options.ecmaVersion >= 5; + } + + public isES6(): boolean { + return this.#options.ecmaVersion != null && this.#options.ecmaVersion >= 6; + } + + /** + * Get the variables that a given AST node defines. The gotten variables' `def[].node`/`def[].parent` property is the node. + * If the node does not define any variable, this returns an empty array. + * @param node An AST node to get their variables. + * @public + */ + public getDeclaredVariables(node: TSESTree.Node): Variable[] { + return this.declaredVariables.get(node) ?? []; + } + + /** + * Get the scope of a given AST node. The gotten scope's `block` property is the node. + * This method never returns `function-expression-name` scope. If the node does not have their scope, this returns `null`. + * + * @param node An AST node to get their scope. + * @param inner If the node has multiple scopes, this returns the outermost scope normally. + * If `inner` is `true` then this returns the innermost scope. + * @public + */ + public acquire(node: TSESTree.Node, inner = false): Scope | null { + function predicate(testScope: Scope): boolean { + if (testScope.type === 'function' && testScope.functionExpressionScope) { + return false; + } + return true; + } + + const scopes = this.nodeToScope.get(node); + + if (!scopes || scopes.length === 0) { + return null; + } + + // Heuristic selection from all scopes. + // If you would like to get all scopes, please use ScopeManager#acquireAll. + if (scopes.length === 1) { + return scopes[0]; + } + + if (inner) { + for (let i = scopes.length - 1; i >= 0; --i) { + const scope = scopes[i]; + + if (predicate(scope)) { + return scope; + } + } + } else { + for (let i = 0; i < scopes.length; ++i) { + const scope = scopes[i]; + + if (predicate(scope)) { + return scope; + } + } + } + + return null; + } + + protected nestScope(scope: T): T; + protected nestScope(scope: Scope): Scope { + if (scope instanceof GlobalScope) { + assert(this.currentScope === null); + this.globalScope = scope; + } + this.currentScope = scope; + return scope; + } + + public nestBlockScope(node: BlockScope['block']): BlockScope { + assert(this.currentScope); + return this.nestScope(new BlockScope(this, this.currentScope, node)); + } + + public nestCatchScope(node: CatchScope['block']): CatchScope { + assert(this.currentScope); + return this.nestScope(new CatchScope(this, this.currentScope, node)); + } + + public nestClassScope(node: ClassScope['block']): ClassScope { + assert(this.currentScope); + return this.nestScope(new ClassScope(this, this.currentScope, node)); + } + + public nestConditionalTypeScope( + node: ConditionalTypeScope['block'], + ): ConditionalTypeScope { + assert(this.currentScope); + return this.nestScope( + new ConditionalTypeScope(this, this.currentScope, node), + ); + } + + public nestForScope(node: ForScope['block']): ForScope { + assert(this.currentScope); + return this.nestScope(new ForScope(this, this.currentScope, node)); + } + + public nestFunctionExpressionNameScope( + node: FunctionExpressionNameScope['block'], + ): FunctionExpressionNameScope { + assert(this.currentScope); + return this.nestScope( + new FunctionExpressionNameScope(this, this.currentScope, node), + ); + } + + public nestFunctionScope( + node: FunctionScope['block'], + isMethodDefinition: boolean, + ): FunctionScope { + assert(this.currentScope); + return this.nestScope( + new FunctionScope(this, this.currentScope, node, isMethodDefinition), + ); + } + + public nestFunctionTypeScope( + node: FunctionTypeScope['block'], + ): FunctionTypeScope { + assert(this.currentScope); + return this.nestScope(new FunctionTypeScope(this, this.currentScope, node)); + } + + public nestGlobalScope(node: GlobalScope['block']): GlobalScope { + return this.nestScope(new GlobalScope(this, node)); + } + + public nestMappedTypeScope(node: MappedTypeScope['block']): MappedTypeScope { + assert(this.currentScope); + return this.nestScope(new MappedTypeScope(this, this.currentScope, node)); + } + + public nestModuleScope(node: ModuleScope['block']): ModuleScope { + assert(this.currentScope); + return this.nestScope(new ModuleScope(this, this.currentScope, node)); + } + + public nestSwitchScope(node: SwitchScope['block']): SwitchScope { + assert(this.currentScope); + return this.nestScope(new SwitchScope(this, this.currentScope, node)); + } + + public nestTSEnumScope(node: TSEnumScope['block']): TSEnumScope { + assert(this.currentScope); + return this.nestScope(new TSEnumScope(this, this.currentScope, node)); + } + + public nestTSModuleScope(node: TSModuleScope['block']): TSModuleScope { + assert(this.currentScope); + return this.nestScope(new TSModuleScope(this, this.currentScope, node)); + } + + public nestTypeScope(node: TypeScope['block']): TypeScope { + assert(this.currentScope); + return this.nestScope(new TypeScope(this, this.currentScope, node)); + } + + public nestWithScope(node: WithScope['block']): WithScope { + assert(this.currentScope); + return this.nestScope(new WithScope(this, this.currentScope, node)); + } +} + +export { ScopeManager }; diff --git a/packages/scope-manager/src/analyze.ts b/packages/scope-manager/src/analyze.ts new file mode 100644 index 00000000000..2c7e3949176 --- /dev/null +++ b/packages/scope-manager/src/analyze.ts @@ -0,0 +1,103 @@ +import { TSESTree, EcmaVersion, Lib } from '@typescript-eslint/types'; +import { visitorKeys } from '@typescript-eslint/visitor-keys'; +import { Referencer, ReferencerOptions } from './referencer'; +import { ScopeManager } from './ScopeManager'; + +//////////////////////////////////////////////////// +// MAKE SURE THIS IS KEPT IN SYNC WITH THE README // +//////////////////////////////////////////////////// + +interface AnalyzeOptions { + /** + * Known visitor keys. + */ + childVisitorKeys?: ReferencerOptions['childVisitorKeys']; + + /** + * Which ECMAScript version is considered. + * Defaults to `2018`. + */ + ecmaVersion?: EcmaVersion; + + /** + * Whether the whole script is executed under node.js environment. + * When enabled, the scope manager adds a function scope immediately following the global scope. + * Defaults to `false`. + */ + globalReturn?: boolean; + + /** + * Implied strict mode (if ecmaVersion >= 5). + * Defaults to `false`. + */ + impliedStrict?: boolean; + + /** + * The lib used by the project. + * This automatically defines a type variable for any types provided by the configured TS libs. + * Defaults to the lib for the provided `ecmaVersion`. + * + * https://www.typescriptlang.org/tsconfig#lib + */ + lib?: Lib[]; + + /** + * The source type of the script. + */ + sourceType?: 'script' | 'module'; +} + +const DEFAULT_OPTIONS: Required = { + childVisitorKeys: visitorKeys, + ecmaVersion: 2018, + globalReturn: false, + impliedStrict: false, + lib: ['es2018'], + sourceType: 'script', +}; + +function mapEcmaVersion(version: EcmaVersion | undefined): Lib { + if (version == null || version === 3 || version === 5) { + return 'es5'; + } + + if (version > 2000) { + return `es${version}` as Lib; + } + + const year = 2015 + (version - 6); + return `es${year}` as Lib; +} + +/** + * Takes an AST and returns the analyzed scopes. + */ +function analyze( + tree: TSESTree.Node, + providedOptions?: AnalyzeOptions, +): ScopeManager { + const ecmaVersion = + providedOptions?.ecmaVersion ?? DEFAULT_OPTIONS.ecmaVersion; + const options: Required = { + globalReturn: providedOptions?.globalReturn ?? DEFAULT_OPTIONS.globalReturn, + impliedStrict: + providedOptions?.impliedStrict ?? DEFAULT_OPTIONS.impliedStrict, + sourceType: providedOptions?.sourceType ?? DEFAULT_OPTIONS.sourceType, + ecmaVersion, + childVisitorKeys: + providedOptions?.childVisitorKeys ?? DEFAULT_OPTIONS.childVisitorKeys, + lib: providedOptions?.lib ?? [mapEcmaVersion(ecmaVersion)], + }; + + // ensure the option is lower cased + options.lib = options.lib.map(l => l.toLowerCase() as Lib); + + const scopeManager = new ScopeManager(options); + const referencer = new Referencer(options, scopeManager); + + referencer.visit(tree); + + return scopeManager; +} + +export { analyze, AnalyzeOptions }; diff --git a/packages/scope-manager/src/assert.ts b/packages/scope-manager/src/assert.ts new file mode 100644 index 00000000000..6dc93e24b63 --- /dev/null +++ b/packages/scope-manager/src/assert.ts @@ -0,0 +1,8 @@ +// the base assert module doesn't use ts assertion syntax +function assert(value: unknown, message?: string): asserts value { + if (value == null) { + throw new Error(message); + } +} + +export { assert }; diff --git a/packages/scope-manager/src/definition/CatchClauseDefinition.ts b/packages/scope-manager/src/definition/CatchClauseDefinition.ts new file mode 100644 index 00000000000..1bfb569e044 --- /dev/null +++ b/packages/scope-manager/src/definition/CatchClauseDefinition.ts @@ -0,0 +1,19 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { DefinitionBase } from './DefinitionBase'; + +class CatchClauseDefinition extends DefinitionBase< + DefinitionType.CatchClause, + TSESTree.CatchClause, + null, + TSESTree.BindingName +> { + constructor(name: TSESTree.BindingName, node: CatchClauseDefinition['node']) { + super(DefinitionType.CatchClause, name, node, null); + } + + public readonly isTypeDefinition = false; + public readonly isVariableDefinition = true; +} + +export { CatchClauseDefinition }; diff --git a/packages/scope-manager/src/definition/ClassNameDefinition.ts b/packages/scope-manager/src/definition/ClassNameDefinition.ts new file mode 100644 index 00000000000..5d587b342ad --- /dev/null +++ b/packages/scope-manager/src/definition/ClassNameDefinition.ts @@ -0,0 +1,19 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { DefinitionBase } from './DefinitionBase'; + +class ClassNameDefinition extends DefinitionBase< + DefinitionType.ClassName, + TSESTree.ClassDeclaration | TSESTree.ClassExpression, + null, + TSESTree.Identifier +> { + constructor(name: TSESTree.Identifier, node: ClassNameDefinition['node']) { + super(DefinitionType.ClassName, name, node, null); + } + + public readonly isTypeDefinition = true; + public readonly isVariableDefinition = true; +} + +export { ClassNameDefinition }; diff --git a/packages/scope-manager/src/definition/Definition.ts b/packages/scope-manager/src/definition/Definition.ts new file mode 100644 index 00000000000..19814bf892d --- /dev/null +++ b/packages/scope-manager/src/definition/Definition.ts @@ -0,0 +1,26 @@ +import { CatchClauseDefinition } from './CatchClauseDefinition'; +import { ClassNameDefinition } from './ClassNameDefinition'; +import { FunctionNameDefinition } from './FunctionNameDefinition'; +import { ImplicitGlobalVariableDefinition } from './ImplicitGlobalVariableDefinition'; +import { ImportBindingDefinition } from './ImportBindingDefinition'; +import { ParameterDefinition } from './ParameterDefinition'; +import { TSEnumMemberDefinition } from './TSEnumMemberDefinition'; +import { TSEnumNameDefinition } from './TSEnumNameDefinition'; +import { TSModuleNameDefinition } from './TSModuleNameDefinition'; +import { TypeDefinition } from './TypeDefinition'; +import { VariableDefinition } from './VariableDefinition'; + +type Definition = + | CatchClauseDefinition + | ClassNameDefinition + | FunctionNameDefinition + | ImplicitGlobalVariableDefinition + | ImportBindingDefinition + | ParameterDefinition + | TSEnumMemberDefinition + | TSEnumNameDefinition + | TSModuleNameDefinition + | TypeDefinition + | VariableDefinition; + +export { Definition }; diff --git a/packages/scope-manager/src/definition/DefinitionBase.ts b/packages/scope-manager/src/definition/DefinitionBase.ts new file mode 100644 index 00000000000..ed25a72293d --- /dev/null +++ b/packages/scope-manager/src/definition/DefinitionBase.ts @@ -0,0 +1,60 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { createIdGenerator } from '../ID'; + +const generator = createIdGenerator(); + +abstract class DefinitionBase< + TType extends DefinitionType, + TNode extends TSESTree.Node, + TParent extends TSESTree.Node | null, + TName extends TSESTree.Node = TSESTree.BindingName +> { + /** + * A unique ID for this instance - primarily used to help debugging and testing + */ + public readonly $id: number = generator(); + + /** + * The type of the definition + * @public + */ + public readonly type: TType; + + /** + * The `Identifier` node of this definition + * @public + */ + public readonly name: TName; + + /** + * The enclosing node of the name. + * @public + */ + public readonly node: TNode; + + /** + * the enclosing statement node of the identifier. + * @public + */ + public readonly parent: TParent; + + constructor(type: TType, name: TName, node: TNode, parent: TParent) { + this.type = type; + this.name = name; + this.node = node; + this.parent = parent; + } + + /** + * `true` if the variable is valid in a type context, false otherwise + */ + public abstract readonly isTypeDefinition: boolean; + + /** + * `true` if the variable is valid in a value context, false otherwise + */ + public abstract readonly isVariableDefinition: boolean; +} + +export { DefinitionBase }; diff --git a/packages/scope-manager/src/definition/DefinitionType.ts b/packages/scope-manager/src/definition/DefinitionType.ts new file mode 100644 index 00000000000..7f689d45ed5 --- /dev/null +++ b/packages/scope-manager/src/definition/DefinitionType.ts @@ -0,0 +1,16 @@ +enum DefinitionType { + // eslint-disable-next-line @typescript-eslint/internal/prefer-ast-types-enum + CatchClause = 'CatchClause', + ClassName = 'ClassName', + FunctionName = 'FunctionName', + ImplicitGlobalVariable = 'ImplicitGlobalVariable', + ImportBinding = 'ImportBinding', + Parameter = 'Parameter', + TSEnumName = 'TSEnumName', + TSEnumMember = 'TSEnumMemberName', + TSModuleName = 'TSModuleName', + Type = 'Type', + Variable = 'Variable', +} + +export { DefinitionType }; diff --git a/packages/scope-manager/src/definition/FunctionNameDefinition.ts b/packages/scope-manager/src/definition/FunctionNameDefinition.ts new file mode 100644 index 00000000000..b4cf2405552 --- /dev/null +++ b/packages/scope-manager/src/definition/FunctionNameDefinition.ts @@ -0,0 +1,22 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { DefinitionBase } from './DefinitionBase'; + +class FunctionNameDefinition extends DefinitionBase< + DefinitionType.FunctionName, + | TSESTree.FunctionDeclaration + | TSESTree.FunctionExpression + | TSESTree.TSDeclareFunction + | TSESTree.TSEmptyBodyFunctionExpression, + null, + TSESTree.Identifier +> { + constructor(name: TSESTree.Identifier, node: FunctionNameDefinition['node']) { + super(DefinitionType.FunctionName, name, node, null); + } + + public readonly isTypeDefinition = false; + public readonly isVariableDefinition = true; +} + +export { FunctionNameDefinition }; diff --git a/packages/scope-manager/src/definition/ImplicitGlobalVariableDefinition.ts b/packages/scope-manager/src/definition/ImplicitGlobalVariableDefinition.ts new file mode 100644 index 00000000000..43012c0fce9 --- /dev/null +++ b/packages/scope-manager/src/definition/ImplicitGlobalVariableDefinition.ts @@ -0,0 +1,22 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { DefinitionBase } from './DefinitionBase'; + +class ImplicitGlobalVariableDefinition extends DefinitionBase< + DefinitionType.ImplicitGlobalVariable, + TSESTree.Node, + null, + TSESTree.BindingName +> { + constructor( + name: TSESTree.BindingName, + node: ImplicitGlobalVariableDefinition['node'], + ) { + super(DefinitionType.ImplicitGlobalVariable, name, node, null); + } + + public readonly isTypeDefinition = false; + public readonly isVariableDefinition = true; +} + +export { ImplicitGlobalVariableDefinition }; diff --git a/packages/scope-manager/src/definition/ImportBindingDefinition.ts b/packages/scope-manager/src/definition/ImportBindingDefinition.ts new file mode 100644 index 00000000000..e3e1d840140 --- /dev/null +++ b/packages/scope-manager/src/definition/ImportBindingDefinition.ts @@ -0,0 +1,44 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { DefinitionBase } from './DefinitionBase'; + +class ImportBindingDefinition extends DefinitionBase< + DefinitionType.ImportBinding, + | TSESTree.ImportSpecifier + | TSESTree.ImportDefaultSpecifier + | TSESTree.ImportNamespaceSpecifier + | TSESTree.TSImportEqualsDeclaration, + TSESTree.ImportDeclaration | TSESTree.TSImportEqualsDeclaration, + TSESTree.Identifier +> { + constructor( + name: TSESTree.Identifier, + node: TSESTree.TSImportEqualsDeclaration, + decl: TSESTree.TSImportEqualsDeclaration, + ); + constructor( + name: TSESTree.Identifier, + node: Exclude< + ImportBindingDefinition['node'], + TSESTree.TSImportEqualsDeclaration + >, + decl: TSESTree.ImportDeclaration, + ); + constructor( + name: TSESTree.Identifier, + node: ImportBindingDefinition['node'], + decl: TSESTree.ImportDeclaration | TSESTree.TSImportEqualsDeclaration, + ) { + super(DefinitionType.ImportBinding, name, node, decl); + if ('importKind' in this.parent && this.parent.importKind === 'type') { + this.isVariableDefinition = false; + } else { + this.isVariableDefinition = true; + } + } + + public readonly isTypeDefinition = true; + public readonly isVariableDefinition: boolean; +} + +export { ImportBindingDefinition }; diff --git a/packages/scope-manager/src/definition/ParameterDefinition.ts b/packages/scope-manager/src/definition/ParameterDefinition.ts new file mode 100644 index 00000000000..b0c0ea3280d --- /dev/null +++ b/packages/scope-manager/src/definition/ParameterDefinition.ts @@ -0,0 +1,37 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { DefinitionBase } from './DefinitionBase'; + +class ParameterDefinition extends DefinitionBase< + DefinitionType.Parameter, + | TSESTree.ArrowFunctionExpression + | TSESTree.FunctionDeclaration + | TSESTree.FunctionExpression + | TSESTree.TSCallSignatureDeclaration + | TSESTree.TSConstructorType + | TSESTree.TSConstructSignatureDeclaration + | TSESTree.TSDeclareFunction + | TSESTree.TSEmptyBodyFunctionExpression + | TSESTree.TSFunctionType + | TSESTree.TSMethodSignature, + null, + TSESTree.BindingName +> { + /** + * Whether the parameter definition is a part of a rest parameter. + */ + public readonly rest: boolean; + constructor( + name: TSESTree.BindingName, + node: ParameterDefinition['node'], + rest: boolean, + ) { + super(DefinitionType.Parameter, name, node, null); + this.rest = rest; + } + + public readonly isTypeDefinition = false; + public readonly isVariableDefinition = true; +} + +export { ParameterDefinition }; diff --git a/packages/scope-manager/src/definition/TSEnumMemberDefinition.ts b/packages/scope-manager/src/definition/TSEnumMemberDefinition.ts new file mode 100644 index 00000000000..cff6bbaa6d1 --- /dev/null +++ b/packages/scope-manager/src/definition/TSEnumMemberDefinition.ts @@ -0,0 +1,22 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { DefinitionBase } from './DefinitionBase'; + +class TSEnumMemberDefinition extends DefinitionBase< + DefinitionType.TSEnumMember, + TSESTree.TSEnumMember, + null, + TSESTree.Identifier | TSESTree.StringLiteral +> { + constructor( + name: TSESTree.Identifier | TSESTree.StringLiteral, + node: TSEnumMemberDefinition['node'], + ) { + super(DefinitionType.TSEnumMember, name, node, null); + } + + public readonly isTypeDefinition = true; + public readonly isVariableDefinition = true; +} + +export { TSEnumMemberDefinition }; diff --git a/packages/scope-manager/src/definition/TSEnumNameDefinition.ts b/packages/scope-manager/src/definition/TSEnumNameDefinition.ts new file mode 100644 index 00000000000..5374a56260a --- /dev/null +++ b/packages/scope-manager/src/definition/TSEnumNameDefinition.ts @@ -0,0 +1,19 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { DefinitionBase } from './DefinitionBase'; + +class TSEnumNameDefinition extends DefinitionBase< + DefinitionType.TSEnumName, + TSESTree.TSEnumDeclaration, + null, + TSESTree.Identifier +> { + constructor(name: TSESTree.Identifier, node: TSEnumNameDefinition['node']) { + super(DefinitionType.TSEnumName, name, node, null); + } + + public readonly isTypeDefinition = true; + public readonly isVariableDefinition = true; +} + +export { TSEnumNameDefinition }; diff --git a/packages/scope-manager/src/definition/TSModuleNameDefinition.ts b/packages/scope-manager/src/definition/TSModuleNameDefinition.ts new file mode 100644 index 00000000000..98f907789b7 --- /dev/null +++ b/packages/scope-manager/src/definition/TSModuleNameDefinition.ts @@ -0,0 +1,19 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { DefinitionBase } from './DefinitionBase'; + +class TSModuleNameDefinition extends DefinitionBase< + DefinitionType.TSModuleName, + TSESTree.TSModuleDeclaration, + null, + TSESTree.Identifier +> { + constructor(name: TSESTree.Identifier, node: TSModuleNameDefinition['node']) { + super(DefinitionType.TSModuleName, name, node, null); + } + + public readonly isTypeDefinition = true; + public readonly isVariableDefinition = true; +} + +export { TSModuleNameDefinition }; diff --git a/packages/scope-manager/src/definition/TypeDefinition.ts b/packages/scope-manager/src/definition/TypeDefinition.ts new file mode 100644 index 00000000000..ad3b4368791 --- /dev/null +++ b/packages/scope-manager/src/definition/TypeDefinition.ts @@ -0,0 +1,21 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { DefinitionBase } from './DefinitionBase'; + +class TypeDefinition extends DefinitionBase< + DefinitionType.Type, + | TSESTree.TSInterfaceDeclaration + | TSESTree.TSTypeAliasDeclaration + | TSESTree.TSTypeParameter, + null, + TSESTree.Identifier +> { + constructor(name: TSESTree.Identifier, node: TypeDefinition['node']) { + super(DefinitionType.Type, name, node, null); + } + + public readonly isTypeDefinition = true; + public readonly isVariableDefinition = false; +} + +export { TypeDefinition }; diff --git a/packages/scope-manager/src/definition/VariableDefinition.ts b/packages/scope-manager/src/definition/VariableDefinition.ts new file mode 100644 index 00000000000..975c5886185 --- /dev/null +++ b/packages/scope-manager/src/definition/VariableDefinition.ts @@ -0,0 +1,23 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { DefinitionType } from './DefinitionType'; +import { DefinitionBase } from './DefinitionBase'; + +class VariableDefinition extends DefinitionBase< + DefinitionType.Variable, + TSESTree.VariableDeclarator, + TSESTree.VariableDeclaration, + TSESTree.Identifier +> { + constructor( + name: TSESTree.Identifier, + node: VariableDefinition['node'], + decl: TSESTree.VariableDeclaration, + ) { + super(DefinitionType.Variable, name, node, decl); + } + + public readonly isTypeDefinition = false; + public readonly isVariableDefinition = true; +} + +export { VariableDefinition }; diff --git a/packages/scope-manager/src/definition/index.ts b/packages/scope-manager/src/definition/index.ts new file mode 100644 index 00000000000..9bd1f012337 --- /dev/null +++ b/packages/scope-manager/src/definition/index.ts @@ -0,0 +1,13 @@ +export * from './CatchClauseDefinition'; +export * from './ClassNameDefinition'; +export * from './Definition'; +export * from './DefinitionType'; +export * from './FunctionNameDefinition'; +export * from './ImplicitGlobalVariableDefinition'; +export * from './ImportBindingDefinition'; +export * from './ParameterDefinition'; +export * from './TSEnumMemberDefinition'; +export * from './TSEnumNameDefinition'; +export * from './TSModuleNameDefinition'; +export * from './TypeDefinition'; +export * from './VariableDefinition'; diff --git a/packages/scope-manager/src/index.ts b/packages/scope-manager/src/index.ts new file mode 100644 index 00000000000..8dc52ac4ac8 --- /dev/null +++ b/packages/scope-manager/src/index.ts @@ -0,0 +1,12 @@ +export { analyze, AnalyzeOptions } from './analyze'; +export * from './definition'; +export { Reference } from './referencer/Reference'; +export { Visitor } from './referencer/Visitor'; +export { + PatternVisitor, + PatternVisitorCallback, + PatternVisitorOptions, +} from './referencer/PatternVisitor'; +export * from './scope'; +export { ScopeManager } from './ScopeManager'; +export * from './variable'; diff --git a/packages/scope-manager/src/lib/dom.iterable.ts b/packages/scope-manager/src/lib/dom.iterable.ts new file mode 100644 index 00000000000..d6970cee99a --- /dev/null +++ b/packages/scope-manager/src/lib/dom.iterable.ts @@ -0,0 +1,372 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const dom_iterable = { + AudioParam: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioParam', + writeable: false, + }, + AudioParamMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioParamMap', + writeable: false, + }, + BaseAudioContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BaseAudioContext', + writeable: false, + }, + CSSRuleList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CSSRuleList', + writeable: false, + }, + CSSStyleDeclaration: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CSSStyleDeclaration', + writeable: false, + }, + Cache: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Cache', + writeable: false, + }, + CanvasPathDrawingStyles: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasPathDrawingStyles', + writeable: false, + }, + ClientRectList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ClientRectList', + writeable: false, + }, + DOMRectList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMRectList', + writeable: false, + }, + DOMStringList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMStringList', + writeable: false, + }, + DOMTokenList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMTokenList', + writeable: false, + }, + DataTransferItemList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DataTransferItemList', + writeable: false, + }, + FileList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FileList', + writeable: false, + }, + FormData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FormData', + writeable: false, + }, + HTMLAllCollection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLAllCollection', + writeable: false, + }, + HTMLCollectionBase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLCollectionBase', + writeable: false, + }, + HTMLCollectionOf: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLCollectionOf', + writeable: false, + }, + HTMLFormElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLFormElement', + writeable: false, + }, + HTMLSelectElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLSelectElement', + writeable: false, + }, + Headers: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Headers', + writeable: false, + }, + IDBObjectStore: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBObjectStore', + writeable: false, + }, + MediaKeyStatusMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaKeyStatusMap', + writeable: false, + }, + MediaList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaList', + writeable: false, + }, + MimeTypeArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MimeTypeArray', + writeable: false, + }, + NamedNodeMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NamedNodeMap', + writeable: false, + }, + Navigator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Navigator', + writeable: false, + }, + NodeList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NodeList', + writeable: false, + }, + NodeListOf: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NodeListOf', + writeable: false, + }, + Plugin: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Plugin', + writeable: false, + }, + PluginArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PluginArray', + writeable: false, + }, + RTCRtpTransceiver: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpTransceiver', + writeable: false, + }, + RTCStatsReport: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCStatsReport', + writeable: false, + }, + SVGLengthList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGLengthList', + writeable: false, + }, + SVGNumberList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGNumberList', + writeable: false, + }, + SVGPointList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGPointList', + writeable: false, + }, + SVGStringList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGStringList', + writeable: false, + }, + SourceBufferList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SourceBufferList', + writeable: false, + }, + SpeechGrammarList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SpeechGrammarList', + writeable: false, + }, + SpeechRecognitionResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SpeechRecognitionResult', + writeable: false, + }, + SpeechRecognitionResultList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SpeechRecognitionResultList', + writeable: false, + }, + StyleSheetList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'StyleSheetList', + writeable: false, + }, + TextTrackCueList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextTrackCueList', + writeable: false, + }, + TextTrackList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextTrackList', + writeable: false, + }, + TouchList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TouchList', + writeable: false, + }, + URLSearchParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'URLSearchParams', + writeable: false, + }, + VRDisplay: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VRDisplay', + writeable: false, + }, + WEBGL_draw_buffers: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_draw_buffers', + writeable: false, + }, + WebAuthentication: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebAuthentication', + writeable: false, + }, + WebGL2RenderingContextBase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGL2RenderingContextBase', + writeable: false, + }, + WebGL2RenderingContextOverloads: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGL2RenderingContextOverloads', + writeable: false, + }, + WebGLRenderingContextBase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLRenderingContextBase', + writeable: false, + }, + WebGLRenderingContextOverloads: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLRenderingContextOverloads', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/dom.ts b/packages/scope-manager/src/lib/dom.ts new file mode 100644 index 00000000000..7cb6708e05f --- /dev/null +++ b/packages/scope-manager/src/lib/dom.ts @@ -0,0 +1,9213 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const dom = { + Account: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Account', + writeable: false, + }, + AddEventListenerOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AddEventListenerOptions', + writeable: false, + }, + AesCbcParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesCbcParams', + writeable: false, + }, + AesCtrParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesCtrParams', + writeable: false, + }, + AesDerivedKeyParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesDerivedKeyParams', + writeable: false, + }, + AesGcmParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesGcmParams', + writeable: false, + }, + AesKeyAlgorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesKeyAlgorithm', + writeable: false, + }, + AesKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesKeyGenParams', + writeable: false, + }, + Algorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Algorithm', + writeable: false, + }, + AnalyserOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AnalyserOptions', + writeable: false, + }, + AnimationEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AnimationEventInit', + writeable: false, + }, + AnimationPlaybackEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AnimationPlaybackEventInit', + writeable: false, + }, + AssertionOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AssertionOptions', + writeable: false, + }, + AssignedNodesOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AssignedNodesOptions', + writeable: false, + }, + AudioBufferOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioBufferOptions', + writeable: false, + }, + AudioBufferSourceOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioBufferSourceOptions', + writeable: false, + }, + AudioContextInfo: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioContextInfo', + writeable: false, + }, + AudioContextOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioContextOptions', + writeable: false, + }, + AudioNodeOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioNodeOptions', + writeable: false, + }, + AudioParamDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioParamDescriptor', + writeable: false, + }, + AudioProcessingEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioProcessingEventInit', + writeable: false, + }, + AudioTimestamp: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioTimestamp', + writeable: false, + }, + AudioWorkletNodeOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioWorkletNodeOptions', + writeable: false, + }, + AuthenticationExtensionsClientInputs: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AuthenticationExtensionsClientInputs', + writeable: false, + }, + AuthenticationExtensionsClientOutputs: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AuthenticationExtensionsClientOutputs', + writeable: false, + }, + AuthenticatorSelectionCriteria: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AuthenticatorSelectionCriteria', + writeable: false, + }, + BiquadFilterOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BiquadFilterOptions', + writeable: false, + }, + BlobPropertyBag: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BlobPropertyBag', + writeable: false, + }, + ByteLengthChunk: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ByteLengthChunk', + writeable: false, + }, + CacheQueryOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CacheQueryOptions', + writeable: false, + }, + CanvasRenderingContext2DSettings: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasRenderingContext2DSettings', + writeable: false, + }, + ChannelMergerOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ChannelMergerOptions', + writeable: false, + }, + ChannelSplitterOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ChannelSplitterOptions', + writeable: false, + }, + ClientData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ClientData', + writeable: false, + }, + ClientQueryOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ClientQueryOptions', + writeable: false, + }, + ClipboardEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ClipboardEventInit', + writeable: false, + }, + CloseEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CloseEventInit', + writeable: false, + }, + CompositionEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CompositionEventInit', + writeable: false, + }, + ComputedEffectTiming: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ComputedEffectTiming', + writeable: false, + }, + ComputedKeyframe: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ComputedKeyframe', + writeable: false, + }, + ConfirmSiteSpecificExceptionsInformation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConfirmSiteSpecificExceptionsInformation', + writeable: false, + }, + ConstantSourceOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConstantSourceOptions', + writeable: false, + }, + ConstrainBooleanParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConstrainBooleanParameters', + writeable: false, + }, + ConstrainDOMStringParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConstrainDOMStringParameters', + writeable: false, + }, + ConstrainDoubleRange: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConstrainDoubleRange', + writeable: false, + }, + ConstrainULongRange: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConstrainULongRange', + writeable: false, + }, + ConstrainVideoFacingModeParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConstrainVideoFacingModeParameters', + writeable: false, + }, + ConvolverOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConvolverOptions', + writeable: false, + }, + CredentialCreationOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CredentialCreationOptions', + writeable: false, + }, + CredentialRequestOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CredentialRequestOptions', + writeable: false, + }, + CustomEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CustomEventInit', + writeable: false, + }, + DOMMatrix2DInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMMatrix2DInit', + writeable: false, + }, + DOMMatrixInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMMatrixInit', + writeable: false, + }, + DOMPointInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMPointInit', + writeable: false, + }, + DOMQuadInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMQuadInit', + writeable: false, + }, + DOMRectInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMRectInit', + writeable: false, + }, + DelayOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DelayOptions', + writeable: false, + }, + DeviceLightEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DeviceLightEventInit', + writeable: false, + }, + DeviceMotionEventAccelerationInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DeviceMotionEventAccelerationInit', + writeable: false, + }, + DeviceMotionEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DeviceMotionEventInit', + writeable: false, + }, + DeviceMotionEventRotationRateInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DeviceMotionEventRotationRateInit', + writeable: false, + }, + DeviceOrientationEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DeviceOrientationEventInit', + writeable: false, + }, + DevicePermissionDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DevicePermissionDescriptor', + writeable: false, + }, + DocumentTimelineOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DocumentTimelineOptions', + writeable: false, + }, + DoubleRange: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DoubleRange', + writeable: false, + }, + DragEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DragEventInit', + writeable: false, + }, + DynamicsCompressorOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DynamicsCompressorOptions', + writeable: false, + }, + EcKeyAlgorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EcKeyAlgorithm', + writeable: false, + }, + EcKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EcKeyGenParams', + writeable: false, + }, + EcKeyImportParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EcKeyImportParams', + writeable: false, + }, + EcdhKeyDeriveParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EcdhKeyDeriveParams', + writeable: false, + }, + EcdsaParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EcdsaParams', + writeable: false, + }, + EffectTiming: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EffectTiming', + writeable: false, + }, + ElementCreationOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ElementCreationOptions', + writeable: false, + }, + ElementDefinitionOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ElementDefinitionOptions', + writeable: false, + }, + ErrorEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ErrorEventInit', + writeable: false, + }, + EventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventInit', + writeable: false, + }, + EventListenerOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventListenerOptions', + writeable: false, + }, + EventModifierInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventModifierInit', + writeable: false, + }, + EventSourceInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventSourceInit', + writeable: false, + }, + ExceptionInformation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ExceptionInformation', + writeable: false, + }, + FilePropertyBag: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FilePropertyBag', + writeable: false, + }, + FocusEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FocusEventInit', + writeable: false, + }, + FocusNavigationEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FocusNavigationEventInit', + writeable: false, + }, + FocusNavigationOrigin: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FocusNavigationOrigin', + writeable: false, + }, + FocusOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FocusOptions', + writeable: false, + }, + FullscreenOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FullscreenOptions', + writeable: false, + }, + GainOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GainOptions', + writeable: false, + }, + GamepadEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GamepadEventInit', + writeable: false, + }, + GetNotificationOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GetNotificationOptions', + writeable: false, + }, + GetRootNodeOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GetRootNodeOptions', + writeable: false, + }, + HashChangeEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HashChangeEventInit', + writeable: false, + }, + HkdfParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HkdfParams', + writeable: false, + }, + HmacImportParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HmacImportParams', + writeable: false, + }, + HmacKeyAlgorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HmacKeyAlgorithm', + writeable: false, + }, + HmacKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HmacKeyGenParams', + writeable: false, + }, + IDBIndexParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBIndexParameters', + writeable: false, + }, + IDBObjectStoreParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBObjectStoreParameters', + writeable: false, + }, + IDBVersionChangeEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBVersionChangeEventInit', + writeable: false, + }, + IIRFilterOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IIRFilterOptions', + writeable: false, + }, + ImageBitmapOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageBitmapOptions', + writeable: false, + }, + ImageBitmapRenderingContextSettings: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageBitmapRenderingContextSettings', + writeable: false, + }, + ImageEncodeOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageEncodeOptions', + writeable: false, + }, + InputEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'InputEventInit', + writeable: false, + }, + IntersectionObserverEntryInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IntersectionObserverEntryInit', + writeable: false, + }, + IntersectionObserverInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IntersectionObserverInit', + writeable: false, + }, + JsonWebKey: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'JsonWebKey', + writeable: false, + }, + KeyAlgorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'KeyAlgorithm', + writeable: false, + }, + KeyboardEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'KeyboardEventInit', + writeable: false, + }, + Keyframe: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Keyframe', + writeable: false, + }, + KeyframeAnimationOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'KeyframeAnimationOptions', + writeable: false, + }, + KeyframeEffectOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'KeyframeEffectOptions', + writeable: false, + }, + MediaElementAudioSourceOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaElementAudioSourceOptions', + writeable: false, + }, + MediaEncryptedEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaEncryptedEventInit', + writeable: false, + }, + MediaKeyMessageEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaKeyMessageEventInit', + writeable: false, + }, + MediaKeySystemConfiguration: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaKeySystemConfiguration', + writeable: false, + }, + MediaKeySystemMediaCapability: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaKeySystemMediaCapability', + writeable: false, + }, + MediaQueryListEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaQueryListEventInit', + writeable: false, + }, + MediaStreamAudioSourceOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaStreamAudioSourceOptions', + writeable: false, + }, + MediaStreamConstraints: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaStreamConstraints', + writeable: false, + }, + MediaStreamErrorEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaStreamErrorEventInit', + writeable: false, + }, + MediaStreamEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaStreamEventInit', + writeable: false, + }, + MediaStreamTrackAudioSourceOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaStreamTrackAudioSourceOptions', + writeable: false, + }, + MediaStreamTrackEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaStreamTrackEventInit', + writeable: false, + }, + MediaTrackCapabilities: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaTrackCapabilities', + writeable: false, + }, + MediaTrackConstraintSet: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaTrackConstraintSet', + writeable: false, + }, + MediaTrackConstraints: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaTrackConstraints', + writeable: false, + }, + MediaTrackSettings: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaTrackSettings', + writeable: false, + }, + MediaTrackSupportedConstraints: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaTrackSupportedConstraints', + writeable: false, + }, + MessageEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MessageEventInit', + writeable: false, + }, + MidiPermissionDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MidiPermissionDescriptor', + writeable: false, + }, + MouseEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MouseEventInit', + writeable: false, + }, + MultiCacheQueryOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MultiCacheQueryOptions', + writeable: false, + }, + MutationObserverInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MutationObserverInit', + writeable: false, + }, + NavigationPreloadState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigationPreloadState', + writeable: false, + }, + NotificationAction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationAction', + writeable: false, + }, + NotificationOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationOptions', + writeable: false, + }, + OfflineAudioCompletionEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OfflineAudioCompletionEventInit', + writeable: false, + }, + OfflineAudioContextOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OfflineAudioContextOptions', + writeable: false, + }, + OptionalEffectTiming: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OptionalEffectTiming', + writeable: false, + }, + OscillatorOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OscillatorOptions', + writeable: false, + }, + PageTransitionEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PageTransitionEventInit', + writeable: false, + }, + PannerOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PannerOptions', + writeable: false, + }, + PaymentCurrencyAmount: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentCurrencyAmount', + writeable: false, + }, + PaymentDetailsBase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentDetailsBase', + writeable: false, + }, + PaymentDetailsInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentDetailsInit', + writeable: false, + }, + PaymentDetailsModifier: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentDetailsModifier', + writeable: false, + }, + PaymentDetailsUpdate: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentDetailsUpdate', + writeable: false, + }, + PaymentItem: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentItem', + writeable: false, + }, + PaymentMethodData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentMethodData', + writeable: false, + }, + PaymentOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentOptions', + writeable: false, + }, + PaymentRequestUpdateEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentRequestUpdateEventInit', + writeable: false, + }, + PaymentShippingOption: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentShippingOption', + writeable: false, + }, + Pbkdf2Params: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Pbkdf2Params', + writeable: false, + }, + PerformanceObserverInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PerformanceObserverInit', + writeable: false, + }, + PeriodicWaveConstraints: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PeriodicWaveConstraints', + writeable: false, + }, + PeriodicWaveOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PeriodicWaveOptions', + writeable: false, + }, + PermissionDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PermissionDescriptor', + writeable: false, + }, + PipeOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PipeOptions', + writeable: false, + }, + PointerEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PointerEventInit', + writeable: false, + }, + PopStateEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PopStateEventInit', + writeable: false, + }, + PositionOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PositionOptions', + writeable: false, + }, + PostMessageOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PostMessageOptions', + writeable: false, + }, + ProgressEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ProgressEventInit', + writeable: false, + }, + PromiseRejectionEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseRejectionEventInit', + writeable: false, + }, + PropertyIndexedKeyframes: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PropertyIndexedKeyframes', + writeable: false, + }, + PublicKeyCredentialCreationOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PublicKeyCredentialCreationOptions', + writeable: false, + }, + PublicKeyCredentialDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PublicKeyCredentialDescriptor', + writeable: false, + }, + PublicKeyCredentialEntity: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PublicKeyCredentialEntity', + writeable: false, + }, + PublicKeyCredentialParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PublicKeyCredentialParameters', + writeable: false, + }, + PublicKeyCredentialRequestOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PublicKeyCredentialRequestOptions', + writeable: false, + }, + PublicKeyCredentialRpEntity: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PublicKeyCredentialRpEntity', + writeable: false, + }, + PublicKeyCredentialUserEntity: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PublicKeyCredentialUserEntity', + writeable: false, + }, + PushPermissionDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushPermissionDescriptor', + writeable: false, + }, + PushSubscriptionJSON: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushSubscriptionJSON', + writeable: false, + }, + PushSubscriptionOptionsInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushSubscriptionOptionsInit', + writeable: false, + }, + QueuingStrategy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'QueuingStrategy', + writeable: false, + }, + RTCAnswerOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCAnswerOptions', + writeable: false, + }, + RTCCertificateExpiration: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCCertificateExpiration', + writeable: false, + }, + RTCConfiguration: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCConfiguration', + writeable: false, + }, + RTCDTMFToneChangeEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDTMFToneChangeEventInit', + writeable: false, + }, + RTCDataChannelEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDataChannelEventInit', + writeable: false, + }, + RTCDataChannelInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDataChannelInit', + writeable: false, + }, + RTCDtlsFingerprint: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDtlsFingerprint', + writeable: false, + }, + RTCDtlsParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDtlsParameters', + writeable: false, + }, + RTCErrorEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCErrorEventInit', + writeable: false, + }, + RTCErrorInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCErrorInit', + writeable: false, + }, + RTCIceCandidateAttributes: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceCandidateAttributes', + writeable: false, + }, + RTCIceCandidateComplete: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceCandidateComplete', + writeable: false, + }, + RTCIceCandidateDictionary: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceCandidateDictionary', + writeable: false, + }, + RTCIceCandidateInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceCandidateInit', + writeable: false, + }, + RTCIceCandidatePair: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceCandidatePair', + writeable: false, + }, + RTCIceCandidatePairStats: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceCandidatePairStats', + writeable: false, + }, + RTCIceGatherOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceGatherOptions', + writeable: false, + }, + RTCIceParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceParameters', + writeable: false, + }, + RTCIceServer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceServer', + writeable: false, + }, + RTCIdentityProviderOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIdentityProviderOptions', + writeable: false, + }, + RTCInboundRTPStreamStats: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCInboundRTPStreamStats', + writeable: false, + }, + RTCMediaStreamTrackStats: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCMediaStreamTrackStats', + writeable: false, + }, + RTCOAuthCredential: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCOAuthCredential', + writeable: false, + }, + RTCOfferAnswerOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCOfferAnswerOptions', + writeable: false, + }, + RTCOfferOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCOfferOptions', + writeable: false, + }, + RTCOutboundRTPStreamStats: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCOutboundRTPStreamStats', + writeable: false, + }, + RTCPeerConnectionIceErrorEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCPeerConnectionIceErrorEventInit', + writeable: false, + }, + RTCPeerConnectionIceEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCPeerConnectionIceEventInit', + writeable: false, + }, + RTCRTPStreamStats: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRTPStreamStats', + writeable: false, + }, + RTCRtcpFeedback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtcpFeedback', + writeable: false, + }, + RTCRtcpParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtcpParameters', + writeable: false, + }, + RTCRtpCapabilities: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpCapabilities', + writeable: false, + }, + RTCRtpCodecCapability: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpCodecCapability', + writeable: false, + }, + RTCRtpCodecParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpCodecParameters', + writeable: false, + }, + RTCRtpCodingParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpCodingParameters', + writeable: false, + }, + RTCRtpContributingSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpContributingSource', + writeable: false, + }, + RTCRtpDecodingParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpDecodingParameters', + writeable: false, + }, + RTCRtpEncodingParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpEncodingParameters', + writeable: false, + }, + RTCRtpFecParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpFecParameters', + writeable: false, + }, + RTCRtpHeaderExtension: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpHeaderExtension', + writeable: false, + }, + RTCRtpHeaderExtensionCapability: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpHeaderExtensionCapability', + writeable: false, + }, + RTCRtpHeaderExtensionParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpHeaderExtensionParameters', + writeable: false, + }, + RTCRtpParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpParameters', + writeable: false, + }, + RTCRtpReceiveParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpReceiveParameters', + writeable: false, + }, + RTCRtpRtxParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpRtxParameters', + writeable: false, + }, + RTCRtpSendParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpSendParameters', + writeable: false, + }, + RTCRtpSynchronizationSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpSynchronizationSource', + writeable: false, + }, + RTCRtpTransceiverInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpTransceiverInit', + writeable: false, + }, + RTCRtpUnhandled: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpUnhandled', + writeable: false, + }, + RTCSessionDescriptionInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCSessionDescriptionInit', + writeable: false, + }, + RTCSrtpKeyParam: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCSrtpKeyParam', + writeable: false, + }, + RTCSrtpSdesParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCSrtpSdesParameters', + writeable: false, + }, + RTCSsrcRange: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCSsrcRange', + writeable: false, + }, + RTCStats: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCStats', + writeable: false, + }, + RTCStatsEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCStatsEventInit', + writeable: false, + }, + RTCStatsReport: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCStatsReport', + writeable: false, + }, + RTCTrackEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCTrackEventInit', + writeable: false, + }, + RTCTransportStats: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCTransportStats', + writeable: false, + }, + ReadableStreamReadDoneResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamReadDoneResult', + writeable: false, + }, + ReadableStreamReadValueResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamReadValueResult', + writeable: false, + }, + RegistrationOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegistrationOptions', + writeable: false, + }, + RequestInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestInit', + writeable: false, + }, + ResponseInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ResponseInit', + writeable: false, + }, + RsaHashedImportParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaHashedImportParams', + writeable: false, + }, + RsaHashedKeyAlgorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaHashedKeyAlgorithm', + writeable: false, + }, + RsaHashedKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaHashedKeyGenParams', + writeable: false, + }, + RsaKeyAlgorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaKeyAlgorithm', + writeable: false, + }, + RsaKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaKeyGenParams', + writeable: false, + }, + RsaOaepParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaOaepParams', + writeable: false, + }, + RsaOtherPrimesInfo: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaOtherPrimesInfo', + writeable: false, + }, + RsaPssParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaPssParams', + writeable: false, + }, + SVGBoundingBoxOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGBoundingBoxOptions', + writeable: false, + }, + ScopedCredentialDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScopedCredentialDescriptor', + writeable: false, + }, + ScopedCredentialOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScopedCredentialOptions', + writeable: false, + }, + ScopedCredentialParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScopedCredentialParameters', + writeable: false, + }, + ScrollIntoViewOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScrollIntoViewOptions', + writeable: false, + }, + ScrollOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScrollOptions', + writeable: false, + }, + ScrollToOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScrollToOptions', + writeable: false, + }, + SecurityPolicyViolationEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SecurityPolicyViolationEventInit', + writeable: false, + }, + ServiceWorkerMessageEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerMessageEventInit', + writeable: false, + }, + ShadowRootInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ShadowRootInit', + writeable: false, + }, + ShareData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ShareData', + writeable: false, + }, + SpeechSynthesisErrorEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SpeechSynthesisErrorEventInit', + writeable: false, + }, + SpeechSynthesisEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SpeechSynthesisEventInit', + writeable: false, + }, + StaticRangeInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'StaticRangeInit', + writeable: false, + }, + StereoPannerOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'StereoPannerOptions', + writeable: false, + }, + StorageEstimate: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'StorageEstimate', + writeable: false, + }, + StorageEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'StorageEventInit', + writeable: false, + }, + StoreExceptionsInformation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'StoreExceptionsInformation', + writeable: false, + }, + StoreSiteSpecificExceptionsInformation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'StoreSiteSpecificExceptionsInformation', + writeable: false, + }, + TextDecodeOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextDecodeOptions', + writeable: false, + }, + TextDecoderOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextDecoderOptions', + writeable: false, + }, + TextEncoderEncodeIntoResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextEncoderEncodeIntoResult', + writeable: false, + }, + TouchEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TouchEventInit', + writeable: false, + }, + TouchInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TouchInit', + writeable: false, + }, + TrackEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TrackEventInit', + writeable: false, + }, + Transformer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Transformer', + writeable: false, + }, + TransitionEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TransitionEventInit', + writeable: false, + }, + UIEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'UIEventInit', + writeable: false, + }, + ULongRange: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ULongRange', + writeable: false, + }, + UnderlyingByteSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'UnderlyingByteSource', + writeable: false, + }, + UnderlyingSink: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'UnderlyingSink', + writeable: false, + }, + UnderlyingSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'UnderlyingSource', + writeable: false, + }, + VRDisplayEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VRDisplayEventInit', + writeable: false, + }, + VRLayer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VRLayer', + writeable: false, + }, + VRStageParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VRStageParameters', + writeable: false, + }, + WaveShaperOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WaveShaperOptions', + writeable: false, + }, + WebAuthnExtensions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebAuthnExtensions', + writeable: false, + }, + WebGLContextAttributes: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLContextAttributes', + writeable: false, + }, + WebGLContextEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLContextEventInit', + writeable: false, + }, + WheelEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WheelEventInit', + writeable: false, + }, + WorkerOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WorkerOptions', + writeable: false, + }, + WorkletOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WorkletOptions', + writeable: false, + }, + txAuthGenericArg: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'txAuthGenericArg', + writeable: false, + }, + EventListener: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventListener', + writeable: false, + }, + XPathNSResolver: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'XPathNSResolver', + writeable: false, + }, + ANGLE_instanced_arrays: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ANGLE_instanced_arrays', + writeable: false, + }, + AbortController: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AbortController', + writeable: false, + }, + AbortSignalEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AbortSignalEventMap', + writeable: false, + }, + AbortSignal: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AbortSignal', + writeable: false, + }, + AbstractRange: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AbstractRange', + writeable: false, + }, + AbstractWorkerEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AbstractWorkerEventMap', + writeable: false, + }, + AbstractWorker: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AbstractWorker', + writeable: false, + }, + AesCfbParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesCfbParams', + writeable: false, + }, + AesCmacParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesCmacParams', + writeable: false, + }, + AnalyserNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AnalyserNode', + writeable: false, + }, + Animatable: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Animatable', + writeable: false, + }, + AnimationEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AnimationEventMap', + writeable: false, + }, + Animation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Animation', + writeable: false, + }, + AnimationEffect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AnimationEffect', + writeable: false, + }, + AnimationEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AnimationEvent', + writeable: false, + }, + AnimationFrameProvider: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AnimationFrameProvider', + writeable: false, + }, + AnimationPlaybackEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AnimationPlaybackEvent', + writeable: false, + }, + AnimationTimeline: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AnimationTimeline', + writeable: false, + }, + ApplicationCacheEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ApplicationCacheEventMap', + writeable: false, + }, + ApplicationCache: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ApplicationCache', + writeable: false, + }, + Attr: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Attr', + writeable: false, + }, + AudioBuffer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioBuffer', + writeable: false, + }, + AudioBufferSourceNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioBufferSourceNode', + writeable: false, + }, + AudioContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioContext', + writeable: false, + }, + AudioDestinationNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioDestinationNode', + writeable: false, + }, + AudioListener: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioListener', + writeable: false, + }, + AudioNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioNode', + writeable: false, + }, + AudioParam: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioParam', + writeable: false, + }, + AudioParamMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioParamMap', + writeable: false, + }, + AudioProcessingEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioProcessingEvent', + writeable: false, + }, + AudioScheduledSourceNodeEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioScheduledSourceNodeEventMap', + writeable: false, + }, + AudioScheduledSourceNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioScheduledSourceNode', + writeable: false, + }, + AudioWorklet: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioWorklet', + writeable: false, + }, + AudioWorkletNodeEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioWorkletNodeEventMap', + writeable: false, + }, + AudioWorkletNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AudioWorkletNode', + writeable: false, + }, + AuthenticatorAssertionResponse: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AuthenticatorAssertionResponse', + writeable: false, + }, + AuthenticatorAttestationResponse: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AuthenticatorAttestationResponse', + writeable: false, + }, + AuthenticatorResponse: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AuthenticatorResponse', + writeable: false, + }, + BarProp: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BarProp', + writeable: false, + }, + BaseAudioContextEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BaseAudioContextEventMap', + writeable: false, + }, + BaseAudioContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BaseAudioContext', + writeable: false, + }, + BeforeUnloadEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BeforeUnloadEvent', + writeable: false, + }, + BhxBrowser: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BhxBrowser', + writeable: false, + }, + BiquadFilterNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BiquadFilterNode', + writeable: false, + }, + Blob: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Blob', + writeable: false, + }, + Body: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Body', + writeable: false, + }, + BroadcastChannelEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BroadcastChannelEventMap', + writeable: false, + }, + BroadcastChannel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BroadcastChannel', + writeable: false, + }, + ByteLengthQueuingStrategy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ByteLengthQueuingStrategy', + writeable: false, + }, + CDATASection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CDATASection', + writeable: false, + }, + CSSConditionRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSConditionRule', + writeable: false, + }, + CSSFontFaceRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSFontFaceRule', + writeable: false, + }, + CSSGroupingRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSGroupingRule', + writeable: false, + }, + CSSImportRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSImportRule', + writeable: false, + }, + CSSKeyframeRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSKeyframeRule', + writeable: false, + }, + CSSKeyframesRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSKeyframesRule', + writeable: false, + }, + CSSMediaRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSMediaRule', + writeable: false, + }, + CSSNamespaceRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSNamespaceRule', + writeable: false, + }, + CSSPageRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSPageRule', + writeable: false, + }, + CSSRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSRule', + writeable: false, + }, + CSSRuleList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSRuleList', + writeable: false, + }, + CSSStyleDeclaration: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSStyleDeclaration', + writeable: false, + }, + CSSStyleRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSStyleRule', + writeable: false, + }, + CSSStyleSheet: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSStyleSheet', + writeable: false, + }, + CSSSupportsRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSSSupportsRule', + writeable: false, + }, + Cache: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Cache', + writeable: false, + }, + CacheStorage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CacheStorage', + writeable: false, + }, + CanvasCompositing: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasCompositing', + writeable: false, + }, + CanvasDrawImage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasDrawImage', + writeable: false, + }, + CanvasDrawPath: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasDrawPath', + writeable: false, + }, + CanvasFillStrokeStyles: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasFillStrokeStyles', + writeable: false, + }, + CanvasFilters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasFilters', + writeable: false, + }, + CanvasGradient: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CanvasGradient', + writeable: false, + }, + CanvasImageData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasImageData', + writeable: false, + }, + CanvasImageSmoothing: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasImageSmoothing', + writeable: false, + }, + CanvasPath: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasPath', + writeable: false, + }, + CanvasPathDrawingStyles: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasPathDrawingStyles', + writeable: false, + }, + CanvasPattern: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CanvasPattern', + writeable: false, + }, + CanvasRect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasRect', + writeable: false, + }, + CanvasRenderingContext2D: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CanvasRenderingContext2D', + writeable: false, + }, + CanvasShadowStyles: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasShadowStyles', + writeable: false, + }, + CanvasState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasState', + writeable: false, + }, + CanvasText: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasText', + writeable: false, + }, + CanvasTextDrawingStyles: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasTextDrawingStyles', + writeable: false, + }, + CanvasTransform: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasTransform', + writeable: false, + }, + CanvasUserInterface: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasUserInterface', + writeable: false, + }, + CaretPosition: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CaretPosition', + writeable: false, + }, + ChannelMergerNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ChannelMergerNode', + writeable: false, + }, + ChannelSplitterNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ChannelSplitterNode', + writeable: false, + }, + CharacterData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CharacterData', + writeable: false, + }, + ChildNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ChildNode', + writeable: false, + }, + ClientRect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ClientRect', + writeable: false, + }, + ClientRectList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ClientRectList', + writeable: false, + }, + Clipboard: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Clipboard', + writeable: false, + }, + ClipboardEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ClipboardEvent', + writeable: false, + }, + CloseEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CloseEvent', + writeable: false, + }, + Comment: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Comment', + writeable: false, + }, + CompositionEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CompositionEvent', + writeable: false, + }, + ConcatParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConcatParams', + writeable: false, + }, + ConstantSourceNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ConstantSourceNode', + writeable: false, + }, + ConvolverNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ConvolverNode', + writeable: false, + }, + Coordinates: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Coordinates', + writeable: false, + }, + CountQueuingStrategy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CountQueuingStrategy', + writeable: false, + }, + Credential: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Credential', + writeable: false, + }, + CredentialsContainer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CredentialsContainer', + writeable: false, + }, + Crypto: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Crypto', + writeable: false, + }, + CryptoKey: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CryptoKey', + writeable: false, + }, + CryptoKeyPair: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CryptoKeyPair', + writeable: false, + }, + CustomElementRegistry: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CustomElementRegistry', + writeable: false, + }, + CustomEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CustomEvent', + writeable: false, + }, + DOMError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMError', + writeable: false, + }, + DOMException: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMException', + writeable: false, + }, + DOMImplementation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMImplementation', + writeable: false, + }, + DOML2DeprecatedColorProperty: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOML2DeprecatedColorProperty', + writeable: false, + }, + DOMMatrix: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMMatrix', + writeable: false, + }, + SVGMatrix: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGMatrix', + writeable: false, + }, + WebKitCSSMatrix: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebKitCSSMatrix', + writeable: false, + }, + DOMMatrixReadOnly: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMMatrixReadOnly', + writeable: false, + }, + DOMParser: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMParser', + writeable: false, + }, + DOMPoint: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMPoint', + writeable: false, + }, + SVGPoint: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPoint', + writeable: false, + }, + DOMPointReadOnly: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMPointReadOnly', + writeable: false, + }, + DOMQuad: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMQuad', + writeable: false, + }, + DOMRect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMRect', + writeable: false, + }, + SVGRect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGRect', + writeable: false, + }, + DOMRectList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMRectList', + writeable: false, + }, + DOMRectReadOnly: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMRectReadOnly', + writeable: false, + }, + DOMSettableTokenList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMSettableTokenList', + writeable: false, + }, + DOMStringList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMStringList', + writeable: false, + }, + DOMStringMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMStringMap', + writeable: false, + }, + DOMTokenList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMTokenList', + writeable: false, + }, + DataCue: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DataCue', + writeable: false, + }, + DataTransfer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DataTransfer', + writeable: false, + }, + DataTransferItem: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DataTransferItem', + writeable: false, + }, + DataTransferItemList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DataTransferItemList', + writeable: false, + }, + DeferredPermissionRequest: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DeferredPermissionRequest', + writeable: false, + }, + DelayNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DelayNode', + writeable: false, + }, + DeviceAcceleration: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DeviceAcceleration', + writeable: false, + }, + DeviceLightEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DeviceLightEvent', + writeable: false, + }, + DeviceMotionEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DeviceMotionEvent', + writeable: false, + }, + DeviceMotionEventAcceleration: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DeviceMotionEventAcceleration', + writeable: false, + }, + DeviceMotionEventRotationRate: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DeviceMotionEventRotationRate', + writeable: false, + }, + DeviceOrientationEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DeviceOrientationEvent', + writeable: false, + }, + DeviceRotationRate: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DeviceRotationRate', + writeable: false, + }, + DhImportKeyParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DhImportKeyParams', + writeable: false, + }, + DhKeyAlgorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DhKeyAlgorithm', + writeable: false, + }, + DhKeyDeriveParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DhKeyDeriveParams', + writeable: false, + }, + DhKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DhKeyGenParams', + writeable: false, + }, + DocumentEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DocumentEventMap', + writeable: false, + }, + Document: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Document', + writeable: false, + }, + DocumentAndElementEventHandlersEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DocumentAndElementEventHandlersEventMap', + writeable: false, + }, + DocumentAndElementEventHandlers: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DocumentAndElementEventHandlers', + writeable: false, + }, + DocumentEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DocumentEvent', + writeable: false, + }, + DocumentFragment: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DocumentFragment', + writeable: false, + }, + DocumentOrShadowRoot: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DocumentOrShadowRoot', + writeable: false, + }, + DocumentTimeline: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DocumentTimeline', + writeable: false, + }, + DocumentType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DocumentType', + writeable: false, + }, + DragEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DragEvent', + writeable: false, + }, + DynamicsCompressorNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DynamicsCompressorNode', + writeable: false, + }, + EXT_blend_minmax: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EXT_blend_minmax', + writeable: false, + }, + EXT_frag_depth: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EXT_frag_depth', + writeable: false, + }, + EXT_sRGB: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EXT_sRGB', + writeable: false, + }, + EXT_shader_texture_lod: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EXT_shader_texture_lod', + writeable: false, + }, + EXT_texture_filter_anisotropic: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EXT_texture_filter_anisotropic', + writeable: false, + }, + ElementEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ElementEventMap', + writeable: false, + }, + Element: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Element', + writeable: false, + }, + ElementCSSInlineStyle: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ElementCSSInlineStyle', + writeable: false, + }, + ElementContentEditable: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ElementContentEditable', + writeable: false, + }, + ErrorEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ErrorEvent', + writeable: false, + }, + Event: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Event', + writeable: false, + }, + EventListenerObject: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventListenerObject', + writeable: false, + }, + EventSourceEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventSourceEventMap', + writeable: false, + }, + EventSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'EventSource', + writeable: false, + }, + EventTarget: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'EventTarget', + writeable: false, + }, + ExtensionScriptApis: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ExtensionScriptApis', + writeable: false, + }, + External: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'External', + writeable: false, + }, + File: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'File', + writeable: false, + }, + FileList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'FileList', + writeable: false, + }, + FileReaderEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FileReaderEventMap', + writeable: false, + }, + FileReader: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'FileReader', + writeable: false, + }, + FocusEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'FocusEvent', + writeable: false, + }, + FocusNavigationEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'FocusNavigationEvent', + writeable: false, + }, + FormData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'FormData', + writeable: false, + }, + GainNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'GainNode', + writeable: false, + }, + Gamepad: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Gamepad', + writeable: false, + }, + GamepadButton: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'GamepadButton', + writeable: false, + }, + GamepadEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'GamepadEvent', + writeable: false, + }, + GamepadHapticActuator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'GamepadHapticActuator', + writeable: false, + }, + GamepadPose: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'GamepadPose', + writeable: false, + }, + GenericTransformStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GenericTransformStream', + writeable: false, + }, + Geolocation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Geolocation', + writeable: false, + }, + GlobalEventHandlersEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GlobalEventHandlersEventMap', + writeable: false, + }, + GlobalEventHandlers: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GlobalEventHandlers', + writeable: false, + }, + HTMLAllCollection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLAllCollection', + writeable: false, + }, + HTMLAnchorElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLAnchorElement', + writeable: false, + }, + HTMLAppletElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLAppletElement', + writeable: false, + }, + HTMLAreaElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLAreaElement', + writeable: false, + }, + HTMLAudioElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLAudioElement', + writeable: false, + }, + HTMLBRElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLBRElement', + writeable: false, + }, + HTMLBaseElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLBaseElement', + writeable: false, + }, + HTMLBaseFontElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLBaseFontElement', + writeable: false, + }, + HTMLBodyElementEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLBodyElementEventMap', + writeable: false, + }, + HTMLBodyElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLBodyElement', + writeable: false, + }, + HTMLButtonElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLButtonElement', + writeable: false, + }, + HTMLCanvasElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLCanvasElement', + writeable: false, + }, + HTMLCollectionBase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLCollectionBase', + writeable: false, + }, + HTMLCollection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLCollection', + writeable: false, + }, + HTMLCollectionOf: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLCollectionOf', + writeable: false, + }, + HTMLDListElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLDListElement', + writeable: false, + }, + HTMLDataElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLDataElement', + writeable: false, + }, + HTMLDataListElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLDataListElement', + writeable: false, + }, + HTMLDetailsElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLDetailsElement', + writeable: false, + }, + HTMLDialogElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLDialogElement', + writeable: false, + }, + HTMLDirectoryElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLDirectoryElement', + writeable: false, + }, + HTMLDivElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLDivElement', + writeable: false, + }, + HTMLDocument: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLDocument', + writeable: false, + }, + HTMLElementEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLElementEventMap', + writeable: false, + }, + HTMLElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLElement', + writeable: false, + }, + HTMLEmbedElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLEmbedElement', + writeable: false, + }, + HTMLFieldSetElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLFieldSetElement', + writeable: false, + }, + HTMLFontElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLFontElement', + writeable: false, + }, + HTMLFormControlsCollection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLFormControlsCollection', + writeable: false, + }, + HTMLFormElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLFormElement', + writeable: false, + }, + HTMLFrameElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLFrameElement', + writeable: false, + }, + HTMLFrameSetElementEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLFrameSetElementEventMap', + writeable: false, + }, + HTMLFrameSetElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLFrameSetElement', + writeable: false, + }, + HTMLHRElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLHRElement', + writeable: false, + }, + HTMLHeadElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLHeadElement', + writeable: false, + }, + HTMLHeadingElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLHeadingElement', + writeable: false, + }, + HTMLHtmlElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLHtmlElement', + writeable: false, + }, + HTMLHyperlinkElementUtils: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLHyperlinkElementUtils', + writeable: false, + }, + HTMLIFrameElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLIFrameElement', + writeable: false, + }, + HTMLImageElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLImageElement', + writeable: false, + }, + HTMLInputElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLInputElement', + writeable: false, + }, + HTMLLIElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLLIElement', + writeable: false, + }, + HTMLLabelElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLLabelElement', + writeable: false, + }, + HTMLLegendElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLLegendElement', + writeable: false, + }, + HTMLLinkElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLLinkElement', + writeable: false, + }, + HTMLMapElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLMapElement', + writeable: false, + }, + HTMLMarqueeElementEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLMarqueeElementEventMap', + writeable: false, + }, + HTMLMarqueeElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLMarqueeElement', + writeable: false, + }, + HTMLMediaElementEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLMediaElementEventMap', + writeable: false, + }, + HTMLMediaElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLMediaElement', + writeable: false, + }, + HTMLMenuElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLMenuElement', + writeable: false, + }, + HTMLMetaElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLMetaElement', + writeable: false, + }, + HTMLMeterElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLMeterElement', + writeable: false, + }, + HTMLModElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLModElement', + writeable: false, + }, + HTMLOListElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLOListElement', + writeable: false, + }, + HTMLObjectElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLObjectElement', + writeable: false, + }, + HTMLOptGroupElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLOptGroupElement', + writeable: false, + }, + HTMLOptionElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLOptionElement', + writeable: false, + }, + HTMLOptionsCollection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLOptionsCollection', + writeable: false, + }, + HTMLOrSVGElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLOrSVGElement', + writeable: false, + }, + HTMLOutputElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLOutputElement', + writeable: false, + }, + HTMLParagraphElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLParagraphElement', + writeable: false, + }, + HTMLParamElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLParamElement', + writeable: false, + }, + HTMLPictureElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLPictureElement', + writeable: false, + }, + HTMLPreElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLPreElement', + writeable: false, + }, + HTMLProgressElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLProgressElement', + writeable: false, + }, + HTMLQuoteElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLQuoteElement', + writeable: false, + }, + HTMLScriptElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLScriptElement', + writeable: false, + }, + HTMLSelectElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLSelectElement', + writeable: false, + }, + HTMLSlotElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLSlotElement', + writeable: false, + }, + HTMLSourceElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLSourceElement', + writeable: false, + }, + HTMLSpanElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLSpanElement', + writeable: false, + }, + HTMLStyleElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLStyleElement', + writeable: false, + }, + HTMLTableCaptionElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTableCaptionElement', + writeable: false, + }, + HTMLTableCellElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTableCellElement', + writeable: false, + }, + HTMLTableColElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTableColElement', + writeable: false, + }, + HTMLTableDataCellElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTableDataCellElement', + writeable: false, + }, + HTMLTableElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTableElement', + writeable: false, + }, + HTMLTableHeaderCellElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTableHeaderCellElement', + writeable: false, + }, + HTMLTableRowElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTableRowElement', + writeable: false, + }, + HTMLTableSectionElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTableSectionElement', + writeable: false, + }, + HTMLTemplateElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTemplateElement', + writeable: false, + }, + HTMLTextAreaElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTextAreaElement', + writeable: false, + }, + HTMLTimeElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTimeElement', + writeable: false, + }, + HTMLTitleElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTitleElement', + writeable: false, + }, + HTMLTrackElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLTrackElement', + writeable: false, + }, + HTMLUListElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLUListElement', + writeable: false, + }, + HTMLUnknownElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLUnknownElement', + writeable: false, + }, + HTMLVideoElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HTMLVideoElement', + writeable: false, + }, + HashChangeEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'HashChangeEvent', + writeable: false, + }, + Headers: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Headers', + writeable: false, + }, + History: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'History', + writeable: false, + }, + HkdfCtrParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HkdfCtrParams', + writeable: false, + }, + IDBArrayKey: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBArrayKey', + writeable: false, + }, + IDBCursor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBCursor', + writeable: false, + }, + IDBCursorWithValue: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBCursorWithValue', + writeable: false, + }, + IDBDatabaseEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBDatabaseEventMap', + writeable: false, + }, + IDBDatabase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBDatabase', + writeable: false, + }, + IDBFactory: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBFactory', + writeable: false, + }, + IDBIndex: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBIndex', + writeable: false, + }, + IDBKeyRange: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBKeyRange', + writeable: false, + }, + IDBObjectStore: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBObjectStore', + writeable: false, + }, + IDBOpenDBRequestEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBOpenDBRequestEventMap', + writeable: false, + }, + IDBOpenDBRequest: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBOpenDBRequest', + writeable: false, + }, + IDBRequestEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBRequestEventMap', + writeable: false, + }, + IDBRequest: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBRequest', + writeable: false, + }, + IDBTransactionEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBTransactionEventMap', + writeable: false, + }, + IDBTransaction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBTransaction', + writeable: false, + }, + IDBVersionChangeEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBVersionChangeEvent', + writeable: false, + }, + IIRFilterNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IIRFilterNode', + writeable: false, + }, + ImageBitmap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ImageBitmap', + writeable: false, + }, + ImageBitmapRenderingContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ImageBitmapRenderingContext', + writeable: false, + }, + ImageData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ImageData', + writeable: false, + }, + InnerHTML: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'InnerHTML', + writeable: false, + }, + InputDeviceInfo: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'InputDeviceInfo', + writeable: false, + }, + InputEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'InputEvent', + writeable: false, + }, + IntersectionObserver: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IntersectionObserver', + writeable: false, + }, + IntersectionObserverEntry: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IntersectionObserverEntry', + writeable: false, + }, + KeyboardEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'KeyboardEvent', + writeable: false, + }, + KeyframeEffect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'KeyframeEffect', + writeable: false, + }, + LinkStyle: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'LinkStyle', + writeable: false, + }, + ListeningStateChangedEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ListeningStateChangedEvent', + writeable: false, + }, + Location: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Location', + writeable: false, + }, + MSAssertion: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSAssertion', + writeable: false, + }, + MSBlobBuilder: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSBlobBuilder', + writeable: false, + }, + MSFIDOCredentialAssertion: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSFIDOCredentialAssertion', + writeable: false, + }, + MSFIDOSignature: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSFIDOSignature', + writeable: false, + }, + MSFIDOSignatureAssertion: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSFIDOSignatureAssertion', + writeable: false, + }, + MSFileSaver: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MSFileSaver', + writeable: false, + }, + MSGesture: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSGesture', + writeable: false, + }, + MSGestureEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSGestureEvent', + writeable: false, + }, + MSGraphicsTrust: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSGraphicsTrust', + writeable: false, + }, + MSInputMethodContextEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MSInputMethodContextEventMap', + writeable: false, + }, + MSInputMethodContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSInputMethodContext', + writeable: false, + }, + MSMediaKeyError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSMediaKeyError', + writeable: false, + }, + MSMediaKeyMessageEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSMediaKeyMessageEvent', + writeable: false, + }, + MSMediaKeyNeededEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSMediaKeyNeededEvent', + writeable: false, + }, + MSMediaKeySession: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSMediaKeySession', + writeable: false, + }, + MSMediaKeys: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSMediaKeys', + writeable: false, + }, + MSNavigatorDoNotTrack: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MSNavigatorDoNotTrack', + writeable: false, + }, + MSPointerEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSPointerEvent', + writeable: false, + }, + MSStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MSStream', + writeable: false, + }, + MediaDeviceInfo: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaDeviceInfo', + writeable: false, + }, + MediaDevicesEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaDevicesEventMap', + writeable: false, + }, + MediaDevices: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaDevices', + writeable: false, + }, + MediaElementAudioSourceNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaElementAudioSourceNode', + writeable: false, + }, + MediaEncryptedEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaEncryptedEvent', + writeable: false, + }, + MediaError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaError', + writeable: false, + }, + MediaKeyMessageEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaKeyMessageEvent', + writeable: false, + }, + MediaKeySessionEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaKeySessionEventMap', + writeable: false, + }, + MediaKeySession: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaKeySession', + writeable: false, + }, + MediaKeyStatusMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaKeyStatusMap', + writeable: false, + }, + MediaKeySystemAccess: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaKeySystemAccess', + writeable: false, + }, + MediaKeys: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaKeys', + writeable: false, + }, + MediaList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaList', + writeable: false, + }, + MediaQueryListEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaQueryListEventMap', + writeable: false, + }, + MediaQueryList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaQueryList', + writeable: false, + }, + MediaQueryListEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaQueryListEvent', + writeable: false, + }, + MediaSourceEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaSourceEventMap', + writeable: false, + }, + MediaSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaSource', + writeable: false, + }, + MediaStreamEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaStreamEventMap', + writeable: false, + }, + MediaStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaStream', + writeable: false, + }, + MediaStreamAudioDestinationNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaStreamAudioDestinationNode', + writeable: false, + }, + MediaStreamAudioSourceNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaStreamAudioSourceNode', + writeable: false, + }, + MediaStreamError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaStreamError', + writeable: false, + }, + MediaStreamErrorEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaStreamErrorEvent', + writeable: false, + }, + MediaStreamEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaStreamEvent', + writeable: false, + }, + MediaStreamTrackEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaStreamTrackEventMap', + writeable: false, + }, + MediaStreamTrack: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaStreamTrack', + writeable: false, + }, + MediaStreamTrackAudioSourceNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaStreamTrackAudioSourceNode', + writeable: false, + }, + MediaStreamTrackEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MediaStreamTrackEvent', + writeable: false, + }, + MessageChannel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MessageChannel', + writeable: false, + }, + MessageEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MessageEvent', + writeable: false, + }, + MessagePortEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MessagePortEventMap', + writeable: false, + }, + MessagePort: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MessagePort', + writeable: false, + }, + MimeType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MimeType', + writeable: false, + }, + MimeTypeArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MimeTypeArray', + writeable: false, + }, + MouseEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MouseEvent', + writeable: false, + }, + MutationEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MutationEvent', + writeable: false, + }, + MutationObserver: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MutationObserver', + writeable: false, + }, + MutationRecord: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MutationRecord', + writeable: false, + }, + NamedNodeMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'NamedNodeMap', + writeable: false, + }, + NavigationPreloadManager: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'NavigationPreloadManager', + writeable: false, + }, + Navigator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Navigator', + writeable: false, + }, + NavigatorAutomationInformation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorAutomationInformation', + writeable: false, + }, + NavigatorBeacon: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorBeacon', + writeable: false, + }, + NavigatorConcurrentHardware: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorConcurrentHardware', + writeable: false, + }, + NavigatorContentUtils: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorContentUtils', + writeable: false, + }, + NavigatorCookies: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorCookies', + writeable: false, + }, + NavigatorID: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorID', + writeable: false, + }, + NavigatorLanguage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorLanguage', + writeable: false, + }, + NavigatorOnLine: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorOnLine', + writeable: false, + }, + NavigatorPlugins: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorPlugins', + writeable: false, + }, + NavigatorStorage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorStorage', + writeable: false, + }, + Node: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Node', + writeable: false, + }, + NodeFilter: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'NodeFilter', + writeable: false, + }, + NodeIterator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'NodeIterator', + writeable: false, + }, + NodeList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'NodeList', + writeable: false, + }, + NodeListOf: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NodeListOf', + writeable: false, + }, + NonDocumentTypeChildNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NonDocumentTypeChildNode', + writeable: false, + }, + NonElementParentNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NonElementParentNode', + writeable: false, + }, + NotificationEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationEventMap', + writeable: false, + }, + Notification: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Notification', + writeable: false, + }, + OES_element_index_uint: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_element_index_uint', + writeable: false, + }, + OES_standard_derivatives: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_standard_derivatives', + writeable: false, + }, + OES_texture_float: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_texture_float', + writeable: false, + }, + OES_texture_float_linear: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_texture_float_linear', + writeable: false, + }, + OES_texture_half_float: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_texture_half_float', + writeable: false, + }, + OES_texture_half_float_linear: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_texture_half_float_linear', + writeable: false, + }, + OES_vertex_array_object: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_vertex_array_object', + writeable: false, + }, + OfflineAudioCompletionEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'OfflineAudioCompletionEvent', + writeable: false, + }, + OfflineAudioContextEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OfflineAudioContextEventMap', + writeable: false, + }, + OfflineAudioContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'OfflineAudioContext', + writeable: false, + }, + OffscreenCanvas: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'OffscreenCanvas', + writeable: false, + }, + OffscreenCanvasRenderingContext2D: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'OffscreenCanvasRenderingContext2D', + writeable: false, + }, + OscillatorNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'OscillatorNode', + writeable: false, + }, + OverconstrainedError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'OverconstrainedError', + writeable: false, + }, + OverflowEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'OverflowEvent', + writeable: false, + }, + PageTransitionEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PageTransitionEvent', + writeable: false, + }, + PannerNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PannerNode', + writeable: false, + }, + ParentNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ParentNode', + writeable: false, + }, + Path2D: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Path2D', + writeable: false, + }, + PaymentAddress: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PaymentAddress', + writeable: false, + }, + PaymentRequestEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentRequestEventMap', + writeable: false, + }, + PaymentRequest: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PaymentRequest', + writeable: false, + }, + PaymentRequestUpdateEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PaymentRequestUpdateEvent', + writeable: false, + }, + PaymentResponse: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PaymentResponse', + writeable: false, + }, + PerfWidgetExternal: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerfWidgetExternal', + writeable: false, + }, + PerformanceEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PerformanceEventMap', + writeable: false, + }, + Performance: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Performance', + writeable: false, + }, + PerformanceEntry: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceEntry', + writeable: false, + }, + PerformanceMark: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceMark', + writeable: false, + }, + PerformanceMeasure: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceMeasure', + writeable: false, + }, + PerformanceNavigation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceNavigation', + writeable: false, + }, + PerformanceNavigationTiming: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceNavigationTiming', + writeable: false, + }, + PerformanceObserver: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceObserver', + writeable: false, + }, + PerformanceObserverEntryList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceObserverEntryList', + writeable: false, + }, + PerformanceResourceTiming: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceResourceTiming', + writeable: false, + }, + PerformanceTiming: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceTiming', + writeable: false, + }, + PeriodicWave: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PeriodicWave', + writeable: false, + }, + PermissionRequest: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PermissionRequest', + writeable: false, + }, + PermissionRequestedEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PermissionRequestedEvent', + writeable: false, + }, + PermissionStatusEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PermissionStatusEventMap', + writeable: false, + }, + PermissionStatus: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PermissionStatus', + writeable: false, + }, + Permissions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Permissions', + writeable: false, + }, + Plugin: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Plugin', + writeable: false, + }, + PluginArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PluginArray', + writeable: false, + }, + PointerEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PointerEvent', + writeable: false, + }, + PopStateEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PopStateEvent', + writeable: false, + }, + Position: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Position', + writeable: false, + }, + PositionError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PositionError', + writeable: false, + }, + ProcessingInstruction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ProcessingInstruction', + writeable: false, + }, + ProgressEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ProgressEvent', + writeable: false, + }, + PromiseRejectionEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PromiseRejectionEvent', + writeable: false, + }, + PublicKeyCredential: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PublicKeyCredential', + writeable: false, + }, + PushManager: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PushManager', + writeable: false, + }, + PushSubscription: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PushSubscription', + writeable: false, + }, + PushSubscriptionOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PushSubscriptionOptions', + writeable: false, + }, + RTCCertificate: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCCertificate', + writeable: false, + }, + RTCDTMFSenderEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDTMFSenderEventMap', + writeable: false, + }, + RTCDTMFSender: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCDTMFSender', + writeable: false, + }, + RTCDTMFToneChangeEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCDTMFToneChangeEvent', + writeable: false, + }, + RTCDataChannelEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDataChannelEventMap', + writeable: false, + }, + RTCDataChannel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCDataChannel', + writeable: false, + }, + RTCDataChannelEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCDataChannelEvent', + writeable: false, + }, + RTCDtlsTransportEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDtlsTransportEventMap', + writeable: false, + }, + RTCDtlsTransport: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCDtlsTransport', + writeable: false, + }, + RTCDtlsTransportStateChangedEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCDtlsTransportStateChangedEvent', + writeable: false, + }, + RTCDtmfSenderEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDtmfSenderEventMap', + writeable: false, + }, + RTCDtmfSender: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCDtmfSender', + writeable: false, + }, + RTCError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCError', + writeable: false, + }, + RTCErrorEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCErrorEvent', + writeable: false, + }, + RTCIceCandidate: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCIceCandidate', + writeable: false, + }, + RTCIceCandidatePairChangedEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCIceCandidatePairChangedEvent', + writeable: false, + }, + RTCIceGathererEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceGathererEventMap', + writeable: false, + }, + RTCIceGatherer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCIceGatherer', + writeable: false, + }, + RTCIceGathererEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCIceGathererEvent', + writeable: false, + }, + RTCIceTransportEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceTransportEventMap', + writeable: false, + }, + RTCIceTransport: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCIceTransport', + writeable: false, + }, + RTCIceTransportStateChangedEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCIceTransportStateChangedEvent', + writeable: false, + }, + RTCIdentityAssertion: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCIdentityAssertion', + writeable: false, + }, + RTCPeerConnectionEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCPeerConnectionEventMap', + writeable: false, + }, + RTCPeerConnection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCPeerConnection', + writeable: false, + }, + RTCPeerConnectionIceErrorEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCPeerConnectionIceErrorEvent', + writeable: false, + }, + RTCPeerConnectionIceEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCPeerConnectionIceEvent', + writeable: false, + }, + RTCRtpReceiver: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCRtpReceiver', + writeable: false, + }, + RTCRtpSender: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCRtpSender', + writeable: false, + }, + RTCRtpTransceiver: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCRtpTransceiver', + writeable: false, + }, + RTCSctpTransportEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCSctpTransportEventMap', + writeable: false, + }, + RTCSctpTransport: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCSctpTransport', + writeable: false, + }, + RTCSessionDescription: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCSessionDescription', + writeable: false, + }, + RTCSrtpSdesTransportEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCSrtpSdesTransportEventMap', + writeable: false, + }, + RTCSrtpSdesTransport: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCSrtpSdesTransport', + writeable: false, + }, + RTCSsrcConflictEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCSsrcConflictEvent', + writeable: false, + }, + RTCStatsEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCStatsEvent', + writeable: false, + }, + RTCStatsProvider: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCStatsProvider', + writeable: false, + }, + RTCTrackEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RTCTrackEvent', + writeable: false, + }, + RadioNodeList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RadioNodeList', + writeable: false, + }, + RandomSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RandomSource', + writeable: false, + }, + Range: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Range', + writeable: false, + }, + ReadableByteStreamController: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableByteStreamController', + writeable: false, + }, + ReadableStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ReadableStream', + writeable: false, + }, + ReadableStreamBYOBReader: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamBYOBReader', + writeable: false, + }, + ReadableStreamBYOBRequest: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamBYOBRequest', + writeable: false, + }, + ReadableStreamDefaultController: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamDefaultController', + writeable: false, + }, + ReadableStreamDefaultReader: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamDefaultReader', + writeable: false, + }, + ReadableStreamReader: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ReadableStreamReader', + writeable: false, + }, + Request: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Request', + writeable: false, + }, + Response: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Response', + writeable: false, + }, + SVGAElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAElement', + writeable: false, + }, + SVGAngle: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAngle', + writeable: false, + }, + SVGAnimateElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimateElement', + writeable: false, + }, + SVGAnimateMotionElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimateMotionElement', + writeable: false, + }, + SVGAnimateTransformElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimateTransformElement', + writeable: false, + }, + SVGAnimatedAngle: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedAngle', + writeable: false, + }, + SVGAnimatedBoolean: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedBoolean', + writeable: false, + }, + SVGAnimatedEnumeration: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedEnumeration', + writeable: false, + }, + SVGAnimatedInteger: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedInteger', + writeable: false, + }, + SVGAnimatedLength: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedLength', + writeable: false, + }, + SVGAnimatedLengthList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedLengthList', + writeable: false, + }, + SVGAnimatedNumber: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedNumber', + writeable: false, + }, + SVGAnimatedNumberList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedNumberList', + writeable: false, + }, + SVGAnimatedPoints: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGAnimatedPoints', + writeable: false, + }, + SVGAnimatedPreserveAspectRatio: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedPreserveAspectRatio', + writeable: false, + }, + SVGAnimatedRect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedRect', + writeable: false, + }, + SVGAnimatedString: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedString', + writeable: false, + }, + SVGAnimatedTransformList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimatedTransformList', + writeable: false, + }, + SVGAnimationElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGAnimationElement', + writeable: false, + }, + SVGCircleElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGCircleElement', + writeable: false, + }, + SVGClipPathElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGClipPathElement', + writeable: false, + }, + SVGComponentTransferFunctionElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGComponentTransferFunctionElement', + writeable: false, + }, + SVGCursorElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGCursorElement', + writeable: false, + }, + SVGDefsElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGDefsElement', + writeable: false, + }, + SVGDescElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGDescElement', + writeable: false, + }, + SVGElementEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGElementEventMap', + writeable: false, + }, + SVGElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGElement', + writeable: false, + }, + SVGElementInstance: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGElementInstance', + writeable: false, + }, + SVGElementInstanceList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGElementInstanceList', + writeable: false, + }, + SVGEllipseElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGEllipseElement', + writeable: false, + }, + SVGFEBlendElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEBlendElement', + writeable: false, + }, + SVGFEColorMatrixElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEColorMatrixElement', + writeable: false, + }, + SVGFEComponentTransferElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEComponentTransferElement', + writeable: false, + }, + SVGFECompositeElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFECompositeElement', + writeable: false, + }, + SVGFEConvolveMatrixElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEConvolveMatrixElement', + writeable: false, + }, + SVGFEDiffuseLightingElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEDiffuseLightingElement', + writeable: false, + }, + SVGFEDisplacementMapElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEDisplacementMapElement', + writeable: false, + }, + SVGFEDistantLightElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEDistantLightElement', + writeable: false, + }, + SVGFEDropShadowElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEDropShadowElement', + writeable: false, + }, + SVGFEFloodElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEFloodElement', + writeable: false, + }, + SVGFEFuncAElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEFuncAElement', + writeable: false, + }, + SVGFEFuncBElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEFuncBElement', + writeable: false, + }, + SVGFEFuncGElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEFuncGElement', + writeable: false, + }, + SVGFEFuncRElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEFuncRElement', + writeable: false, + }, + SVGFEGaussianBlurElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEGaussianBlurElement', + writeable: false, + }, + SVGFEImageElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEImageElement', + writeable: false, + }, + SVGFEMergeElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEMergeElement', + writeable: false, + }, + SVGFEMergeNodeElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEMergeNodeElement', + writeable: false, + }, + SVGFEMorphologyElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEMorphologyElement', + writeable: false, + }, + SVGFEOffsetElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEOffsetElement', + writeable: false, + }, + SVGFEPointLightElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFEPointLightElement', + writeable: false, + }, + SVGFESpecularLightingElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFESpecularLightingElement', + writeable: false, + }, + SVGFESpotLightElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFESpotLightElement', + writeable: false, + }, + SVGFETileElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFETileElement', + writeable: false, + }, + SVGFETurbulenceElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFETurbulenceElement', + writeable: false, + }, + SVGFilterElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGFilterElement', + writeable: false, + }, + SVGFilterPrimitiveStandardAttributes: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGFilterPrimitiveStandardAttributes', + writeable: false, + }, + SVGFitToViewBox: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGFitToViewBox', + writeable: false, + }, + SVGForeignObjectElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGForeignObjectElement', + writeable: false, + }, + SVGGElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGGElement', + writeable: false, + }, + SVGGeometryElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGGeometryElement', + writeable: false, + }, + SVGGradientElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGGradientElement', + writeable: false, + }, + SVGGraphicsElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGGraphicsElement', + writeable: false, + }, + SVGImageElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGImageElement', + writeable: false, + }, + SVGLength: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGLength', + writeable: false, + }, + SVGLengthList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGLengthList', + writeable: false, + }, + SVGLineElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGLineElement', + writeable: false, + }, + SVGLinearGradientElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGLinearGradientElement', + writeable: false, + }, + SVGMarkerElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGMarkerElement', + writeable: false, + }, + SVGMaskElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGMaskElement', + writeable: false, + }, + SVGMetadataElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGMetadataElement', + writeable: false, + }, + SVGNumber: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGNumber', + writeable: false, + }, + SVGNumberList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGNumberList', + writeable: false, + }, + SVGPathElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathElement', + writeable: false, + }, + SVGPathSeg: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSeg', + writeable: false, + }, + SVGPathSegArcAbs: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegArcAbs', + writeable: false, + }, + SVGPathSegArcRel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegArcRel', + writeable: false, + }, + SVGPathSegClosePath: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegClosePath', + writeable: false, + }, + SVGPathSegCurvetoCubicAbs: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegCurvetoCubicAbs', + writeable: false, + }, + SVGPathSegCurvetoCubicRel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegCurvetoCubicRel', + writeable: false, + }, + SVGPathSegCurvetoCubicSmoothAbs: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegCurvetoCubicSmoothAbs', + writeable: false, + }, + SVGPathSegCurvetoCubicSmoothRel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegCurvetoCubicSmoothRel', + writeable: false, + }, + SVGPathSegCurvetoQuadraticAbs: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegCurvetoQuadraticAbs', + writeable: false, + }, + SVGPathSegCurvetoQuadraticRel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegCurvetoQuadraticRel', + writeable: false, + }, + SVGPathSegCurvetoQuadraticSmoothAbs: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegCurvetoQuadraticSmoothAbs', + writeable: false, + }, + SVGPathSegCurvetoQuadraticSmoothRel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegCurvetoQuadraticSmoothRel', + writeable: false, + }, + SVGPathSegLinetoAbs: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegLinetoAbs', + writeable: false, + }, + SVGPathSegLinetoHorizontalAbs: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegLinetoHorizontalAbs', + writeable: false, + }, + SVGPathSegLinetoHorizontalRel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegLinetoHorizontalRel', + writeable: false, + }, + SVGPathSegLinetoRel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegLinetoRel', + writeable: false, + }, + SVGPathSegLinetoVerticalAbs: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegLinetoVerticalAbs', + writeable: false, + }, + SVGPathSegLinetoVerticalRel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegLinetoVerticalRel', + writeable: false, + }, + SVGPathSegList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegList', + writeable: false, + }, + SVGPathSegMovetoAbs: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegMovetoAbs', + writeable: false, + }, + SVGPathSegMovetoRel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPathSegMovetoRel', + writeable: false, + }, + SVGPatternElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPatternElement', + writeable: false, + }, + SVGPointList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPointList', + writeable: false, + }, + SVGPolygonElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPolygonElement', + writeable: false, + }, + SVGPolylineElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPolylineElement', + writeable: false, + }, + SVGPreserveAspectRatio: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGPreserveAspectRatio', + writeable: false, + }, + SVGRadialGradientElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGRadialGradientElement', + writeable: false, + }, + SVGRectElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGRectElement', + writeable: false, + }, + SVGSVGElementEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGSVGElementEventMap', + writeable: false, + }, + SVGSVGElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGSVGElement', + writeable: false, + }, + SVGScriptElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGScriptElement', + writeable: false, + }, + SVGStopElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGStopElement', + writeable: false, + }, + SVGStringList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGStringList', + writeable: false, + }, + SVGStyleElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGStyleElement', + writeable: false, + }, + SVGSwitchElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGSwitchElement', + writeable: false, + }, + SVGSymbolElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGSymbolElement', + writeable: false, + }, + SVGTSpanElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGTSpanElement', + writeable: false, + }, + SVGTests: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGTests', + writeable: false, + }, + SVGTextContentElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGTextContentElement', + writeable: false, + }, + SVGTextElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGTextElement', + writeable: false, + }, + SVGTextPathElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGTextPathElement', + writeable: false, + }, + SVGTextPositioningElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGTextPositioningElement', + writeable: false, + }, + SVGTitleElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGTitleElement', + writeable: false, + }, + SVGTransform: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGTransform', + writeable: false, + }, + SVGTransformList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGTransformList', + writeable: false, + }, + SVGURIReference: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGURIReference', + writeable: false, + }, + SVGUnitTypes: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGUnitTypes', + writeable: false, + }, + SVGUseElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGUseElement', + writeable: false, + }, + SVGViewElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGViewElement', + writeable: false, + }, + SVGZoomAndPan: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGZoomAndPan', + writeable: false, + }, + SVGZoomEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SVGZoomEvent', + writeable: false, + }, + ScopedCredential: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ScopedCredential', + writeable: false, + }, + ScopedCredentialInfo: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ScopedCredentialInfo', + writeable: false, + }, + Screen: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Screen', + writeable: false, + }, + ScreenOrientationEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScreenOrientationEventMap', + writeable: false, + }, + ScreenOrientation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ScreenOrientation', + writeable: false, + }, + ScriptProcessorNodeEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScriptProcessorNodeEventMap', + writeable: false, + }, + ScriptProcessorNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ScriptProcessorNode', + writeable: false, + }, + SecurityPolicyViolationEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SecurityPolicyViolationEvent', + writeable: false, + }, + Selection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Selection', + writeable: false, + }, + ServiceUIFrameContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ServiceUIFrameContext', + writeable: false, + }, + ServiceWorkerEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerEventMap', + writeable: false, + }, + ServiceWorker: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ServiceWorker', + writeable: false, + }, + ServiceWorkerContainerEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerContainerEventMap', + writeable: false, + }, + ServiceWorkerContainer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ServiceWorkerContainer', + writeable: false, + }, + ServiceWorkerMessageEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ServiceWorkerMessageEvent', + writeable: false, + }, + ServiceWorkerRegistrationEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerRegistrationEventMap', + writeable: false, + }, + ServiceWorkerRegistration: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ServiceWorkerRegistration', + writeable: false, + }, + ShadowRoot: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ShadowRoot', + writeable: false, + }, + SharedWorker: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SharedWorker', + writeable: false, + }, + Slotable: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Slotable', + writeable: false, + }, + SourceBufferEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SourceBufferEventMap', + writeable: false, + }, + SourceBuffer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SourceBuffer', + writeable: false, + }, + SourceBufferListEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SourceBufferListEventMap', + writeable: false, + }, + SourceBufferList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SourceBufferList', + writeable: false, + }, + SpeechGrammar: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechGrammar', + writeable: false, + }, + SpeechGrammarList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechGrammarList', + writeable: false, + }, + SpeechRecognitionEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SpeechRecognitionEventMap', + writeable: false, + }, + SpeechRecognition: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechRecognition', + writeable: false, + }, + SpeechRecognitionAlternative: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechRecognitionAlternative', + writeable: false, + }, + SpeechRecognitionEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechRecognitionEvent', + writeable: false, + }, + SpeechRecognitionResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechRecognitionResult', + writeable: false, + }, + SpeechRecognitionResultList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechRecognitionResultList', + writeable: false, + }, + SpeechSynthesisEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SpeechSynthesisEventMap', + writeable: false, + }, + SpeechSynthesis: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechSynthesis', + writeable: false, + }, + SpeechSynthesisErrorEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechSynthesisErrorEvent', + writeable: false, + }, + SpeechSynthesisEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechSynthesisEvent', + writeable: false, + }, + SpeechSynthesisUtteranceEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SpeechSynthesisUtteranceEventMap', + writeable: false, + }, + SpeechSynthesisUtterance: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechSynthesisUtterance', + writeable: false, + }, + SpeechSynthesisVoice: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SpeechSynthesisVoice', + writeable: false, + }, + StaticRange: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'StaticRange', + writeable: false, + }, + StereoPannerNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'StereoPannerNode', + writeable: false, + }, + Storage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Storage', + writeable: false, + }, + StorageEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'StorageEvent', + writeable: false, + }, + StorageManager: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'StorageManager', + writeable: false, + }, + StyleMedia: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'StyleMedia', + writeable: false, + }, + StyleSheet: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'StyleSheet', + writeable: false, + }, + StyleSheetList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'StyleSheetList', + writeable: false, + }, + SubtleCrypto: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SubtleCrypto', + writeable: false, + }, + SyncManager: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SyncManager', + writeable: false, + }, + Text: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Text', + writeable: false, + }, + TextDecoder: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextDecoder', + writeable: false, + }, + TextDecoderCommon: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextDecoderCommon', + writeable: false, + }, + TextDecoderStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextDecoderStream', + writeable: false, + }, + TextEncoder: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextEncoder', + writeable: false, + }, + TextEncoderCommon: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextEncoderCommon', + writeable: false, + }, + TextEncoderStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextEncoderStream', + writeable: false, + }, + TextEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextEvent', + writeable: false, + }, + TextMetrics: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextMetrics', + writeable: false, + }, + TextTrackEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextTrackEventMap', + writeable: false, + }, + TextTrack: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextTrack', + writeable: false, + }, + TextTrackCueEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextTrackCueEventMap', + writeable: false, + }, + TextTrackCue: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextTrackCue', + writeable: false, + }, + TextTrackCueList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextTrackCueList', + writeable: false, + }, + TextTrackListEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextTrackListEventMap', + writeable: false, + }, + TextTrackList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextTrackList', + writeable: false, + }, + TimeRanges: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TimeRanges', + writeable: false, + }, + Touch: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Touch', + writeable: false, + }, + TouchEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TouchEvent', + writeable: false, + }, + TouchList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TouchList', + writeable: false, + }, + TrackEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TrackEvent', + writeable: false, + }, + TransformStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TransformStream', + writeable: false, + }, + TransformStreamDefaultController: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TransformStreamDefaultController', + writeable: false, + }, + TransitionEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TransitionEvent', + writeable: false, + }, + TreeWalker: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TreeWalker', + writeable: false, + }, + UIEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'UIEvent', + writeable: false, + }, + URL: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'URL', + writeable: false, + }, + webkitURL: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'webkitURL', + writeable: false, + }, + URLSearchParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'URLSearchParams', + writeable: false, + }, + VRDisplay: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VRDisplay', + writeable: false, + }, + VRDisplayCapabilities: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VRDisplayCapabilities', + writeable: false, + }, + VRDisplayEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VRDisplayEvent', + writeable: false, + }, + VREyeParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VREyeParameters', + writeable: false, + }, + VRFieldOfView: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VRFieldOfView', + writeable: false, + }, + VRFrameData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VRFrameData', + writeable: false, + }, + VRPose: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VRPose', + writeable: false, + }, + VTTCue: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VTTCue', + writeable: false, + }, + VTTRegion: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VTTRegion', + writeable: false, + }, + ValidityState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ValidityState', + writeable: false, + }, + VideoPlaybackQuality: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VideoPlaybackQuality', + writeable: false, + }, + WEBGL_color_buffer_float: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_color_buffer_float', + writeable: false, + }, + WEBGL_compressed_texture_astc: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_compressed_texture_astc', + writeable: false, + }, + WEBGL_compressed_texture_s3tc: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_compressed_texture_s3tc', + writeable: false, + }, + WEBGL_compressed_texture_s3tc_srgb: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_compressed_texture_s3tc_srgb', + writeable: false, + }, + WEBGL_debug_renderer_info: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_debug_renderer_info', + writeable: false, + }, + WEBGL_debug_shaders: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_debug_shaders', + writeable: false, + }, + WEBGL_depth_texture: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_depth_texture', + writeable: false, + }, + WEBGL_draw_buffers: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_draw_buffers', + writeable: false, + }, + WEBGL_lose_context: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_lose_context', + writeable: false, + }, + WaveShaperNode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WaveShaperNode', + writeable: false, + }, + WebAuthentication: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebAuthentication', + writeable: false, + }, + WebAuthnAssertion: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebAuthnAssertion', + writeable: false, + }, + WebGL2RenderingContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGL2RenderingContext', + writeable: false, + }, + WebGL2RenderingContextBase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGL2RenderingContextBase', + writeable: false, + }, + WebGL2RenderingContextOverloads: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGL2RenderingContextOverloads', + writeable: false, + }, + WebGLActiveInfo: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLActiveInfo', + writeable: false, + }, + WebGLBuffer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLBuffer', + writeable: false, + }, + WebGLContextEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLContextEvent', + writeable: false, + }, + WebGLFramebuffer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLFramebuffer', + writeable: false, + }, + WebGLObject: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLObject', + writeable: false, + }, + WebGLProgram: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLProgram', + writeable: false, + }, + WebGLQuery: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLQuery', + writeable: false, + }, + WebGLRenderbuffer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLRenderbuffer', + writeable: false, + }, + WebGLRenderingContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLRenderingContext', + writeable: false, + }, + WebGLRenderingContextBase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLRenderingContextBase', + writeable: false, + }, + WebGLRenderingContextOverloads: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLRenderingContextOverloads', + writeable: false, + }, + WebGLSampler: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLSampler', + writeable: false, + }, + WebGLShader: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLShader', + writeable: false, + }, + WebGLShaderPrecisionFormat: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLShaderPrecisionFormat', + writeable: false, + }, + WebGLSync: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLSync', + writeable: false, + }, + WebGLTexture: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLTexture', + writeable: false, + }, + WebGLTransformFeedback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLTransformFeedback', + writeable: false, + }, + WebGLUniformLocation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLUniformLocation', + writeable: false, + }, + WebGLVertexArrayObject: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLVertexArrayObject', + writeable: false, + }, + WebGLVertexArrayObjectOES: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLVertexArrayObjectOES', + writeable: false, + }, + WebKitPoint: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebKitPoint', + writeable: false, + }, + WebSocketEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebSocketEventMap', + writeable: false, + }, + WebSocket: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebSocket', + writeable: false, + }, + WheelEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WheelEvent', + writeable: false, + }, + WindowEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WindowEventMap', + writeable: false, + }, + Window: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Window', + writeable: false, + }, + WindowEventHandlersEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WindowEventHandlersEventMap', + writeable: false, + }, + WindowEventHandlers: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WindowEventHandlers', + writeable: false, + }, + WindowLocalStorage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WindowLocalStorage', + writeable: false, + }, + WindowOrWorkerGlobalScope: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WindowOrWorkerGlobalScope', + writeable: false, + }, + WindowSessionStorage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WindowSessionStorage', + writeable: false, + }, + WorkerEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WorkerEventMap', + writeable: false, + }, + Worker: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Worker', + writeable: false, + }, + Worklet: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Worklet', + writeable: false, + }, + WritableStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WritableStream', + writeable: false, + }, + WritableStreamDefaultController: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamDefaultController', + writeable: false, + }, + WritableStreamDefaultWriter: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamDefaultWriter', + writeable: false, + }, + XMLDocument: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XMLDocument', + writeable: false, + }, + XMLHttpRequestEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'XMLHttpRequestEventMap', + writeable: false, + }, + XMLHttpRequest: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XMLHttpRequest', + writeable: false, + }, + XMLHttpRequestEventTargetEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'XMLHttpRequestEventTargetEventMap', + writeable: false, + }, + XMLHttpRequestEventTarget: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XMLHttpRequestEventTarget', + writeable: false, + }, + XMLHttpRequestUpload: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XMLHttpRequestUpload', + writeable: false, + }, + XMLSerializer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XMLSerializer', + writeable: false, + }, + XPathEvaluator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XPathEvaluator', + writeable: false, + }, + XPathEvaluatorBase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'XPathEvaluatorBase', + writeable: false, + }, + XPathExpression: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XPathExpression', + writeable: false, + }, + XPathResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XPathResult', + writeable: false, + }, + XSLTProcessor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XSLTProcessor', + writeable: false, + }, + webkitRTCPeerConnection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'webkitRTCPeerConnection', + writeable: false, + }, + EventListenerOrEventListenerObject: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventListenerOrEventListenerObject', + writeable: false, + }, + Console: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Console', + writeable: false, + }, + CSS: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CSS', + writeable: false, + }, + WebAssembly: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebAssembly', + writeable: false, + }, + BlobCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BlobCallback', + writeable: false, + }, + CustomElementConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CustomElementConstructor', + writeable: false, + }, + DecodeErrorCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DecodeErrorCallback', + writeable: false, + }, + DecodeSuccessCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DecodeSuccessCallback', + writeable: false, + }, + EventHandlerNonNull: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventHandlerNonNull', + writeable: false, + }, + ForEachCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ForEachCallback', + writeable: false, + }, + FrameRequestCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FrameRequestCallback', + writeable: false, + }, + FunctionStringCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FunctionStringCallback', + writeable: false, + }, + IntersectionObserverCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IntersectionObserverCallback', + writeable: false, + }, + MSLaunchUriCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MSLaunchUriCallback', + writeable: false, + }, + MutationCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MutationCallback', + writeable: false, + }, + NavigatorUserMediaErrorCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorUserMediaErrorCallback', + writeable: false, + }, + NavigatorUserMediaSuccessCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorUserMediaSuccessCallback', + writeable: false, + }, + NotificationPermissionCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationPermissionCallback', + writeable: false, + }, + OnBeforeUnloadEventHandlerNonNull: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OnBeforeUnloadEventHandlerNonNull', + writeable: false, + }, + OnErrorEventHandlerNonNull: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OnErrorEventHandlerNonNull', + writeable: false, + }, + PerformanceObserverCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PerformanceObserverCallback', + writeable: false, + }, + PositionCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PositionCallback', + writeable: false, + }, + PositionErrorCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PositionErrorCallback', + writeable: false, + }, + QueuingStrategySizeCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'QueuingStrategySizeCallback', + writeable: false, + }, + RTCPeerConnectionErrorCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCPeerConnectionErrorCallback', + writeable: false, + }, + RTCSessionDescriptionCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCSessionDescriptionCallback', + writeable: false, + }, + RTCStatsCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCStatsCallback', + writeable: false, + }, + ReadableByteStreamControllerCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableByteStreamControllerCallback', + writeable: false, + }, + ReadableStreamDefaultControllerCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamDefaultControllerCallback', + writeable: false, + }, + ReadableStreamErrorCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamErrorCallback', + writeable: false, + }, + TransformStreamDefaultControllerCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TransformStreamDefaultControllerCallback', + writeable: false, + }, + TransformStreamDefaultControllerTransformCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TransformStreamDefaultControllerTransformCallback', + writeable: false, + }, + VoidFunction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VoidFunction', + writeable: false, + }, + WritableStreamDefaultControllerCloseCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamDefaultControllerCloseCallback', + writeable: false, + }, + WritableStreamDefaultControllerStartCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamDefaultControllerStartCallback', + writeable: false, + }, + WritableStreamDefaultControllerWriteCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamDefaultControllerWriteCallback', + writeable: false, + }, + WritableStreamErrorCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamErrorCallback', + writeable: false, + }, + HTMLElementTagNameMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLElementTagNameMap', + writeable: false, + }, + HTMLElementDeprecatedTagNameMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLElementDeprecatedTagNameMap', + writeable: false, + }, + SVGElementTagNameMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SVGElementTagNameMap', + writeable: false, + }, + ElementTagNameMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ElementTagNameMap', + writeable: false, + }, + HeadersInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HeadersInit', + writeable: false, + }, + BodyInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BodyInit', + writeable: false, + }, + RequestInfo: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestInfo', + writeable: false, + }, + BlobPart: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BlobPart', + writeable: false, + }, + DOMHighResTimeStamp: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMHighResTimeStamp', + writeable: false, + }, + RenderingContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RenderingContext', + writeable: false, + }, + HTMLOrSVGImageElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLOrSVGImageElement', + writeable: false, + }, + CanvasImageSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasImageSource', + writeable: false, + }, + OffscreenRenderingContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OffscreenRenderingContext', + writeable: false, + }, + MessageEventSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MessageEventSource', + writeable: false, + }, + HTMLOrSVGScriptElement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HTMLOrSVGScriptElement', + writeable: false, + }, + ImageBitmapSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageBitmapSource', + writeable: false, + }, + MediaProvider: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaProvider', + writeable: false, + }, + OnErrorEventHandler: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OnErrorEventHandler', + writeable: false, + }, + OnBeforeUnloadEventHandler: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OnBeforeUnloadEventHandler', + writeable: false, + }, + TimerHandler: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TimerHandler', + writeable: false, + }, + ConstrainULong: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConstrainULong', + writeable: false, + }, + ConstrainDouble: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConstrainDouble', + writeable: false, + }, + ConstrainBoolean: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConstrainBoolean', + writeable: false, + }, + ConstrainDOMString: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConstrainDOMString', + writeable: false, + }, + PerformanceEntryList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PerformanceEntryList', + writeable: false, + }, + ReadableStreamReadResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamReadResult', + writeable: false, + }, + VibratePattern: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VibratePattern', + writeable: false, + }, + COSEAlgorithmIdentifier: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'COSEAlgorithmIdentifier', + writeable: false, + }, + AuthenticatorSelectionList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AuthenticatorSelectionList', + writeable: false, + }, + AAGUID: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AAGUID', + writeable: false, + }, + AuthenticationExtensionsSupported: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AuthenticationExtensionsSupported', + writeable: false, + }, + UvmEntry: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'UvmEntry', + writeable: false, + }, + UvmEntries: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'UvmEntries', + writeable: false, + }, + AlgorithmIdentifier: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AlgorithmIdentifier', + writeable: false, + }, + HashAlgorithmIdentifier: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HashAlgorithmIdentifier', + writeable: false, + }, + BigInteger: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BigInteger', + writeable: false, + }, + NamedCurve: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NamedCurve', + writeable: false, + }, + GLenum: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLenum', + writeable: false, + }, + GLboolean: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLboolean', + writeable: false, + }, + GLbitfield: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLbitfield', + writeable: false, + }, + GLint: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLint', + writeable: false, + }, + GLsizei: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLsizei', + writeable: false, + }, + GLintptr: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLintptr', + writeable: false, + }, + GLsizeiptr: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLsizeiptr', + writeable: false, + }, + GLuint: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLuint', + writeable: false, + }, + GLfloat: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLfloat', + writeable: false, + }, + GLclampf: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLclampf', + writeable: false, + }, + TexImageSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TexImageSource', + writeable: false, + }, + Float32List: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float32List', + writeable: false, + }, + Int32List: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int32List', + writeable: false, + }, + GLint64: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLint64', + writeable: false, + }, + GLuint64: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLuint64', + writeable: false, + }, + Uint32List: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint32List', + writeable: false, + }, + BufferSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BufferSource', + writeable: false, + }, + DOMTimeStamp: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMTimeStamp', + writeable: false, + }, + LineAndPositionSetting: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'LineAndPositionSetting', + writeable: false, + }, + FormDataEntryValue: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FormDataEntryValue', + writeable: false, + }, + InsertPosition: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'InsertPosition', + writeable: false, + }, + IDBValidKey: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBValidKey', + writeable: false, + }, + MutationRecordType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MutationRecordType', + writeable: false, + }, + IDBKeyPath: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBKeyPath', + writeable: false, + }, + Transferable: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Transferable', + writeable: false, + }, + RTCIceGatherCandidate: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceGatherCandidate', + writeable: false, + }, + RTCTransport: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCTransport', + writeable: false, + }, + MouseWheelEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MouseWheelEvent', + writeable: false, + }, + WindowProxy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WindowProxy', + writeable: false, + }, + AlignSetting: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AlignSetting', + writeable: false, + }, + AnimationPlayState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AnimationPlayState', + writeable: false, + }, + AppendMode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AppendMode', + writeable: false, + }, + AttestationConveyancePreference: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AttestationConveyancePreference', + writeable: false, + }, + AudioContextLatencyCategory: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioContextLatencyCategory', + writeable: false, + }, + AudioContextState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AudioContextState', + writeable: false, + }, + AuthenticatorAttachment: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AuthenticatorAttachment', + writeable: false, + }, + AuthenticatorTransport: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AuthenticatorTransport', + writeable: false, + }, + AutoKeyword: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AutoKeyword', + writeable: false, + }, + AutomationRate: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AutomationRate', + writeable: false, + }, + BinaryType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BinaryType', + writeable: false, + }, + BiquadFilterType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BiquadFilterType', + writeable: false, + }, + CanPlayTypeResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanPlayTypeResult', + writeable: false, + }, + CanvasDirection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasDirection', + writeable: false, + }, + CanvasFillRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasFillRule', + writeable: false, + }, + CanvasLineCap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasLineCap', + writeable: false, + }, + CanvasLineJoin: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasLineJoin', + writeable: false, + }, + CanvasTextAlign: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasTextAlign', + writeable: false, + }, + CanvasTextBaseline: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasTextBaseline', + writeable: false, + }, + ChannelCountMode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ChannelCountMode', + writeable: false, + }, + ChannelInterpretation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ChannelInterpretation', + writeable: false, + }, + ClientTypes: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ClientTypes', + writeable: false, + }, + ColorSpaceConversion: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ColorSpaceConversion', + writeable: false, + }, + CompositeOperation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CompositeOperation', + writeable: false, + }, + CompositeOperationOrAuto: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CompositeOperationOrAuto', + writeable: false, + }, + CredentialMediationRequirement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CredentialMediationRequirement', + writeable: false, + }, + DirectionSetting: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DirectionSetting', + writeable: false, + }, + DisplayCaptureSurfaceType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DisplayCaptureSurfaceType', + writeable: false, + }, + DistanceModelType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DistanceModelType', + writeable: false, + }, + DocumentReadyState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DocumentReadyState', + writeable: false, + }, + EndOfStreamError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EndOfStreamError', + writeable: false, + }, + EndingType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EndingType', + writeable: false, + }, + FillMode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FillMode', + writeable: false, + }, + FullscreenNavigationUI: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FullscreenNavigationUI', + writeable: false, + }, + GamepadHand: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GamepadHand', + writeable: false, + }, + GamepadHapticActuatorType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GamepadHapticActuatorType', + writeable: false, + }, + GamepadMappingType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GamepadMappingType', + writeable: false, + }, + IDBCursorDirection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBCursorDirection', + writeable: false, + }, + IDBRequestReadyState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBRequestReadyState', + writeable: false, + }, + IDBTransactionMode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBTransactionMode', + writeable: false, + }, + ImageOrientation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageOrientation', + writeable: false, + }, + ImageSmoothingQuality: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageSmoothingQuality', + writeable: false, + }, + IterationCompositeOperation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IterationCompositeOperation', + writeable: false, + }, + KeyFormat: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'KeyFormat', + writeable: false, + }, + KeyType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'KeyType', + writeable: false, + }, + KeyUsage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'KeyUsage', + writeable: false, + }, + LineAlignSetting: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'LineAlignSetting', + writeable: false, + }, + ListeningState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ListeningState', + writeable: false, + }, + MSCredentialType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MSCredentialType', + writeable: false, + }, + MSTransportType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MSTransportType', + writeable: false, + }, + MSWebViewPermissionState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MSWebViewPermissionState', + writeable: false, + }, + MSWebViewPermissionType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MSWebViewPermissionType', + writeable: false, + }, + MediaDeviceKind: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaDeviceKind', + writeable: false, + }, + MediaKeyMessageType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaKeyMessageType', + writeable: false, + }, + MediaKeySessionType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaKeySessionType', + writeable: false, + }, + MediaKeyStatus: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaKeyStatus', + writeable: false, + }, + MediaKeysRequirement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaKeysRequirement', + writeable: false, + }, + MediaStreamTrackState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MediaStreamTrackState', + writeable: false, + }, + NavigationReason: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigationReason', + writeable: false, + }, + NavigationType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigationType', + writeable: false, + }, + NotificationDirection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationDirection', + writeable: false, + }, + NotificationPermission: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationPermission', + writeable: false, + }, + OffscreenRenderingContextId: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OffscreenRenderingContextId', + writeable: false, + }, + OrientationLockType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OrientationLockType', + writeable: false, + }, + OrientationType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OrientationType', + writeable: false, + }, + OscillatorType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OscillatorType', + writeable: false, + }, + OverSampleType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OverSampleType', + writeable: false, + }, + PanningModelType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PanningModelType', + writeable: false, + }, + PaymentComplete: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentComplete', + writeable: false, + }, + PaymentShippingType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PaymentShippingType', + writeable: false, + }, + PermissionName: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PermissionName', + writeable: false, + }, + PermissionState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PermissionState', + writeable: false, + }, + PlaybackDirection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PlaybackDirection', + writeable: false, + }, + PositionAlignSetting: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PositionAlignSetting', + writeable: false, + }, + PremultiplyAlpha: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PremultiplyAlpha', + writeable: false, + }, + PublicKeyCredentialType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PublicKeyCredentialType', + writeable: false, + }, + PushEncryptionKeyName: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushEncryptionKeyName', + writeable: false, + }, + PushPermissionState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushPermissionState', + writeable: false, + }, + RTCBundlePolicy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCBundlePolicy', + writeable: false, + }, + RTCDataChannelState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDataChannelState', + writeable: false, + }, + RTCDegradationPreference: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDegradationPreference', + writeable: false, + }, + RTCDtlsRole: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDtlsRole', + writeable: false, + }, + RTCDtlsTransportState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDtlsTransportState', + writeable: false, + }, + RTCDtxStatus: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCDtxStatus', + writeable: false, + }, + RTCErrorDetailType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCErrorDetailType', + writeable: false, + }, + RTCIceCandidateType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceCandidateType', + writeable: false, + }, + RTCIceComponent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceComponent', + writeable: false, + }, + RTCIceConnectionState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceConnectionState', + writeable: false, + }, + RTCIceCredentialType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceCredentialType', + writeable: false, + }, + RTCIceGatherPolicy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceGatherPolicy', + writeable: false, + }, + RTCIceGathererState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceGathererState', + writeable: false, + }, + RTCIceGatheringState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceGatheringState', + writeable: false, + }, + RTCIceProtocol: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceProtocol', + writeable: false, + }, + RTCIceRole: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceRole', + writeable: false, + }, + RTCIceTcpCandidateType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceTcpCandidateType', + writeable: false, + }, + RTCIceTransportPolicy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceTransportPolicy', + writeable: false, + }, + RTCIceTransportState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCIceTransportState', + writeable: false, + }, + RTCPeerConnectionState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCPeerConnectionState', + writeable: false, + }, + RTCPriorityType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCPriorityType', + writeable: false, + }, + RTCRtcpMuxPolicy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtcpMuxPolicy', + writeable: false, + }, + RTCRtpTransceiverDirection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCRtpTransceiverDirection', + writeable: false, + }, + RTCSctpTransportState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCSctpTransportState', + writeable: false, + }, + RTCSdpType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCSdpType', + writeable: false, + }, + RTCSignalingState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCSignalingState', + writeable: false, + }, + RTCStatsIceCandidatePairState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCStatsIceCandidatePairState', + writeable: false, + }, + RTCStatsIceCandidateType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCStatsIceCandidateType', + writeable: false, + }, + RTCStatsType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RTCStatsType', + writeable: false, + }, + ReadyState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadyState', + writeable: false, + }, + ReferrerPolicy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReferrerPolicy', + writeable: false, + }, + RequestCache: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestCache', + writeable: false, + }, + RequestCredentials: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestCredentials', + writeable: false, + }, + RequestDestination: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestDestination', + writeable: false, + }, + RequestMode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestMode', + writeable: false, + }, + RequestRedirect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestRedirect', + writeable: false, + }, + ResizeQuality: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ResizeQuality', + writeable: false, + }, + ResponseType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ResponseType', + writeable: false, + }, + ScopedCredentialType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScopedCredentialType', + writeable: false, + }, + ScrollBehavior: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScrollBehavior', + writeable: false, + }, + ScrollLogicalPosition: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScrollLogicalPosition', + writeable: false, + }, + ScrollRestoration: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScrollRestoration', + writeable: false, + }, + ScrollSetting: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ScrollSetting', + writeable: false, + }, + SelectionMode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SelectionMode', + writeable: false, + }, + ServiceWorkerState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerState', + writeable: false, + }, + ServiceWorkerUpdateViaCache: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerUpdateViaCache', + writeable: false, + }, + ShadowRootMode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ShadowRootMode', + writeable: false, + }, + SpeechSynthesisErrorCode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SpeechSynthesisErrorCode', + writeable: false, + }, + SupportedType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SupportedType', + writeable: false, + }, + TextTrackKind: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextTrackKind', + writeable: false, + }, + TextTrackMode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextTrackMode', + writeable: false, + }, + TouchType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TouchType', + writeable: false, + }, + Transport: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Transport', + writeable: false, + }, + UserVerificationRequirement: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'UserVerificationRequirement', + writeable: false, + }, + VRDisplayEventReason: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VRDisplayEventReason', + writeable: false, + }, + VideoFacingModeEnum: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VideoFacingModeEnum', + writeable: false, + }, + VisibilityState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VisibilityState', + writeable: false, + }, + WebGLPowerPreference: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLPowerPreference', + writeable: false, + }, + WorkerType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WorkerType', + writeable: false, + }, + XMLHttpRequestResponseType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'XMLHttpRequestResponseType', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2015.collection.ts b/packages/scope-manager/src/lib/es2015.collection.ts new file mode 100644 index 00000000000..a5136e2a448 --- /dev/null +++ b/packages/scope-manager/src/lib/es2015.collection.ts @@ -0,0 +1,78 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2015_collection = { + Map: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Map', + writeable: false, + }, + MapConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MapConstructor', + writeable: false, + }, + ReadonlyMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadonlyMap', + writeable: false, + }, + WeakMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WeakMap', + writeable: false, + }, + WeakMapConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WeakMapConstructor', + writeable: false, + }, + Set: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Set', + writeable: false, + }, + SetConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SetConstructor', + writeable: false, + }, + ReadonlySet: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadonlySet', + writeable: false, + }, + WeakSet: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WeakSet', + writeable: false, + }, + WeakSetConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WeakSetConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2015.core.ts b/packages/scope-manager/src/lib/es2015.core.ts new file mode 100644 index 00000000000..e3c3f694d43 --- /dev/null +++ b/packages/scope-manager/src/lib/es2015.core.ts @@ -0,0 +1,92 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2015_core = { + Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Array', + writeable: false, + }, + ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayConstructor', + writeable: false, + }, + DateConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DateConstructor', + writeable: false, + }, + Function: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Function', + writeable: false, + }, + Math: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Math', + writeable: false, + }, + NumberConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NumberConstructor', + writeable: false, + }, + ObjectConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ObjectConstructor', + writeable: false, + }, + ReadonlyArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadonlyArray', + writeable: false, + }, + RegExp: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegExp', + writeable: false, + }, + RegExpConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegExpConstructor', + writeable: false, + }, + String: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'String', + writeable: false, + }, + StringConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'StringConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2015.generator.ts b/packages/scope-manager/src/lib/es2015.generator.ts new file mode 100644 index 00000000000..acebae492b4 --- /dev/null +++ b/packages/scope-manager/src/lib/es2015.generator.ts @@ -0,0 +1,31 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2015_iterable } from './es2015.iterable'; + +export const es2015_generator = { + ...es2015_iterable, + Generator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Generator', + writeable: false, + }, + GeneratorFunction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GeneratorFunction', + writeable: false, + }, + GeneratorFunctionConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GeneratorFunctionConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2015.iterable.ts b/packages/scope-manager/src/lib/es2015.iterable.ts new file mode 100644 index 00000000000..e618b738139 --- /dev/null +++ b/packages/scope-manager/src/lib/es2015.iterable.ts @@ -0,0 +1,311 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2015_symbol } from './es2015.symbol'; + +export const es2015_iterable = { + ...es2015_symbol, + SymbolConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SymbolConstructor', + writeable: false, + }, + IteratorYieldResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IteratorYieldResult', + writeable: false, + }, + IteratorReturnResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IteratorReturnResult', + writeable: false, + }, + IteratorResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IteratorResult', + writeable: false, + }, + Iterator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Iterator', + writeable: false, + }, + Iterable: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Iterable', + writeable: false, + }, + IterableIterator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IterableIterator', + writeable: false, + }, + Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Array', + writeable: false, + }, + ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayConstructor', + writeable: false, + }, + ReadonlyArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadonlyArray', + writeable: false, + }, + IArguments: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IArguments', + writeable: false, + }, + Map: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Map', + writeable: false, + }, + ReadonlyMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadonlyMap', + writeable: false, + }, + MapConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MapConstructor', + writeable: false, + }, + WeakMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WeakMap', + writeable: false, + }, + WeakMapConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WeakMapConstructor', + writeable: false, + }, + Set: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Set', + writeable: false, + }, + ReadonlySet: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadonlySet', + writeable: false, + }, + SetConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SetConstructor', + writeable: false, + }, + WeakSet: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WeakSet', + writeable: false, + }, + WeakSetConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WeakSetConstructor', + writeable: false, + }, + Promise: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Promise', + writeable: false, + }, + PromiseConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseConstructor', + writeable: false, + }, + Reflect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Reflect', + writeable: false, + }, + String: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'String', + writeable: false, + }, + Int8Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int8Array', + writeable: false, + }, + Int8ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int8ArrayConstructor', + writeable: false, + }, + Uint8Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8Array', + writeable: false, + }, + Uint8ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8ArrayConstructor', + writeable: false, + }, + Uint8ClampedArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8ClampedArray', + writeable: false, + }, + Uint8ClampedArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8ClampedArrayConstructor', + writeable: false, + }, + Int16Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int16Array', + writeable: false, + }, + Int16ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int16ArrayConstructor', + writeable: false, + }, + Uint16Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint16Array', + writeable: false, + }, + Uint16ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint16ArrayConstructor', + writeable: false, + }, + Int32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int32Array', + writeable: false, + }, + Int32ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int32ArrayConstructor', + writeable: false, + }, + Uint32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint32Array', + writeable: false, + }, + Uint32ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint32ArrayConstructor', + writeable: false, + }, + Float32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float32Array', + writeable: false, + }, + Float32ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float32ArrayConstructor', + writeable: false, + }, + Float64Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float64Array', + writeable: false, + }, + Float64ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float64ArrayConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2015.promise.ts b/packages/scope-manager/src/lib/es2015.promise.ts new file mode 100644 index 00000000000..ab084a766dd --- /dev/null +++ b/packages/scope-manager/src/lib/es2015.promise.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2015_promise = { + PromiseConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2015.proxy.ts b/packages/scope-manager/src/lib/es2015.proxy.ts new file mode 100644 index 00000000000..4ff461292dc --- /dev/null +++ b/packages/scope-manager/src/lib/es2015.proxy.ts @@ -0,0 +1,22 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2015_proxy = { + ProxyHandler: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ProxyHandler', + writeable: false, + }, + ProxyConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ProxyConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2015.reflect.ts b/packages/scope-manager/src/lib/es2015.reflect.ts new file mode 100644 index 00000000000..8c7fca66513 --- /dev/null +++ b/packages/scope-manager/src/lib/es2015.reflect.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2015_reflect = { + Reflect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Reflect', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2015.symbol.ts b/packages/scope-manager/src/lib/es2015.symbol.ts new file mode 100644 index 00000000000..c356e8e8276 --- /dev/null +++ b/packages/scope-manager/src/lib/es2015.symbol.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2015_symbol = { + SymbolConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SymbolConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2015.symbol.wellknown.ts b/packages/scope-manager/src/lib/es2015.symbol.wellknown.ts new file mode 100644 index 00000000000..cc1f0f7d68f --- /dev/null +++ b/packages/scope-manager/src/lib/es2015.symbol.wellknown.ts @@ -0,0 +1,234 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2015_symbol } from './es2015.symbol'; + +export const es2015_symbol_wellknown = { + ...es2015_symbol, + SymbolConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SymbolConstructor', + writeable: false, + }, + Symbol: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Symbol', + writeable: false, + }, + Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Array', + writeable: false, + }, + Date: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Date', + writeable: false, + }, + Map: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Map', + writeable: false, + }, + WeakMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WeakMap', + writeable: false, + }, + Set: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Set', + writeable: false, + }, + WeakSet: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WeakSet', + writeable: false, + }, + JSON: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'JSON', + writeable: false, + }, + Function: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Function', + writeable: false, + }, + GeneratorFunction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GeneratorFunction', + writeable: false, + }, + Math: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Math', + writeable: false, + }, + Promise: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Promise', + writeable: false, + }, + PromiseConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseConstructor', + writeable: false, + }, + RegExp: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegExp', + writeable: false, + }, + RegExpConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegExpConstructor', + writeable: false, + }, + String: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'String', + writeable: false, + }, + ArrayBuffer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayBuffer', + writeable: false, + }, + DataView: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DataView', + writeable: false, + }, + Int8Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int8Array', + writeable: false, + }, + Uint8Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8Array', + writeable: false, + }, + Uint8ClampedArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8ClampedArray', + writeable: false, + }, + Int16Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int16Array', + writeable: false, + }, + Uint16Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint16Array', + writeable: false, + }, + Int32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int32Array', + writeable: false, + }, + Uint32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint32Array', + writeable: false, + }, + Float32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float32Array', + writeable: false, + }, + Float64Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float64Array', + writeable: false, + }, + ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayConstructor', + writeable: false, + }, + MapConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MapConstructor', + writeable: false, + }, + SetConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SetConstructor', + writeable: false, + }, + ArrayBufferConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayBufferConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2015.ts b/packages/scope-manager/src/lib/es2015.ts new file mode 100644 index 00000000000..45404aca29a --- /dev/null +++ b/packages/scope-manager/src/lib/es2015.ts @@ -0,0 +1,28 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es5 } from './es5'; +import { es2015_core } from './es2015.core'; +import { es2015_collection } from './es2015.collection'; +import { es2015_iterable } from './es2015.iterable'; +import { es2015_generator } from './es2015.generator'; +import { es2015_promise } from './es2015.promise'; +import { es2015_proxy } from './es2015.proxy'; +import { es2015_reflect } from './es2015.reflect'; +import { es2015_symbol } from './es2015.symbol'; +import { es2015_symbol_wellknown } from './es2015.symbol.wellknown'; + +export const es2015 = { + ...es5, + ...es2015_core, + ...es2015_collection, + ...es2015_iterable, + ...es2015_generator, + ...es2015_promise, + ...es2015_proxy, + ...es2015_reflect, + ...es2015_symbol, + ...es2015_symbol_wellknown, +} as Record; diff --git a/packages/scope-manager/src/lib/es2016.array.include.ts b/packages/scope-manager/src/lib/es2016.array.include.ts new file mode 100644 index 00000000000..f105a21228a --- /dev/null +++ b/packages/scope-manager/src/lib/es2016.array.include.ts @@ -0,0 +1,85 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2016_array_include = { + Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Array', + writeable: false, + }, + ReadonlyArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadonlyArray', + writeable: false, + }, + Int8Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int8Array', + writeable: false, + }, + Uint8Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8Array', + writeable: false, + }, + Uint8ClampedArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8ClampedArray', + writeable: false, + }, + Int16Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int16Array', + writeable: false, + }, + Uint16Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint16Array', + writeable: false, + }, + Int32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int32Array', + writeable: false, + }, + Uint32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint32Array', + writeable: false, + }, + Float32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float32Array', + writeable: false, + }, + Float64Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float64Array', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2016.full.ts b/packages/scope-manager/src/lib/es2016.full.ts new file mode 100644 index 00000000000..cb66feb8864 --- /dev/null +++ b/packages/scope-manager/src/lib/es2016.full.ts @@ -0,0 +1,18 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2016 } from './es2016'; +import { dom } from './dom'; +import { webworker_importscripts } from './webworker.importscripts'; +import { scripthost } from './scripthost'; +import { dom_iterable } from './dom.iterable'; + +export const es2016_full = { + ...es2016, + ...dom, + ...webworker_importscripts, + ...scripthost, + ...dom_iterable, +} as Record; diff --git a/packages/scope-manager/src/lib/es2016.ts b/packages/scope-manager/src/lib/es2016.ts new file mode 100644 index 00000000000..9b8fc232b77 --- /dev/null +++ b/packages/scope-manager/src/lib/es2016.ts @@ -0,0 +1,12 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2015 } from './es2015'; +import { es2016_array_include } from './es2016.array.include'; + +export const es2016 = { + ...es2015, + ...es2016_array_include, +} as Record; diff --git a/packages/scope-manager/src/lib/es2017.full.ts b/packages/scope-manager/src/lib/es2017.full.ts new file mode 100644 index 00000000000..08f851dc7de --- /dev/null +++ b/packages/scope-manager/src/lib/es2017.full.ts @@ -0,0 +1,18 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2017 } from './es2017'; +import { dom } from './dom'; +import { webworker_importscripts } from './webworker.importscripts'; +import { scripthost } from './scripthost'; +import { dom_iterable } from './dom.iterable'; + +export const es2017_full = { + ...es2017, + ...dom, + ...webworker_importscripts, + ...scripthost, + ...dom_iterable, +} as Record; diff --git a/packages/scope-manager/src/lib/es2017.intl.ts b/packages/scope-manager/src/lib/es2017.intl.ts new file mode 100644 index 00000000000..74e41866712 --- /dev/null +++ b/packages/scope-manager/src/lib/es2017.intl.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2017_intl = { + Intl: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Intl', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2017.object.ts b/packages/scope-manager/src/lib/es2017.object.ts new file mode 100644 index 00000000000..ce8c26bad88 --- /dev/null +++ b/packages/scope-manager/src/lib/es2017.object.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2017_object = { + ObjectConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ObjectConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2017.sharedmemory.ts b/packages/scope-manager/src/lib/es2017.sharedmemory.ts new file mode 100644 index 00000000000..b97e1ee8a87 --- /dev/null +++ b/packages/scope-manager/src/lib/es2017.sharedmemory.ts @@ -0,0 +1,40 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2015_symbol } from './es2015.symbol'; +import { es2015_symbol_wellknown } from './es2015.symbol.wellknown'; + +export const es2017_sharedmemory = { + ...es2015_symbol, + ...es2015_symbol_wellknown, + SharedArrayBuffer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SharedArrayBuffer', + writeable: false, + }, + SharedArrayBufferConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SharedArrayBufferConstructor', + writeable: false, + }, + ArrayBufferTypes: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayBufferTypes', + writeable: false, + }, + Atomics: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Atomics', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2017.string.ts b/packages/scope-manager/src/lib/es2017.string.ts new file mode 100644 index 00000000000..6034f9f58bc --- /dev/null +++ b/packages/scope-manager/src/lib/es2017.string.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2017_string = { + String: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'String', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2017.ts b/packages/scope-manager/src/lib/es2017.ts new file mode 100644 index 00000000000..3a07d1ba155 --- /dev/null +++ b/packages/scope-manager/src/lib/es2017.ts @@ -0,0 +1,20 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2016 } from './es2016'; +import { es2017_object } from './es2017.object'; +import { es2017_sharedmemory } from './es2017.sharedmemory'; +import { es2017_string } from './es2017.string'; +import { es2017_intl } from './es2017.intl'; +import { es2017_typedarrays } from './es2017.typedarrays'; + +export const es2017 = { + ...es2016, + ...es2017_object, + ...es2017_sharedmemory, + ...es2017_string, + ...es2017_intl, + ...es2017_typedarrays, +} as Record; diff --git a/packages/scope-manager/src/lib/es2017.typedarrays.ts b/packages/scope-manager/src/lib/es2017.typedarrays.ts new file mode 100644 index 00000000000..2cab0364091 --- /dev/null +++ b/packages/scope-manager/src/lib/es2017.typedarrays.ts @@ -0,0 +1,71 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2017_typedarrays = { + Int8ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int8ArrayConstructor', + writeable: false, + }, + Uint8ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8ArrayConstructor', + writeable: false, + }, + Uint8ClampedArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8ClampedArrayConstructor', + writeable: false, + }, + Int16ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int16ArrayConstructor', + writeable: false, + }, + Uint16ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint16ArrayConstructor', + writeable: false, + }, + Int32ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int32ArrayConstructor', + writeable: false, + }, + Uint32ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint32ArrayConstructor', + writeable: false, + }, + Float32ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float32ArrayConstructor', + writeable: false, + }, + Float64ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float64ArrayConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2018.asyncgenerator.ts b/packages/scope-manager/src/lib/es2018.asyncgenerator.ts new file mode 100644 index 00000000000..302acfed1cc --- /dev/null +++ b/packages/scope-manager/src/lib/es2018.asyncgenerator.ts @@ -0,0 +1,31 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2018_asynciterable } from './es2018.asynciterable'; + +export const es2018_asyncgenerator = { + ...es2018_asynciterable, + AsyncGenerator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AsyncGenerator', + writeable: false, + }, + AsyncGeneratorFunction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AsyncGeneratorFunction', + writeable: false, + }, + AsyncGeneratorFunctionConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AsyncGeneratorFunctionConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2018.asynciterable.ts b/packages/scope-manager/src/lib/es2018.asynciterable.ts new file mode 100644 index 00000000000..2ba2fd26900 --- /dev/null +++ b/packages/scope-manager/src/lib/es2018.asynciterable.ts @@ -0,0 +1,40 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2015_symbol } from './es2015.symbol'; +import { es2015_iterable } from './es2015.iterable'; + +export const es2018_asynciterable = { + ...es2015_symbol, + ...es2015_iterable, + SymbolConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SymbolConstructor', + writeable: false, + }, + AsyncIterator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AsyncIterator', + writeable: false, + }, + AsyncIterable: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AsyncIterable', + writeable: false, + }, + AsyncIterableIterator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AsyncIterableIterator', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2018.full.ts b/packages/scope-manager/src/lib/es2018.full.ts new file mode 100644 index 00000000000..bd92e56dac2 --- /dev/null +++ b/packages/scope-manager/src/lib/es2018.full.ts @@ -0,0 +1,18 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2018 } from './es2018'; +import { dom } from './dom'; +import { webworker_importscripts } from './webworker.importscripts'; +import { scripthost } from './scripthost'; +import { dom_iterable } from './dom.iterable'; + +export const es2018_full = { + ...es2018, + ...dom, + ...webworker_importscripts, + ...scripthost, + ...dom_iterable, +} as Record; diff --git a/packages/scope-manager/src/lib/es2018.intl.ts b/packages/scope-manager/src/lib/es2018.intl.ts new file mode 100644 index 00000000000..159131a3ed3 --- /dev/null +++ b/packages/scope-manager/src/lib/es2018.intl.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2018_intl = { + Intl: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Intl', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2018.promise.ts b/packages/scope-manager/src/lib/es2018.promise.ts new file mode 100644 index 00000000000..4aeb4f24c34 --- /dev/null +++ b/packages/scope-manager/src/lib/es2018.promise.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2018_promise = { + Promise: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Promise', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2018.regexp.ts b/packages/scope-manager/src/lib/es2018.regexp.ts new file mode 100644 index 00000000000..97d426c5e9f --- /dev/null +++ b/packages/scope-manager/src/lib/es2018.regexp.ts @@ -0,0 +1,29 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2018_regexp = { + RegExpMatchArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegExpMatchArray', + writeable: false, + }, + RegExpExecArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegExpExecArray', + writeable: false, + }, + RegExp: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegExp', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2018.ts b/packages/scope-manager/src/lib/es2018.ts new file mode 100644 index 00000000000..942b7ad7dd5 --- /dev/null +++ b/packages/scope-manager/src/lib/es2018.ts @@ -0,0 +1,20 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2017 } from './es2017'; +import { es2018_asynciterable } from './es2018.asynciterable'; +import { es2018_asyncgenerator } from './es2018.asyncgenerator'; +import { es2018_promise } from './es2018.promise'; +import { es2018_regexp } from './es2018.regexp'; +import { es2018_intl } from './es2018.intl'; + +export const es2018 = { + ...es2017, + ...es2018_asynciterable, + ...es2018_asyncgenerator, + ...es2018_promise, + ...es2018_regexp, + ...es2018_intl, +} as Record; diff --git a/packages/scope-manager/src/lib/es2019.array.ts b/packages/scope-manager/src/lib/es2019.array.ts new file mode 100644 index 00000000000..43cab778d0f --- /dev/null +++ b/packages/scope-manager/src/lib/es2019.array.ts @@ -0,0 +1,29 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2019_array = { + FlatArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FlatArray', + writeable: false, + }, + ReadonlyArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadonlyArray', + writeable: false, + }, + Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Array', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2019.full.ts b/packages/scope-manager/src/lib/es2019.full.ts new file mode 100644 index 00000000000..055cb72803e --- /dev/null +++ b/packages/scope-manager/src/lib/es2019.full.ts @@ -0,0 +1,18 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2019 } from './es2019'; +import { dom } from './dom'; +import { webworker_importscripts } from './webworker.importscripts'; +import { scripthost } from './scripthost'; +import { dom_iterable } from './dom.iterable'; + +export const es2019_full = { + ...es2019, + ...dom, + ...webworker_importscripts, + ...scripthost, + ...dom_iterable, +} as Record; diff --git a/packages/scope-manager/src/lib/es2019.object.ts b/packages/scope-manager/src/lib/es2019.object.ts new file mode 100644 index 00000000000..e1a2addeb37 --- /dev/null +++ b/packages/scope-manager/src/lib/es2019.object.ts @@ -0,0 +1,17 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2015_iterable } from './es2015.iterable'; + +export const es2019_object = { + ...es2015_iterable, + ObjectConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ObjectConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2019.string.ts b/packages/scope-manager/src/lib/es2019.string.ts new file mode 100644 index 00000000000..519fc93c7a1 --- /dev/null +++ b/packages/scope-manager/src/lib/es2019.string.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2019_string = { + String: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'String', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2019.symbol.ts b/packages/scope-manager/src/lib/es2019.symbol.ts new file mode 100644 index 00000000000..2024d1e3f7a --- /dev/null +++ b/packages/scope-manager/src/lib/es2019.symbol.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2019_symbol = { + Symbol: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Symbol', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2019.ts b/packages/scope-manager/src/lib/es2019.ts new file mode 100644 index 00000000000..d24fd1a8339 --- /dev/null +++ b/packages/scope-manager/src/lib/es2019.ts @@ -0,0 +1,18 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2018 } from './es2018'; +import { es2019_array } from './es2019.array'; +import { es2019_object } from './es2019.object'; +import { es2019_string } from './es2019.string'; +import { es2019_symbol } from './es2019.symbol'; + +export const es2019 = { + ...es2018, + ...es2019_array, + ...es2019_object, + ...es2019_string, + ...es2019_symbol, +} as Record; diff --git a/packages/scope-manager/src/lib/es2020.bigint.ts b/packages/scope-manager/src/lib/es2020.bigint.ts new file mode 100644 index 00000000000..83e31c0cbab --- /dev/null +++ b/packages/scope-manager/src/lib/es2020.bigint.ts @@ -0,0 +1,57 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2020_bigint = { + BigInt: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BigInt', + writeable: false, + }, + BigIntConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BigIntConstructor', + writeable: false, + }, + BigInt64Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BigInt64Array', + writeable: false, + }, + BigInt64ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BigInt64ArrayConstructor', + writeable: false, + }, + BigUint64Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BigUint64Array', + writeable: false, + }, + BigUint64ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BigUint64ArrayConstructor', + writeable: false, + }, + DataView: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DataView', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2020.full.ts b/packages/scope-manager/src/lib/es2020.full.ts new file mode 100644 index 00000000000..d444d3877a3 --- /dev/null +++ b/packages/scope-manager/src/lib/es2020.full.ts @@ -0,0 +1,18 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2020 } from './es2020'; +import { dom } from './dom'; +import { webworker_importscripts } from './webworker.importscripts'; +import { scripthost } from './scripthost'; +import { dom_iterable } from './dom.iterable'; + +export const es2020_full = { + ...es2020, + ...dom, + ...webworker_importscripts, + ...scripthost, + ...dom_iterable, +} as Record; diff --git a/packages/scope-manager/src/lib/es2020.promise.ts b/packages/scope-manager/src/lib/es2020.promise.ts new file mode 100644 index 00000000000..fed66024f8b --- /dev/null +++ b/packages/scope-manager/src/lib/es2020.promise.ts @@ -0,0 +1,36 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es2020_promise = { + PromiseFulfilledResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseFulfilledResult', + writeable: false, + }, + PromiseRejectedResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseRejectedResult', + writeable: false, + }, + PromiseSettledResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseSettledResult', + writeable: false, + }, + PromiseConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2020.string.ts b/packages/scope-manager/src/lib/es2020.string.ts new file mode 100644 index 00000000000..2bfed8f2b62 --- /dev/null +++ b/packages/scope-manager/src/lib/es2020.string.ts @@ -0,0 +1,17 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2015_iterable } from './es2015.iterable'; + +export const es2020_string = { + ...es2015_iterable, + String: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'String', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2020.symbol.wellknown.ts b/packages/scope-manager/src/lib/es2020.symbol.wellknown.ts new file mode 100644 index 00000000000..1cc58e9ec4f --- /dev/null +++ b/packages/scope-manager/src/lib/es2020.symbol.wellknown.ts @@ -0,0 +1,26 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2015_iterable } from './es2015.iterable'; +import { es2015_symbol } from './es2015.symbol'; + +export const es2020_symbol_wellknown = { + ...es2015_iterable, + ...es2015_symbol, + SymbolConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SymbolConstructor', + writeable: false, + }, + RegExp: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegExp', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es2020.ts b/packages/scope-manager/src/lib/es2020.ts new file mode 100644 index 00000000000..ad4aff629c3 --- /dev/null +++ b/packages/scope-manager/src/lib/es2020.ts @@ -0,0 +1,18 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2019 } from './es2019'; +import { es2020_bigint } from './es2020.bigint'; +import { es2020_promise } from './es2020.promise'; +import { es2020_string } from './es2020.string'; +import { es2020_symbol_wellknown } from './es2020.symbol.wellknown'; + +export const es2020 = { + ...es2019, + ...es2020_bigint, + ...es2020_promise, + ...es2020_string, + ...es2020_symbol_wellknown, +} as Record; diff --git a/packages/scope-manager/src/lib/es5.ts b/packages/scope-manager/src/lib/es5.ts new file mode 100644 index 00000000000..fb6cc4af4ed --- /dev/null +++ b/packages/scope-manager/src/lib/es5.ts @@ -0,0 +1,680 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const es5 = { + Symbol: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Symbol', + writeable: false, + }, + PropertyKey: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PropertyKey', + writeable: false, + }, + PropertyDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PropertyDescriptor', + writeable: false, + }, + PropertyDescriptorMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PropertyDescriptorMap', + writeable: false, + }, + Object: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Object', + writeable: false, + }, + ObjectConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ObjectConstructor', + writeable: false, + }, + Function: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Function', + writeable: false, + }, + FunctionConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FunctionConstructor', + writeable: false, + }, + ThisParameterType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ThisParameterType', + writeable: false, + }, + OmitThisParameter: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OmitThisParameter', + writeable: false, + }, + CallableFunction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CallableFunction', + writeable: false, + }, + NewableFunction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NewableFunction', + writeable: false, + }, + IArguments: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IArguments', + writeable: false, + }, + String: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'String', + writeable: false, + }, + StringConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'StringConstructor', + writeable: false, + }, + Boolean: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Boolean', + writeable: false, + }, + BooleanConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BooleanConstructor', + writeable: false, + }, + Number: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Number', + writeable: false, + }, + NumberConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NumberConstructor', + writeable: false, + }, + TemplateStringsArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TemplateStringsArray', + writeable: false, + }, + ImportMeta: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImportMeta', + writeable: false, + }, + Math: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Math', + writeable: false, + }, + Date: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Date', + writeable: false, + }, + DateConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DateConstructor', + writeable: false, + }, + RegExpMatchArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegExpMatchArray', + writeable: false, + }, + RegExpExecArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegExpExecArray', + writeable: false, + }, + RegExp: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RegExp', + writeable: false, + }, + RegExpConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegExpConstructor', + writeable: false, + }, + Error: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Error', + writeable: false, + }, + ErrorConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ErrorConstructor', + writeable: false, + }, + EvalError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'EvalError', + writeable: false, + }, + EvalErrorConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EvalErrorConstructor', + writeable: false, + }, + RangeError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'RangeError', + writeable: false, + }, + RangeErrorConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RangeErrorConstructor', + writeable: false, + }, + ReferenceError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ReferenceError', + writeable: false, + }, + ReferenceErrorConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReferenceErrorConstructor', + writeable: false, + }, + SyntaxError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SyntaxError', + writeable: false, + }, + SyntaxErrorConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SyntaxErrorConstructor', + writeable: false, + }, + TypeError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TypeError', + writeable: false, + }, + TypeErrorConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TypeErrorConstructor', + writeable: false, + }, + URIError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'URIError', + writeable: false, + }, + URIErrorConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'URIErrorConstructor', + writeable: false, + }, + JSON: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'JSON', + writeable: false, + }, + ReadonlyArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadonlyArray', + writeable: false, + }, + ConcatArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConcatArray', + writeable: false, + }, + Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Array', + writeable: false, + }, + ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayConstructor', + writeable: false, + }, + TypedPropertyDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TypedPropertyDescriptor', + writeable: false, + }, + ClassDecorator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ClassDecorator', + writeable: false, + }, + PropertyDecorator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PropertyDecorator', + writeable: false, + }, + MethodDecorator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MethodDecorator', + writeable: false, + }, + ParameterDecorator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ParameterDecorator', + writeable: false, + }, + PromiseConstructorLike: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseConstructorLike', + writeable: false, + }, + PromiseLike: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseLike', + writeable: false, + }, + Promise: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Promise', + writeable: false, + }, + ArrayLike: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayLike', + writeable: false, + }, + Partial: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Partial', + writeable: false, + }, + Required: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Required', + writeable: false, + }, + Readonly: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Readonly', + writeable: false, + }, + Pick: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Pick', + writeable: false, + }, + Record: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Record', + writeable: false, + }, + Exclude: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Exclude', + writeable: false, + }, + Extract: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Extract', + writeable: false, + }, + Omit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Omit', + writeable: false, + }, + NonNullable: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NonNullable', + writeable: false, + }, + Parameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Parameters', + writeable: false, + }, + ConstructorParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConstructorParameters', + writeable: false, + }, + ReturnType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReturnType', + writeable: false, + }, + InstanceType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'InstanceType', + writeable: false, + }, + ThisType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ThisType', + writeable: false, + }, + ArrayBuffer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ArrayBuffer', + writeable: false, + }, + ArrayBufferTypes: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayBufferTypes', + writeable: false, + }, + ArrayBufferLike: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayBufferLike', + writeable: false, + }, + ArrayBufferConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayBufferConstructor', + writeable: false, + }, + ArrayBufferView: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ArrayBufferView', + writeable: false, + }, + DataView: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DataView', + writeable: false, + }, + DataViewConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DataViewConstructor', + writeable: false, + }, + Int8Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Int8Array', + writeable: false, + }, + Int8ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int8ArrayConstructor', + writeable: false, + }, + Uint8Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Uint8Array', + writeable: false, + }, + Uint8ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8ArrayConstructor', + writeable: false, + }, + Uint8ClampedArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Uint8ClampedArray', + writeable: false, + }, + Uint8ClampedArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint8ClampedArrayConstructor', + writeable: false, + }, + Int16Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Int16Array', + writeable: false, + }, + Int16ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int16ArrayConstructor', + writeable: false, + }, + Uint16Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Uint16Array', + writeable: false, + }, + Uint16ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint16ArrayConstructor', + writeable: false, + }, + Int32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Int32Array', + writeable: false, + }, + Int32ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int32ArrayConstructor', + writeable: false, + }, + Uint32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Uint32Array', + writeable: false, + }, + Uint32ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint32ArrayConstructor', + writeable: false, + }, + Float32Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Float32Array', + writeable: false, + }, + Float32ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float32ArrayConstructor', + writeable: false, + }, + Float64Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Float64Array', + writeable: false, + }, + Float64ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float64ArrayConstructor', + writeable: false, + }, + Intl: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Intl', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/es6.ts b/packages/scope-manager/src/lib/es6.ts new file mode 100644 index 00000000000..2ffac6ac245 --- /dev/null +++ b/packages/scope-manager/src/lib/es6.ts @@ -0,0 +1,28 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es5 } from './es5'; +import { es2015_core } from './es2015.core'; +import { es2015_collection } from './es2015.collection'; +import { es2015_iterable } from './es2015.iterable'; +import { es2015_generator } from './es2015.generator'; +import { es2015_promise } from './es2015.promise'; +import { es2015_proxy } from './es2015.proxy'; +import { es2015_reflect } from './es2015.reflect'; +import { es2015_symbol } from './es2015.symbol'; +import { es2015_symbol_wellknown } from './es2015.symbol.wellknown'; + +export const es6 = { + ...es5, + ...es2015_core, + ...es2015_collection, + ...es2015_iterable, + ...es2015_generator, + ...es2015_promise, + ...es2015_proxy, + ...es2015_reflect, + ...es2015_symbol, + ...es2015_symbol_wellknown, +} as Record; diff --git a/packages/scope-manager/src/lib/es7.ts b/packages/scope-manager/src/lib/es7.ts new file mode 100644 index 00000000000..ace0e33ca75 --- /dev/null +++ b/packages/scope-manager/src/lib/es7.ts @@ -0,0 +1,12 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2015 } from './es2015'; +import { es2016_array_include } from './es2016.array.include'; + +export const es7 = { + ...es2015, + ...es2016_array_include, +} as Record; diff --git a/packages/scope-manager/src/lib/esnext.array.ts b/packages/scope-manager/src/lib/esnext.array.ts new file mode 100644 index 00000000000..b48090a0a60 --- /dev/null +++ b/packages/scope-manager/src/lib/esnext.array.ts @@ -0,0 +1,29 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const esnext_array = { + FlatArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FlatArray', + writeable: false, + }, + ReadonlyArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadonlyArray', + writeable: false, + }, + Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Array', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/esnext.asynciterable.ts b/packages/scope-manager/src/lib/esnext.asynciterable.ts new file mode 100644 index 00000000000..c4d16fc52e4 --- /dev/null +++ b/packages/scope-manager/src/lib/esnext.asynciterable.ts @@ -0,0 +1,40 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2015_symbol } from './es2015.symbol'; +import { es2015_iterable } from './es2015.iterable'; + +export const esnext_asynciterable = { + ...es2015_symbol, + ...es2015_iterable, + SymbolConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SymbolConstructor', + writeable: false, + }, + AsyncIterator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AsyncIterator', + writeable: false, + }, + AsyncIterable: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AsyncIterable', + writeable: false, + }, + AsyncIterableIterator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AsyncIterableIterator', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/esnext.bigint.ts b/packages/scope-manager/src/lib/esnext.bigint.ts new file mode 100644 index 00000000000..359aa1c1c30 --- /dev/null +++ b/packages/scope-manager/src/lib/esnext.bigint.ts @@ -0,0 +1,57 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const esnext_bigint = { + BigInt: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BigInt', + writeable: false, + }, + BigIntConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BigIntConstructor', + writeable: false, + }, + BigInt64Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BigInt64Array', + writeable: false, + }, + BigInt64ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BigInt64ArrayConstructor', + writeable: false, + }, + BigUint64Array: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BigUint64Array', + writeable: false, + }, + BigUint64ArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BigUint64ArrayConstructor', + writeable: false, + }, + DataView: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DataView', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/esnext.full.ts b/packages/scope-manager/src/lib/esnext.full.ts new file mode 100644 index 00000000000..c68442fe441 --- /dev/null +++ b/packages/scope-manager/src/lib/esnext.full.ts @@ -0,0 +1,18 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { esnext } from './esnext'; +import { dom } from './dom'; +import { webworker_importscripts } from './webworker.importscripts'; +import { scripthost } from './scripthost'; +import { dom_iterable } from './dom.iterable'; + +export const esnext_full = { + ...esnext, + ...dom, + ...webworker_importscripts, + ...scripthost, + ...dom_iterable, +} as Record; diff --git a/packages/scope-manager/src/lib/esnext.intl.ts b/packages/scope-manager/src/lib/esnext.intl.ts new file mode 100644 index 00000000000..bc5b2619724 --- /dev/null +++ b/packages/scope-manager/src/lib/esnext.intl.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const esnext_intl = { + Intl: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Intl', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/esnext.promise.ts b/packages/scope-manager/src/lib/esnext.promise.ts new file mode 100644 index 00000000000..a5b1238df15 --- /dev/null +++ b/packages/scope-manager/src/lib/esnext.promise.ts @@ -0,0 +1,29 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const esnext_promise = { + AggregateError: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AggregateError', + writeable: false, + }, + AggregateErrorConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AggregateErrorConstructor', + writeable: false, + }, + PromiseConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseConstructor', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/esnext.string.ts b/packages/scope-manager/src/lib/esnext.string.ts new file mode 100644 index 00000000000..4a64eab6984 --- /dev/null +++ b/packages/scope-manager/src/lib/esnext.string.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const esnext_string = { + String: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'String', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/esnext.symbol.ts b/packages/scope-manager/src/lib/esnext.symbol.ts new file mode 100644 index 00000000000..8cdc142d4ed --- /dev/null +++ b/packages/scope-manager/src/lib/esnext.symbol.ts @@ -0,0 +1,15 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const esnext_symbol = { + Symbol: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Symbol', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/esnext.ts b/packages/scope-manager/src/lib/esnext.ts new file mode 100644 index 00000000000..cdd59bb0bcf --- /dev/null +++ b/packages/scope-manager/src/lib/esnext.ts @@ -0,0 +1,16 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es2020 } from './es2020'; +import { esnext_intl } from './esnext.intl'; +import { esnext_string } from './esnext.string'; +import { esnext_promise } from './esnext.promise'; + +export const esnext = { + ...es2020, + ...esnext_intl, + ...esnext_string, + ...esnext_promise, +} as Record; diff --git a/packages/scope-manager/src/lib/index.ts b/packages/scope-manager/src/lib/index.ts new file mode 100644 index 00000000000..16b14f312fd --- /dev/null +++ b/packages/scope-manager/src/lib/index.ts @@ -0,0 +1,123 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { es5 } from './es5'; +import { es6 } from './es6'; +import { es2015 } from './es2015'; +import { es7 } from './es7'; +import { es2016 } from './es2016'; +import { es2017 } from './es2017'; +import { es2018 } from './es2018'; +import { es2019 } from './es2019'; +import { es2020 } from './es2020'; +import { esnext } from './esnext'; +import { dom } from './dom'; +import { dom_iterable } from './dom.iterable'; +import { webworker } from './webworker'; +import { webworker_importscripts } from './webworker.importscripts'; +import { scripthost } from './scripthost'; +import { es2015_core } from './es2015.core'; +import { es2015_collection } from './es2015.collection'; +import { es2015_generator } from './es2015.generator'; +import { es2015_iterable } from './es2015.iterable'; +import { es2015_promise } from './es2015.promise'; +import { es2015_proxy } from './es2015.proxy'; +import { es2015_reflect } from './es2015.reflect'; +import { es2015_symbol } from './es2015.symbol'; +import { es2015_symbol_wellknown } from './es2015.symbol.wellknown'; +import { es2016_array_include } from './es2016.array.include'; +import { es2017_object } from './es2017.object'; +import { es2017_sharedmemory } from './es2017.sharedmemory'; +import { es2017_string } from './es2017.string'; +import { es2017_intl } from './es2017.intl'; +import { es2017_typedarrays } from './es2017.typedarrays'; +import { es2018_asyncgenerator } from './es2018.asyncgenerator'; +import { es2018_asynciterable } from './es2018.asynciterable'; +import { es2018_intl } from './es2018.intl'; +import { es2018_promise } from './es2018.promise'; +import { es2018_regexp } from './es2018.regexp'; +import { es2019_array } from './es2019.array'; +import { es2019_object } from './es2019.object'; +import { es2019_string } from './es2019.string'; +import { es2019_symbol } from './es2019.symbol'; +import { es2020_bigint } from './es2020.bigint'; +import { es2020_promise } from './es2020.promise'; +import { es2020_string } from './es2020.string'; +import { es2020_symbol_wellknown } from './es2020.symbol.wellknown'; +import { esnext_array } from './esnext.array'; +import { esnext_symbol } from './esnext.symbol'; +import { esnext_asynciterable } from './esnext.asynciterable'; +import { esnext_intl } from './esnext.intl'; +import { esnext_bigint } from './esnext.bigint'; +import { esnext_string } from './esnext.string'; +import { esnext_promise } from './esnext.promise'; +import { es2016_full } from './es2016.full'; +import { es2017_full } from './es2017.full'; +import { es2018_full } from './es2018.full'; +import { es2019_full } from './es2019.full'; +import { es2020_full } from './es2020.full'; +import { esnext_full } from './esnext.full'; +import { lib as libBase } from './lib'; + +const lib = { + es5, + es6, + es2015, + es7, + es2016, + es2017, + es2018, + es2019, + es2020, + esnext, + dom, + 'dom.iterable': dom_iterable, + webworker, + 'webworker.importscripts': webworker_importscripts, + scripthost, + 'es2015.core': es2015_core, + 'es2015.collection': es2015_collection, + 'es2015.generator': es2015_generator, + 'es2015.iterable': es2015_iterable, + 'es2015.promise': es2015_promise, + 'es2015.proxy': es2015_proxy, + 'es2015.reflect': es2015_reflect, + 'es2015.symbol': es2015_symbol, + 'es2015.symbol.wellknown': es2015_symbol_wellknown, + 'es2016.array.include': es2016_array_include, + 'es2017.object': es2017_object, + 'es2017.sharedmemory': es2017_sharedmemory, + 'es2017.string': es2017_string, + 'es2017.intl': es2017_intl, + 'es2017.typedarrays': es2017_typedarrays, + 'es2018.asyncgenerator': es2018_asyncgenerator, + 'es2018.asynciterable': es2018_asynciterable, + 'es2018.intl': es2018_intl, + 'es2018.promise': es2018_promise, + 'es2018.regexp': es2018_regexp, + 'es2019.array': es2019_array, + 'es2019.object': es2019_object, + 'es2019.string': es2019_string, + 'es2019.symbol': es2019_symbol, + 'es2020.bigint': es2020_bigint, + 'es2020.promise': es2020_promise, + 'es2020.string': es2020_string, + 'es2020.symbol.wellknown': es2020_symbol_wellknown, + 'esnext.array': esnext_array, + 'esnext.symbol': esnext_symbol, + 'esnext.asynciterable': esnext_asynciterable, + 'esnext.intl': esnext_intl, + 'esnext.bigint': esnext_bigint, + 'esnext.string': esnext_string, + 'esnext.promise': esnext_promise, + 'es2016.full': es2016_full, + 'es2017.full': es2017_full, + 'es2018.full': es2018_full, + 'es2019.full': es2019_full, + 'es2020.full': es2020_full, + 'esnext.full': esnext_full, + lib: libBase, +} as const; + +export { lib }; diff --git a/packages/scope-manager/src/lib/lib.ts b/packages/scope-manager/src/lib/lib.ts new file mode 100644 index 00000000000..7ad2255439c --- /dev/null +++ b/packages/scope-manager/src/lib/lib.ts @@ -0,0 +1,16 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; +import { es5 } from './es5'; +import { dom } from './dom'; +import { webworker_importscripts } from './webworker.importscripts'; +import { scripthost } from './scripthost'; + +export const lib = { + ...es5, + ...dom, + ...webworker_importscripts, + ...scripthost, +} as Record; diff --git a/packages/scope-manager/src/lib/scripthost.ts b/packages/scope-manager/src/lib/scripthost.ts new file mode 100644 index 00000000000..a022d78e03c --- /dev/null +++ b/packages/scope-manager/src/lib/scripthost.ts @@ -0,0 +1,99 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const scripthost = { + ActiveXObject: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ActiveXObject', + writeable: false, + }, + ITextWriter: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ITextWriter', + writeable: false, + }, + TextStreamBase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextStreamBase', + writeable: false, + }, + TextStreamWriter: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextStreamWriter', + writeable: false, + }, + TextStreamReader: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextStreamReader', + writeable: false, + }, + SafeArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SafeArray', + writeable: false, + }, + Enumerator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Enumerator', + writeable: false, + }, + EnumeratorConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EnumeratorConstructor', + writeable: false, + }, + VBArray: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VBArray', + writeable: false, + }, + VBArrayConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VBArrayConstructor', + writeable: false, + }, + VarDate: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'VarDate', + writeable: false, + }, + DateConstructor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DateConstructor', + writeable: false, + }, + Date: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Date', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/lib/webworker.importscripts.ts b/packages/scope-manager/src/lib/webworker.importscripts.ts new file mode 100644 index 00000000000..90cd98bb630 --- /dev/null +++ b/packages/scope-manager/src/lib/webworker.importscripts.ts @@ -0,0 +1,10 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const webworker_importscripts = {} as Record< + string, + ImplicitLibVariableOptions +>; diff --git a/packages/scope-manager/src/lib/webworker.ts b/packages/scope-manager/src/lib/webworker.ts new file mode 100644 index 00000000000..f60d467decd --- /dev/null +++ b/packages/scope-manager/src/lib/webworker.ts @@ -0,0 +1,2885 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +import { ImplicitLibVariableOptions } from '../variable'; + +export const webworker = { + AddEventListenerOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AddEventListenerOptions', + writeable: false, + }, + AesCbcParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesCbcParams', + writeable: false, + }, + AesCtrParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesCtrParams', + writeable: false, + }, + AesDerivedKeyParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesDerivedKeyParams', + writeable: false, + }, + AesGcmParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesGcmParams', + writeable: false, + }, + AesKeyAlgorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesKeyAlgorithm', + writeable: false, + }, + AesKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesKeyGenParams', + writeable: false, + }, + Algorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Algorithm', + writeable: false, + }, + BlobPropertyBag: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BlobPropertyBag', + writeable: false, + }, + CacheQueryOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CacheQueryOptions', + writeable: false, + }, + CanvasRenderingContext2DSettings: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasRenderingContext2DSettings', + writeable: false, + }, + ClientQueryOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ClientQueryOptions', + writeable: false, + }, + CloseEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CloseEventInit', + writeable: false, + }, + CryptoKeyPair: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CryptoKeyPair', + writeable: false, + }, + CustomEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CustomEventInit', + writeable: false, + }, + DOMMatrix2DInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMMatrix2DInit', + writeable: false, + }, + DOMMatrixInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMMatrixInit', + writeable: false, + }, + DOMPointInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMPointInit', + writeable: false, + }, + DOMQuadInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMQuadInit', + writeable: false, + }, + DOMRectInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMRectInit', + writeable: false, + }, + DevicePermissionDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DevicePermissionDescriptor', + writeable: false, + }, + EcKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EcKeyGenParams', + writeable: false, + }, + EcKeyImportParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EcKeyImportParams', + writeable: false, + }, + EcdhKeyDeriveParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EcdhKeyDeriveParams', + writeable: false, + }, + EcdsaParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EcdsaParams', + writeable: false, + }, + ErrorEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ErrorEventInit', + writeable: false, + }, + EventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventInit', + writeable: false, + }, + EventListenerOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventListenerOptions', + writeable: false, + }, + EventSourceInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventSourceInit', + writeable: false, + }, + ExtendableEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ExtendableEventInit', + writeable: false, + }, + ExtendableMessageEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ExtendableMessageEventInit', + writeable: false, + }, + FetchEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FetchEventInit', + writeable: false, + }, + FilePropertyBag: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FilePropertyBag', + writeable: false, + }, + GetNotificationOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GetNotificationOptions', + writeable: false, + }, + HmacImportParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HmacImportParams', + writeable: false, + }, + HmacKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HmacKeyGenParams', + writeable: false, + }, + IDBIndexParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBIndexParameters', + writeable: false, + }, + IDBObjectStoreParameters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBObjectStoreParameters', + writeable: false, + }, + IDBVersionChangeEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBVersionChangeEventInit', + writeable: false, + }, + ImageBitmapOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageBitmapOptions', + writeable: false, + }, + ImageBitmapRenderingContextSettings: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageBitmapRenderingContextSettings', + writeable: false, + }, + ImageEncodeOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageEncodeOptions', + writeable: false, + }, + JsonWebKey: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'JsonWebKey', + writeable: false, + }, + KeyAlgorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'KeyAlgorithm', + writeable: false, + }, + MessageEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MessageEventInit', + writeable: false, + }, + MidiPermissionDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MidiPermissionDescriptor', + writeable: false, + }, + MultiCacheQueryOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MultiCacheQueryOptions', + writeable: false, + }, + NavigationPreloadState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigationPreloadState', + writeable: false, + }, + NotificationAction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationAction', + writeable: false, + }, + NotificationEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationEventInit', + writeable: false, + }, + NotificationOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationOptions', + writeable: false, + }, + Pbkdf2Params: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Pbkdf2Params', + writeable: false, + }, + PerformanceObserverInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PerformanceObserverInit', + writeable: false, + }, + PermissionDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PermissionDescriptor', + writeable: false, + }, + PipeOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PipeOptions', + writeable: false, + }, + PostMessageOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PostMessageOptions', + writeable: false, + }, + ProgressEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ProgressEventInit', + writeable: false, + }, + PromiseRejectionEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PromiseRejectionEventInit', + writeable: false, + }, + PushEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushEventInit', + writeable: false, + }, + PushPermissionDescriptor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushPermissionDescriptor', + writeable: false, + }, + PushSubscriptionChangeEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushSubscriptionChangeEventInit', + writeable: false, + }, + PushSubscriptionJSON: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushSubscriptionJSON', + writeable: false, + }, + PushSubscriptionOptionsInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushSubscriptionOptionsInit', + writeable: false, + }, + QueuingStrategy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'QueuingStrategy', + writeable: false, + }, + ReadableStreamReadDoneResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamReadDoneResult', + writeable: false, + }, + ReadableStreamReadValueResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamReadValueResult', + writeable: false, + }, + RegistrationOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RegistrationOptions', + writeable: false, + }, + RequestInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestInit', + writeable: false, + }, + ResponseInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ResponseInit', + writeable: false, + }, + RsaHashedImportParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaHashedImportParams', + writeable: false, + }, + RsaHashedKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaHashedKeyGenParams', + writeable: false, + }, + RsaKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaKeyGenParams', + writeable: false, + }, + RsaOaepParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaOaepParams', + writeable: false, + }, + RsaOtherPrimesInfo: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaOtherPrimesInfo', + writeable: false, + }, + RsaPssParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RsaPssParams', + writeable: false, + }, + StorageEstimate: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'StorageEstimate', + writeable: false, + }, + SyncEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SyncEventInit', + writeable: false, + }, + TextDecodeOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextDecodeOptions', + writeable: false, + }, + TextDecoderOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextDecoderOptions', + writeable: false, + }, + TextEncoderEncodeIntoResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextEncoderEncodeIntoResult', + writeable: false, + }, + Transformer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Transformer', + writeable: false, + }, + UnderlyingByteSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'UnderlyingByteSource', + writeable: false, + }, + UnderlyingSink: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'UnderlyingSink', + writeable: false, + }, + UnderlyingSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'UnderlyingSource', + writeable: false, + }, + WebGLContextAttributes: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLContextAttributes', + writeable: false, + }, + WebGLContextEventInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLContextEventInit', + writeable: false, + }, + WorkerOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WorkerOptions', + writeable: false, + }, + EventListener: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventListener', + writeable: false, + }, + ANGLE_instanced_arrays: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ANGLE_instanced_arrays', + writeable: false, + }, + AbortController: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AbortController', + writeable: false, + }, + AbortSignalEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AbortSignalEventMap', + writeable: false, + }, + AbortSignal: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'AbortSignal', + writeable: false, + }, + AbstractWorkerEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AbstractWorkerEventMap', + writeable: false, + }, + AbstractWorker: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AbstractWorker', + writeable: false, + }, + AesCfbParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesCfbParams', + writeable: false, + }, + AesCmacParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AesCmacParams', + writeable: false, + }, + AnimationFrameProvider: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AnimationFrameProvider', + writeable: false, + }, + Blob: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Blob', + writeable: false, + }, + Body: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Body', + writeable: false, + }, + BroadcastChannelEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BroadcastChannelEventMap', + writeable: false, + }, + BroadcastChannel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'BroadcastChannel', + writeable: false, + }, + ByteLengthQueuingStrategy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ByteLengthQueuingStrategy', + writeable: false, + }, + Cache: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Cache', + writeable: false, + }, + CacheStorage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CacheStorage', + writeable: false, + }, + CanvasCompositing: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasCompositing', + writeable: false, + }, + CanvasDrawImage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasDrawImage', + writeable: false, + }, + CanvasDrawPath: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasDrawPath', + writeable: false, + }, + CanvasFillStrokeStyles: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasFillStrokeStyles', + writeable: false, + }, + CanvasFilters: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasFilters', + writeable: false, + }, + CanvasGradient: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CanvasGradient', + writeable: false, + }, + CanvasImageData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasImageData', + writeable: false, + }, + CanvasImageSmoothing: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasImageSmoothing', + writeable: false, + }, + CanvasPath: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasPath', + writeable: false, + }, + CanvasPathDrawingStyles: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasPathDrawingStyles', + writeable: false, + }, + CanvasPattern: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CanvasPattern', + writeable: false, + }, + CanvasRect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasRect', + writeable: false, + }, + CanvasShadowStyles: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasShadowStyles', + writeable: false, + }, + CanvasState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasState', + writeable: false, + }, + CanvasText: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasText', + writeable: false, + }, + CanvasTextDrawingStyles: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasTextDrawingStyles', + writeable: false, + }, + CanvasTransform: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasTransform', + writeable: false, + }, + Client: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Client', + writeable: false, + }, + Clients: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Clients', + writeable: false, + }, + CloseEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CloseEvent', + writeable: false, + }, + ConcatParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ConcatParams', + writeable: false, + }, + CountQueuingStrategy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CountQueuingStrategy', + writeable: false, + }, + Crypto: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Crypto', + writeable: false, + }, + CryptoKey: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CryptoKey', + writeable: false, + }, + CustomEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'CustomEvent', + writeable: false, + }, + DOMException: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMException', + writeable: false, + }, + DOMMatrix: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMMatrix', + writeable: false, + }, + DOMMatrixReadOnly: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMMatrixReadOnly', + writeable: false, + }, + DOMPoint: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMPoint', + writeable: false, + }, + DOMPointReadOnly: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMPointReadOnly', + writeable: false, + }, + DOMQuad: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMQuad', + writeable: false, + }, + DOMRect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMRect', + writeable: false, + }, + DOMRectReadOnly: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMRectReadOnly', + writeable: false, + }, + DOMStringList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DOMStringList', + writeable: false, + }, + DedicatedWorkerGlobalScopeEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DedicatedWorkerGlobalScopeEventMap', + writeable: false, + }, + DedicatedWorkerGlobalScope: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'DedicatedWorkerGlobalScope', + writeable: false, + }, + DhImportKeyParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DhImportKeyParams', + writeable: false, + }, + DhKeyAlgorithm: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DhKeyAlgorithm', + writeable: false, + }, + DhKeyDeriveParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DhKeyDeriveParams', + writeable: false, + }, + DhKeyGenParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DhKeyGenParams', + writeable: false, + }, + EXT_blend_minmax: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EXT_blend_minmax', + writeable: false, + }, + EXT_frag_depth: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EXT_frag_depth', + writeable: false, + }, + EXT_sRGB: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EXT_sRGB', + writeable: false, + }, + EXT_shader_texture_lod: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EXT_shader_texture_lod', + writeable: false, + }, + EXT_texture_filter_anisotropic: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EXT_texture_filter_anisotropic', + writeable: false, + }, + ErrorEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ErrorEvent', + writeable: false, + }, + Event: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Event', + writeable: false, + }, + EventListenerObject: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventListenerObject', + writeable: false, + }, + EventSourceEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventSourceEventMap', + writeable: false, + }, + EventSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'EventSource', + writeable: false, + }, + EventTarget: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'EventTarget', + writeable: false, + }, + ExtendableEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ExtendableEvent', + writeable: false, + }, + ExtendableMessageEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ExtendableMessageEvent', + writeable: false, + }, + FetchEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'FetchEvent', + writeable: false, + }, + File: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'File', + writeable: false, + }, + FileList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'FileList', + writeable: false, + }, + FileReaderEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FileReaderEventMap', + writeable: false, + }, + FileReader: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'FileReader', + writeable: false, + }, + FileReaderSync: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'FileReaderSync', + writeable: false, + }, + FormData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'FormData', + writeable: false, + }, + GenericTransformStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GenericTransformStream', + writeable: false, + }, + Headers: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Headers', + writeable: false, + }, + HkdfCtrParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HkdfCtrParams', + writeable: false, + }, + IDBArrayKey: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBArrayKey', + writeable: false, + }, + IDBCursor: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBCursor', + writeable: false, + }, + IDBCursorWithValue: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBCursorWithValue', + writeable: false, + }, + IDBDatabaseEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBDatabaseEventMap', + writeable: false, + }, + IDBDatabase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBDatabase', + writeable: false, + }, + IDBFactory: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBFactory', + writeable: false, + }, + IDBIndex: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBIndex', + writeable: false, + }, + IDBKeyRange: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBKeyRange', + writeable: false, + }, + IDBObjectStore: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBObjectStore', + writeable: false, + }, + IDBOpenDBRequestEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBOpenDBRequestEventMap', + writeable: false, + }, + IDBOpenDBRequest: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBOpenDBRequest', + writeable: false, + }, + IDBRequestEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBRequestEventMap', + writeable: false, + }, + IDBRequest: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBRequest', + writeable: false, + }, + IDBTransactionEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBTransactionEventMap', + writeable: false, + }, + IDBTransaction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBTransaction', + writeable: false, + }, + IDBVersionChangeEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'IDBVersionChangeEvent', + writeable: false, + }, + ImageBitmap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ImageBitmap', + writeable: false, + }, + ImageBitmapRenderingContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ImageBitmapRenderingContext', + writeable: false, + }, + ImageData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ImageData', + writeable: false, + }, + MessageChannel: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MessageChannel', + writeable: false, + }, + MessageEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MessageEvent', + writeable: false, + }, + MessagePortEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MessagePortEventMap', + writeable: false, + }, + MessagePort: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'MessagePort', + writeable: false, + }, + NavigationPreloadManager: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'NavigationPreloadManager', + writeable: false, + }, + NavigatorConcurrentHardware: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorConcurrentHardware', + writeable: false, + }, + NavigatorID: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorID', + writeable: false, + }, + NavigatorLanguage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorLanguage', + writeable: false, + }, + NavigatorOnLine: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorOnLine', + writeable: false, + }, + NavigatorStorage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NavigatorStorage', + writeable: false, + }, + NotificationEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationEventMap', + writeable: false, + }, + Notification: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Notification', + writeable: false, + }, + NotificationEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'NotificationEvent', + writeable: false, + }, + OES_element_index_uint: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_element_index_uint', + writeable: false, + }, + OES_standard_derivatives: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_standard_derivatives', + writeable: false, + }, + OES_texture_float: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_texture_float', + writeable: false, + }, + OES_texture_float_linear: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_texture_float_linear', + writeable: false, + }, + OES_texture_half_float: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_texture_half_float', + writeable: false, + }, + OES_texture_half_float_linear: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_texture_half_float_linear', + writeable: false, + }, + OES_vertex_array_object: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OES_vertex_array_object', + writeable: false, + }, + OffscreenCanvas: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'OffscreenCanvas', + writeable: false, + }, + OffscreenCanvasRenderingContext2D: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'OffscreenCanvasRenderingContext2D', + writeable: false, + }, + Path2D: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Path2D', + writeable: false, + }, + PerformanceEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PerformanceEventMap', + writeable: false, + }, + Performance: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Performance', + writeable: false, + }, + PerformanceEntry: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceEntry', + writeable: false, + }, + PerformanceMark: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceMark', + writeable: false, + }, + PerformanceMeasure: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceMeasure', + writeable: false, + }, + PerformanceObserver: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceObserver', + writeable: false, + }, + PerformanceObserverEntryList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceObserverEntryList', + writeable: false, + }, + PerformanceResourceTiming: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PerformanceResourceTiming', + writeable: false, + }, + PermissionStatusEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PermissionStatusEventMap', + writeable: false, + }, + PermissionStatus: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PermissionStatus', + writeable: false, + }, + Permissions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Permissions', + writeable: false, + }, + ProgressEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ProgressEvent', + writeable: false, + }, + PromiseRejectionEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PromiseRejectionEvent', + writeable: false, + }, + PushEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PushEvent', + writeable: false, + }, + PushManager: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PushManager', + writeable: false, + }, + PushMessageData: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PushMessageData', + writeable: false, + }, + PushSubscription: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PushSubscription', + writeable: false, + }, + PushSubscriptionChangeEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PushSubscriptionChangeEvent', + writeable: false, + }, + PushSubscriptionOptions: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'PushSubscriptionOptions', + writeable: false, + }, + ReadableByteStreamController: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableByteStreamController', + writeable: false, + }, + ReadableStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ReadableStream', + writeable: false, + }, + ReadableStreamBYOBReader: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamBYOBReader', + writeable: false, + }, + ReadableStreamBYOBRequest: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamBYOBRequest', + writeable: false, + }, + ReadableStreamDefaultController: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamDefaultController', + writeable: false, + }, + ReadableStreamDefaultReader: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamDefaultReader', + writeable: false, + }, + ReadableStreamReader: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ReadableStreamReader', + writeable: false, + }, + Request: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Request', + writeable: false, + }, + Response: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Response', + writeable: false, + }, + ServiceWorkerEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerEventMap', + writeable: false, + }, + ServiceWorker: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ServiceWorker', + writeable: false, + }, + ServiceWorkerContainerEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerContainerEventMap', + writeable: false, + }, + ServiceWorkerContainer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ServiceWorkerContainer', + writeable: false, + }, + ServiceWorkerGlobalScopeEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerGlobalScopeEventMap', + writeable: false, + }, + ServiceWorkerGlobalScope: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ServiceWorkerGlobalScope', + writeable: false, + }, + ServiceWorkerRegistrationEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerRegistrationEventMap', + writeable: false, + }, + ServiceWorkerRegistration: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'ServiceWorkerRegistration', + writeable: false, + }, + SharedWorker: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SharedWorker', + writeable: false, + }, + SharedWorkerGlobalScopeEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'SharedWorkerGlobalScopeEventMap', + writeable: false, + }, + SharedWorkerGlobalScope: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SharedWorkerGlobalScope', + writeable: false, + }, + StorageManager: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'StorageManager', + writeable: false, + }, + SubtleCrypto: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SubtleCrypto', + writeable: false, + }, + SyncEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SyncEvent', + writeable: false, + }, + SyncManager: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'SyncManager', + writeable: false, + }, + TextDecoder: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextDecoder', + writeable: false, + }, + TextDecoderCommon: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextDecoderCommon', + writeable: false, + }, + TextDecoderStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextDecoderStream', + writeable: false, + }, + TextEncoder: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextEncoder', + writeable: false, + }, + TextEncoderCommon: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TextEncoderCommon', + writeable: false, + }, + TextEncoderStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextEncoderStream', + writeable: false, + }, + TextMetrics: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TextMetrics', + writeable: false, + }, + TransformStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'TransformStream', + writeable: false, + }, + TransformStreamDefaultController: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TransformStreamDefaultController', + writeable: false, + }, + URL: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'URL', + writeable: false, + }, + URLSearchParams: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'URLSearchParams', + writeable: false, + }, + WEBGL_color_buffer_float: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_color_buffer_float', + writeable: false, + }, + WEBGL_compressed_texture_astc: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_compressed_texture_astc', + writeable: false, + }, + WEBGL_compressed_texture_s3tc: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_compressed_texture_s3tc', + writeable: false, + }, + WEBGL_compressed_texture_s3tc_srgb: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_compressed_texture_s3tc_srgb', + writeable: false, + }, + WEBGL_debug_renderer_info: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_debug_renderer_info', + writeable: false, + }, + WEBGL_debug_shaders: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_debug_shaders', + writeable: false, + }, + WEBGL_depth_texture: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_depth_texture', + writeable: false, + }, + WEBGL_draw_buffers: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_draw_buffers', + writeable: false, + }, + WEBGL_lose_context: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WEBGL_lose_context', + writeable: false, + }, + WebGL2RenderingContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGL2RenderingContext', + writeable: false, + }, + WebGL2RenderingContextBase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGL2RenderingContextBase', + writeable: false, + }, + WebGL2RenderingContextOverloads: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGL2RenderingContextOverloads', + writeable: false, + }, + WebGLActiveInfo: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLActiveInfo', + writeable: false, + }, + WebGLBuffer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLBuffer', + writeable: false, + }, + WebGLContextEvent: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLContextEvent', + writeable: false, + }, + WebGLFramebuffer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLFramebuffer', + writeable: false, + }, + WebGLObject: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLObject', + writeable: false, + }, + WebGLProgram: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLProgram', + writeable: false, + }, + WebGLQuery: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLQuery', + writeable: false, + }, + WebGLRenderbuffer: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLRenderbuffer', + writeable: false, + }, + WebGLRenderingContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLRenderingContext', + writeable: false, + }, + WebGLRenderingContextBase: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLRenderingContextBase', + writeable: false, + }, + WebGLRenderingContextOverloads: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLRenderingContextOverloads', + writeable: false, + }, + WebGLSampler: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLSampler', + writeable: false, + }, + WebGLShader: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLShader', + writeable: false, + }, + WebGLShaderPrecisionFormat: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLShaderPrecisionFormat', + writeable: false, + }, + WebGLSync: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLSync', + writeable: false, + }, + WebGLTexture: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLTexture', + writeable: false, + }, + WebGLTransformFeedback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLTransformFeedback', + writeable: false, + }, + WebGLUniformLocation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLUniformLocation', + writeable: false, + }, + WebGLVertexArrayObject: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebGLVertexArrayObject', + writeable: false, + }, + WebGLVertexArrayObjectOES: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLVertexArrayObjectOES', + writeable: false, + }, + WebSocketEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebSocketEventMap', + writeable: false, + }, + WebSocket: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebSocket', + writeable: false, + }, + WindowClient: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WindowClient', + writeable: false, + }, + WindowOrWorkerGlobalScope: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WindowOrWorkerGlobalScope', + writeable: false, + }, + WorkerEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WorkerEventMap', + writeable: false, + }, + Worker: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'Worker', + writeable: false, + }, + WorkerGlobalScopeEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WorkerGlobalScopeEventMap', + writeable: false, + }, + WorkerGlobalScope: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WorkerGlobalScope', + writeable: false, + }, + WorkerLocation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WorkerLocation', + writeable: false, + }, + WorkerNavigator: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WorkerNavigator', + writeable: false, + }, + WritableStream: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WritableStream', + writeable: false, + }, + WritableStreamDefaultController: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamDefaultController', + writeable: false, + }, + WritableStreamDefaultWriter: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamDefaultWriter', + writeable: false, + }, + XMLHttpRequestEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'XMLHttpRequestEventMap', + writeable: false, + }, + XMLHttpRequest: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XMLHttpRequest', + writeable: false, + }, + XMLHttpRequestEventTargetEventMap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'XMLHttpRequestEventTargetEventMap', + writeable: false, + }, + XMLHttpRequestEventTarget: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XMLHttpRequestEventTarget', + writeable: false, + }, + XMLHttpRequestUpload: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'XMLHttpRequestUpload', + writeable: false, + }, + EventListenerOrEventListenerObject: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EventListenerOrEventListenerObject', + writeable: false, + }, + Console: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Console', + writeable: false, + }, + WebAssembly: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: true, + name: 'WebAssembly', + writeable: false, + }, + FrameRequestCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FrameRequestCallback', + writeable: false, + }, + OnErrorEventHandlerNonNull: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OnErrorEventHandlerNonNull', + writeable: false, + }, + PerformanceObserverCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PerformanceObserverCallback', + writeable: false, + }, + QueuingStrategySizeCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'QueuingStrategySizeCallback', + writeable: false, + }, + ReadableByteStreamControllerCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableByteStreamControllerCallback', + writeable: false, + }, + ReadableStreamDefaultControllerCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamDefaultControllerCallback', + writeable: false, + }, + ReadableStreamErrorCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamErrorCallback', + writeable: false, + }, + TransformStreamDefaultControllerCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TransformStreamDefaultControllerCallback', + writeable: false, + }, + TransformStreamDefaultControllerTransformCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TransformStreamDefaultControllerTransformCallback', + writeable: false, + }, + VoidFunction: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VoidFunction', + writeable: false, + }, + WritableStreamDefaultControllerCloseCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamDefaultControllerCloseCallback', + writeable: false, + }, + WritableStreamDefaultControllerStartCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamDefaultControllerStartCallback', + writeable: false, + }, + WritableStreamDefaultControllerWriteCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamDefaultControllerWriteCallback', + writeable: false, + }, + WritableStreamErrorCallback: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WritableStreamErrorCallback', + writeable: false, + }, + HeadersInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HeadersInit', + writeable: false, + }, + BodyInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BodyInit', + writeable: false, + }, + RequestInfo: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestInfo', + writeable: false, + }, + BlobPart: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BlobPart', + writeable: false, + }, + DOMHighResTimeStamp: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMHighResTimeStamp', + writeable: false, + }, + CanvasImageSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasImageSource', + writeable: false, + }, + OffscreenRenderingContext: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OffscreenRenderingContext', + writeable: false, + }, + MessageEventSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'MessageEventSource', + writeable: false, + }, + ImageBitmapSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageBitmapSource', + writeable: false, + }, + OnErrorEventHandler: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OnErrorEventHandler', + writeable: false, + }, + TimerHandler: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TimerHandler', + writeable: false, + }, + PerformanceEntryList: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PerformanceEntryList', + writeable: false, + }, + PushMessageDataInit: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushMessageDataInit', + writeable: false, + }, + ReadableStreamReadResult: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReadableStreamReadResult', + writeable: false, + }, + VibratePattern: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VibratePattern', + writeable: false, + }, + AlgorithmIdentifier: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'AlgorithmIdentifier', + writeable: false, + }, + HashAlgorithmIdentifier: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'HashAlgorithmIdentifier', + writeable: false, + }, + BigInteger: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BigInteger', + writeable: false, + }, + NamedCurve: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NamedCurve', + writeable: false, + }, + GLenum: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLenum', + writeable: false, + }, + GLboolean: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLboolean', + writeable: false, + }, + GLbitfield: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLbitfield', + writeable: false, + }, + GLint: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLint', + writeable: false, + }, + GLsizei: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLsizei', + writeable: false, + }, + GLintptr: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLintptr', + writeable: false, + }, + GLsizeiptr: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLsizeiptr', + writeable: false, + }, + GLuint: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLuint', + writeable: false, + }, + GLfloat: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLfloat', + writeable: false, + }, + GLclampf: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLclampf', + writeable: false, + }, + TexImageSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'TexImageSource', + writeable: false, + }, + Float32List: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Float32List', + writeable: false, + }, + Int32List: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Int32List', + writeable: false, + }, + GLint64: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLint64', + writeable: false, + }, + GLuint64: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'GLuint64', + writeable: false, + }, + Uint32List: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Uint32List', + writeable: false, + }, + BufferSource: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BufferSource', + writeable: false, + }, + DOMTimeStamp: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'DOMTimeStamp', + writeable: false, + }, + FormDataEntryValue: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FormDataEntryValue', + writeable: false, + }, + IDBValidKey: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBValidKey', + writeable: false, + }, + Transferable: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'Transferable', + writeable: false, + }, + BinaryType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'BinaryType', + writeable: false, + }, + CanvasDirection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasDirection', + writeable: false, + }, + CanvasFillRule: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasFillRule', + writeable: false, + }, + CanvasLineCap: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasLineCap', + writeable: false, + }, + CanvasLineJoin: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasLineJoin', + writeable: false, + }, + CanvasTextAlign: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasTextAlign', + writeable: false, + }, + CanvasTextBaseline: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'CanvasTextBaseline', + writeable: false, + }, + ClientTypes: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ClientTypes', + writeable: false, + }, + ColorSpaceConversion: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ColorSpaceConversion', + writeable: false, + }, + EndingType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'EndingType', + writeable: false, + }, + FrameType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'FrameType', + writeable: false, + }, + IDBCursorDirection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBCursorDirection', + writeable: false, + }, + IDBRequestReadyState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBRequestReadyState', + writeable: false, + }, + IDBTransactionMode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'IDBTransactionMode', + writeable: false, + }, + ImageOrientation: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageOrientation', + writeable: false, + }, + ImageSmoothingQuality: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ImageSmoothingQuality', + writeable: false, + }, + KeyFormat: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'KeyFormat', + writeable: false, + }, + KeyType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'KeyType', + writeable: false, + }, + KeyUsage: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'KeyUsage', + writeable: false, + }, + NotificationDirection: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationDirection', + writeable: false, + }, + NotificationPermission: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'NotificationPermission', + writeable: false, + }, + OffscreenRenderingContextId: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'OffscreenRenderingContextId', + writeable: false, + }, + PermissionName: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PermissionName', + writeable: false, + }, + PermissionState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PermissionState', + writeable: false, + }, + PremultiplyAlpha: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PremultiplyAlpha', + writeable: false, + }, + PushEncryptionKeyName: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushEncryptionKeyName', + writeable: false, + }, + PushPermissionState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'PushPermissionState', + writeable: false, + }, + ReferrerPolicy: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ReferrerPolicy', + writeable: false, + }, + RequestCache: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestCache', + writeable: false, + }, + RequestCredentials: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestCredentials', + writeable: false, + }, + RequestDestination: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestDestination', + writeable: false, + }, + RequestMode: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestMode', + writeable: false, + }, + RequestRedirect: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'RequestRedirect', + writeable: false, + }, + ResizeQuality: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ResizeQuality', + writeable: false, + }, + ResponseType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ResponseType', + writeable: false, + }, + ServiceWorkerState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerState', + writeable: false, + }, + ServiceWorkerUpdateViaCache: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'ServiceWorkerUpdateViaCache', + writeable: false, + }, + VisibilityState: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'VisibilityState', + writeable: false, + }, + WebGLPowerPreference: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WebGLPowerPreference', + writeable: false, + }, + WorkerType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'WorkerType', + writeable: false, + }, + XMLHttpRequestResponseType: { + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: true, + isValueVariable: false, + name: 'XMLHttpRequestResponseType', + writeable: false, + }, +} as Record; diff --git a/packages/scope-manager/src/referencer/ExportVisitor.ts b/packages/scope-manager/src/referencer/ExportVisitor.ts new file mode 100644 index 00000000000..bae523ae6b2 --- /dev/null +++ b/packages/scope-manager/src/referencer/ExportVisitor.ts @@ -0,0 +1,72 @@ +import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/types'; +import { Referencer } from './Referencer'; +import { Visitor } from './Visitor'; + +type ExportNode = + | TSESTree.ExportAllDeclaration + | TSESTree.ExportDefaultDeclaration + | TSESTree.ExportNamedDeclaration; + +class ExportVisitor extends Visitor { + readonly #referencer: Referencer; + readonly #exportNode: ExportNode; + + constructor(node: ExportNode, referencer: Referencer) { + super(referencer); + this.#exportNode = node; + this.#referencer = referencer; + } + + static visit(referencer: Referencer, node: ExportNode): void { + const exportReferencer = new ExportVisitor(node, referencer); + exportReferencer.visit(node); + } + + protected Identifier(node: TSESTree.Identifier): void { + if (this.#exportNode.exportKind === 'type') { + // type exports can only reference types + this.#referencer.currentScope().referenceType(node); + } else { + this.#referencer.currentScope().referenceDualValueType(node); + } + } + + protected ExportDefaultDeclaration( + node: TSESTree.ExportDefaultDeclaration, + ): void { + if (node.declaration.type === AST_NODE_TYPES.Identifier) { + // export default A; + // this could be a type or a variable + this.visit(node.declaration); + } else { + // export const a = 1; + // export something(); + // etc + // these not included in the scope of this visitor as they are all guaranteed to be values or declare variables + } + } + + protected ExportNamedDeclaration( + node: TSESTree.ExportNamedDeclaration, + ): void { + if (node.source) { + // export ... from 'foo'; + // these are external identifiers so there shouldn't be references or defs + return; + } + + if (!node.declaration) { + // export { x }; + this.visitChildren(node); + } else { + // export const x = 1; + // this is not included in the scope of this visitor as it creates a variable + } + } + + protected ExportSpecifier(node: TSESTree.ExportSpecifier): void { + this.visit(node.local); + } +} + +export { ExportVisitor }; diff --git a/packages/scope-manager/src/referencer/ImportVisitor.ts b/packages/scope-manager/src/referencer/ImportVisitor.ts new file mode 100644 index 00000000000..19a9b1d7d5e --- /dev/null +++ b/packages/scope-manager/src/referencer/ImportVisitor.ts @@ -0,0 +1,59 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { ImportBindingDefinition } from '../definition'; +import { Referencer } from './Referencer'; +import { Visitor } from './Visitor'; + +class ImportVisitor extends Visitor { + readonly #declaration: TSESTree.ImportDeclaration; + readonly #referencer: Referencer; + + constructor(declaration: TSESTree.ImportDeclaration, referencer: Referencer) { + super(referencer); + this.#declaration = declaration; + this.#referencer = referencer; + } + + static visit( + referencer: Referencer, + declaration: TSESTree.ImportDeclaration, + ): void { + const importReferencer = new ImportVisitor(declaration, referencer); + importReferencer.visit(declaration); + } + + protected visitImport( + id: TSESTree.Identifier, + specifier: + | TSESTree.ImportDefaultSpecifier + | TSESTree.ImportNamespaceSpecifier + | TSESTree.ImportSpecifier, + ): void { + this.#referencer + .currentScope() + .defineIdentifier( + id, + new ImportBindingDefinition(id, specifier, this.#declaration), + ); + } + + protected ImportNamespaceSpecifier( + node: TSESTree.ImportNamespaceSpecifier, + ): void { + const local = node.local; + this.visitImport(local, node); + } + + protected ImportDefaultSpecifier( + node: TSESTree.ImportDefaultSpecifier, + ): void { + const local = node.local; + this.visitImport(local, node); + } + + protected ImportSpecifier(node: TSESTree.ImportSpecifier): void { + const local = node.local; + this.visitImport(local, node); + } +} + +export { ImportVisitor }; diff --git a/packages/scope-manager/src/referencer/PatternVisitor.ts b/packages/scope-manager/src/referencer/PatternVisitor.ts new file mode 100644 index 00000000000..eaca842cbd5 --- /dev/null +++ b/packages/scope-manager/src/referencer/PatternVisitor.ts @@ -0,0 +1,142 @@ +import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/types'; +import { VisitorBase, VisitorOptions } from './Visitor'; + +type PatternVisitorCallback = ( + pattern: TSESTree.Identifier, + info: { + assignments: (TSESTree.AssignmentPattern | TSESTree.AssignmentExpression)[]; + rest: boolean; + topLevel: boolean; + }, +) => void; + +type PatternVisitorOptions = VisitorOptions; +class PatternVisitor extends VisitorBase { + public static isPattern( + node: TSESTree.Node, + ): node is + | TSESTree.Identifier + | TSESTree.ObjectPattern + | TSESTree.ArrayPattern + | TSESTree.SpreadElement + | TSESTree.RestElement + | TSESTree.AssignmentPattern { + const nodeType = node.type; + + return ( + nodeType === AST_NODE_TYPES.Identifier || + nodeType === AST_NODE_TYPES.ObjectPattern || + nodeType === AST_NODE_TYPES.ArrayPattern || + nodeType === AST_NODE_TYPES.SpreadElement || + nodeType === AST_NODE_TYPES.RestElement || + nodeType === AST_NODE_TYPES.AssignmentPattern + ); + } + + readonly #rootPattern: TSESTree.Node; + readonly #callback: PatternVisitorCallback; + readonly #assignments: ( + | TSESTree.AssignmentPattern + | TSESTree.AssignmentExpression + )[] = []; + public readonly rightHandNodes: TSESTree.Node[] = []; + readonly #restElements: TSESTree.RestElement[] = []; + + constructor( + options: PatternVisitorOptions, + rootPattern: TSESTree.Node, + callback: PatternVisitorCallback, + ) { + super(options); + this.#rootPattern = rootPattern; + this.#callback = callback; + } + + protected ArrayExpression(node: TSESTree.ArrayExpression): void { + node.elements.forEach(this.visit, this); + } + + protected ArrayPattern(pattern: TSESTree.ArrayPattern): void { + for (const element of pattern.elements) { + this.visit(element); + } + } + + protected AssignmentExpression(node: TSESTree.AssignmentExpression): void { + this.#assignments.push(node); + this.visit(node.left); + this.rightHandNodes.push(node.right); + this.#assignments.pop(); + } + + protected AssignmentPattern(pattern: TSESTree.AssignmentPattern): void { + this.#assignments.push(pattern); + this.visit(pattern.left); + this.rightHandNodes.push(pattern.right); + this.#assignments.pop(); + } + + protected CallExpression(node: TSESTree.CallExpression): void { + // arguments are right hand nodes. + node.arguments.forEach(a => { + this.rightHandNodes.push(a); + }); + this.visit(node.callee); + } + + protected Decorator(): void { + // don't visit any decorators when exploring a pattern + } + + protected Identifier(pattern: TSESTree.Identifier): void { + const lastRestElement = + this.#restElements[this.#restElements.length - 1] ?? null; + + this.#callback(pattern, { + topLevel: pattern === this.#rootPattern, + rest: + lastRestElement !== null && + lastRestElement !== undefined && + lastRestElement.argument === pattern, + assignments: this.#assignments, + }); + } + + protected MemberExpression(node: TSESTree.MemberExpression): void { + // Computed property's key is a right hand node. + if (node.computed) { + this.rightHandNodes.push(node.property); + } + + // the object is only read, write to its property. + this.rightHandNodes.push(node.object); + } + + protected Property(property: TSESTree.Property): void { + // Computed property's key is a right hand node. + if (property.computed) { + this.rightHandNodes.push(property.key); + } + + // If it's shorthand, its key is same as its value. + // If it's shorthand and has its default value, its key is same as its value.left (the value is AssignmentPattern). + // If it's not shorthand, the name of new variable is its value's. + this.visit(property.value); + } + + protected RestElement(pattern: TSESTree.RestElement): void { + this.#restElements.push(pattern); + this.visit(pattern.argument); + this.#restElements.pop(); + } + + protected SpreadElement(node: TSESTree.SpreadElement): void { + this.visit(node.argument); + } + + protected TSTypeAnnotation(): void { + // we don't want to visit types + } +} + +export { PatternVisitor, PatternVisitorCallback, PatternVisitorOptions }; diff --git a/packages/scope-manager/src/referencer/Reference.ts b/packages/scope-manager/src/referencer/Reference.ts new file mode 100644 index 00000000000..5786c501730 --- /dev/null +++ b/packages/scope-manager/src/referencer/Reference.ts @@ -0,0 +1,148 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { createIdGenerator } from '../ID'; +import { Scope } from '../scope'; +import { Variable } from '../variable'; + +enum ReferenceFlag { + Read = 0x1, + Write = 0x2, + ReadWrite = 0x3, +} + +interface ReferenceImplicitGlobal { + node: TSESTree.Node; + pattern: TSESTree.BindingName; + ref?: Reference; +} + +const generator = createIdGenerator(); + +enum ReferenceTypeFlag { + Value = 0x1, + Type = 0x2, +} + +/** + * A Reference represents a single occurrence of an identifier in code. + */ +class Reference { + /** + * A unique ID for this instance - primarily used to help debugging and testing + */ + public readonly $id: number = generator(); + /** + * The read-write mode of the reference. + */ + readonly #flag: ReferenceFlag; + /** + * Reference to the enclosing Scope. + * @public + */ + public readonly from: Scope; + /** + * Identifier syntax node. + * @public + */ + public readonly identifier: TSESTree.Identifier; + /** + * `true` if this writing reference is a variable initializer or a default value. + * @public + */ + public readonly init?: boolean; + /** + * The {@link Variable} object that this reference refers to. If such variable was not defined, this is `null`. + * @public + */ + public resolved: Variable | null; + /** + * If reference is writeable, this is the node being written to it. + * @public + */ + public readonly writeExpr?: TSESTree.Node | null; + + public readonly maybeImplicitGlobal?: ReferenceImplicitGlobal | null; + + /** + * In some cases, a reference may be a type, value or both a type and value reference. + */ + readonly #referenceType: ReferenceTypeFlag; + + /** + * True if this reference can reference types + */ + public get isTypeReference(): boolean { + return (this.#referenceType & ReferenceTypeFlag.Type) !== 0; + } + + /** + * True if this reference can reference values + */ + public get isValueReference(): boolean { + return (this.#referenceType & ReferenceTypeFlag.Value) !== 0; + } + + constructor( + identifier: TSESTree.Identifier, + scope: Scope, + flag: ReferenceFlag, + writeExpr?: TSESTree.Node | null, + maybeImplicitGlobal?: ReferenceImplicitGlobal | null, + init?: boolean, + referenceType = ReferenceTypeFlag.Value, + ) { + this.identifier = identifier; + this.from = scope; + this.resolved = null; + this.#flag = flag; + + if (this.isWrite()) { + this.writeExpr = writeExpr; + this.init = init; + } + + this.maybeImplicitGlobal = maybeImplicitGlobal; + this.#referenceType = referenceType; + } + + /** + * Whether the reference is writeable. + * @public + */ + public isWrite(): boolean { + return !!(this.#flag & ReferenceFlag.Write); + } + + /** + * Whether the reference is readable. + * @public + */ + public isRead(): boolean { + return !!(this.#flag & ReferenceFlag.Read); + } + + /** + * Whether the reference is read-only. + * @public + */ + public isReadOnly(): boolean { + return this.#flag === ReferenceFlag.Read; + } + + /** + * Whether the reference is write-only. + * @public + */ + public isWriteOnly(): boolean { + return this.#flag === ReferenceFlag.Write; + } + + /** + * Whether the reference is read-write. + * @public + */ + public isReadWrite(): boolean { + return this.#flag === ReferenceFlag.ReadWrite; + } +} + +export { Reference, ReferenceFlag, ReferenceTypeFlag, ReferenceImplicitGlobal }; diff --git a/packages/scope-manager/src/referencer/Referencer.ts b/packages/scope-manager/src/referencer/Referencer.ts new file mode 100644 index 00000000000..d3d13982340 --- /dev/null +++ b/packages/scope-manager/src/referencer/Referencer.ts @@ -0,0 +1,764 @@ +import { AST_NODE_TYPES, Lib, TSESTree } from '@typescript-eslint/types'; +import { ExportVisitor } from './ExportVisitor'; +import { ImportVisitor } from './ImportVisitor'; +import { PatternVisitor } from './PatternVisitor'; +import { ReferenceFlag, ReferenceImplicitGlobal } from './Reference'; +import { ScopeManager } from '../ScopeManager'; +import { TypeVisitor } from './TypeVisitor'; +import { Visitor, VisitorOptions } from './Visitor'; +import { assert } from '../assert'; +import { + CatchClauseDefinition, + ClassNameDefinition, + FunctionNameDefinition, + ImportBindingDefinition, + ParameterDefinition, + TSEnumMemberDefinition, + TSEnumNameDefinition, + TSModuleNameDefinition, + VariableDefinition, +} from '../definition'; +import { lib as TSLibraries } from '../lib'; +import { Scope, GlobalScope } from '../scope'; + +interface ReferencerOptions extends VisitorOptions { + lib: Lib[]; +} + +// Referencing variables and creating bindings. +class Referencer extends Visitor { + #isInnerMethodDefinition: boolean; + #lib: Lib[]; + public readonly scopeManager: ScopeManager; + + constructor(options: ReferencerOptions, scopeManager: ScopeManager) { + super(options); + this.scopeManager = scopeManager; + this.#lib = options.lib; + this.#isInnerMethodDefinition = false; + } + + public currentScope(): Scope; + public currentScope(throwOnNull: true): Scope | null; + public currentScope(dontThrowOnNull?: true): Scope | null { + if (!dontThrowOnNull) { + assert(this.scopeManager.currentScope, 'aaa'); + } + return this.scopeManager.currentScope; + } + + public close(node: TSESTree.Node): void { + while (this.currentScope(true) && node === this.currentScope().block) { + this.scopeManager.currentScope = this.currentScope().close( + this.scopeManager, + ); + } + } + + protected pushInnerMethodDefinition( + isInnerMethodDefinition: boolean, + ): boolean { + const previous = this.#isInnerMethodDefinition; + + this.#isInnerMethodDefinition = isInnerMethodDefinition; + return previous; + } + + protected popInnerMethodDefinition( + isInnerMethodDefinition: boolean | undefined, + ): void { + this.#isInnerMethodDefinition = !!isInnerMethodDefinition; + } + + protected referencingDefaultValue( + pattern: TSESTree.Identifier, + assignments: (TSESTree.AssignmentExpression | TSESTree.AssignmentPattern)[], + maybeImplicitGlobal: ReferenceImplicitGlobal | null, + init: boolean, + ): void { + assignments.forEach(assignment => { + this.currentScope().referenceValue( + pattern, + ReferenceFlag.Write, + assignment.right, + maybeImplicitGlobal, + init, + ); + }); + } + + private populateGlobalsFromLib(globalScope: GlobalScope): void { + for (const lib of this.#lib) { + const variables = TSLibraries[lib]; + /* istanbul ignore if */ if (!variables) { + throw new Error(`Invalid value for lib provided: ${lib}`); + } + for (const variable of Object.values(variables)) { + globalScope.defineImplicitVariable(variable); + } + } + } + + /////////////////// + // Visit helpers // + /////////////////// + + protected visitClass( + node: TSESTree.ClassDeclaration | TSESTree.ClassExpression, + ): void { + if (node.type === AST_NODE_TYPES.ClassDeclaration && node.id) { + this.currentScope().defineIdentifier( + node.id, + new ClassNameDefinition(node.id, node), + ); + } + + node.decorators?.forEach(d => this.visit(d)); + + this.scopeManager.nestClassScope(node); + + if (node.id) { + // define the class name again inside the new scope + // references to the class should not resolve directly to the parent class + this.currentScope().defineIdentifier( + node.id, + new ClassNameDefinition(node.id, node), + ); + } + + this.visit(node.superClass); + + // visit the type param declarations + this.visitType(node.typeParameters); + // then the usages + this.visitType(node.superTypeParameters); + node.implements?.forEach(imp => this.visitType(imp)); + + this.visit(node.body); + + this.close(node); + } + + protected visitForIn( + node: TSESTree.ForInStatement | TSESTree.ForOfStatement, + ): void { + if ( + node.left.type === AST_NODE_TYPES.VariableDeclaration && + node.left.kind !== 'var' + ) { + this.scopeManager.nestForScope(node); + } + + if (node.left.type === AST_NODE_TYPES.VariableDeclaration) { + this.visit(node.left); + this.visitPattern(node.left.declarations[0].id, pattern => { + this.currentScope().referenceValue( + pattern, + ReferenceFlag.Write, + node.right, + null, + true, + ); + }); + } else { + this.visitPattern( + node.left, + (pattern, info) => { + const maybeImplicitGlobal = !this.currentScope().isStrict + ? { + pattern, + node, + } + : null; + this.referencingDefaultValue( + pattern, + info.assignments, + maybeImplicitGlobal, + false, + ); + this.currentScope().referenceValue( + pattern, + ReferenceFlag.Write, + node.right, + maybeImplicitGlobal, + false, + ); + }, + { processRightHandNodes: true }, + ); + } + this.visit(node.right); + this.visit(node.body); + + this.close(node); + } + + protected visitFunctionParameterTypeAnnotation( + node: TSESTree.Parameter, + ): void { + if ('typeAnnotation' in node) { + this.visitType(node.typeAnnotation); + } else if (node.type === AST_NODE_TYPES.AssignmentPattern) { + this.visitType(node.left.typeAnnotation); + } else if (node.type === AST_NODE_TYPES.TSParameterProperty) { + this.visitFunctionParameterTypeAnnotation(node.parameter); + } + } + protected visitFunction( + node: + | TSESTree.ArrowFunctionExpression + | TSESTree.FunctionDeclaration + | TSESTree.FunctionExpression + | TSESTree.TSDeclareFunction + | TSESTree.TSEmptyBodyFunctionExpression, + ): void { + // FunctionDeclaration name is defined in upper scope + // NOTE: Not referring variableScope. It is intended. + // Since + // in ES5, FunctionDeclaration should be in FunctionBody. + // in ES6, FunctionDeclaration should be block scoped. + + if (node.type === AST_NODE_TYPES.FunctionExpression) { + if (node.id) { + // FunctionExpression with name creates its special scope; + // FunctionExpressionNameScope. + this.scopeManager.nestFunctionExpressionNameScope(node); + } + } else if (node.id) { + // id is defined in upper scope + this.currentScope().defineIdentifier( + node.id, + new FunctionNameDefinition(node.id, node), + ); + } + + // Consider this function is in the MethodDefinition. + this.scopeManager.nestFunctionScope(node, this.#isInnerMethodDefinition); + + // Process parameter declarations. + for (const param of node.params) { + this.visitPattern( + param, + (pattern, info) => { + this.currentScope().defineIdentifier( + pattern, + new ParameterDefinition(pattern, node, info.rest), + ); + + this.referencingDefaultValue(pattern, info.assignments, null, true); + }, + { processRightHandNodes: true }, + ); + this.visitFunctionParameterTypeAnnotation(param); + param.decorators?.forEach(d => this.visit(d)); + } + + this.visitType(node.returnType); + this.visitType(node.typeParameters); + + // In TypeScript there are a number of function-like constructs which have no body, + // so check it exists before traversing + if (node.body) { + // Skip BlockStatement to prevent creating BlockStatement scope. + if (node.body.type === AST_NODE_TYPES.BlockStatement) { + this.visitChildren(node.body); + } else { + this.visit(node.body); + } + } + + this.close(node); + } + + protected visitProperty( + node: + | TSESTree.ClassProperty + | TSESTree.MethodDefinition + | TSESTree.Property + | TSESTree.TSAbstractClassProperty + | TSESTree.TSAbstractMethodDefinition, + ): void { + let previous; + + if (node.computed) { + this.visit(node.key); + } + + const isMethodDefinition = node.type === AST_NODE_TYPES.MethodDefinition; + if (isMethodDefinition) { + previous = this.pushInnerMethodDefinition(true); + } + this.visit(node.value); + if (isMethodDefinition) { + this.popInnerMethodDefinition(previous); + } + + if ('decorators' in node) { + node.decorators?.forEach(d => this.visit(d)); + } + } + + protected visitType(node: TSESTree.Node | null | undefined): void { + if (!node) { + return; + } + TypeVisitor.visit(this, node); + } + + protected visitTypeAssertion( + node: TSESTree.TSAsExpression | TSESTree.TSTypeAssertion, + ): void { + this.visit(node.expression); + this.visitType(node.typeAnnotation); + } + + ///////////////////// + // Visit selectors // + ///////////////////// + + protected ArrowFunctionExpression( + node: TSESTree.ArrowFunctionExpression, + ): void { + this.visitFunction(node); + } + + protected AssignmentExpression(node: TSESTree.AssignmentExpression): void { + if (PatternVisitor.isPattern(node.left)) { + if (node.operator === '=') { + this.visitPattern( + node.left, + (pattern, info) => { + const maybeImplicitGlobal = !this.currentScope().isStrict + ? { + pattern, + node, + } + : null; + this.referencingDefaultValue( + pattern, + info.assignments, + maybeImplicitGlobal, + false, + ); + this.currentScope().referenceValue( + pattern, + ReferenceFlag.Write, + node.right, + maybeImplicitGlobal, + false, + ); + }, + { processRightHandNodes: true }, + ); + } else if (node.left.type === AST_NODE_TYPES.Identifier) { + this.currentScope().referenceValue( + node.left, + ReferenceFlag.ReadWrite, + node.right, + ); + } + } else { + this.visit(node.left); + } + this.visit(node.right); + } + + protected BlockStatement(node: TSESTree.BlockStatement): void { + if (this.scopeManager.isES6()) { + this.scopeManager.nestBlockScope(node); + } + + this.visitChildren(node); + + this.close(node); + } + + protected BreakStatement(): void { + // don't reference the break statement's label + } + + protected CallExpression( + node: TSESTree.CallExpression | TSESTree.OptionalCallExpression, + ): void { + this.visitChildren(node, ['typeParameters']); + this.visitType(node.typeParameters); + } + + protected CatchClause(node: TSESTree.CatchClause): void { + this.scopeManager.nestCatchScope(node); + + if (node.param) { + const param = node.param; + this.visitPattern( + param, + (pattern, info) => { + this.currentScope().defineIdentifier( + pattern, + new CatchClauseDefinition(param, node), + ); + this.referencingDefaultValue(pattern, info.assignments, null, true); + }, + { processRightHandNodes: true }, + ); + } + this.visit(node.body); + + this.close(node); + } + + protected ClassExpression(node: TSESTree.ClassExpression): void { + this.visitClass(node); + } + + protected ClassDeclaration(node: TSESTree.ClassDeclaration): void { + this.visitClass(node); + } + + protected ClassProperty(node: TSESTree.ClassProperty): void { + this.visitProperty(node); + this.visitType(node.typeAnnotation); + } + + protected ContinueStatement(): void { + // don't reference the continue statement's label + } + + protected ExportAllDeclaration(): void { + // this defines no local variables + } + + protected ExportDefaultDeclaration( + node: TSESTree.ExportDefaultDeclaration, + ): void { + if (node.declaration.type === AST_NODE_TYPES.Identifier) { + ExportVisitor.visit(this, node); + } else { + this.visit(node.declaration); + } + } + + protected ExportNamedDeclaration( + node: TSESTree.ExportNamedDeclaration, + ): void { + if (node.declaration) { + this.visit(node.declaration); + } else { + ExportVisitor.visit(this, node); + } + } + + protected ForInStatement(node: TSESTree.ForInStatement): void { + this.visitForIn(node); + } + + protected ForOfStatement(node: TSESTree.ForOfStatement): void { + this.visitForIn(node); + } + + protected ForStatement(node: TSESTree.ForStatement): void { + // Create ForStatement declaration. + // NOTE: In ES6, ForStatement dynamically generates per iteration environment. However, this is + // a static analyzer, we only generate one scope for ForStatement. + if ( + node.init && + node.init.type === AST_NODE_TYPES.VariableDeclaration && + node.init.kind !== 'var' + ) { + this.scopeManager.nestForScope(node); + } + + this.visitChildren(node); + + this.close(node); + } + + protected FunctionDeclaration(node: TSESTree.FunctionDeclaration): void { + this.visitFunction(node); + } + + protected FunctionExpression(node: TSESTree.FunctionExpression): void { + this.visitFunction(node); + } + + protected Identifier(node: TSESTree.Identifier): void { + this.currentScope().referenceValue(node); + this.visitType(node.typeAnnotation); + } + + protected ImportDeclaration(node: TSESTree.ImportDeclaration): void { + assert( + this.scopeManager.isES6() && this.scopeManager.isModule(), + 'ImportDeclaration should appear when the mode is ES6 and in the module context.', + ); + + ImportVisitor.visit(this, node); + } + + protected LabeledStatement(node: TSESTree.LabeledStatement): void { + this.visit(node.body); + } + + protected MemberExpression( + node: TSESTree.MemberExpression | TSESTree.OptionalMemberExpression, + ): void { + this.visit(node.object); + if (node.computed) { + this.visit(node.property); + } + } + + protected MetaProperty(): void { + // meta properties all builtin globals + } + + protected MethodDefinition(node: TSESTree.MethodDefinition): void { + this.visitProperty(node); + } + + protected NewExpression(node: TSESTree.NewExpression): void { + this.visitChildren(node, ['typeParameters']); + this.visitType(node.typeParameters); + } + + protected OptionalCallExpression( + node: TSESTree.OptionalCallExpression, + ): void { + this.CallExpression(node); + } + + protected OptionalMemberExpression( + node: TSESTree.OptionalMemberExpression, + ): void { + this.MemberExpression(node); + } + + protected Program(node: TSESTree.Program): void { + const globalScope = this.scopeManager.nestGlobalScope(node); + this.populateGlobalsFromLib(globalScope); + + if (this.scopeManager.isGlobalReturn()) { + // Force strictness of GlobalScope to false when using node.js scope. + this.currentScope().isStrict = false; + this.scopeManager.nestFunctionScope(node, false); + } + + if (this.scopeManager.isES6() && this.scopeManager.isModule()) { + this.scopeManager.nestModuleScope(node); + } + + if ( + this.scopeManager.isStrictModeSupported() && + this.scopeManager.isImpliedStrict() + ) { + this.currentScope().isStrict = true; + } + + this.visitChildren(node); + this.close(node); + } + + protected Property(node: TSESTree.Property): void { + this.visitProperty(node); + } + + protected SwitchStatement(node: TSESTree.SwitchStatement): void { + this.visit(node.discriminant); + + if (this.scopeManager.isES6()) { + this.scopeManager.nestSwitchScope(node); + } + + for (const switchCase of node.cases) { + this.visit(switchCase); + } + + this.close(node); + } + + protected TSAbstractClassProperty( + node: TSESTree.TSAbstractClassProperty, + ): void { + this.visitProperty(node); + } + + protected TSAbstractMethodDefinition( + node: TSESTree.TSAbstractMethodDefinition, + ): void { + this.visitProperty(node); + } + + protected TSAsExpression(node: TSESTree.TSAsExpression): void { + this.visitTypeAssertion(node); + } + + protected TSDeclareFunction(node: TSESTree.TSDeclareFunction): void { + this.visitFunction(node); + } + + protected TSImportEqualsDeclaration( + node: TSESTree.TSImportEqualsDeclaration, + ): void { + this.currentScope().defineIdentifier( + node.id, + new ImportBindingDefinition(node.id, node, node), + ); + + if (node.moduleReference.type === AST_NODE_TYPES.TSQualifiedName) { + this.visit(node.moduleReference.left); + } else { + this.visit(node.moduleReference); + } + } + + protected TSEmptyBodyFunctionExpression( + node: TSESTree.TSEmptyBodyFunctionExpression, + ): void { + this.visitFunction(node); + } + + protected TSEnumDeclaration(node: TSESTree.TSEnumDeclaration): void { + this.currentScope().defineIdentifier( + node.id, + new TSEnumNameDefinition(node.id, node), + ); + + // enum members can be referenced within the enum body + this.scopeManager.nestTSEnumScope(node); + + // define the enum name again inside the new enum scope + // references to the enum should not resolve directly to the enum + this.currentScope().defineIdentifier( + node.id, + new TSEnumNameDefinition(node.id, node), + ); + + for (const member of node.members) { + // TS resolves literal named members to be actual names + // enum Foo { + // 'a' = 1, + // b = a, // this references the 'a' member + // } + if ( + member.id.type === AST_NODE_TYPES.Literal && + typeof member.id.value === 'string' + ) { + const name = member.id as TSESTree.StringLiteral; + this.currentScope().defineLiteralIdentifier( + name, + new TSEnumMemberDefinition(name, member), + ); + } else if ( + !member.computed && + member.id.type === AST_NODE_TYPES.Identifier + ) { + this.currentScope().defineIdentifier( + member.id, + new TSEnumMemberDefinition(member.id, member), + ); + } + + this.visit(member.initializer); + } + + this.close(node); + } + + protected TSInterfaceDeclaration( + node: TSESTree.TSInterfaceDeclaration, + ): void { + this.visitType(node); + } + + protected TSModuleDeclaration(node: TSESTree.TSModuleDeclaration): void { + if (node.id.type === AST_NODE_TYPES.Identifier) { + this.currentScope().defineIdentifier( + node.id, + new TSModuleNameDefinition(node.id, node), + ); + } + + this.scopeManager.nestTSModuleScope(node); + + this.visit(node.body); + + this.close(node); + } + + protected TSTypeAliasDeclaration( + node: TSESTree.TSTypeAliasDeclaration, + ): void { + this.visitType(node); + } + + protected TSTypeAssertion(node: TSESTree.TSTypeAssertion): void { + this.visitTypeAssertion(node); + } + + protected UpdateExpression(node: TSESTree.UpdateExpression): void { + if (PatternVisitor.isPattern(node.argument)) { + this.visitPattern(node.argument, pattern => { + this.currentScope().referenceValue( + pattern, + ReferenceFlag.ReadWrite, + null, + ); + }); + } else { + this.visitChildren(node); + } + } + + protected VariableDeclaration(node: TSESTree.VariableDeclaration): void { + const variableTargetScope = + node.kind === 'var' + ? this.currentScope().variableScope + : this.currentScope(); + + for (const decl of node.declarations) { + const init = decl.init; + + this.visitPattern( + decl.id, + (pattern, info) => { + variableTargetScope.defineIdentifier( + pattern, + new VariableDefinition(pattern, decl, node), + ); + + this.referencingDefaultValue(pattern, info.assignments, null, true); + if (init) { + this.currentScope().referenceValue( + pattern, + ReferenceFlag.Write, + init, + null, + true, + ); + } + }, + { processRightHandNodes: true }, + ); + + if (decl.init) { + this.visit(decl.init); + } + + if ('typeAnnotation' in decl.id) { + this.visitType(decl.id.typeAnnotation); + } + } + } + + protected WithStatement(node: TSESTree.WithStatement): void { + this.visit(node.object); + + // Then nest scope for WithStatement. + this.scopeManager.nestWithScope(node); + + this.visit(node.body); + + this.close(node); + } +} + +export { Referencer, ReferencerOptions }; diff --git a/packages/scope-manager/src/referencer/TypeVisitor.ts b/packages/scope-manager/src/referencer/TypeVisitor.ts new file mode 100644 index 00000000000..f4f895279f0 --- /dev/null +++ b/packages/scope-manager/src/referencer/TypeVisitor.ts @@ -0,0 +1,201 @@ +import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/types'; +import { Referencer } from './Referencer'; +import { Visitor } from './Visitor'; +import { ParameterDefinition, TypeDefinition } from '../definition'; + +class TypeVisitor extends Visitor { + readonly #referencer: Referencer; + + constructor(referencer: Referencer) { + super(referencer); + this.#referencer = referencer; + } + + static visit(referencer: Referencer, node: TSESTree.Node): void { + const typeReferencer = new TypeVisitor(referencer); + typeReferencer.visit(node); + } + + /////////////////// + // Visit helpers // + /////////////////// + + protected visitFunctionType( + node: + | TSESTree.TSCallSignatureDeclaration + | TSESTree.TSConstructorType + | TSESTree.TSConstructSignatureDeclaration + | TSESTree.TSFunctionType + | TSESTree.TSMethodSignature, + ): void { + // arguments and type parameters can only be referenced from within the function + this.#referencer.scopeManager.nestFunctionTypeScope(node); + this.visit(node.typeParameters); + + for (const param of node.params) { + this.visitPattern(param, (pattern, info) => { + // a parameter name creates a value type variable which can be referenced later via typeof arg + this.#referencer + .currentScope() + .defineIdentifier( + pattern, + new ParameterDefinition(pattern, node, info.rest), + ); + this.visit(pattern.typeAnnotation); + }); + } + this.visit(node.returnType); + + this.#referencer.close(node); + } + + protected visitPropertyKey( + node: TSESTree.TSMethodSignature | TSESTree.TSPropertySignature, + ): void { + if (!node.computed) { + return; + } + // computed members are treated as value references, and TS expects they have a literal type + this.#referencer.visit(node.key); + } + + ///////////////////// + // Visit selectors // + ///////////////////// + + protected Identifier(node: TSESTree.Identifier): void { + this.#referencer.currentScope().referenceType(node); + } + + protected MemberExpression(node: TSESTree.MemberExpression): void { + this.visit(node.object); + // don't visit the property + } + + protected TSCallSignatureDeclaration( + node: TSESTree.TSCallSignatureDeclaration, + ): void { + this.visitFunctionType(node); + } + + protected TSConditionalType(node: TSESTree.TSConditionalType): void { + // conditional types can define inferred type parameters + // which are only accessible from inside the conditional parameter + this.#referencer.scopeManager.nestConditionalTypeScope(node); + + this.visitChildren(node); + + this.#referencer.close(node); + } + + protected TSConstructorType(node: TSESTree.TSConstructorType): void { + this.visitFunctionType(node); + } + + protected TSConstructSignatureDeclaration( + node: TSESTree.TSConstructSignatureDeclaration, + ): void { + this.visitFunctionType(node); + } + + protected TSFunctionType(node: TSESTree.TSFunctionType): void { + this.visitFunctionType(node); + } + + protected TSIndexSignature(node: TSESTree.TSIndexSignature): void { + for (const param of node.parameters) { + if (param.type === AST_NODE_TYPES.Identifier) { + this.visit(param.typeAnnotation); + } + } + this.visit(node.typeAnnotation); + } + + protected TSInterfaceDeclaration( + node: TSESTree.TSInterfaceDeclaration, + ): void { + this.#referencer + .currentScope() + .defineIdentifier(node.id, new TypeDefinition(node.id, node)); + + if (node.typeParameters) { + // type parameters cannot be referenced from outside their current scope + this.#referencer.scopeManager.nestTypeScope(node); + this.visit(node.typeParameters); + } + + node.extends?.forEach(this.visit, this); + node.implements?.forEach(this.visit, this); + this.visit(node.body); + + if (node.typeParameters) { + this.#referencer.close(node); + } + } + + protected TSMappedType(node: TSESTree.TSMappedType): void { + // mapped types key can only be referenced within their return value + this.#referencer.scopeManager.nestMappedTypeScope(node); + this.visitChildren(node); + this.#referencer.close(node); + } + + protected TSMethodSignature(node: TSESTree.TSMethodSignature): void { + this.visitPropertyKey(node); + this.visitFunctionType(node); + } + + protected TSPropertySignature(node: TSESTree.TSPropertySignature): void { + this.visitPropertyKey(node); + this.visit(node.typeAnnotation); + } + + protected TSQualifiedName(node: TSESTree.TSQualifiedName): void { + this.visit(node.left); + // we don't visit the right as it a name on the thing, not a name to reference + } + + protected TSTypeAliasDeclaration( + node: TSESTree.TSTypeAliasDeclaration, + ): void { + this.#referencer + .currentScope() + .defineIdentifier(node.id, new TypeDefinition(node.id, node)); + + if (node.typeParameters) { + // type parameters cannot be referenced from outside their current scope + this.#referencer.scopeManager.nestTypeScope(node); + this.visit(node.typeParameters); + } + + this.visit(node.typeAnnotation); + + if (node.typeParameters) { + this.#referencer.close(node); + } + } + + protected TSTypeParameter(node: TSESTree.TSTypeParameter): void { + this.#referencer + .currentScope() + .defineIdentifier(node.name, new TypeDefinition(node.name, node)); + + this.visit(node.constraint); + this.visit(node.default); + } + + // a type query `typeof foo` is a special case that references a _non-type_ variable, + protected TSTypeQuery(node: TSESTree.TSTypeQuery): void { + if (node.exprName.type === AST_NODE_TYPES.Identifier) { + this.#referencer.currentScope().referenceValue(node.exprName); + } else { + let expr = node.exprName.left; + while (expr.type !== AST_NODE_TYPES.Identifier) { + expr = expr.left; + } + this.#referencer.currentScope().referenceValue(expr); + } + } +} + +export { TypeVisitor }; diff --git a/packages/scope-manager/src/referencer/Visitor.ts b/packages/scope-manager/src/referencer/Visitor.ts new file mode 100644 index 00000000000..a3e1e989d51 --- /dev/null +++ b/packages/scope-manager/src/referencer/Visitor.ts @@ -0,0 +1,44 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { VisitorBase, VisitorOptions } from './VisitorBase'; +import { + PatternVisitor, + PatternVisitorCallback, + PatternVisitorOptions, +} from './PatternVisitor'; + +interface VisitPatternOptions extends PatternVisitorOptions { + processRightHandNodes?: boolean; +} +class Visitor extends VisitorBase { + readonly #options: VisitorOptions; + constructor(optionsOrVisitor: VisitorOptions | Visitor) { + super( + optionsOrVisitor instanceof Visitor + ? optionsOrVisitor.#options + : optionsOrVisitor, + ); + + this.#options = + optionsOrVisitor instanceof Visitor + ? optionsOrVisitor.#options + : optionsOrVisitor; + } + + protected visitPattern( + node: TSESTree.Node, + callback: PatternVisitorCallback, + options: VisitPatternOptions = { processRightHandNodes: false }, + ): void { + // Call the callback at left hand identifier nodes, and Collect right hand nodes. + const visitor = new PatternVisitor(this.#options, node, callback); + + visitor.visit(node); + + // Process the right hand nodes recursively. + if (options.processRightHandNodes) { + visitor.rightHandNodes.forEach(this.visit, this); + } + } +} + +export { Visitor, VisitorBase, VisitorOptions }; diff --git a/packages/scope-manager/src/referencer/VisitorBase.ts b/packages/scope-manager/src/referencer/VisitorBase.ts new file mode 100644 index 00000000000..0d37ac31e35 --- /dev/null +++ b/packages/scope-manager/src/referencer/VisitorBase.ts @@ -0,0 +1,79 @@ +import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/types'; +import { visitorKeys, VisitorKeys } from '@typescript-eslint/visitor-keys'; + +interface VisitorOptions { + childVisitorKeys?: VisitorKeys | null; +} + +function isObject(obj: unknown): obj is Record { + return typeof obj === 'object' && obj != null; +} +function isNode(node: unknown): node is TSESTree.Node { + return isObject(node) && typeof node.type === 'string'; +} + +type NodeVisitor = { + [K in AST_NODE_TYPES]?: (node: TSESTree.Node) => void; +}; + +abstract class VisitorBase { + readonly #childVisitorKeys: VisitorKeys; + constructor(options: VisitorOptions) { + this.#childVisitorKeys = options.childVisitorKeys ?? visitorKeys; + } + + /** + * Default method for visiting children. + * @param node the node whose children should be visited + * @param exclude a list of keys to not visit + */ + visitChildren( + node: T | null | undefined, + excludeArr?: (keyof T)[], + ): void { + if (node == null || node.type == null) { + return; + } + + const exclude = new Set(excludeArr) as Set; + const children = this.#childVisitorKeys[node.type] ?? Object.keys(node); + for (const key of children) { + if (exclude.has(key)) { + continue; + } + + const child = node[key as keyof TSESTree.Node] as unknown; + if (!child) { + continue; + } + + if (Array.isArray(child)) { + for (const subChild of child) { + if (isNode(subChild)) { + this.visit(subChild); + } + } + } else if (isNode(child)) { + this.visit(child); + } + } + } + + /** + * Dispatching node. + */ + visit(node: TSESTree.Node | null | undefined): void { + if (node == null || node.type == null) { + return; + } + + const visitor = (this as NodeVisitor)[node.type]; + if (visitor) { + return visitor.call(this, node); + } + + this.visitChildren(node); + } +} + +export { VisitorBase, VisitorOptions, VisitorKeys }; diff --git a/packages/scope-manager/src/referencer/index.ts b/packages/scope-manager/src/referencer/index.ts new file mode 100644 index 00000000000..6ac29bd3e0e --- /dev/null +++ b/packages/scope-manager/src/referencer/index.ts @@ -0,0 +1 @@ +export { Referencer, ReferencerOptions } from './Referencer'; diff --git a/packages/scope-manager/src/scope/BlockScope.ts b/packages/scope-manager/src/scope/BlockScope.ts new file mode 100644 index 00000000000..959044282c2 --- /dev/null +++ b/packages/scope-manager/src/scope/BlockScope.ts @@ -0,0 +1,21 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class BlockScope extends ScopeBase< + ScopeType.block, + TSESTree.BlockStatement, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: BlockScope['upper'], + block: BlockScope['block'], + ) { + super(scopeManager, ScopeType.block, upperScope, block, false); + } +} + +export { BlockScope }; diff --git a/packages/scope-manager/src/scope/CatchScope.ts b/packages/scope-manager/src/scope/CatchScope.ts new file mode 100644 index 00000000000..46b4005f3ac --- /dev/null +++ b/packages/scope-manager/src/scope/CatchScope.ts @@ -0,0 +1,21 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class CatchScope extends ScopeBase< + ScopeType.catch, + TSESTree.CatchClause, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: CatchScope['upper'], + block: CatchScope['block'], + ) { + super(scopeManager, ScopeType.catch, upperScope, block, false); + } +} + +export { CatchScope }; diff --git a/packages/scope-manager/src/scope/ClassScope.ts b/packages/scope-manager/src/scope/ClassScope.ts new file mode 100644 index 00000000000..ee28a31aa08 --- /dev/null +++ b/packages/scope-manager/src/scope/ClassScope.ts @@ -0,0 +1,21 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class ClassScope extends ScopeBase< + ScopeType.class, + TSESTree.ClassDeclaration | TSESTree.ClassExpression, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: ClassScope['upper'], + block: ClassScope['block'], + ) { + super(scopeManager, ScopeType.class, upperScope, block, false); + } +} + +export { ClassScope }; diff --git a/packages/scope-manager/src/scope/ConditionalTypeScope.ts b/packages/scope-manager/src/scope/ConditionalTypeScope.ts new file mode 100644 index 00000000000..c20f1217e0e --- /dev/null +++ b/packages/scope-manager/src/scope/ConditionalTypeScope.ts @@ -0,0 +1,21 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class ConditionalTypeScope extends ScopeBase< + ScopeType.conditionalType, + TSESTree.TSConditionalType, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: ConditionalTypeScope['upper'], + block: ConditionalTypeScope['block'], + ) { + super(scopeManager, ScopeType.conditionalType, upperScope, block, false); + } +} + +export { ConditionalTypeScope }; diff --git a/packages/scope-manager/src/scope/ForScope.ts b/packages/scope-manager/src/scope/ForScope.ts new file mode 100644 index 00000000000..36703b5d197 --- /dev/null +++ b/packages/scope-manager/src/scope/ForScope.ts @@ -0,0 +1,21 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class ForScope extends ScopeBase< + ScopeType.for, + TSESTree.ForInStatement | TSESTree.ForOfStatement | TSESTree.ForStatement, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: ForScope['upper'], + block: ForScope['block'], + ) { + super(scopeManager, ScopeType.for, upperScope, block, false); + } +} + +export { ForScope }; diff --git a/packages/scope-manager/src/scope/FunctionExpressionNameScope.ts b/packages/scope-manager/src/scope/FunctionExpressionNameScope.ts new file mode 100644 index 00000000000..a84bc4b2c8d --- /dev/null +++ b/packages/scope-manager/src/scope/FunctionExpressionNameScope.ts @@ -0,0 +1,36 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { Scope } from './Scope'; +import { FunctionNameDefinition } from '../definition'; +import { ScopeManager } from '../ScopeManager'; + +class FunctionExpressionNameScope extends ScopeBase< + ScopeType.functionExpressionName, + TSESTree.FunctionExpression, + Scope +> { + public readonly functionExpressionScope: true; + constructor( + scopeManager: ScopeManager, + upperScope: FunctionExpressionNameScope['upper'], + block: FunctionExpressionNameScope['block'], + ) { + super( + scopeManager, + ScopeType.functionExpressionName, + upperScope, + block, + false, + ); + if (block.id) { + this.defineIdentifier( + block.id, + new FunctionNameDefinition(block.id, block), + ); + } + this.functionExpressionScope = true; + } +} + +export { FunctionExpressionNameScope }; diff --git a/packages/scope-manager/src/scope/FunctionScope.ts b/packages/scope-manager/src/scope/FunctionScope.ts new file mode 100644 index 00000000000..18e12321374 --- /dev/null +++ b/packages/scope-manager/src/scope/FunctionScope.ts @@ -0,0 +1,65 @@ +import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { Reference } from '../referencer/Reference'; +import { ScopeManager } from '../ScopeManager'; +import { Variable } from '../variable'; + +class FunctionScope extends ScopeBase< + ScopeType.function, + | TSESTree.ArrowFunctionExpression + | TSESTree.FunctionDeclaration + | TSESTree.FunctionExpression + | TSESTree.TSDeclareFunction + | TSESTree.TSEmptyBodyFunctionExpression + | TSESTree.Program, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: FunctionScope['upper'], + block: FunctionScope['block'], + isMethodDefinition: boolean, + ) { + super( + scopeManager, + ScopeType.function, + upperScope, + block, + isMethodDefinition, + ); + + // section 9.2.13, FunctionDeclarationInstantiation. + // NOTE Arrow functions never have an arguments objects. + if (this.block.type !== AST_NODE_TYPES.ArrowFunctionExpression) { + this.defineVariable('arguments', this.set, this.variables, null, null); + } + } + + // References in default parameters isn't resolved to variables which are in their function body. + // const x = 1 + // function f(a = x) { // This `x` is resolved to the `x` in the outer scope. + // const x = 2 + // console.log(a) + // } + protected isValidResolution(ref: Reference, variable: Variable): boolean { + // If `options.gloablReturn` is true, `this.block` becomes a Program node. + if (this.block.type === AST_NODE_TYPES.Program) { + return true; + } + + const bodyStart = this.block.body?.range[0] ?? -1; + + // It's invalid resolution in the following case: + return !( + ( + variable.scope === this && + ref.identifier.range[0] < bodyStart && // the reference is in the parameter part. + variable.defs.every(d => d.name.range[0] >= bodyStart) + ) // the variable is in the body. + ); + } +} + +export { FunctionScope }; diff --git a/packages/scope-manager/src/scope/FunctionTypeScope.ts b/packages/scope-manager/src/scope/FunctionTypeScope.ts new file mode 100644 index 00000000000..d459070cdf8 --- /dev/null +++ b/packages/scope-manager/src/scope/FunctionTypeScope.ts @@ -0,0 +1,25 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class FunctionTypeScope extends ScopeBase< + ScopeType.functionType, + | TSESTree.TSCallSignatureDeclaration + | TSESTree.TSConstructorType + | TSESTree.TSConstructSignatureDeclaration + | TSESTree.TSFunctionType + | TSESTree.TSMethodSignature, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: FunctionTypeScope['upper'], + block: FunctionTypeScope['block'], + ) { + super(scopeManager, ScopeType.functionType, upperScope, block, false); + } +} + +export { FunctionTypeScope }; diff --git a/packages/scope-manager/src/scope/GlobalScope.ts b/packages/scope-manager/src/scope/GlobalScope.ts new file mode 100644 index 00000000000..3da909c1cee --- /dev/null +++ b/packages/scope-manager/src/scope/GlobalScope.ts @@ -0,0 +1,78 @@ +import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { assert } from '../assert'; +import { ImplicitGlobalVariableDefinition } from '../definition/ImplicitGlobalVariableDefinition'; +import { Reference } from '../referencer/Reference'; +import { ScopeManager } from '../ScopeManager'; +import { + Variable, + ImplicitLibVariable, + ImplicitLibVariableOptions, +} from '../variable'; + +class GlobalScope extends ScopeBase< + ScopeType.global, + TSESTree.Program, + /** + * The global scope has no parent. + */ + null +> { + // note this is accessed in used in the legacy eslint-scope tests, so it can't be true private + private readonly implicit: { + readonly set: Map; + readonly variables: Variable[]; + /** + * List of {@link Reference}s that are left to be resolved (i.e. which + * need to be linked to the variable they refer to). + */ + leftToBeResolved: Reference[]; + }; + + constructor(scopeManager: ScopeManager, block: GlobalScope['block']) { + super(scopeManager, ScopeType.global, null, block, false); + this.implicit = { + set: new Map(), + variables: [], + leftToBeResolved: [], + }; + } + + public defineImplicitVariable(options: ImplicitLibVariableOptions): void { + this.defineVariable( + new ImplicitLibVariable(this, options), + this.set, + this.variables, + null, + null, + ); + } + + public close(scopeManager: ScopeManager): Scope | null { + assert(this.leftToResolve); + + for (const ref of this.leftToResolve) { + if (ref.maybeImplicitGlobal && !this.set.has(ref.identifier.name)) { + // create an implicit global variable from assignment expression + const info = ref.maybeImplicitGlobal; + const node = info.pattern; + if (node && node.type === AST_NODE_TYPES.Identifier) { + this.defineVariable( + node.name, + this.implicit.set, + this.implicit.variables, + node, + new ImplicitGlobalVariableDefinition(info.pattern, info.node), + ); + } + } + } + + this.implicit.leftToBeResolved = this.leftToResolve; + return super.close(scopeManager); + } +} + +export { GlobalScope }; diff --git a/packages/scope-manager/src/scope/MappedTypeScope.ts b/packages/scope-manager/src/scope/MappedTypeScope.ts new file mode 100644 index 00000000000..9b5c2a05d4b --- /dev/null +++ b/packages/scope-manager/src/scope/MappedTypeScope.ts @@ -0,0 +1,21 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class MappedTypeScope extends ScopeBase< + ScopeType.mappedType, + TSESTree.TSMappedType, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: MappedTypeScope['upper'], + block: MappedTypeScope['block'], + ) { + super(scopeManager, ScopeType.mappedType, upperScope, block, false); + } +} + +export { MappedTypeScope }; diff --git a/packages/scope-manager/src/scope/ModuleScope.ts b/packages/scope-manager/src/scope/ModuleScope.ts new file mode 100644 index 00000000000..87c5ab52830 --- /dev/null +++ b/packages/scope-manager/src/scope/ModuleScope.ts @@ -0,0 +1,17 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class ModuleScope extends ScopeBase { + constructor( + scopeManager: ScopeManager, + upperScope: ModuleScope['upper'], + block: ModuleScope['block'], + ) { + super(scopeManager, ScopeType.module, upperScope, block, false); + } +} + +export { ModuleScope }; diff --git a/packages/scope-manager/src/scope/Scope.ts b/packages/scope-manager/src/scope/Scope.ts new file mode 100644 index 00000000000..7df3f941629 --- /dev/null +++ b/packages/scope-manager/src/scope/Scope.ts @@ -0,0 +1,36 @@ +import { BlockScope } from './BlockScope'; +import { CatchScope } from './CatchScope'; +import { ClassScope } from './ClassScope'; +import { ConditionalTypeScope } from './ConditionalTypeScope'; +import { ForScope } from './ForScope'; +import { FunctionExpressionNameScope } from './FunctionExpressionNameScope'; +import { FunctionScope } from './FunctionScope'; +import { FunctionTypeScope } from './FunctionTypeScope'; +import { GlobalScope } from './GlobalScope'; +import { MappedTypeScope } from './MappedTypeScope'; +import { ModuleScope } from './ModuleScope'; +import { SwitchScope } from './SwitchScope'; +import { TSEnumScope } from './TSEnumScope'; +import { TSModuleScope } from './TSModuleScope'; +import { TypeScope } from './TypeScope'; +import { WithScope } from './WithScope'; + +type Scope = + | BlockScope + | CatchScope + | ClassScope + | ConditionalTypeScope + | ForScope + | FunctionExpressionNameScope + | FunctionScope + | FunctionTypeScope + | GlobalScope + | MappedTypeScope + | ModuleScope + | SwitchScope + | TSEnumScope + | TSModuleScope + | TypeScope + | WithScope; + +export { Scope }; diff --git a/packages/scope-manager/src/scope/ScopeBase.ts b/packages/scope-manager/src/scope/ScopeBase.ts new file mode 100644 index 00000000000..cc38cdb3f97 --- /dev/null +++ b/packages/scope-manager/src/scope/ScopeBase.ts @@ -0,0 +1,500 @@ +import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/types'; +import { FunctionScope } from './FunctionScope'; +import { GlobalScope } from './GlobalScope'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; +import { Scope } from './Scope'; +import { ModuleScope } from './ModuleScope'; +import { assert } from '../assert'; +import { Definition, DefinitionType } from '../definition'; +import { createIdGenerator } from '../ID'; +import { + Reference, + ReferenceFlag, + ReferenceImplicitGlobal, + ReferenceTypeFlag, +} from '../referencer/Reference'; +import { Variable } from '../variable'; + +/** + * Test if scope is strict + */ +function isStrictScope( + scope: Scope, + block: TSESTree.Node, + isMethodDefinition: boolean, +): boolean { + let body: TSESTree.BlockStatement | TSESTree.Program | null | undefined; + + // When upper scope is exists and strict, inner scope is also strict. + if (scope.upper?.isStrict) { + return true; + } + + if (isMethodDefinition) { + return true; + } + + if ( + scope.type === ScopeType.class || + scope.type === ScopeType.conditionalType || + scope.type === ScopeType.functionType || + scope.type === ScopeType.mappedType || + scope.type === ScopeType.module || + scope.type === ScopeType.tsEnum || + scope.type === ScopeType.tsModule || + scope.type === ScopeType.type + ) { + return true; + } + + if (scope.type === ScopeType.block || scope.type === ScopeType.switch) { + return false; + } + + if (scope.type === ScopeType.function) { + const functionBody = block as FunctionScope['block']; + switch (functionBody.type) { + case AST_NODE_TYPES.ArrowFunctionExpression: + if (functionBody.body.type !== AST_NODE_TYPES.BlockStatement) { + return false; + } + body = functionBody.body; + break; + + case AST_NODE_TYPES.Program: + body = functionBody; + break; + + default: + body = functionBody.body; + } + + if (!body) { + return false; + } + } else if (scope.type === ScopeType.global) { + body = block as GlobalScope['block']; + } else { + return false; + } + + // Search 'use strict' directive. + for (let i = 0; i < body.body.length; ++i) { + const stmt = body.body[i]; + + if (stmt.type !== AST_NODE_TYPES.ExpressionStatement) { + break; + } + const expr = stmt.expression; + + if ( + expr.type !== AST_NODE_TYPES.Literal || + typeof expr.value !== 'string' + ) { + break; + } + if (expr.raw !== null && expr.raw !== undefined) { + if (expr.raw === '"use strict"' || expr.raw === "'use strict'") { + return true; + } + } else { + if (expr.value === 'use strict') { + return true; + } + } + } + return false; +} + +/** + * Register scope + */ +function registerScope(scopeManager: ScopeManager, scope: Scope): void { + scopeManager.scopes.push(scope); + + const scopes = scopeManager.nodeToScope.get(scope.block); + + if (scopes) { + scopes.push(scope); + } else { + scopeManager.nodeToScope.set(scope.block, [scope]); + } +} + +const generator = createIdGenerator(); + +type AnyScope = ScopeBase; +abstract class ScopeBase< + TType extends ScopeType, + TBlock extends TSESTree.Node, + TUpper extends Scope | null +> { + /** + * A unique ID for this instance - primarily used to help debugging and testing + */ + public readonly $id: number = generator(); + + /** + * The AST node which created this scope. + * @public + */ + public readonly block: TBlock; + /** + * The array of child scopes. This does not include grandchild scopes. + * @public + */ + public readonly childScopes: Scope[] = []; + /** + * A map of the variables for each node in this scope. + * This is map is a pointer to the one in the parent ScopeManager instance + */ + readonly #declaredVariables: WeakMap; + /** + * Generally, through the lexical scoping of JS you can always know which variable an identifier in the source code + * refers to. There are a few exceptions to this rule. With `global` and `with` scopes you can only decide at runtime + * which variable a reference refers to. + * All those scopes are considered "dynamic". + */ + #dynamic: boolean; + /** + * Whether this scope is created by a FunctionExpression. + * @public + */ + public readonly functionExpressionScope: boolean = false; + /** + * Whether 'use strict' is in effect in this scope. + * @public + */ + public isStrict: boolean; + /** + * List of {@link Reference}s that are left to be resolved (i.e. which + * need to be linked to the variable they refer to). + */ + protected leftToResolve: Reference[] | null = []; + /** + * Any variable {@link Reference} found in this scope. + * This includes occurrences of local variables as well as variables from parent scopes (including the global scope). + * For local variables this also includes defining occurrences (like in a 'var' statement). + * In a 'function' scope this does not include the occurrences of the formal parameter in the parameter list. + * @public + */ + public readonly references: Reference[] = []; + /** + * The map from variable names to variable objects. + * @public + */ + public readonly set = new Map(); + /** + * The {@link Reference}s that are not resolved with this scope. + * @public + */ + public readonly through: Reference[] = []; + /** + * The type of scope + * @public + */ + public readonly type: TType; + /** + * Reference to the parent {@link Scope}. + * @public + */ + public readonly upper: TUpper; + /** + * The scoped {@link Variable}s of this scope. + * In the case of a 'function' scope this includes the automatic argument `arguments` as its first element, as well + * as all further formal arguments. + * This does not include variables which are defined in child scopes. + * @public + */ + public readonly variables: Variable[] = []; + /** + * For 'global', 'function', and 'module' scopes, this is a self-reference. + * For other scope types this is the *variableScope* value of the parent scope. + * @public + */ + public readonly variableScope: GlobalScope | FunctionScope | ModuleScope; + + constructor( + scopeManager: ScopeManager, + type: TType, + upperScope: TUpper, + block: TBlock, + isMethodDefinition: boolean, + ) { + const upperScopeAsScopeBase = upperScope as Scope; + + this.type = type; + this.#dynamic = + this.type === ScopeType.global || this.type === ScopeType.with; + this.block = block; + this.variableScope = + this.type === 'global' || + this.type === 'function' || + this.type === 'module' + ? (this as AnyScope['variableScope']) + : upperScopeAsScopeBase.variableScope; + this.upper = upperScope; + + /** + * Whether 'use strict' is in effect in this scope. + * @member {boolean} Scope#isStrict + */ + this.isStrict = isStrictScope(this as Scope, block, isMethodDefinition); + + if (upperScopeAsScopeBase) { + // this is guaranteed to be correct at runtime + upperScopeAsScopeBase.childScopes.push(this as Scope); + } + + this.#declaredVariables = scopeManager.declaredVariables; + + registerScope(scopeManager, this as Scope); + } + + public shouldStaticallyClose(): boolean { + return !this.#dynamic; + } + + private shouldStaticallyCloseForGlobal( + ref: Reference, + scopeManager: ScopeManager, + ): boolean { + // On global scope, let/const/class declarations should be resolved statically. + const name = ref.identifier.name; + + const variable = this.set.get(name); + if (!variable) { + return false; + } + // variable exists on the scope + + // in module mode, we can statically resolve everything, regardless of its decl type + if (scopeManager.isModule()) { + return true; + } + + // in script mode, only certain cases should be statically resolved + // Example: + // a `var` decl is ignored by the runtime if it clashes with a global name + // this means that we should not resolve the reference to the variable + const defs = variable.defs; + return ( + defs.length > 0 && + defs.every(def => { + if ( + def.type === DefinitionType.Variable && + def.parent?.type === AST_NODE_TYPES.VariableDeclaration && + def.parent.kind === 'var' + ) { + return false; + } + return true; + }) + ); + } + + #staticCloseRef = (ref: Reference): void => { + const resolve = (): boolean => { + const name = ref.identifier.name; + const variable = this.set.get(name); + + if (!variable) { + return false; + } + + if (!this.isValidResolution(ref, variable)) { + return false; + } + + // make sure we don't match a type reference to a value variable + const isValidTypeReference = + ref.isTypeReference && variable.isTypeVariable; + const isValidValueReference = + ref.isValueReference && variable.isValueVariable; + if (!isValidTypeReference && !isValidValueReference) { + return false; + } + + variable.references.push(ref); + ref.resolved = variable; + + return true; + }; + + if (!resolve()) { + this.delegateToUpperScope(ref); + } + }; + + #dynamicCloseRef = (ref: Reference): void => { + // notify all names are through to global + let current = this as Scope | null; + + do { + current!.through.push(ref); + current = current!.upper; + } while (current); + }; + + #globalCloseRef = (ref: Reference, scopeManager: ScopeManager): void => { + // let/const/class declarations should be resolved statically. + // others should be resolved dynamically. + if (this.shouldStaticallyCloseForGlobal(ref, scopeManager)) { + this.#staticCloseRef(ref); + } else { + this.#dynamicCloseRef(ref); + } + }; + + public close(scopeManager: ScopeManager): Scope | null { + let closeRef; + + if (this.shouldStaticallyClose()) { + closeRef = this.#staticCloseRef; + } else if (this.type !== 'global') { + closeRef = this.#dynamicCloseRef; + } else { + closeRef = this.#globalCloseRef; + } + + // Try Resolving all references in this scope. + assert(this.leftToResolve); + for (let i = 0; i < this.leftToResolve.length; ++i) { + const ref = this.leftToResolve[i]; + + closeRef(ref, scopeManager); + } + this.leftToResolve = null; + + return this.upper; + } + + /** + * To override by function scopes. + * References in default parameters isn't resolved to variables which are in their function body. + */ + protected isValidResolution(_ref: Reference, _variable: Variable): boolean { + return true; + } + + protected delegateToUpperScope(ref: Reference): void { + const upper = (this.upper as Scope) as AnyScope; + if (upper?.leftToResolve) { + upper.leftToResolve.push(ref); + } + this.through.push(ref); + } + + private addDeclaredVariablesOfNode( + variable: Variable, + node: TSESTree.Node | null | undefined, + ): void { + if (node == null) { + return; + } + + let variables = this.#declaredVariables.get(node); + + if (variables == null) { + variables = []; + this.#declaredVariables.set(node, variables); + } + if (!variables.includes(variable)) { + variables.push(variable); + } + } + + protected defineVariable( + nameOrVariable: string | Variable, + set: Map, + variables: Variable[], + node: TSESTree.Identifier | null, + def: Definition | null, + ): void { + const name = + typeof nameOrVariable === 'string' ? nameOrVariable : nameOrVariable.name; + let variable = set.get(name); + if (!variable) { + variable = + typeof nameOrVariable === 'string' + ? new Variable(name, this as Scope) + : nameOrVariable; + set.set(name, variable); + variables.push(variable); + } + + if (def) { + variable.defs.push(def); + this.addDeclaredVariablesOfNode(variable, def.node); + this.addDeclaredVariablesOfNode(variable, def.parent); + } + if (node) { + variable.identifiers.push(node); + } + } + + public defineIdentifier(node: TSESTree.Identifier, def: Definition): void { + this.defineVariable(node.name, this.set, this.variables, node, def); + } + + public defineLiteralIdentifier( + node: TSESTree.StringLiteral, + def: Definition, + ): void { + this.defineVariable(node.value, this.set, this.variables, null, def); + } + + public referenceValue( + node: TSESTree.Identifier, + assign: ReferenceFlag = ReferenceFlag.Read, + writeExpr?: TSESTree.Expression | null, + maybeImplicitGlobal?: ReferenceImplicitGlobal | null, + init = false, + ): void { + const ref = new Reference( + node, + this as Scope, + assign, + writeExpr, + maybeImplicitGlobal, + init, + ReferenceTypeFlag.Value, + ); + + this.references.push(ref); + this.leftToResolve?.push(ref); + } + + public referenceType(node: TSESTree.Identifier): void { + const ref = new Reference( + node, + this as Scope, + ReferenceFlag.Read, + null, + null, + false, + ReferenceTypeFlag.Type, + ); + + this.references.push(ref); + this.leftToResolve?.push(ref); + } + + public referenceDualValueType(node: TSESTree.Identifier): void { + const ref = new Reference( + node, + this as Scope, + ReferenceFlag.Read, + null, + null, + false, + ReferenceTypeFlag.Type | ReferenceTypeFlag.Value, + ); + + this.references.push(ref); + this.leftToResolve?.push(ref); + } +} + +export { ScopeBase }; diff --git a/packages/scope-manager/src/scope/ScopeType.ts b/packages/scope-manager/src/scope/ScopeType.ts new file mode 100644 index 00000000000..23d70fedbe8 --- /dev/null +++ b/packages/scope-manager/src/scope/ScopeType.ts @@ -0,0 +1,20 @@ +enum ScopeType { + block = 'block', + catch = 'catch', + class = 'class', + conditionalType = 'conditionalType', + for = 'for', + function = 'function', + functionExpressionName = 'function-expression-name', + functionType = 'functionType', + global = 'global', + mappedType = 'mappedType', + module = 'module', + switch = 'switch', + tsEnum = 'tsEnum', + tsModule = 'tsModule', + type = 'type', + with = 'with', +} + +export { ScopeType }; diff --git a/packages/scope-manager/src/scope/SwitchScope.ts b/packages/scope-manager/src/scope/SwitchScope.ts new file mode 100644 index 00000000000..7a684564cd4 --- /dev/null +++ b/packages/scope-manager/src/scope/SwitchScope.ts @@ -0,0 +1,21 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class SwitchScope extends ScopeBase< + ScopeType.switch, + TSESTree.SwitchStatement, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: SwitchScope['upper'], + block: SwitchScope['block'], + ) { + super(scopeManager, ScopeType.switch, upperScope, block, false); + } +} + +export { SwitchScope }; diff --git a/packages/scope-manager/src/scope/TSEnumScope.ts b/packages/scope-manager/src/scope/TSEnumScope.ts new file mode 100644 index 00000000000..3962784acd2 --- /dev/null +++ b/packages/scope-manager/src/scope/TSEnumScope.ts @@ -0,0 +1,21 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class TSEnumScope extends ScopeBase< + ScopeType.tsEnum, + TSESTree.TSEnumDeclaration, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: TSEnumScope['upper'], + block: TSEnumScope['block'], + ) { + super(scopeManager, ScopeType.tsEnum, upperScope, block, false); + } +} + +export { TSEnumScope }; diff --git a/packages/scope-manager/src/scope/TSModuleScope.ts b/packages/scope-manager/src/scope/TSModuleScope.ts new file mode 100644 index 00000000000..bdc7c7dc329 --- /dev/null +++ b/packages/scope-manager/src/scope/TSModuleScope.ts @@ -0,0 +1,21 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class TSModuleScope extends ScopeBase< + ScopeType.tsModule, + TSESTree.TSModuleDeclaration, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: TSModuleScope['upper'], + block: TSModuleScope['block'], + ) { + super(scopeManager, ScopeType.tsModule, upperScope, block, false); + } +} + +export { TSModuleScope }; diff --git a/packages/scope-manager/src/scope/TypeScope.ts b/packages/scope-manager/src/scope/TypeScope.ts new file mode 100644 index 00000000000..7f21a60f22b --- /dev/null +++ b/packages/scope-manager/src/scope/TypeScope.ts @@ -0,0 +1,21 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { ScopeManager } from '../ScopeManager'; + +class TypeScope extends ScopeBase< + ScopeType.type, + TSESTree.TSInterfaceDeclaration | TSESTree.TSTypeAliasDeclaration, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: TypeScope['upper'], + block: TypeScope['block'], + ) { + super(scopeManager, ScopeType.type, upperScope, block, false); + } +} + +export { TypeScope }; diff --git a/packages/scope-manager/src/scope/WithScope.ts b/packages/scope-manager/src/scope/WithScope.ts new file mode 100644 index 00000000000..84a3e4c76ff --- /dev/null +++ b/packages/scope-manager/src/scope/WithScope.ts @@ -0,0 +1,34 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Scope } from './Scope'; +import { ScopeBase } from './ScopeBase'; +import { ScopeType } from './ScopeType'; +import { assert } from '../assert'; +import { ScopeManager } from '../ScopeManager'; + +class WithScope extends ScopeBase< + ScopeType.with, + TSESTree.WithStatement, + Scope +> { + constructor( + scopeManager: ScopeManager, + upperScope: WithScope['upper'], + block: WithScope['block'], + ) { + super(scopeManager, ScopeType.with, upperScope, block, false); + } + close(scopeManager: ScopeManager): Scope | null { + if (this.shouldStaticallyClose()) { + return super.close(scopeManager); + } + assert(this.leftToResolve); + for (let i = 0; i < this.leftToResolve.length; ++i) { + const ref = this.leftToResolve[i]; + this.delegateToUpperScope(ref); + } + this.leftToResolve = null; + return this.upper; + } +} + +export { WithScope }; diff --git a/packages/scope-manager/src/scope/index.ts b/packages/scope-manager/src/scope/index.ts new file mode 100644 index 00000000000..8e4683dbe68 --- /dev/null +++ b/packages/scope-manager/src/scope/index.ts @@ -0,0 +1,18 @@ +export * from './BlockScope'; +export * from './CatchScope'; +export * from './ClassScope'; +export * from './ConditionalTypeScope'; +export * from './ForScope'; +export * from './FunctionExpressionNameScope'; +export * from './FunctionScope'; +export * from './FunctionTypeScope'; +export * from './GlobalScope'; +export * from './MappedTypeScope'; +export * from './ModuleScope'; +export * from './Scope'; +export * from './ScopeType'; +export * from './SwitchScope'; +export * from './TSEnumScope'; +export * from './TSModuleScope'; +export * from './TypeScope'; +export * from './WithScope'; diff --git a/packages/scope-manager/src/variable/ESLintScopeVariable.ts b/packages/scope-manager/src/variable/ESLintScopeVariable.ts new file mode 100644 index 00000000000..b40bb1c9026 --- /dev/null +++ b/packages/scope-manager/src/variable/ESLintScopeVariable.ts @@ -0,0 +1,38 @@ +import { VariableBase } from './VariableBase'; +import { TSESTree } from '@typescript-eslint/types'; + +/** + * ESLint defines global variables using the eslint-scope Variable class + * This is declared her for consumers to use + */ +class ESLintScopeVariable extends VariableBase { + /** + * Written to by ESLint. + * If this key exists, this variable is a global variable added by ESLint. + * If this is `true`, this variable can be assigned arbitrary values. + * If this is `false`, this variable is readonly. + */ + public writeable?: boolean; // note that this isn't a typo - ESlint uses this spelling here + + /** + * Written to by ESLint. + * This property is undefined if there are no globals directive comments. + * The array of globals directive comments which defined this global variable in the source code file. + */ + public eslintExplicitGlobal?: boolean; + + /** + * Written to by ESLint. + * The configured value in config files. This can be different from `variable.writeable` if there are globals directive comments. + */ + public eslintImplicitGlobalSetting?: 'readonly' | 'writable'; + + /** + * Written to by ESLint. + * If this key exists, it is a global variable added by ESLint. + * If `true`, this global variable was defined by a globals directive comment in the source code file. + */ + public eslintExplicitGlobalComments?: TSESTree.Comment[]; +} + +export { ESLintScopeVariable }; diff --git a/packages/scope-manager/src/variable/ImplicitLibVariable.ts b/packages/scope-manager/src/variable/ImplicitLibVariable.ts new file mode 100644 index 00000000000..ee3d69995d7 --- /dev/null +++ b/packages/scope-manager/src/variable/ImplicitLibVariable.ts @@ -0,0 +1,46 @@ +import { ESLintScopeVariable } from './ESLintScopeVariable'; +import { Variable } from './Variable'; +import { Scope } from '../scope'; + +interface ImplicitLibVariableOptions { + readonly eslintImplicitGlobalSetting?: ESLintScopeVariable['eslintImplicitGlobalSetting']; + readonly isTypeVariable?: boolean; + readonly isValueVariable?: boolean; + readonly name: string; + readonly writeable?: boolean; +} + +/** + * An variable implicitly defined by the TS Lib + */ +class ImplicitLibVariable extends ESLintScopeVariable implements Variable { + /** + * `true` if the variable is valid in a type context, false otherwise + */ + public readonly isTypeVariable: boolean; + + /** + * `true` if the variable is valid in a value context, false otherwise + */ + public readonly isValueVariable: boolean; + + public constructor( + scope: Scope, + { + isTypeVariable, + isValueVariable, + name, + writeable, + eslintImplicitGlobalSetting, + }: ImplicitLibVariableOptions, + ) { + super(name, scope); + this.isTypeVariable = isTypeVariable ?? false; + this.isValueVariable = isValueVariable ?? false; + this.writeable = writeable ?? false; + this.eslintImplicitGlobalSetting = + eslintImplicitGlobalSetting ?? 'readonly'; + } +} + +export { ImplicitLibVariable, ImplicitLibVariableOptions }; diff --git a/packages/scope-manager/src/variable/Variable.ts b/packages/scope-manager/src/variable/Variable.ts new file mode 100644 index 00000000000..b748af8a548 --- /dev/null +++ b/packages/scope-manager/src/variable/Variable.ts @@ -0,0 +1,34 @@ +import { VariableBase } from './VariableBase'; + +/** + * A Variable represents a locally scoped identifier. These include arguments to functions. + */ +class Variable extends VariableBase { + /** + * `true` if the variable is valid in a type context, false otherwise + * @public + */ + public get isTypeVariable(): boolean { + if (this.defs.length === 0) { + // we don't statically know whether this is a type or a value + return true; + } + + return this.defs.some(def => def.isTypeDefinition); + } + + /** + * `true` if the variable is valid in a value context, false otherwise + * @public + */ + public get isValueVariable(): boolean { + if (this.defs.length === 0) { + // we don't statically know whether this is a type or a value + return true; + } + + return this.defs.some(def => def.isVariableDefinition); + } +} + +export { Variable }; diff --git a/packages/scope-manager/src/variable/VariableBase.ts b/packages/scope-manager/src/variable/VariableBase.ts new file mode 100644 index 00000000000..95b1796196b --- /dev/null +++ b/packages/scope-manager/src/variable/VariableBase.ts @@ -0,0 +1,53 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { Definition } from '../definition'; +import { createIdGenerator } from '../ID'; +import { Reference } from '../referencer/Reference'; +import { Scope } from '../scope'; + +const generator = createIdGenerator(); + +class VariableBase { + /** + * A unique ID for this instance - primarily used to help debugging and testing + */ + public readonly $id: number = generator(); + + /** + * The array of the definitions of this variable. + * @public + */ + public readonly defs: Definition[] = []; + /** + * True if the variable is considered used for the purposes of `no-unused-vars`, false otherwise. + * @public + */ + public eslintUsed = false; + /** + * The array of `Identifier` nodes which define this variable. + * If this variable is redeclared, this array includes two or more nodes. + * @public + */ + public readonly identifiers: TSESTree.Identifier[] = []; + /** + * The variable name, as given in the source code. + * @public + */ + public readonly name: string; + /** + * List of {@link Reference} of this variable (excluding parameter entries) in its defining scope and all nested scopes. + * For defining occurrences only see {@link Variable#defs}. + * @public + */ + public readonly references: Reference[] = []; + /** + * Reference to the enclosing Scope. + */ + public readonly scope: Scope; + + constructor(name: string, scope: Scope) { + this.name = name; + this.scope = scope; + } +} + +export { VariableBase }; diff --git a/packages/scope-manager/src/variable/index.ts b/packages/scope-manager/src/variable/index.ts new file mode 100644 index 00000000000..912aebcf05c --- /dev/null +++ b/packages/scope-manager/src/variable/index.ts @@ -0,0 +1,6 @@ +export { ESLintScopeVariable } from './ESLintScopeVariable'; +export { + ImplicitLibVariable, + ImplicitLibVariableOptions, +} from './ImplicitLibVariable'; +export { Variable } from './Variable'; diff --git a/packages/scope-manager/tests/eslint-scope/README.md b/packages/scope-manager/tests/eslint-scope/README.md new file mode 100644 index 00000000000..1397ce3cd76 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/README.md @@ -0,0 +1,13 @@ +# `scope-manager` `eslint-scope` Tests + +These tests are taken from the [`eslint-scope`](https://github.com/eslint/eslint-scope) package. +The intention is to help us ensure we do not regress functionality compared to the original package. + +They have been modified to: + +- be written in TypeScript +- work with jest +- work with our folder structure +- adhere to our formatting and linting style + +[The code was forked from `dbddf14d5771b21b5da704213e4508c660ca1c64`](https://github.com/eslint/eslint-scope/blob/dbddf14d5771b21b5da704213e4508c660ca1c64/tests/). diff --git a/packages/scope-manager/tests/eslint-scope/arguments.test.ts b/packages/scope-manager/tests/eslint-scope/arguments.test.ts new file mode 100644 index 00000000000..e3bbef8899f --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/arguments.test.ts @@ -0,0 +1,29 @@ +import { + expectToBeFunctionScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('arguments', () => { + it('arguments are correctly materialized', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + arguments; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].resolved).toBe(scope.variables[0]); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/catch-scope.test.ts b/packages/scope-manager/tests/eslint-scope/catch-scope.test.ts new file mode 100644 index 00000000000..bb3ad8f2b5f --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/catch-scope.test.ts @@ -0,0 +1,48 @@ +import { + expectToBeBlockScope, + expectToBeCatchScope, + expectToBeFunctionScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('catch', () => { + it('creates scope', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + try { + } catch (e) { + } + }()); + `); + + expect(scopeManager.scopes).toHaveLength(5); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[2]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[3]; + expectToBeCatchScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('e'); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[4]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/child-visitor-keys.test.ts b/packages/scope-manager/tests/eslint-scope/child-visitor-keys.test.ts new file mode 100644 index 00000000000..8975dc5043d --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/child-visitor-keys.test.ts @@ -0,0 +1,54 @@ +import { TSESTree } from '@typescript-eslint/types'; +import { parse } from '../util'; +import { analyze } from '../../src/analyze'; + +describe('childVisitorKeys option', () => { + it('should not visit to properties which are not given.', () => { + const ast = parse(` + let foo = bar; + `); + + const decl = ast.body[0] as TSESTree.VariableDeclaration; + decl.declarations[0].init = { + type: 'TestNode', + argument: decl.declarations[0].init, + } as never; + + const result = analyze(ast, { + childVisitorKeys: { + TestNode: [], + }, + }); + + expect(result.scopes).toHaveLength(1); + const globalScope = result.scopes[0]; + + // `bar` in TestNode has not been visited. + expect(globalScope.through).toHaveLength(0); + }); + + it('should visit to given properties.', () => { + const ast = parse(` + let foo = bar; + `); + + const decl = ast.body[0] as TSESTree.VariableDeclaration; + decl.declarations[0].init = { + type: 'TestNode', + argument: decl.declarations[0].init, + } as never; + + const result = analyze(ast, { + childVisitorKeys: { + TestNode: ['argument'], + }, + }); + + expect(result.scopes).toHaveLength(1); + const globalScope = result.scopes[0]; + + // `bar` in TestNode has been visited. + expect(globalScope.through).toHaveLength(1); + expect(globalScope.through[0].identifier.name).toBe('bar'); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-arrow-function-expression.test.ts b/packages/scope-manager/tests/eslint-scope/es6-arrow-function-expression.test.ts new file mode 100644 index 00000000000..3032af6726d --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-arrow-function-expression.test.ts @@ -0,0 +1,118 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { + expectToBeFunctionScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('ES6 arrow function expression', () => { + it('materialize scope for arrow function expression', () => { + const { scopeManager } = parseAndAnalyze(` + var arrow = () => { + let i = 0; + var j = 20; + console.log(i); + } + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(1); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.ArrowFunctionExpression); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(2); + + // There's no "arguments" + expect(scope.variables[0].name).toBe('i'); + expect(scope.variables[1].name).toBe('j'); + }); + + it('generate bindings for parameters', () => { + const { scopeManager } = parseAndAnalyze('var arrow = (a, b, c, d) => {}'); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(1); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.ArrowFunctionExpression); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(4); + + // There's no "arguments" + expect(scope.variables[0].name).toBe('a'); + expect(scope.variables[1].name).toBe('b'); + expect(scope.variables[2].name).toBe('c'); + expect(scope.variables[3].name).toBe('d'); + }); + + it('inherits upper scope strictness', () => { + const { scopeManager } = parseAndAnalyze(` + "use strict"; + var arrow = () => {}; + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(1); + + scope = scopeManager.scopes[1]; + + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.ArrowFunctionExpression); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(0); + }); + + it('is strict when a strictness directive is used', () => { + const { scopeManager } = parseAndAnalyze(` + var arrow = () => { + "use strict"; + }; + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(1); + + scope = scopeManager.scopes[1]; + + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.ArrowFunctionExpression); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(0); + }); + + it('works with no body', () => { + const { scopeManager } = parseAndAnalyze('var arrow = a => a;'); + + expect(scopeManager.scopes).toHaveLength(2); + + const scope = scopeManager.scopes[1]; + + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.ArrowFunctionExpression); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(1); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-block-scope.test.ts b/packages/scope-manager/tests/eslint-scope/es6-block-scope.test.ts new file mode 100644 index 00000000000..e2b51c0f926 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-block-scope.test.ts @@ -0,0 +1,149 @@ +import { + expectToBeBlockScope, + expectToBeFunctionScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('ES6 block scope', () => { + it('let is materialized in ES6 block scope#1', () => { + const { scopeManager } = parseAndAnalyze(` + { + let i = 20; + i; + } + `); + + expect(scopeManager.scopes).toHaveLength(2); // Program and BlockStatement scope. + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); // No variable in Program scope. + + scope = scopeManager.scopes[1]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(1); // `i` in block scope. + expect(scope.variables[0].name).toBe('i'); + expect(scope.references).toHaveLength(2); + expect(scope.references[0].identifier.name).toBe('i'); + expect(scope.references[1].identifier.name).toBe('i'); + }); + + it('function delaration is materialized in ES6 block scope', () => { + const { scopeManager } = parseAndAnalyze(` + { + function test() { + } + test(); + } + `); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('test'); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('test'); + + scope = scopeManager.scopes[2]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); + }); + + it('let is not hoistable#1', () => { + const { scopeManager } = parseAndAnalyze(` + var i = 42; (1) + { + i; // (2) ReferenceError at runtime. + let i = 20; // (2) + i; // (2) + } + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('i'); + expect(scope.references).toHaveLength(1); + + scope = scopeManager.scopes[1]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('i'); + expect(scope.references).toHaveLength(3); + expect(scope.references[0].resolved).toBe(scope.variables[0]); + expect(scope.references[1].resolved).toBe(scope.variables[0]); + expect(scope.references[2].resolved).toBe(scope.variables[0]); + }); + + it('let is not hoistable#2', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var i = 42; // (1) + i; // (1) + { + i; // (3) + { + i; // (2) + let i = 20; // (2) + i; // (2) + } + let i = 30; // (3) + i; // (3) + } + i; // (1) + }()); + `); + + expect(scopeManager.scopes).toHaveLength(4); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('i'); + const v1 = scope.variables[1]; + + expect(scope.references).toHaveLength(3); + expect(scope.references[0].resolved).toBe(v1); + expect(scope.references[1].resolved).toBe(v1); + expect(scope.references[2].resolved).toBe(v1); + + scope = scopeManager.scopes[2]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('i'); + const v3 = scope.variables[0]; + + expect(scope.references).toHaveLength(3); + expect(scope.references[0].resolved).toBe(v3); + expect(scope.references[1].resolved).toBe(v3); + expect(scope.references[2].resolved).toBe(v3); + + scope = scopeManager.scopes[3]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('i'); + const v2 = scope.variables[0]; + + expect(scope.references).toHaveLength(3); + expect(scope.references[0].resolved).toBe(v2); + expect(scope.references[1].resolved).toBe(v2); + expect(scope.references[2].resolved).toBe(v2); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-catch.test.ts b/packages/scope-manager/tests/eslint-scope/es6-catch.test.ts new file mode 100644 index 00000000000..906e8d8ba38 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-catch.test.ts @@ -0,0 +1,64 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { + expectToBeBlockScope, + expectToBeCatchScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('ES6 catch', () => { + it('takes binding pattern', () => { + const { scopeManager } = parseAndAnalyze(` + try { + } catch ({ a, b, c, d }) { + let e = 20; + a; + b; + c; + d; + } + `); + + expect(scopeManager.scopes).toHaveLength(4); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeBlockScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.BlockStatement); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[2]; + expectToBeCatchScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.CatchClause); + expect(scope.isStrict).toBeFalsy(); + + expect(scope.variables).toHaveLength(4); + expect(scope.variables[0].name).toBe('a'); + expect(scope.variables[1].name).toBe('b'); + expect(scope.variables[2].name).toBe('c'); + expect(scope.variables[3].name).toBe('d'); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[3]; + expectToBeBlockScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.BlockStatement); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables.map(variable => variable.name)).toEqual(['e']); + expect(scope.references.map(ref => ref.identifier.name)).toEqual([ + 'e', + 'a', + 'b', + 'c', + 'd', + ]); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-class.test.ts b/packages/scope-manager/tests/eslint-scope/es6-class.test.ts new file mode 100644 index 00000000000..c0594ac7a2b --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-class.test.ts @@ -0,0 +1,181 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { + expectToBeClassScope, + expectToBeFunctionScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('ES6 class', () => { + it('declaration name creates class scope', () => { + const { scopeManager } = parseAndAnalyze(` + class Derived extends Base { + constructor() { + } + } + new Derived(); + `); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('Derived'); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('Derived'); + + scope = scopeManager.scopes[1]; + expectToBeClassScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.ClassDeclaration); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('Derived'); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('Base'); + + scope = scopeManager.scopes[2]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionExpression); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); + }); + + it('expression name creates class scope#1', () => { + const { scopeManager } = parseAndAnalyze(` + (class Derived extends Base { + constructor() { + } + }); + `); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeClassScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.ClassExpression); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('Derived'); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('Base'); + + scope = scopeManager.scopes[2]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionExpression); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); + }); + + it('expression name creates class scope#2', () => { + const { scopeManager } = parseAndAnalyze(` + (class extends Base { + constructor() { + } + }); + `); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeClassScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.ClassExpression); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('Base'); + + scope = scopeManager.scopes[2]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionExpression); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); + }); + + it('computed property key may refer variables', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var yuyushiki = 42; + (class { + [yuyushiki]() { + } + + [yuyushiki + 40]() { + } + }); + }()); + `); + + expect(scopeManager.scopes).toHaveLength(5); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionExpression); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('yuyushiki'); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('yuyushiki'); + + scope = scopeManager.scopes[2]; + expectToBeClassScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.ClassExpression); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(2); + expect(scope.references[0].identifier.name).toBe('yuyushiki'); + expect(scope.references[1].identifier.name).toBe('yuyushiki'); + }); + + it('regression #49', () => { + const { scopeManager } = parseAndAnalyze(` + class Shoe { + constructor() { + //Shoe.x = true; + } + } + let shoe = new Shoe(); + `); + + expect(scopeManager.scopes).toHaveLength(3); + + const scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('Shoe'); + expect(scope.variables[1].name).toBe('shoe'); + expect(scope.references).toHaveLength(2); + expect(scope.references[0].identifier.name).toBe('shoe'); + expect(scope.references[1].identifier.name).toBe('Shoe'); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-default-parameters.test.ts b/packages/scope-manager/tests/eslint-scope/es6-default-parameters.test.ts new file mode 100644 index 00000000000..f9868a575d6 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-default-parameters.test.ts @@ -0,0 +1,338 @@ +import { parseAndAnalyze } from '../util'; + +function forEach( + obj: Record, + cb: (name: T) => void, +): void { + Object.keys(obj).forEach(name => { + cb(name as T); + }); +} + +describe('ES6 default parameters:', () => { + describe('a default parameter creates a writable reference for its initialization:', () => { + const patterns = { + FunctionDeclaration: 'function foo(a, b = 0) {}', + FunctionExpression: 'let foo = function(a, b = 0) {};', + ArrowExpression: 'let foo = (a, b = 0) => {};', + }; + + forEach(patterns, name => { + const code = patterns[name]; + + it(name, () => { + const numVars = name === 'ArrowExpression' ? 2 : 3; + const { scopeManager } = parseAndAnalyze(code); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(numVars); // [arguments?, a, b] + expect(scope.references).toHaveLength(1); + + const reference = scope.references[0]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('b'); + expect(reference.resolved).toBe(scope.variables[numVars - 1]); + expect(reference.writeExpr).not.toBeUndefined(); + expect(reference.isWrite()).toBeTruthy(); + expect(reference.isRead()).toBeFalsy(); + }); + }); + }); + + describe('a default parameter creates a readable reference for references in right:', () => { + const patterns = { + FunctionDeclaration: ` + let a; + function foo(b = a) {} + `, + FunctionExpression: ` + let a; + let foo = function(b = a) {} + `, + ArrowExpression: ` + let a; + let foo = (b = a) => {}; + `, + }; + + forEach(patterns, name => { + const code = patterns[name]; + + it(name, () => { + const numVars = name === 'ArrowExpression' ? 1 : 2; + const { scopeManager } = parseAndAnalyze(code); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(numVars); // [arguments?, b] + expect(scope.references).toHaveLength(2); // [b, a] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scopeManager.scopes[0].variables[0]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + }); + + describe('a default parameter creates a readable reference for references in right (for const):', () => { + const patterns = { + FunctionDeclaration: ` + const a = 0; + function foo(b = a) {} + `, + FunctionExpression: ` + const a = 0; + let foo = function(b = a) {} + `, + ArrowExpression: ` + const a = 0; + let foo = (b = a) => {}; + `, + }; + + forEach(patterns, name => { + const code = patterns[name]; + + it(name, () => { + const numVars = name === 'ArrowExpression' ? 1 : 2; + const { scopeManager } = parseAndAnalyze(code); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(numVars); // [arguments?, b] + expect(scope.references).toHaveLength(2); // [b, a] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scopeManager.scopes[0].variables[0]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + }); + + describe('a default parameter creates a readable reference for references in right (partial):', () => { + const patterns = { + FunctionDeclaration: ` + let a; + function foo(b = a.c) {} + `, + FunctionExpression: ` + let a; + let foo = function(b = a.c) {} + `, + ArrowExpression: ` + let a; + let foo = (b = a.c) => {}; + `, + }; + + forEach(patterns, name => { + const code = patterns[name]; + + it(name, () => { + const numVars = name === 'ArrowExpression' ? 1 : 2; + const { scopeManager } = parseAndAnalyze(code); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(numVars); // [arguments?, b] + expect(scope.references).toHaveLength(2); // [b, a] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scopeManager.scopes[0].variables[0]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + }); + + describe("a default parameter creates a readable reference for references in right's nested scope:", () => { + const patterns = { + FunctionDeclaration: ` + let a; + function foo(b = function() { return a; }) {} + `, + FunctionExpression: ` + let a; + let foo = function(b = function() { return a; }) {} + `, + ArrowExpression: ` + let a; + let foo = (b = function() { return a; }) => {}; + `, + }; + + forEach(patterns, name => { + const code = patterns[name]; + + it(name, () => { + const { scopeManager } = parseAndAnalyze(code); + + expect(scopeManager.scopes).toHaveLength(3); // [global, foo, anonymous] + + const scope = scopeManager.scopes[2]; + + expect(scope.variables).toHaveLength(1); // [arguments] + expect(scope.references).toHaveLength(1); // [a] + + const reference = scope.references[0]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scopeManager.scopes[0].variables[0]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + }); + + describe("a default parameter creates a readable reference for references in right. It's resolved to outer scope's even if there is the variable in the function body:", () => { + const patterns = { + FunctionDeclaration: ` + let a; + function foo(b = a) { let a; } + `, + FunctionExpression: ` + let a; + let foo = function(b = a) { let a; } + `, + ArrowExpression: ` + let a; + let foo = (b = a) => { let a; }; + `, + }; + + forEach(patterns, name => { + const code = patterns[name]; + + it(name, () => { + const numVars = name === 'ArrowExpression' ? 2 : 3; + const { scopeManager } = parseAndAnalyze(code); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(numVars); // [arguments?, b, a] + expect(scope.references).toHaveLength(2); // [b, a] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scopeManager.scopes[0].variables[0]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + }); + + describe("a default parameter creates a readable reference for references in right. It's resolved to the parameter:", () => { + const patterns = { + FunctionDeclaration: ` + let a; + function foo(b = a, a) { } + `, + FunctionExpression: ` + let a; + let foo = function(b = a, a) { } + `, + ArrowExpression: ` + let a; + let foo = (b = a, a) => { }; + `, + }; + + forEach(patterns, name => { + const code = patterns[name]; + + it(name, () => { + const numVars = name === 'ArrowExpression' ? 2 : 3; + const { scopeManager } = parseAndAnalyze(code); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(numVars); // [arguments?, b, a] + expect(scope.references).toHaveLength(2); // [b, a] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe( + scope.variables[scope.variables.length - 1], + ); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + }); + + describe("a default parameter creates a readable reference for references in right (nested scope). It's resolved to outer scope's even if there is the variable in the function body:", () => { + const patterns = { + FunctionDeclaration: ` + let a; + function foo(b = function(){ a }) { let a; } + `, + FunctionExpression: ` + let a; + let foo = function(b = function(){ a }) { let a; } + `, + ArrowExpression: ` + let a; + let foo = (b = function(){ a }) => { let a; }; + `, + }; + + forEach(patterns, name => { + const code = patterns[name]; + + it(name, () => { + const { scopeManager } = parseAndAnalyze(code); + + expect(scopeManager.scopes).toHaveLength(3); // [global, foo, anonymous function] + + const scope = scopeManager.scopes[2]; + + expect(scope.references).toHaveLength(1); // [a] + + const reference = scope.references[0]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scopeManager.scopes[0].variables[0]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts b/packages/scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts new file mode 100644 index 00000000000..53837e27cd7 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-destructuring-assignments.test.ts @@ -0,0 +1,1179 @@ +import { + expectToBeForScope, + expectToBeFunctionScope, + expectToBeGlobalScope, + expectToBeIdentifier, + expectToBeParameterDefinition, + parseAndAnalyze, +} from '../util'; + +describe('ES6 destructuring assignments', () => { + it('Pattern in var in ForInStatement', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + for (var [a, b, c] in array); + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('array'); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(4); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('a'); + expect(scope.variables[2].name).toBe('b'); + expect(scope.variables[3].name).toBe('c'); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('a'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expect(scope.references[0].resolved).toBe(scope.variables[1]); + expect(scope.references[1].identifier.name).toBe('b'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expect(scope.references[1].resolved).toBe(scope.variables[2]); + expect(scope.references[2].identifier.name).toBe('c'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expect(scope.references[2].resolved).toBe(scope.variables[3]); + expect(scope.references[3].identifier.name).toBe('array'); + expect(scope.references[3].isWrite()).toBeFalsy(); + }); + + it('Pattern in let in ForInStatement', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + for (let [a, b, c] in array); + }()); + `); + + expect(scopeManager.scopes).toHaveLength(3); // [global, function, for] + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('array'); + + scope = scopeManager.scopes[2]; + expectToBeForScope(scope); + expect(scope.variables).toHaveLength(3); + expect(scope.variables[0].name).toBe('a'); + expect(scope.variables[1].name).toBe('b'); + expect(scope.variables[2].name).toBe('c'); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('a'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expect(scope.references[0].resolved).toBe(scope.variables[0]); + expect(scope.references[1].identifier.name).toBe('b'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expect(scope.references[1].resolved).toBe(scope.variables[1]); + expect(scope.references[2].identifier.name).toBe('c'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expect(scope.references[2].resolved).toBe(scope.variables[2]); + expect(scope.references[3].identifier.name).toBe('array'); + expect(scope.references[3].isWrite()).toBeFalsy(); + expect(scope.references[3].resolved).toBeNull(); + }); + + it('Pattern with default values in var in ForInStatement', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + for (var [a, b, c = d] in array); + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(2); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('d'); + expect(scope['implicit'].leftToBeResolved[1].identifier.name).toBe('array'); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(4); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('a'); + expect(scope.variables[2].name).toBe('b'); + expect(scope.variables[3].name).toBe('c'); + expect(scope.references).toHaveLength(6); + expect(scope.references[0].identifier.name).toBe('c'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[0].writeExpr); + expect(scope.references[0].writeExpr.name).toBe('d'); + expect(scope.references[0].resolved).toBe(scope.variables[3]); + expect(scope.references[1].identifier.name).toBe('d'); + expect(scope.references[1].isWrite()).toBeFalsy(); + expect(scope.references[2].identifier.name).toBe('a'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expect(scope.references[2].resolved).toBe(scope.variables[1]); + expect(scope.references[3].identifier.name).toBe('b'); + expect(scope.references[3].isWrite()).toBeTruthy(); + expect(scope.references[3].resolved).toBe(scope.variables[2]); + expect(scope.references[4].identifier.name).toBe('c'); + expect(scope.references[4].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[4].writeExpr); + expect(scope.references[4].writeExpr.name).toBe('array'); + expect(scope.references[4].resolved).toBe(scope.variables[3]); + expect(scope.references[5].identifier.name).toBe('array'); + expect(scope.references[5].isWrite()).toBeFalsy(); + }); + + it('Pattern with default values in let in ForInStatement', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + for (let [a, b, c = d] in array); + }()); + `); + + expect(scopeManager.scopes).toHaveLength(3); // [global, function, for] + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(2); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('d'); + expectToBeForScope(scope['implicit'].leftToBeResolved[0].from); + expect(scope['implicit'].leftToBeResolved[1].identifier.name).toBe('array'); + expectToBeForScope(scope['implicit'].leftToBeResolved[1].from); + + scope = scopeManager.scopes[2]; + expectToBeForScope(scope); + expect(scope.variables).toHaveLength(3); + expect(scope.variables[0].name).toBe('a'); + expect(scope.variables[1].name).toBe('b'); + expect(scope.variables[2].name).toBe('c'); + expect(scope.references).toHaveLength(6); + expect(scope.references[0].identifier.name).toBe('c'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[0].writeExpr); + expect(scope.references[0].writeExpr.name).toBe('d'); + expect(scope.references[0].resolved).toBe(scope.variables[2]); + expect(scope.references[1].identifier.name).toBe('d'); + expect(scope.references[1].isWrite()).toBeFalsy(); + expect(scope.references[2].identifier.name).toBe('a'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[2].writeExpr); + expect(scope.references[2].writeExpr.name).toBe('array'); + expect(scope.references[2].resolved).toBe(scope.variables[0]); + expect(scope.references[3].identifier.name).toBe('b'); + expect(scope.references[3].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[3].writeExpr); + expect(scope.references[3].writeExpr.name).toBe('array'); + expect(scope.references[3].resolved).toBe(scope.variables[1]); + expect(scope.references[4].identifier.name).toBe('c'); + expect(scope.references[4].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[4].writeExpr); + expect(scope.references[4].writeExpr.name).toBe('array'); + expect(scope.references[4].resolved).toBe(scope.variables[2]); + expect(scope.references[5].identifier.name).toBe('array'); + expect(scope.references[5].isWrite()).toBeFalsy(); + expect(scope.references[5].resolved).toBeNull(); + }); + + it('Pattern with nested default values in var in ForInStatement', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + for (var [a, [b, c = d] = e] in array); + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(3); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('d'); + expect(scope['implicit'].leftToBeResolved[1].identifier.name).toBe('e'); + expect(scope['implicit'].leftToBeResolved[2].identifier.name).toBe('array'); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(4); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('a'); + expect(scope.variables[2].name).toBe('b'); + expect(scope.variables[3].name).toBe('c'); + expect(scope.references).toHaveLength(9); + expect(scope.references[0].identifier.name).toBe('b'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[0].writeExpr); + expect(scope.references[0].writeExpr.name).toBe('e'); + expect(scope.references[0].resolved).toBe(scope.variables[2]); + expect(scope.references[1].identifier.name).toBe('c'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[1].writeExpr); + expect(scope.references[1].writeExpr.name).toBe('e'); + expect(scope.references[1].resolved).toBe(scope.variables[3]); + expect(scope.references[2].identifier.name).toBe('c'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[2].writeExpr); + expect(scope.references[2].writeExpr.name).toBe('d'); + expect(scope.references[2].resolved).toBe(scope.variables[3]); + expect(scope.references[3].identifier.name).toBe('d'); + expect(scope.references[3].isWrite()).toBeFalsy(); + expect(scope.references[4].identifier.name).toBe('e'); + expect(scope.references[4].isWrite()).toBeFalsy(); + expect(scope.references[5].identifier.name).toBe('a'); + expect(scope.references[5].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[5].writeExpr); + expect(scope.references[5].writeExpr.name).toBe('array'); + expect(scope.references[5].resolved).toBe(scope.variables[1]); + expect(scope.references[6].identifier.name).toBe('b'); + expect(scope.references[6].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[6].writeExpr); + expect(scope.references[6].writeExpr.name).toBe('array'); + expect(scope.references[6].resolved).toBe(scope.variables[2]); + expect(scope.references[7].identifier.name).toBe('c'); + expect(scope.references[7].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[7].writeExpr); + expect(scope.references[7].writeExpr.name).toBe('array'); + expect(scope.references[7].resolved).toBe(scope.variables[3]); + expect(scope.references[8].identifier.name).toBe('array'); + expect(scope.references[8].isWrite()).toBeFalsy(); + }); + + it('Pattern with nested default values in let in ForInStatement', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + for (let [a, [b, c = d] = e] in array); + }()); + `); + + expect(scopeManager.scopes).toHaveLength(3); // [global, function, for] + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(3); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('d'); + expectToBeForScope(scope['implicit'].leftToBeResolved[0].from); + expect(scope['implicit'].leftToBeResolved[1].identifier.name).toBe('e'); + expectToBeForScope(scope['implicit'].leftToBeResolved[1].from); + expect(scope['implicit'].leftToBeResolved[2].identifier.name).toBe('array'); + expectToBeForScope(scope['implicit'].leftToBeResolved[2].from); + + scope = scopeManager.scopes[2]; + expectToBeForScope(scope); + expect(scope.variables).toHaveLength(3); + expect(scope.variables[0].name).toBe('a'); + expect(scope.variables[1].name).toBe('b'); + expect(scope.variables[2].name).toBe('c'); + expect(scope.references).toHaveLength(9); + expect(scope.references[0].identifier.name).toBe('b'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[0].writeExpr); + expect(scope.references[0].writeExpr.name).toBe('e'); + expect(scope.references[0].resolved).toBe(scope.variables[1]); + expect(scope.references[1].identifier.name).toBe('c'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[1].writeExpr); + expect(scope.references[1].writeExpr.name).toBe('e'); + expect(scope.references[1].resolved).toBe(scope.variables[2]); + expect(scope.references[2].identifier.name).toBe('c'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[2].writeExpr); + expect(scope.references[2].writeExpr.name).toBe('d'); + expect(scope.references[2].resolved).toBe(scope.variables[2]); + expect(scope.references[3].identifier.name).toBe('d'); + expect(scope.references[3].isWrite()).toBeFalsy(); + expect(scope.references[4].identifier.name).toBe('e'); + expect(scope.references[4].isWrite()).toBeFalsy(); + expect(scope.references[5].identifier.name).toBe('a'); + expect(scope.references[5].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[5].writeExpr); + expect(scope.references[5].writeExpr.name).toBe('array'); + expect(scope.references[5].resolved).toBe(scope.variables[0]); + expect(scope.references[6].identifier.name).toBe('b'); + expect(scope.references[6].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[6].writeExpr); + expect(scope.references[6].writeExpr.name).toBe('array'); + expect(scope.references[6].resolved).toBe(scope.variables[1]); + expect(scope.references[7].identifier.name).toBe('c'); + expect(scope.references[7].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[7].writeExpr); + expect(scope.references[7].writeExpr.name).toBe('array'); + expect(scope.references[7].resolved).toBe(scope.variables[2]); + expect(scope.references[8].identifier.name).toBe('array'); + expect(scope.references[8].isWrite()).toBeFalsy(); + expect(scope.references[8].resolved).toBeNull(); + }); + + it('Pattern with default values in var in ForInStatement (separate declarations)', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var a, b, c; + for ([a, b, c = d] in array); + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(2); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('d'); + expect(scope['implicit'].leftToBeResolved[1].identifier.name).toBe('array'); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(4); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('a'); + expect(scope.variables[2].name).toBe('b'); + expect(scope.variables[3].name).toBe('c'); + expect(scope.references).toHaveLength(6); + expect(scope.references[0].identifier.name).toBe('a'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expect(scope.references[0].resolved).toBe(scope.variables[1]); + expect(scope.references[1].identifier.name).toBe('b'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expect(scope.references[1].resolved).toBe(scope.variables[2]); + expect(scope.references[2].identifier.name).toBe('c'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[2].writeExpr); + expect(scope.references[2].writeExpr.name).toBe('d'); + expect(scope.references[2].resolved).toBe(scope.variables[3]); + expect(scope.references[3].identifier.name).toBe('c'); + expect(scope.references[3].isWrite()).toBeTruthy(); + expectToBeIdentifier(scope.references[3].writeExpr); + expect(scope.references[3].writeExpr.name).toBe('array'); + expect(scope.references[3].resolved).toBe(scope.variables[3]); + expect(scope.references[4].identifier.name).toBe('d'); + expect(scope.references[4].isWrite()).toBeFalsy(); + expect(scope.references[5].identifier.name).toBe('array'); + expect(scope.references[5].isWrite()).toBeFalsy(); + }); + + it('Pattern with default values in var in ForInStatement (separate declarations and with MemberExpression)', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var obj; + for ([obj.a, obj.b, obj.c = d] in array); + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(2); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('d'); + expect(scope['implicit'].leftToBeResolved[1].identifier.name).toBe('array'); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('obj'); + expect(scope.references).toHaveLength(5); + expect(scope.references[0].identifier.name).toBe('obj'); // obj.a + expect(scope.references[0].isWrite()).toBeFalsy(); + expect(scope.references[0].isRead()).toBeTruthy(); + expect(scope.references[0].resolved).toBe(scope.variables[1]); + expect(scope.references[1].identifier.name).toBe('obj'); // obj.b + expect(scope.references[1].isWrite()).toBeFalsy(); + expect(scope.references[1].isRead()).toBeTruthy(); + expect(scope.references[1].resolved).toBe(scope.variables[1]); + expect(scope.references[2].identifier.name).toBe('obj'); // obj.c + expect(scope.references[2].isWrite()).toBeFalsy(); + expect(scope.references[2].isRead()).toBeTruthy(); + expect(scope.references[2].resolved).toBe(scope.variables[1]); + expect(scope.references[3].identifier.name).toBe('d'); + expect(scope.references[3].isWrite()).toBeFalsy(); + expect(scope.references[3].isRead()).toBeTruthy(); + expect(scope.references[4].identifier.name).toBe('array'); + expect(scope.references[4].isWrite()).toBeFalsy(); + expect(scope.references[4].isRead()).toBeTruthy(); + }); + + it('ArrayPattern in var', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var [a, b, c] = array; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('array'); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(4); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('a'); + expect(scope.variables[2].name).toBe('b'); + expect(scope.variables[3].name).toBe('c'); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('a'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expect(scope.references[0].resolved).toBe(scope.variables[1]); + expect(scope.references[1].identifier.name).toBe('b'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expect(scope.references[1].resolved).toBe(scope.variables[2]); + expect(scope.references[2].identifier.name).toBe('c'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expect(scope.references[2].resolved).toBe(scope.variables[3]); + expect(scope.references[3].identifier.name).toBe('array'); + expect(scope.references[3].isWrite()).toBeFalsy(); + }); + + it('SpreadElement in var', () => { + let { scopeManager } = parseAndAnalyze(` + (function () { + var [a, b, ...rest] = array; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('array'); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(4); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('a'); + expect(scope.variables[2].name).toBe('b'); + expect(scope.variables[3].name).toBe('rest'); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('a'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expect(scope.references[0].resolved).toBe(scope.variables[1]); + expect(scope.references[1].identifier.name).toBe('b'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expect(scope.references[1].resolved).toBe(scope.variables[2]); + expect(scope.references[2].identifier.name).toBe('rest'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expect(scope.references[2].resolved).toBe(scope.variables[3]); + expect(scope.references[3].identifier.name).toBe('array'); + expect(scope.references[3].isWrite()).toBeFalsy(); + + ({ scopeManager } = parseAndAnalyze(` + (function () { + var [a, b, ...[c, d, ...rest]] = array; + }()); + `)); + + expect(scopeManager.scopes).toHaveLength(2); + + scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('array'); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + + expect(scope.variables).toHaveLength(6); + const expectedVariableNames = ['arguments', 'a', 'b', 'c', 'd', 'rest']; + + for (let index = 0; index < expectedVariableNames.length; index++) { + expect(scope.variables[index].name).toBe(expectedVariableNames[index]); + } + + expect(scope.references).toHaveLength(6); + const expectedReferenceNames = ['a', 'b', 'c', 'd', 'rest']; + + for (let index = 0; index < expectedReferenceNames.length; index++) { + expect(scope.references[index].identifier.name).toBe( + expectedReferenceNames[index], + ); + expect(scope.references[index].isWrite()).toBeTruthy(); + } + expect(scope.references[5].identifier.name).toBe('array'); + expect(scope.references[5].isWrite()).toBeFalsy(); + }); + + it('ObjectPattern in var', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var { + shorthand, + key: value, + hello: { + world + } + } = object; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe( + 'object', + ); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(4); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('shorthand'); + expect(scope.variables[2].name).toBe('value'); + expect(scope.variables[3].name).toBe('world'); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('shorthand'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expect(scope.references[0].resolved).toBe(scope.variables[1]); + expect(scope.references[1].identifier.name).toBe('value'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expect(scope.references[1].resolved).toBe(scope.variables[2]); + expect(scope.references[2].identifier.name).toBe('world'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expect(scope.references[2].resolved).toBe(scope.variables[3]); + expect(scope.references[3].identifier.name).toBe('object'); + expect(scope.references[3].isWrite()).toBeFalsy(); + }); + + it('complex pattern in var', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var { + shorthand, + key: [ a, b, c, d, e ], + hello: { + world + } + } = object; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe( + 'object', + ); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(8); + const expectedVariableNames = [ + 'arguments', + 'shorthand', + 'a', + 'b', + 'c', + 'd', + 'e', + 'world', + ]; + + for (let index = 0; index < expectedVariableNames.length; index++) { + expect(scope.variables[index].name).toBe(expectedVariableNames[index]); + } + expect(scope.references).toHaveLength(8); + const expectedReferenceNames = [ + 'shorthand', + 'a', + 'b', + 'c', + 'd', + 'e', + 'world', + ]; + + for (let index = 0; index < expectedReferenceNames.length; index++) { + expect(scope.references[index].identifier.name).toBe( + expectedReferenceNames[index], + ); + expect(scope.references[index].isWrite()).toBeTruthy(); + } + expect(scope.references[7].identifier.name).toBe('object'); + expect(scope.references[7].isWrite()).toBeFalsy(); + }); + + it('ArrayPattern in AssignmentExpression', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + [a, b, c] = array; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(4); + expect( + scope['implicit'].leftToBeResolved.map(left => left.identifier.name), + ).toEqual(['a', 'b', 'c', 'array']); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('a'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expect(scope.references[0].resolved).toBeNull(); + expect(scope.references[1].identifier.name).toBe('b'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expect(scope.references[1].resolved).toBeNull(); + expect(scope.references[2].identifier.name).toBe('c'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expect(scope.references[2].resolved).toBeNull(); + expect(scope.references[3].identifier.name).toBe('array'); + expect(scope.references[3].isWrite()).toBeFalsy(); + }); + + it('ArrayPattern with MemberExpression in AssignmentExpression', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var obj; + [obj.a, obj.b, obj.c] = array; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('array'); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('obj'); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('obj'); + expect(scope.references[0].isWrite()).toBeFalsy(); + expect(scope.references[0].isRead()).toBeTruthy(); + expect(scope.references[0].resolved).toBe(scope.variables[1]); + expect(scope.references[1].identifier.name).toBe('obj'); + expect(scope.references[1].isWrite()).toBeFalsy(); + expect(scope.references[1].isRead()).toBeTruthy(); + expect(scope.references[1].resolved).toBe(scope.variables[1]); + expect(scope.references[2].identifier.name).toBe('obj'); + expect(scope.references[2].isWrite()).toBeFalsy(); + expect(scope.references[2].isRead()).toBeTruthy(); + expect(scope.references[2].resolved).toBe(scope.variables[1]); + expect(scope.references[3].identifier.name).toBe('array'); + expect(scope.references[3].isWrite()).toBeFalsy(); + expect(scope.references[3].isRead()).toBeTruthy(); + }); + + it('SpreadElement in AssignmentExpression', () => { + let { scopeManager } = parseAndAnalyze(` + (function () { + [a, b, ...rest] = array; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(4); + expect( + scope['implicit'].leftToBeResolved.map(left => left.identifier.name), + ).toEqual(['a', 'b', 'rest', 'array']); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('a'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expect(scope.references[0].resolved).toBeNull(); + expect(scope.references[1].identifier.name).toBe('b'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expect(scope.references[1].resolved).toBeNull(); + expect(scope.references[2].identifier.name).toBe('rest'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expect(scope.references[2].resolved).toBeNull(); + expect(scope.references[3].identifier.name).toBe('array'); + expect(scope.references[3].isWrite()).toBeFalsy(); + + ({ scopeManager } = parseAndAnalyze(` + (function () { + [a, b, ...[c, d, ...rest]] = array; + }()); + `)); + + expect(scopeManager.scopes).toHaveLength(2); + + scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(6); + expect( + scope['implicit'].leftToBeResolved.map(left => left.identifier.name), + ).toEqual(['a', 'b', 'c', 'd', 'rest', 'array']); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + + expect(scope.references).toHaveLength(6); + const expectedReferenceNames = ['a', 'b', 'c', 'd', 'rest']; + + for (let index = 0; index < expectedReferenceNames.length; index++) { + expect(scope.references[index].identifier.name).toBe( + expectedReferenceNames[index], + ); + expect(scope.references[index].isWrite()).toBeTruthy(); + expect(scope.references[index].resolved).toBeNull(); + } + expect(scope.references[5].identifier.name).toBe('array'); + expect(scope.references[5].isWrite()).toBeFalsy(); + }); + + it('SpreadElement with MemberExpression in AssignmentExpression', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + [a, b, ...obj.rest] = array; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(4); + expect( + scope['implicit'].leftToBeResolved.map(left => left.identifier.name), + ).toEqual(['a', 'b', 'obj', 'array']); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('a'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expect(scope.references[0].resolved).toBeNull(); + expect(scope.references[1].identifier.name).toBe('b'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expect(scope.references[1].resolved).toBeNull(); + expect(scope.references[2].identifier.name).toBe('obj'); + expect(scope.references[2].isWrite()).toBeFalsy(); + expect(scope.references[3].identifier.name).toBe('array'); + expect(scope.references[3].isWrite()).toBeFalsy(); + }); + + it('ObjectPattern in AssignmentExpression', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + ({ + shorthand, + key: value, + hello: { + world + } + } = object); + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(4); + expect( + scope['implicit'].leftToBeResolved.map(left => left.identifier.name), + ).toEqual(['shorthand', 'value', 'world', 'object']); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('shorthand'); + expect(scope.references[0].isWrite()).toBeTruthy(); + expect(scope.references[0].resolved).toBeNull(); + expect(scope.references[1].identifier.name).toBe('value'); + expect(scope.references[1].isWrite()).toBeTruthy(); + expect(scope.references[1].resolved).toBeNull(); + expect(scope.references[2].identifier.name).toBe('world'); + expect(scope.references[2].isWrite()).toBeTruthy(); + expect(scope.references[2].resolved).toBeNull(); + expect(scope.references[3].identifier.name).toBe('object'); + expect(scope.references[3].isWrite()).toBeFalsy(); + }); + + it('complex pattern in AssignmentExpression', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + ({ + shorthand, + key: [ a, b, c, d, e ], + hello: { + world + } + } = object); + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + expect(scope['implicit'].leftToBeResolved).toHaveLength(8); + expect( + scope['implicit'].leftToBeResolved.map(left => left.identifier.name), + ).toEqual(['shorthand', 'a', 'b', 'c', 'd', 'e', 'world', 'object']); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(8); + const expectedReferenceNames = [ + 'shorthand', + 'a', + 'b', + 'c', + 'd', + 'e', + 'world', + ]; + + for (let index = 0; index < expectedReferenceNames.length; index++) { + expect(scope.references[index].identifier.name).toBe( + expectedReferenceNames[index], + ); + expect(scope.references[index].isWrite()).toBeTruthy(); + } + expect(scope.references[7].identifier.name).toBe('object'); + expect(scope.references[7].isWrite()).toBeFalsy(); + }); + + it('ArrayPattern in parameters', () => { + const { scopeManager } = parseAndAnalyze(` + (function ([a, b, c]) { + }(array)); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('array'); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('array'); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(4); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('a'); + expect(scope.variables[2].name).toBe('b'); + expect(scope.variables[3].name).toBe('c'); + expect(scope.references).toHaveLength(0); + }); + + it('SpreadElement in parameters', () => { + const { scopeManager } = parseAndAnalyze(` + (function ([a, b, ...rest], ...rest2) { + }(array)); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('array'); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe('array'); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(5); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('a'); + expect(scope.variables[2].name).toBe('b'); + expect(scope.variables[3].name).toBe('rest'); + expectToBeParameterDefinition(scope.variables[3].defs[0]); + expect(scope.variables[3].defs[0].rest).toBeTruthy(); + expect(scope.variables[4].name).toBe('rest2'); + expectToBeParameterDefinition(scope.variables[4].defs[0]); + expect(scope.variables[4].defs[0].rest).toBeTruthy(); + expect(scope.references).toHaveLength(0); + }); + + it('ObjectPattern in parameters', () => { + const { scopeManager } = parseAndAnalyze(` + (function ({ + shorthand, + key: value, + hello: { + world + } + }) { } (object)); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('object'); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe( + 'object', + ); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(4); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('shorthand'); + expect(scope.variables[2].name).toBe('value'); + expect(scope.variables[3].name).toBe('world'); + expect(scope.references).toHaveLength(0); + }); + + it('complex pattern in parameters', () => { + const { scopeManager } = parseAndAnalyze(` + (function ({ + shorthand, + key: [ a, b, c, d, e ], + hello: { + world + } + }) { } (object)); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('object'); + expect(scope['implicit'].leftToBeResolved).toHaveLength(1); + expect(scope['implicit'].leftToBeResolved[0].identifier.name).toBe( + 'object', + ); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(8); + const expectedVariableNames = [ + 'arguments', + 'shorthand', + 'a', + 'b', + 'c', + 'd', + 'e', + 'world', + ]; + + for (let index = 0; index < expectedVariableNames.length; index++) { + expect(scope.variables[index].name).toBe(expectedVariableNames[index]); + } + expect(scope.references).toHaveLength(0); + }); + + it('default values and patterns in var', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var [a, b, c, d = 20 ] = array; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(5); + const expectedVariableNames = ['arguments', 'a', 'b', 'c', 'd']; + + for (let index = 0; index < expectedVariableNames.length; index++) { + expect(scope.variables[index].name).toBe(expectedVariableNames[index]); + } + expect(scope.references).toHaveLength(6); + const expectedReferenceNames = [ + 'a', + 'b', + 'c', + 'd', // assign 20 + 'd', // assign array + 'array', + ]; + + for (let index = 0; index < expectedReferenceNames.length; index++) { + expect(scope.references[index].identifier.name).toBe( + expectedReferenceNames[index], + ); + } + }); + + it('default values containing references and patterns in var', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var [a, b, c, d = e ] = array; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(5); + const expectedVariableNames = ['arguments', 'a', 'b', 'c', 'd']; + + for (let index = 0; index < expectedVariableNames.length; index++) { + expect(scope.variables[index].name).toBe(expectedVariableNames[index]); + } + expect(scope.references).toHaveLength(7); + const expectedReferenceNames = [ + 'a', // assign array + 'b', // assign array + 'c', // assign array + 'd', // assign e + 'd', // assign array + 'e', + 'array', + ]; + + for (let index = 0; index < expectedReferenceNames.length; index++) { + expect(scope.references[index].identifier.name).toBe( + expectedReferenceNames[index], + ); + } + }); + + it('nested default values containing references and patterns in var', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var [a, b, [c, d = e] = f ] = array; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(5); + const expectedVariableNames = ['arguments', 'a', 'b', 'c', 'd']; + + for (let index = 0; index < expectedVariableNames.length; index++) { + expect(scope.variables[index].name).toBe(expectedVariableNames[index]); + } + expect(scope.references).toHaveLength(10); + const expectedReferenceNames = [ + 'a', // assign array + 'b', // assign array + 'c', // assign f + 'c', // assign array + 'd', // assign f + 'd', // assign e + 'd', // assign array + 'e', + 'f', + 'array', + ]; + + for (let index = 0; index < expectedReferenceNames.length; index++) { + expect(scope.references[index].identifier.name).toBe( + expectedReferenceNames[index], + ); + } + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-export.test.ts b/packages/scope-manager/tests/eslint-scope/es6-export.test.ts new file mode 100644 index 00000000000..a172721a28f --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-export.test.ts @@ -0,0 +1,193 @@ +import { + expectToBeFunctionNameDefinition, + expectToBeFunctionScope, + expectToBeGlobalScope, + expectToBeModuleScope, + expectToBeVariableDefinition, + parseAndAnalyze, +} from '../util'; + +describe('export declaration', () => { + // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-static-and-runtme-semantics-module-records + it('should create variable bindings', () => { + const { scopeManager } = parseAndAnalyze('export var v;', 'module'); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('v'); + expectToBeVariableDefinition(scope.variables[0].defs[0]); + expect(scope.references).toHaveLength(0); + }); + + it('should create function declaration bindings', () => { + const { scopeManager } = parseAndAnalyze( + 'export default function f(){};', + 'module', + ); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('f'); + expectToBeFunctionNameDefinition(scope.variables[0].defs[0]); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[2]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); + }); + + it('should export function expression', () => { + const { scopeManager } = parseAndAnalyze( + 'export default function(){};', + 'module', + ); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[2]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); + }); + + it('should export literal', () => { + const { scopeManager } = parseAndAnalyze('export default 42;', 'module'); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + }); + + it('should refer exported references#1', () => { + const { scopeManager } = parseAndAnalyze( + 'const x = 1; export {x};', + 'module', + ); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.references).toHaveLength(2); + expect(scope.references[0].identifier.name).toBe('x'); + expect(scope.references[1].identifier.name).toBe('x'); + }); + + it('should refer exported references#2', () => { + const { scopeManager } = parseAndAnalyze( + 'const v = 1; export {v as x};', + 'module', + ); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.references).toHaveLength(2); + expect(scope.references[0].identifier.name).toBe('v'); + expect(scope.references[1].identifier.name).toBe('v'); + }); + + it('should not refer exported references from other source#1', () => { + const { scopeManager } = parseAndAnalyze( + 'export {x} from "mod";', + 'module', + ); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + }); + + it('should not refer exported references from other source#2', () => { + const { scopeManager } = parseAndAnalyze( + 'export {v as x} from "mod";', + 'module', + ); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + }); + + it('should not refer exported references from other source#3', () => { + const { scopeManager } = parseAndAnalyze('export * from "mod";', 'module'); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-import.test.ts b/packages/scope-manager/tests/eslint-scope/es6-import.test.ts new file mode 100644 index 00000000000..7edd7fd638a --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-import.test.ts @@ -0,0 +1,134 @@ +import { parseAndAnalyze } from '../util/parse'; +import { + expectToBeGlobalScope, + expectToBeImportBindingDefinition, + expectToBeModuleScope, + expectToBeVariableDefinition, +} from '../util'; + +describe('import declaration', () => { + // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-static-and-runtme-semantics-module-records + it('should import names from source', () => { + const { scopeManager } = parseAndAnalyze('import v from "mod";', 'module'); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('v'); + expectToBeImportBindingDefinition(scope.variables[0].defs[0]); + expect(scope.references).toHaveLength(0); + }); + + it('should import namespaces', () => { + const { scopeManager } = parseAndAnalyze( + 'import * as ns from "mod";', + 'module', + ); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('ns'); + expectToBeImportBindingDefinition(scope.variables[0].defs[0]); + expect(scope.references).toHaveLength(0); + }); + + it('should import insided names#1', () => { + const { scopeManager } = parseAndAnalyze( + 'import {x} from "mod";', + 'module', + ); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('x'); + expectToBeImportBindingDefinition(scope.variables[0].defs[0]); + expect(scope.references).toHaveLength(0); + }); + + it('should import insided names#2', () => { + const { scopeManager } = parseAndAnalyze( + 'import {x as v} from "mod";', + 'module', + ); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('v'); + expectToBeImportBindingDefinition(scope.variables[0].defs[0]); + expect(scope.references).toHaveLength(0); + }); + + it('should reference imports', () => { + const imports = [ + 'import v from "mod";', + 'import { v } from "mod";', + 'import * as v from "mod";', + ]; + for (const code of imports) { + const { scopeManager } = parseAndAnalyze( + ` + ${code} + const x = v; + `, + 'module', + ); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(2); + const importV = scope.variables[0]; + expect(importV.name).toBe('v'); + expectToBeImportBindingDefinition(importV.defs[0]); + const variableX = scope.variables[1]; + expect(variableX.name).toBe('x'); + expectToBeVariableDefinition(variableX.defs[0]); + + expect(scope.references).toHaveLength(2); + expect(scope.references[0].resolved).toBe(variableX); + expect(scope.references[1].resolved).toBe(importV); + } + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-iteration-scope.test.ts b/packages/scope-manager/tests/eslint-scope/es6-iteration-scope.test.ts new file mode 100644 index 00000000000..4bd4a6c9179 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-iteration-scope.test.ts @@ -0,0 +1,180 @@ +import { + expectToBeBlockScope, + expectToBeForScope, + expectToBeFunctionScope, + expectToBeGlobalScope, + expectToBeVariableDefinition, + parseAndAnalyze, +} from '../util'; + +describe('ES6 iteration scope', () => { + it('let materialize iteration scope for ForInStatement#1', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + let i = 20; + for (let i in i) { + console.log(i); + } + }()); + `); + + expect(scopeManager.scopes).toHaveLength(4); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('i'); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('i'); + expect(scope.references[0].resolved).toBe(scope.variables[1]); + + const iterScope = (scope = scopeManager.scopes[2]); + + expectToBeForScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('i'); + expect(scope.references).toHaveLength(2); + expect(scope.references[0].identifier.name).toBe('i'); + expect(scope.references[0].resolved).toBe(scope.variables[0]); + expect(scope.references[1].identifier.name).toBe('i'); + expect(scope.references[1].resolved).toBe(scope.variables[0]); + + scope = scopeManager.scopes[3]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(2); + expect(scope.references[0].identifier.name).toBe('console'); + expect(scope.references[0].resolved).toBe(null); + expect(scope.references[1].identifier.name).toBe('i'); + expect(scope.references[1].resolved).toBe(iterScope.variables[0]); + }); + + it('let materialize iteration scope for ForInStatement#2', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + let i = 20; + for (let { i, j, k } in i) { + console.log(i); + } + }()); + `); + + expect(scopeManager.scopes).toHaveLength(4); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('i'); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('i'); + expect(scope.references[0].resolved).toBe(scope.variables[1]); + + const iterScope = (scope = scopeManager.scopes[2]); + + expectToBeForScope(scope); + expect(scope.variables).toHaveLength(3); + expect(scope.variables[0].name).toBe('i'); + expect(scope.variables[1].name).toBe('j'); + expect(scope.variables[2].name).toBe('k'); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('i'); + expect(scope.references[0].resolved).toBe(scope.variables[0]); + expect(scope.references[1].identifier.name).toBe('j'); + expect(scope.references[1].resolved).toBe(scope.variables[1]); + expect(scope.references[2].identifier.name).toBe('k'); + expect(scope.references[2].resolved).toBe(scope.variables[2]); + expect(scope.references[3].identifier.name).toBe('i'); + expect(scope.references[3].resolved).toBe(scope.variables[0]); + + scope = scopeManager.scopes[3]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(2); + expect(scope.references[0].identifier.name).toBe('console'); + expect(scope.references[0].resolved).toBe(null); + expect(scope.references[1].identifier.name).toBe('i'); + expect(scope.references[1].resolved).toBe(iterScope.variables[0]); + }); + + it('let materialize iteration scope for ForStatement#2', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + let i = 20; + let obj = {}; + for (let { i, j, k } = obj; i < okok; ++i) { + console.log(i, j, k); + } + }()); + `); + + expect(scopeManager.scopes).toHaveLength(4); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + + const functionScope = (scope = scopeManager.scopes[1]); + + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(3); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('i'); + expect(scope.variables[2].name).toBe('obj'); + expect(scope.references).toHaveLength(2); + expect(scope.references[0].identifier.name).toBe('i'); + expect(scope.references[0].resolved).toBe(scope.variables[1]); + expect(scope.references[1].identifier.name).toBe('obj'); + expect(scope.references[1].resolved).toBe(scope.variables[2]); + + const iterScope = (scope = scopeManager.scopes[2]); + + expectToBeForScope(scope); + expect(scope.variables).toHaveLength(3); + expect(scope.variables[0].name).toBe('i'); + expectToBeVariableDefinition(scope.variables[0].defs[0]); + expect(scope.variables[1].name).toBe('j'); + expectToBeVariableDefinition(scope.variables[1].defs[0]); + expect(scope.variables[2].name).toBe('k'); + expectToBeVariableDefinition(scope.variables[2].defs[0]); + expect(scope.references).toHaveLength(7); + expect(scope.references[0].identifier.name).toBe('i'); + expect(scope.references[0].resolved).toBe(scope.variables[0]); + expect(scope.references[1].identifier.name).toBe('j'); + expect(scope.references[1].resolved).toBe(scope.variables[1]); + expect(scope.references[2].identifier.name).toBe('k'); + expect(scope.references[2].resolved).toBe(scope.variables[2]); + expect(scope.references[3].identifier.name).toBe('obj'); + expect(scope.references[3].resolved).toBe(functionScope.variables[2]); + expect(scope.references[4].identifier.name).toBe('i'); + expect(scope.references[4].resolved).toBe(scope.variables[0]); + expect(scope.references[5].identifier.name).toBe('okok'); + expect(scope.references[5].resolved).toBeNull(); + expect(scope.references[6].identifier.name).toBe('i'); + expect(scope.references[6].resolved).toBe(scope.variables[0]); + + scope = scopeManager.scopes[3]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(4); + expect(scope.references[0].identifier.name).toBe('console'); + expect(scope.references[0].resolved).toBeNull(); + expect(scope.references[1].identifier.name).toBe('i'); + expect(scope.references[1].resolved).toBe(iterScope.variables[0]); + expect(scope.references[2].identifier.name).toBe('j'); + expect(scope.references[2].resolved).toBe(iterScope.variables[1]); + expect(scope.references[3].identifier.name).toBe('k'); + expect(scope.references[3].resolved).toBe(iterScope.variables[2]); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-new-target.test.ts b/packages/scope-manager/tests/eslint-scope/es6-new-target.test.ts new file mode 100644 index 00000000000..097eee3d98e --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-new-target.test.ts @@ -0,0 +1,25 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { expectToBeFunctionScope, parseAndAnalyze } from '../util'; + +describe('ES6 new.target', () => { + it('should not make references of new.target', () => { + const { scopeManager } = parseAndAnalyze(` + class A { + constructor() { + new.target; + } + } + `); + + expect(scopeManager.scopes).toHaveLength(3); + + const scope = scopeManager.scopes[2]; + + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionExpression); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-object.test.ts b/packages/scope-manager/tests/eslint-scope/es6-object.test.ts new file mode 100644 index 00000000000..77312f7a7cc --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-object.test.ts @@ -0,0 +1,66 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { + expectToBeFunctionScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('ES6 object', () => { + it('method definition', () => { + const { scopeManager } = parseAndAnalyze(` + ({ + constructor() { + } + }) + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionExpression); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); + }); + + it('computed property key may refer variables', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + var yuyushiki = 42; + ({ + [yuyushiki]() { + }, + + [yuyushiki + 40]() { + } + }) + }()); + `); + + expect(scopeManager.scopes).toHaveLength(4); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionExpression); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('yuyushiki'); + expect(scope.references).toHaveLength(3); + expect(scope.references[0].identifier.name).toBe('yuyushiki'); + expect(scope.references[1].identifier.name).toBe('yuyushiki'); + expect(scope.references[2].identifier.name).toBe('yuyushiki'); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-rest-args.test.ts b/packages/scope-manager/tests/eslint-scope/es6-rest-args.test.ts new file mode 100644 index 00000000000..a96f740d4e8 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-rest-args.test.ts @@ -0,0 +1,36 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { + expectToBeFunctionScope, + expectToBeGlobalScope, + expectToBeIdentifier, + expectToBeParameterDefinition, + parseAndAnalyze, +} from '../util'; + +describe('ES6 rest arguments', () => { + it('materialize rest argument in scope', () => { + const { scopeManager } = parseAndAnalyze(` + function foo(...bar) { + return bar; + } + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(1); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('bar'); + expectToBeIdentifier(scope.variables[1].defs[0].name); + expect(scope.variables[1].defs[0].name.name).toBe('bar'); + expectToBeParameterDefinition(scope.variables[1].defs[0]); + expect(scope.variables[1].defs[0].rest).toBeTruthy(); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-super.test.ts b/packages/scope-manager/tests/eslint-scope/es6-super.test.ts new file mode 100644 index 00000000000..66930149b09 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-super.test.ts @@ -0,0 +1,49 @@ +import { + expectToBeClassScope, + expectToBeFunctionScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('ES6 super', () => { + it('is not handled as reference', () => { + const { scopeManager } = parseAndAnalyze(` + class Foo extends Bar { + constructor() { + super(); + } + + method() { + super.method(); + } + } + `); + + expect(scopeManager.scopes).toHaveLength(4); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('Foo'); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeClassScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('Foo'); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('Bar'); + + scope = scopeManager.scopes[2]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); // super is specially handled like `this`. + + scope = scopeManager.scopes[3]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); // super is specially handled like `this`. + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-switch.test.ts b/packages/scope-manager/tests/eslint-scope/es6-switch.test.ts new file mode 100644 index 00000000000..430a17b8a79 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-switch.test.ts @@ -0,0 +1,47 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { + expectToBeGlobalScope, + expectToBeSwitchScope, + parseAndAnalyze, +} from '../util'; + +describe('ES6 switch', () => { + it('materialize scope', () => { + const { scopeManager } = parseAndAnalyze(` + switch (ok) { + case hello: + let i = 20; + i; + break; + + default: + let test = 30; + test; + } + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('ok'); + + scope = scopeManager.scopes[1]; + expectToBeSwitchScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.SwitchStatement); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('i'); + expect(scope.variables[1].name).toBe('test'); + expect(scope.references).toHaveLength(5); + expect(scope.references[0].identifier.name).toBe('hello'); + expect(scope.references[1].identifier.name).toBe('i'); + expect(scope.references[2].identifier.name).toBe('i'); + expect(scope.references[3].identifier.name).toBe('test'); + expect(scope.references[4].identifier.name).toBe('test'); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/es6-template-literal.test.ts b/packages/scope-manager/tests/eslint-scope/es6-template-literal.test.ts new file mode 100644 index 00000000000..91521c39b71 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/es6-template-literal.test.ts @@ -0,0 +1,46 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { + expectToBeFunctionScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('ES6 template literal', () => { + it('refer variables', () => { + const { scopeManager } = parseAndAnalyze(` + (function () { + let i, j, k; + function testing() { } + let template = testing\`testing \${i} and \${j}\` + return template; + }()); + `); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionExpression); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(6); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('i'); + expect(scope.variables[2].name).toBe('j'); + expect(scope.variables[3].name).toBe('k'); + expect(scope.variables[4].name).toBe('testing'); + expect(scope.variables[5].name).toBe('template'); + expect(scope.references).toHaveLength(5); + expect(scope.references[0].identifier.name).toBe('template'); + expect(scope.references[1].identifier.name).toBe('testing'); + expect(scope.references[2].identifier.name).toBe('i'); + expect(scope.references[3].identifier.name).toBe('j'); + expect(scope.references[4].identifier.name).toBe('template'); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/function-expression-name.test.ts b/packages/scope-manager/tests/eslint-scope/function-expression-name.test.ts new file mode 100644 index 00000000000..b0080860710 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/function-expression-name.test.ts @@ -0,0 +1,39 @@ +import { + expectToBeFunctionExpressionNameScope, + expectToBeFunctionScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('function name', () => { + it('should create its special scope', () => { + const { scopeManager } = parseAndAnalyze(` + (function name() { + }()); + `); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + const globalScope = scope; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + // Function expression name scope + scope = scopeManager.scopes[1]; + expectToBeFunctionExpressionNameScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('name'); + expect(scope.references).toHaveLength(0); + expect(scope.upper === globalScope).toBeTruthy(); + + // Function scope + scope = scopeManager.scopes[2]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); + expect(scope.upper === scopeManager.scopes[1]).toBeTruthy(); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/get-declared-variables.test.ts b/packages/scope-manager/tests/eslint-scope/get-declared-variables.test.ts new file mode 100644 index 00000000000..7f57a448375 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/get-declared-variables.test.ts @@ -0,0 +1,228 @@ +import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/types'; +import { simpleTraverse } from '@typescript-eslint/typescript-estree'; +import { parse } from '../util/parse'; +import { analyze } from '../../src/analyze'; + +describe('ScopeManager.prototype.getDeclaredVariables', () => { + function verify( + ast: TSESTree.Node, + type: AST_NODE_TYPES, + expectedNamesList: string[][], + ): void { + const scopeManager = analyze(ast, { + ecmaVersion: 6, + sourceType: 'module', + }); + + simpleTraverse(ast, { + [type](node) { + const expected = expectedNamesList.shift()!; + const actual = scopeManager.getDeclaredVariables(node); + + expect(actual).toHaveLength(expected.length); + if (actual.length > 0) { + const end = actual.length - 1; + + for (let i = 0; i <= end; i++) { + expect(actual[i].name).toBe(expected[i]); + } + } + }, + }); + + expect(expectedNamesList).toHaveLength(0); + } + + it('should get variables that declared on `VariableDeclaration`', () => { + const ast = parse(` + var {a, x: [b], y: {c = 0}} = foo; + let {d, x: [e], y: {f = 0}} = foo; + const {g, x: [h], y: {i = 0}} = foo, {j, k = function() { let l; }} = bar; + `); + + verify(ast, AST_NODE_TYPES.VariableDeclaration, [ + ['a', 'b', 'c'], + ['d', 'e', 'f'], + ['g', 'h', 'i', 'j', 'k'], + ['l'], + ]); + }); + + it('should get variables that declared on `VariableDeclaration` in for-in/of', () => { + const ast = parse(` + for (var {a, x: [b], y: {c = 0}} in foo) { + let g; + } + for (let {d, x: [e], y: {f = 0}} of foo) { + let h; + } + `); + + verify(ast, AST_NODE_TYPES.VariableDeclaration, [ + ['a', 'b', 'c'], + ['g'], + ['d', 'e', 'f'], + ['h'], + ]); + }); + + it('should get variables that declared on `VariableDeclarator`', () => { + const ast = parse(` + var {a, x: [b], y: {c = 0}} = foo; + let {d, x: [e], y: {f = 0}} = foo; + const {g, x: [h], y: {i = 0}} = foo, {j, k = function() { let l; }} = bar; + `); + + verify(ast, AST_NODE_TYPES.VariableDeclarator, [ + ['a', 'b', 'c'], + ['d', 'e', 'f'], + ['g', 'h', 'i'], + ['j', 'k'], + ['l'], + ]); + }); + + it('should get variables that declared on `FunctionDeclaration`', () => { + const ast = parse(` + function foo({a, x: [b], y: {c = 0}}, [d, e]) { + let z; + } + function bar({f, x: [g], y: {h = 0}}, [i, j = function(q) { let w; }]) { + let z; + } + `); + + verify(ast, AST_NODE_TYPES.FunctionDeclaration, [ + ['foo', 'a', 'b', 'c', 'd', 'e'], + ['bar', 'f', 'g', 'h', 'i', 'j'], + ]); + }); + + it('should get variables that declared on `FunctionExpression`', () => { + const ast = parse(` + (function foo({a, x: [b], y: {c = 0}}, [d, e]) { + let z; + }); + (function bar({f, x: [g], y: {h = 0}}, [i, j = function(q) { let w; }]) { + let z; + }); + `); + + verify(ast, AST_NODE_TYPES.FunctionExpression, [ + ['foo', 'a', 'b', 'c', 'd', 'e'], + ['bar', 'f', 'g', 'h', 'i', 'j'], + ['q'], + ]); + }); + + it('should get variables that declared on `ArrowFunctionExpression`', () => { + const ast = parse(` + (({a, x: [b], y: {c = 0}}, [d, e]) => { + let z; + }); + (({f, x: [g], y: {h = 0}}, [i, j]) => { + let z; + }); + `); + + verify(ast, AST_NODE_TYPES.ArrowFunctionExpression, [ + ['a', 'b', 'c', 'd', 'e'], + ['f', 'g', 'h', 'i', 'j'], + ]); + }); + + it('should get variables that declared on `ClassDeclaration`', () => { + const ast = parse(` + class A { foo(x) { let y; } } + class B { foo(x) { let y; } } + `); + + verify(ast, AST_NODE_TYPES.ClassDeclaration, [ + ['A', 'A'], // outer scope"s and inner scope"s. + ['B', 'B'], + ]); + }); + + it('should get variables that declared on `ClassExpression`', () => { + const ast = parse(` + (class A { foo(x) { let y; } }); + (class B { foo(x) { let y; } }); + `); + + verify(ast, AST_NODE_TYPES.ClassExpression, [['A'], ['B']]); + }); + + it('should get variables that declared on `CatchClause`', () => { + const ast = parse(` + try {} catch ({a, b}) { + let x; + try {} catch ({c, d}) { + let y; + } + } + `); + + verify(ast, AST_NODE_TYPES.CatchClause, [ + ['a', 'b'], + ['c', 'd'], + ]); + }); + + it('should get variables that declared on `ImportDeclaration`', () => { + const ast = parse( + ` + import "aaa"; + import * as a from "bbb"; + import b, {c, x as d} from "ccc";\ + `, + 'module', + ); + + verify(ast, AST_NODE_TYPES.ImportDeclaration, [[], ['a'], ['b', 'c', 'd']]); + }); + + it('should get variables that declared on `ImportSpecifier`', () => { + const ast = parse( + ` + import "aaa"; + import * as a from "bbb"; + import b, {c, x as d} from "ccc"; + `, + 'module', + ); + + verify(ast, AST_NODE_TYPES.ImportSpecifier, [['c'], ['d']]); + }); + + it('should get variables that declared on `ImportDefaultSpecifier`', () => { + const ast = parse( + ` + import "aaa"; + import * as a from "bbb"; + import b, {c, x as d} from "ccc"; + `, + 'module', + ); + + verify(ast, AST_NODE_TYPES.ImportDefaultSpecifier, [['b']]); + }); + + it('should get variables that declared on `ImportNamespaceSpecifier`', () => { + const ast = parse( + ` + import "aaa"; + import * as a from "bbb"; + import b, {c, x as d} from "ccc"; + `, + 'module', + ); + + verify(ast, AST_NODE_TYPES.ImportNamespaceSpecifier, [['a']]); + }); + + it("should not get duplicate even if it's declared twice", () => { + const ast = parse('var a = 0, a = 1;'); + + verify(ast, AST_NODE_TYPES.VariableDeclaration, [['a']]); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/global-increment.test.ts b/packages/scope-manager/tests/eslint-scope/global-increment.test.ts new file mode 100644 index 00000000000..4f2fd68384a --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/global-increment.test.ts @@ -0,0 +1,15 @@ +import { expectToBeGlobalScope, parseAndAnalyze } from '../util'; + +describe('global increment', () => { + it('becomes read/write', () => { + const { scopeManager } = parseAndAnalyze('b++;'); + + expect(scopeManager.scopes).toHaveLength(1); + + const scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].isReadWrite()).toBeTruthy(); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/global-return.test.ts b/packages/scope-manager/tests/eslint-scope/global-return.test.ts new file mode 100644 index 00000000000..d5e2756ffc1 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/global-return.test.ts @@ -0,0 +1,67 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { + expectToBeGlobalScope, + expectToBeFunctionScope, + expectToBeModuleScope, + expectToBeImportBindingDefinition, +} from '../util'; +import { parseAndAnalyze } from '../util/parse'; + +describe('gloablReturn option', () => { + it('creates a function scope following the global scope immediately', () => { + const { scopeManager } = parseAndAnalyze( + ` + "use strict"; + var hello = 20; + `, + { globalReturn: true }, + ); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeTruthy(); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.variables[1].name).toBe('hello'); + }); + + it('creates a function scope following the global scope immediately and creates module scope', () => { + const { scopeManager } = parseAndAnalyze("import {x as v} from 'mod';", { + sourceType: 'module', + globalReturn: true, + }); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + + scope = scopeManager.scopes[2]; + expectToBeModuleScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('v'); + expectToBeImportBindingDefinition(scope.variables[0].defs[0]); + expect(scope.references).toHaveLength(0); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/implicit-global-reference.test.ts b/packages/scope-manager/tests/eslint-scope/implicit-global-reference.test.ts new file mode 100644 index 00000000000..e4a81e017bb --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/implicit-global-reference.test.ts @@ -0,0 +1,148 @@ +import { expectToBeGlobalScope, parseAndAnalyze } from '../util'; +import { DefinitionType } from '../../src/definition'; + +describe('implicit global reference', () => { + it('assignments global scope', () => { + const { scopeManager } = parseAndAnalyze(` + var x = 20; + x = 300; + `); + + const scopes = scopeManager.scopes; + + expect( + scopes.map(scope => + scope.variables.map(variable => variable.defs.map(def => def.type)), + ), + ).toEqual([[[DefinitionType.Variable]]]); + + expectToBeGlobalScope(scopes[0]); + expect( + scopes[0]['implicit'].variables.map(variable => variable.name), + ).toEqual([]); + }); + + it('assignments global scope without definition', () => { + const { scopeManager } = parseAndAnalyze(` + x = 300; + x = 300; + `); + + const scopes = scopeManager.scopes; + + expect( + scopes.map(scope => + scope.variables.map(variable => variable.defs.map(def => def.type)), + ), + ).toEqual([[]]); + + expectToBeGlobalScope(scopes[0]); + expect( + scopes[0]['implicit'].variables.map(variable => variable.name), + ).toEqual(['x']); + }); + + it('assignments global scope without definition eval', () => { + const { scopeManager } = parseAndAnalyze(` + function inner() { + eval(str); + x = 300; + } + `); + + const scopes = scopeManager.scopes; + + expect( + scopes.map(scope => + scope.variables.map(variable => variable.defs.map(def => def.type)), + ), + ).toEqual([[[DefinitionType.FunctionName]], [[]]]); + + expectToBeGlobalScope(scopes[0]); + expect( + scopes[0]['implicit'].variables.map(variable => variable.name), + ).toEqual(['x']); + }); + + it('assignment leaks', () => { + const { scopeManager } = parseAndAnalyze(` + function outer() { + x = 20; + } + `); + + const scopes = scopeManager.scopes; + + expect( + scopes.map(scope => scope.variables.map(variable => variable.name)), + ).toEqual([['outer'], ['arguments']]); + + expectToBeGlobalScope(scopes[0]); + expect( + scopes[0]['implicit'].variables.map(variable => variable.name), + ).toEqual(['x']); + }); + + it("assignment doesn't leak", () => { + const { scopeManager } = parseAndAnalyze(` + function outer() { + function inner() { + x = 20; + } + var x; + } + `); + + const scopes = scopeManager.scopes; + + expect( + scopes.map(scope => scope.variables.map(variable => variable.name)), + ).toEqual([['outer'], ['arguments', 'inner', 'x'], ['arguments']]); + + expectToBeGlobalScope(scopes[0]); + expect( + scopes[0]['implicit'].variables.map(variable => variable.name), + ).toEqual([]); + }); + + it('for-in-statement leaks', () => { + const { scopeManager } = parseAndAnalyze(` + function outer() { + for (x in y) { } + } + `); + + const scopes = scopeManager.scopes; + + expect( + scopes.map(scope => scope.variables.map(variable => variable.name)), + ).toEqual([['outer'], ['arguments'], []]); + + expectToBeGlobalScope(scopes[0]); + expect( + scopes[0]['implicit'].variables.map(variable => variable.name), + ).toEqual(['x']); + }); + + it("for-in-statement doesn't leaks", () => { + const { scopeManager } = parseAndAnalyze(` + function outer() { + function inner() { + for (x in y) { } + } + var x; + } + `); + + const scopes = scopeManager.scopes; + + expect( + scopes.map(scope => scope.variables.map(variable => variable.name)), + ).toEqual([['outer'], ['arguments', 'inner', 'x'], ['arguments'], []]); + + expectToBeGlobalScope(scopes[0]); + expect( + scopes[0]['implicit'].variables.map(variable => variable.name), + ).toEqual([]); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/implied-strict.test.ts b/packages/scope-manager/tests/eslint-scope/implied-strict.test.ts new file mode 100644 index 00000000000..645e8c83c07 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/implied-strict.test.ts @@ -0,0 +1,124 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { + expectToBeFunctionScope, + expectToBeGlobalScope, + expectToBeModuleScope, + parseAndAnalyze, +} from '../util'; + +describe('impliedStrict option', () => { + it('ensures all user scopes are strict if ecmaVersion >= 5', () => { + const { scopeManager } = parseAndAnalyze( + ` + function foo() { + function bar() { + "use strict"; + } + } + `, + { + ecmaVersion: 5, + impliedStrict: true, + }, + ); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeTruthy(); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionDeclaration); + expect(scope.isStrict).toBeTruthy(); + + scope = scopeManager.scopes[2]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionDeclaration); + expect(scope.isStrict).toBeTruthy(); + }); + + it('ensures impliedStrict option is only effective when ecmaVersion option >= 5', () => { + const { scopeManager } = parseAndAnalyze( + ` + function foo() {} + `, + { + ecmaVersion: 3, + impliedStrict: true, + }, + ); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionDeclaration); + expect(scope.isStrict).toBeFalsy(); + }); + + it('omits a nodejs global scope when ensuring all user scopes are strict', () => { + const { scopeManager } = parseAndAnalyze( + ` + function foo() {} + `, + { + ecmaVersion: 5, + globalReturn: true, + impliedStrict: true, + }, + ); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeTruthy(); + + scope = scopeManager.scopes[2]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionDeclaration); + expect(scope.isStrict).toBeTruthy(); + }); + + it('omits a module global scope when ensuring all user scopes are strict', () => { + const { scopeManager } = parseAndAnalyze('function foo() {}', { + ecmaVersion: 6, + impliedStrict: true, + sourceType: 'module', + }); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + + expectToBeGlobalScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.Program); + expect(scope.isStrict).toBeFalsy(); + + scope = scopeManager.scopes[1]; + expectToBeModuleScope(scope); + expect(scope.isStrict).toBeTruthy(); + + scope = scopeManager.scopes[2]; + expectToBeFunctionScope(scope); + expect(scope.block.type).toBe(AST_NODE_TYPES.FunctionDeclaration); + expect(scope.isStrict).toBeTruthy(); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/label.test.ts b/packages/scope-manager/tests/eslint-scope/label.test.ts new file mode 100644 index 00000000000..142a8364b5e --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/label.test.ts @@ -0,0 +1,61 @@ +import { + expectToBeBlockScope, + expectToBeFunctionScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('label', () => { + it('should not create variables', () => { + const { scopeManager } = parseAndAnalyze( + 'function bar() { q: for(;;) { break q; } }', + ); + + expect(scopeManager.scopes).toHaveLength(3); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('bar'); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[2]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + }); + + it('should count child node references', () => { + const { scopeManager } = parseAndAnalyze(` + var foo = 5; + + label: while (true) { + console.log(foo); + break; + } + `); + + expect(scopeManager.scopes).toHaveLength(2); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('foo'); + expect(scope.through.length).toBe(3); + expect(scope.through[2].identifier.name).toBe('foo'); + expect(scope.through[2].isRead()).toBeTruthy(); + + scope = scopeManager.scopes[1]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(2); + expect(scope.references[0].identifier.name).toBe('console'); + expect(scope.references[1].identifier.name).toBe('foo'); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/references.test.ts b/packages/scope-manager/tests/eslint-scope/references.test.ts new file mode 100644 index 00000000000..cc9a4d6e873 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/references.test.ts @@ -0,0 +1,512 @@ +import { parseAndAnalyze } from '../util'; + +describe('References:', () => { + describe('When there is a `let` declaration on global,', () => { + it('the reference on global should be resolved.', () => { + const { scopeManager } = parseAndAnalyze('let a = 0;'); + + expect(scopeManager.scopes).toHaveLength(1); + + const scope = scopeManager.scopes[0]; + + expect(scope.variables).toHaveLength(1); + expect(scope.references).toHaveLength(1); + + const reference = scope.references[0]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scope.variables[0]); + expect(reference.writeExpr).not.toBeUndefined(); + expect(reference.isWrite()).toBeTruthy(); + expect(reference.isRead()).toBeFalsy(); + }); + + it('the reference in functions should be resolved.', () => { + const { scopeManager } = parseAndAnalyze(` + let a = 0; + function foo() { + let b = a; + } + `); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(2); // [arguments, b] + expect(scope.references).toHaveLength(2); // [b, a] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scopeManager.scopes[0].variables[0]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + + it('the reference in default parameters should be resolved.', () => { + const { scopeManager } = parseAndAnalyze(` + let a = 0; + function foo(b = a) { + } + `); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(2); // [arguments, b] + expect(scope.references).toHaveLength(2); // [b, a] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scopeManager.scopes[0].variables[0]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + + describe('When there is a `const` declaration on global,', () => { + it('the reference on global should be resolved.', () => { + const { scopeManager } = parseAndAnalyze('const a = 0;'); + + expect(scopeManager.scopes).toHaveLength(1); + + const scope = scopeManager.scopes[0]; + + expect(scope.variables).toHaveLength(1); + expect(scope.references).toHaveLength(1); + + const reference = scope.references[0]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scope.variables[0]); + expect(reference.writeExpr).not.toBeUndefined(); + expect(reference.isWrite()).toBeTruthy(); + expect(reference.isRead()).toBeFalsy(); + }); + + it('the reference in functions should be resolved.', () => { + const { scopeManager } = parseAndAnalyze(` + const a = 0; + function foo() { + const b = a; + } + `); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(2); // [arguments, b] + expect(scope.references).toHaveLength(2); // [b, a] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scopeManager.scopes[0].variables[0]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + + describe('When there is a `var` declaration on global,', () => { + it('the reference on global should NOT be resolved.', () => { + const { scopeManager } = parseAndAnalyze('var a = 0;'); + + expect(scopeManager.scopes).toHaveLength(1); + + const scope = scopeManager.scopes[0]; + + expect(scope.variables).toHaveLength(1); + expect(scope.references).toHaveLength(1); + + const reference = scope.references[0]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBeNull(); + expect(reference.writeExpr).not.toBeUndefined(); + expect(reference.isWrite()).toBeTruthy(); + expect(reference.isRead()).toBeFalsy(); + }); + + it('the reference in functions should NOT be resolved.', () => { + const { scopeManager } = parseAndAnalyze(` + var a = 0; + function foo() { + var b = a; + } + `); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(2); // [arguments, b] + expect(scope.references).toHaveLength(2); // [b, a] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBeNull(); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + + describe('When there is a `class` declaration on global,', () => { + it('the reference on global should be resolved.', () => { + const { scopeManager } = parseAndAnalyze(` + class A {} + let b = new A(); + `); + + expect(scopeManager.scopes).toHaveLength(2); // [global, A] + + const scope = scopeManager.scopes[0]; + + expect(scope.variables).toHaveLength(2); // [A, b] + expect(scope.references).toHaveLength(2); // [b, A] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('A'); + expect(reference.resolved).toBe(scope.variables[0]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + + it('the reference in functions should be resolved.', () => { + const { scopeManager } = parseAndAnalyze(` + class A {} + function foo() { + let b = new A(); + } + `); + + expect(scopeManager.scopes).toHaveLength(3); // [global, A, foo] + + const scope = scopeManager.scopes[2]; + + expect(scope.variables).toHaveLength(2); // [arguments, b] + expect(scope.references).toHaveLength(2); // [b, A] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('A'); + expect(reference.resolved).toBe(scopeManager.scopes[0].variables[0]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + + describe('When there is a `let` declaration in functions,', () => { + it('the reference on the function should be resolved.', () => { + const { scopeManager } = parseAndAnalyze(` + function foo() { + let a = 0; + } + `); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(2); // [arguments, a] + expect(scope.references).toHaveLength(1); + + const reference = scope.references[0]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scope.variables[1]); + expect(reference.writeExpr).not.toBeUndefined(); + expect(reference.isWrite()).toBeTruthy(); + expect(reference.isRead()).toBeFalsy(); + }); + + it('the reference in nested functions should be resolved.', () => { + const { scopeManager } = parseAndAnalyze(` + function foo() { + let a = 0; + function bar() { + let b = a; + } + } + `); + + expect(scopeManager.scopes).toHaveLength(3); // [global, foo, bar] + + const scope = scopeManager.scopes[2]; + + expect(scope.variables).toHaveLength(2); // [arguments, b] + expect(scope.references).toHaveLength(2); // [b, a] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scopeManager.scopes[1].variables[1]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + + describe('When there is a `var` declaration in functions,', () => { + it('the reference on the function should be resolved.', () => { + const { scopeManager } = parseAndAnalyze(` + function foo() { + var a = 0; + } + `); + + expect(scopeManager.scopes).toHaveLength(2); // [global, foo] + + const scope = scopeManager.scopes[1]; + + expect(scope.variables).toHaveLength(2); // [arguments, a] + expect(scope.references).toHaveLength(1); + + const reference = scope.references[0]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scope.variables[1]); + expect(reference.writeExpr).not.toBeUndefined(); + expect(reference.isWrite()).toBeTruthy(); + expect(reference.isRead()).toBeFalsy(); + }); + + it('the reference in nested functions should be resolved.', () => { + const { scopeManager } = parseAndAnalyze(` + function foo() { + var a = 0; + function bar() { + var b = a; + } + } + `); + + expect(scopeManager.scopes).toHaveLength(3); // [global, foo, bar] + + const scope = scopeManager.scopes[2]; + + expect(scope.variables).toHaveLength(2); // [arguments, b] + expect(scope.references).toHaveLength(2); // [b, a] + + const reference = scope.references[1]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scopeManager.scopes[1].variables[1]); + expect(reference.writeExpr).toBeUndefined(); + expect(reference.isWrite()).toBeFalsy(); + expect(reference.isRead()).toBeTruthy(); + }); + }); + + describe('When there is a `let` declaration with destructuring assignment', () => { + it('"let [a] = [1];", the reference should be resolved.', () => { + const { scopeManager } = parseAndAnalyze('let [a] = [1];'); + + expect(scopeManager.scopes).toHaveLength(1); + + const scope = scopeManager.scopes[0]; + + expect(scope.variables).toHaveLength(1); + expect(scope.references).toHaveLength(1); + + const reference = scope.references[0]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scope.variables[0]); + expect(reference.writeExpr).not.toBeUndefined(); + expect(reference.isWrite()).toBeTruthy(); + expect(reference.isRead()).toBeFalsy(); + }); + + it('"let {a} = {a: 1};", the reference should be resolved.', () => { + const { scopeManager } = parseAndAnalyze('let {a} = {a: 1};'); + + expect(scopeManager.scopes).toHaveLength(1); + + const scope = scopeManager.scopes[0]; + + expect(scope.variables).toHaveLength(1); + expect(scope.references).toHaveLength(1); + + const reference = scope.references[0]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scope.variables[0]); + expect(reference.writeExpr).not.toBeUndefined(); + expect(reference.isWrite()).toBeTruthy(); + expect(reference.isRead()).toBeFalsy(); + }); + + it('"let {a: {a}} = {a: {a: 1}};", the reference should be resolved.', () => { + const { scopeManager } = parseAndAnalyze('let {a: {a}} = {a: {a: 1}};'); + + expect(scopeManager.scopes).toHaveLength(1); + + const scope = scopeManager.scopes[0]; + + expect(scope.variables).toHaveLength(1); + expect(scope.references).toHaveLength(1); + + const reference = scope.references[0]; + + expect(reference.from).toBe(scope); + expect(reference.identifier.name).toBe('a'); + expect(reference.resolved).toBe(scope.variables[0]); + expect(reference.writeExpr).not.toBeUndefined(); + expect(reference.isWrite()).toBeTruthy(); + expect(reference.isRead()).toBeFalsy(); + }); + }); + + describe('Reference.init should be a boolean value of whether it is one to initialize or not.', () => { + const trueCodes = [ + 'var a = 0;', + 'let a = 0;', + 'const a = 0;', + 'var [a] = [];', + 'let [a] = [];', + 'const [a] = [];', + 'var [a = 1] = [];', + 'let [a = 1] = [];', + 'const [a = 1] = [];', + 'var {a} = {};', + 'let {a} = {};', + 'const {a} = {};', + 'var {b: a} = {};', + 'let {b: a} = {};', + 'const {b: a} = {};', + 'var {b: a = 0} = {};', + 'let {b: a = 0} = {};', + 'const {b: a = 0} = {};', + 'for (var a in []);', + 'for (let a in []);', + 'for (var [a] in []);', + 'for (let [a] in []);', + 'for (var [a = 0] in []);', + 'for (let [a = 0] in []);', + 'for (var {a} in []);', + 'for (let {a} in []);', + 'for (var {a = 0} in []);', + 'for (let {a = 0} in []);', + 'new function(a = 0) {}', + 'new function([a = 0] = []) {}', + 'new function({b: a = 0} = {}) {}', + ]; + + trueCodes.forEach(code => + it(`"${code}", all references should be true.`, () => { + const { scopeManager } = parseAndAnalyze(code); + + expect(scopeManager.scopes.length).toBeGreaterThanOrEqual(1); + + const scope = scopeManager.scopes[scopeManager.scopes.length - 1]; + + expect(scope.variables.length).toBeGreaterThanOrEqual(1); + expect(scope.references.length).toBeGreaterThanOrEqual(1); + + scope.references.forEach(reference => { + expect(reference.identifier.name).toBe('a'); + expect(reference.isWrite()).toBeTruthy(); + expect(reference.init).toBeTruthy(); + }); + }), + ); + + let falseCodes = [ + 'let a; a = 0;', + 'let a; [a] = [];', + 'let a; [a = 1] = [];', + 'let a; ({a} = {});', + 'let a; ({b: a} = {});', + 'let a; ({b: a = 0} = {});', + 'let a; for (a in []);', + 'let a; for ([a] in []);', + 'let a; for ([a = 0] in []);', + 'let a; for ({a} in []);', + 'let a; for ({a = 0} in []);', + ]; + + falseCodes.forEach(code => + it(`"${code}", all references should be false.`, () => { + const { scopeManager } = parseAndAnalyze(code); + + expect(scopeManager.scopes.length).toBeGreaterThanOrEqual(1); + + const scope = scopeManager.scopes[scopeManager.scopes.length - 1]; + + expect(scope.variables).toHaveLength(1); + expect(scope.references.length).toBeGreaterThanOrEqual(1); + + scope.references.forEach(reference => { + expect(reference.identifier.name).toBe('a'); + expect(reference.isWrite()).toBeTruthy(); + expect(reference.init).toBeFalsy(); + }); + }), + ); + + falseCodes = [ + 'let a; let b = a;', + 'let a; let [b] = a;', + 'let a; let [b = a] = [];', + 'let a; for (var b in a);', + 'let a; for (var [b = a] in []);', + 'let a; for (let b in a);', + 'let a; for (let [b = a] in []);', + 'let a,b; b = a;', + 'let a,b; [b] = a;', + 'let a,b; [b = a] = [];', + 'let a,b; for (b in a);', + 'let a,b; for ([b = a] in []);', + 'let a; a.foo = 0;', + 'let a,b; b = a.foo;', + ]; + falseCodes.forEach(code => + it(`"${code}", readonly references of "a" should be undefined.`, () => { + const { scopeManager } = parseAndAnalyze(code); + + expect(scopeManager.scopes.length).toBeGreaterThanOrEqual(1); + + const scope = scopeManager.scopes[0]; + + expect(scope.variables.length).toBeGreaterThanOrEqual(1); + expect(scope.variables[0].name).toBe('a'); + + const references = scope.variables[0].references; + + expect(references.length).toBeGreaterThanOrEqual(1); + + references.forEach(reference => { + expect(reference.isRead()).toBeTruthy(); + expect(reference.init).toBeUndefined(); + }); + }), + ); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/typescript.test.ts b/packages/scope-manager/tests/eslint-scope/typescript.test.ts new file mode 100644 index 00000000000..c529ddce962 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/typescript.test.ts @@ -0,0 +1,43 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { + expectToBeFunctionScope, + expectToBeGlobalScope, + parseAndAnalyze, +} from '../util'; + +describe('typescript', () => { + describe('multiple call signatures', () => { + it('should create a function scope', () => { + const { scopeManager } = parseAndAnalyze( + ` + function foo(bar: number): number; + function foo(bar: string): string; + function foo(bar: string | number): string | number { + return bar; + } + `, + 'script', + ); + + expect(scopeManager.scopes).toHaveLength(4); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.references).toHaveLength(0); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].defs).toHaveLength(3); + + for (let i = 1; i < 4; i += 1) { + scope = scopeManager.scopes[i]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(2); + expect(scope.variables[0].name).toBe('arguments'); + if (scope.block.type === AST_NODE_TYPES.TSDeclareFunction) { + expect(scope.references).toHaveLength(0); + } else { + expect(scope.references).toHaveLength(1); + } + } + }); + }); +}); diff --git a/packages/scope-manager/tests/eslint-scope/with-scope.test.ts b/packages/scope-manager/tests/eslint-scope/with-scope.test.ts new file mode 100644 index 00000000000..7949d773441 --- /dev/null +++ b/packages/scope-manager/tests/eslint-scope/with-scope.test.ts @@ -0,0 +1,48 @@ +import { + expectToBeBlockScope, + expectToBeFunctionScope, + expectToBeGlobalScope, + expectToBeWithScope, + parseAndAnalyze, +} from '../util'; + +describe('with', () => { + it('creates scope', () => { + const { scopeManager } = parseAndAnalyze( + ` + (function () { + with (obj) { + testing; + } + }()); + `, + 'script', + ); + + expect(scopeManager.scopes).toHaveLength(4); + + let scope = scopeManager.scopes[0]; + expectToBeGlobalScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[1]; + expectToBeFunctionScope(scope); + expect(scope.variables).toHaveLength(1); + expect(scope.variables[0].name).toBe('arguments'); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].resolved).toBeNull(); + + scope = scopeManager.scopes[2]; + expectToBeWithScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(0); + + scope = scopeManager.scopes[3]; + expectToBeBlockScope(scope); + expect(scope.variables).toHaveLength(0); + expect(scope.references).toHaveLength(1); + expect(scope.references[0].identifier.name).toBe('testing'); + expect(scope.references[0].resolved).toBeNull(); + }); +}); diff --git a/packages/scope-manager/tests/fixtures.test.ts b/packages/scope-manager/tests/fixtures.test.ts new file mode 100644 index 00000000000..b1b18a3ab69 --- /dev/null +++ b/packages/scope-manager/tests/fixtures.test.ts @@ -0,0 +1,155 @@ +import fs from 'fs'; +import glob from 'glob'; +import makeDir from 'make-dir'; +import path from 'path'; +import { parseAndAnalyze, AnalyzeOptions } from './util'; + +// Assign a segment set to this variable to limit the test to only this segment +// This is super helpful if you need to debug why a specific fixture isn't producing the correct output +// eg. ['type-declaration', 'signatures', 'method-generic'] will only test /type-declaration/signatures/method-generic.ts +// prettier-ignore +const ONLY = [].join(path.sep); + +const FIXTURES_DIR = path.resolve(__dirname, 'fixtures'); + +const fixtures = glob + .sync(`${FIXTURES_DIR}/**/*.{js,ts,jsx,tsx}`, { + ignore: ['fixtures.test.ts'], + }) + .map(absolute => { + const relative = path.relative(FIXTURES_DIR, absolute); + const { name, dir, ext } = path.parse(relative); + const segments = dir.split(path.sep); + const snapshotPath = path.join(FIXTURES_DIR, dir); + return { + absolute, + name, + segments, + snapshotPath, + snapshotFile: path.join(snapshotPath, `${name}${ext}.shot`), + }; + }); + +const FOUR_SLASH = /^\/\/\/\/[ ]+@(\w+)[ ]*=[ ]*(.+)$/; +const QUOTED_STRING = /^["'](.+?)['"]$/; +type ALLOWED_VALUE = ['number' | 'boolean' | 'string', Set?]; +const ALLOWED_OPTIONS: Map = new Map< + keyof AnalyzeOptions, + ALLOWED_VALUE +>([ + ['ecmaVersion', ['number']], + ['globalReturn', ['boolean']], + ['impliedStrict', ['boolean']], + ['sourceType', ['string', new Set(['module', 'script'])]], +]); + +function nestDescribe( + fixture: typeof fixtures[number], + segments = fixture.segments, +): void { + if (segments.length > 0) { + describe(segments[0], () => { + nestDescribe(fixture, segments.slice(1)); + }); + } else { + const test = (): void => { + const contents = fs.readFileSync(fixture.absolute, 'utf8'); + + const lines = contents.split('\n'); + const options: Record = { + lib: [], + }; + for (const line of lines) { + if (!line.startsWith('////')) { + continue; + } + + const match = FOUR_SLASH.exec(line); + if (!match) { + throw new Error(`Four-slash did not match expected format: ${line}`); + } + const [, key, rawValue] = match; + const type = ALLOWED_OPTIONS.get(key); + if (!type) { + throw new Error(`Unknown option ${key}`); + } + + let value: unknown = rawValue; + switch (type[0]) { + case 'string': { + const strmatch = QUOTED_STRING.exec(rawValue); + if (strmatch) { + value = strmatch[1]; + } + break; + } + + case 'number': { + const parsed = parseFloat(rawValue); + if (isNaN(parsed)) { + throw new Error( + `Expected a number for ${key}, but got ${rawValue}`, + ); + } + value = parsed; + break; + } + + case 'boolean': { + if (rawValue === 'true') { + value = true; + } else if (rawValue === 'false') { + value = false; + } else { + throw new Error( + `Expected a boolean for ${key}, but got ${rawValue}`, + ); + } + break; + } + } + + if (type[1] && !type[1].has(value)) { + throw new Error( + `Expected value for ${key} to be one of (${Array.from(type[1]).join( + ' | ', + )}), but got ${value}`, + ); + } + + if (value === 'true') { + options[key] = true; + } else if (value === 'false') { + options[key] = false; + } else { + options[key] = value; + } + } + + try { + makeDir.sync(fixture.snapshotPath); + } catch (e) { + if ('code' in e && e.code === 'EEXIST') { + // already exists - ignored + } else { + throw e; + } + } + + try { + const { scopeManager } = parseAndAnalyze(contents, options); + expect(scopeManager).toMatchSpecificSnapshot(fixture.snapshotFile); + } catch (e) { + expect(e).toMatchSpecificSnapshot(fixture.snapshotFile); + } + }; + + if ([...fixture.segments, fixture.name].join(path.sep) === ONLY) { + it.only(fixture.name, test); + } else { + it(fixture.name, test); + } + } +} + +fixtures.forEach(f => nestDescribe(f)); diff --git a/packages/scope-manager/tests/fixtures/block/inherited-scope.ts b/packages/scope-manager/tests/fixtures/block/inherited-scope.ts new file mode 100644 index 00000000000..0215e4f1644 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/block/inherited-scope.ts @@ -0,0 +1,5 @@ +const a = 1; + +{ + a; +} diff --git a/packages/scope-manager/tests/fixtures/block/inherited-scope.ts.shot b/packages/scope-manager/tests/fixtures/block/inherited-scope.ts.shot new file mode 100644 index 00000000000..c8f75265822 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/block/inherited-scope.ts.shot @@ -0,0 +1,63 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`block inherited-scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + BlockScope$2 { + block: BlockStatement$4, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map {}, + type: "block", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/block/scope.ts b/packages/scope-manager/tests/fixtures/block/scope.ts new file mode 100644 index 00000000000..a0bf546c53e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/block/scope.ts @@ -0,0 +1,7 @@ +{ + let i = 20; + let j = 1; + i; +} + +j; diff --git a/packages/scope-manager/tests/fixtures/block/scope.ts.shot b/packages/scope-manager/tests/fixtures/block/scope.ts.shot new file mode 100644 index 00000000000..7c445ea2c30 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/block/scope.ts.shot @@ -0,0 +1,93 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`block scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"i">, + node: VariableDeclarator$1, + }, + ], + name: "i", + references: Array [ + Reference$1 { + identifier: Identifier<"i">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$3 { + identifier: Identifier<"i">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"j">, + node: VariableDeclarator$3, + }, + ], + name: "j", + references: Array [ + Reference$2 { + identifier: Identifier<"j">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$4 { + identifier: Identifier<"j">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + BlockScope$2 { + block: BlockStatement$6, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "i" => Variable$1, + "j" => Variable$2, + }, + type: "block", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/call-expression/call-expression.ts b/packages/scope-manager/tests/fixtures/call-expression/call-expression.ts new file mode 100644 index 00000000000..ebfb807a1b0 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/call-expression/call-expression.ts @@ -0,0 +1,5 @@ +const foo = () => {}; +const a = 1; + +foo(a); +foo?.(a); diff --git a/packages/scope-manager/tests/fixtures/call-expression/call-expression.ts.shot b/packages/scope-manager/tests/fixtures/call-expression/call-expression.ts.shot new file mode 100644 index 00000000000..150f5513d8a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/call-expression/call-expression.ts.shot @@ -0,0 +1,107 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`call-expression call-expression 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + Reference$3 { + identifier: Identifier<"foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$5 { + identifier: Identifier<"foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"a">, + node: VariableDeclarator$3, + }, + ], + name: "a", + references: Array [ + Reference$2 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$4, + }, + Reference$4 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + }, + Reference$6 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + Reference$4, + Reference$5, + Reference$6, + ], + set: Map { + "foo" => Variable$1, + "a" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "function", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/call-expression/type-parameters1.ts b/packages/scope-manager/tests/fixtures/call-expression/type-parameters1.ts new file mode 100644 index 00000000000..5d613bd3858 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/call-expression/type-parameters1.ts @@ -0,0 +1,2 @@ +type T = 1; +foo(); diff --git a/packages/scope-manager/tests/fixtures/call-expression/type-parameters1.ts.shot b/packages/scope-manager/tests/fixtures/call-expression/type-parameters1.ts.shot new file mode 100644 index 00000000000..35154a8275d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/call-expression/type-parameters1.ts.shot @@ -0,0 +1,50 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`call-expression type-parameters1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + Reference$2, + ], + set: Map { + "T" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/call-expression/type-parameters2.ts b/packages/scope-manager/tests/fixtures/call-expression/type-parameters2.ts new file mode 100644 index 00000000000..2bb481d6399 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/call-expression/type-parameters2.ts @@ -0,0 +1,2 @@ +const T = 1; +foo(); // should not resolve to value diff --git a/packages/scope-manager/tests/fixtures/call-expression/type-parameters2.ts.shot b/packages/scope-manager/tests/fixtures/call-expression/type-parameters2.ts.shot new file mode 100644 index 00000000000..b95c6b59e27 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/call-expression/type-parameters2.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`call-expression type-parameters2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"T">, + node: VariableDeclarator$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + Reference$2 { + identifier: Identifier<"foo">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + Reference$3 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "T" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/catch/inherited-scope.ts b/packages/scope-manager/tests/fixtures/catch/inherited-scope.ts new file mode 100644 index 00000000000..3d7202f881a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/catch/inherited-scope.ts @@ -0,0 +1,5 @@ +const a = 1; +try { +} catch (e) { + a; +} diff --git a/packages/scope-manager/tests/fixtures/catch/inherited-scope.ts.shot b/packages/scope-manager/tests/fixtures/catch/inherited-scope.ts.shot new file mode 100644 index 00000000000..0b17168ca9e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/catch/inherited-scope.ts.shot @@ -0,0 +1,97 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`catch inherited-scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + CatchClauseDefinition$2 { + name: Identifier<"e">, + node: CatchClause$3, + }, + ], + name: "e", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + BlockScope$2 { + block: BlockStatement$5, + isStrict: false, + references: Array [], + set: Map {}, + type: "block", + upper: GlobalScope$1, + variables: Array [], + }, + CatchScope$3 { + block: CatchClause$3, + isStrict: false, + references: Array [], + set: Map { + "e" => Variable$2, + }, + type: "catch", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + BlockScope$4 { + block: BlockStatement$6, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map {}, + type: "block", + upper: CatchScope$3, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/catch/scope.ts b/packages/scope-manager/tests/fixtures/catch/scope.ts new file mode 100644 index 00000000000..a78dc78c8d9 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/catch/scope.ts @@ -0,0 +1,8 @@ +try { +} catch (e) { + e; + let a = 1; +} + +const unresolved = e; +const dontReference2 = a; diff --git a/packages/scope-manager/tests/fixtures/catch/scope.ts.shot b/packages/scope-manager/tests/fixtures/catch/scope.ts.shot new file mode 100644 index 00000000000..04908947c1c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/catch/scope.ts.shot @@ -0,0 +1,160 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`catch scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + CatchClauseDefinition$1 { + name: Identifier<"e">, + node: CatchClause$1, + }, + ], + name: "e", + references: Array [ + Reference$1 { + identifier: Identifier<"e">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"a">, + node: VariableDeclarator$2, + }, + ], + name: "a", + references: Array [ + Reference$2 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"unresolved">, + node: VariableDeclarator$4, + }, + ], + name: "unresolved", + references: Array [ + Reference$3 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"e">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"dontReference2">, + node: VariableDeclarator$5, + }, + ], + name: "dontReference2", + references: Array [ + Reference$5 { + identifier: Identifier<"dontReference2">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$3, + Reference$4 { + identifier: Identifier<"e">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + Reference$5, + Reference$6 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "unresolved" => Variable$3, + "dontReference2" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + BlockScope$2 { + block: BlockStatement$7, + isStrict: false, + references: Array [], + set: Map {}, + type: "block", + upper: GlobalScope$1, + variables: Array [], + }, + CatchScope$3 { + block: CatchClause$1, + isStrict: false, + references: Array [], + set: Map { + "e" => Variable$1, + }, + type: "catch", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + BlockScope$4 { + block: BlockStatement$8, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "a" => Variable$2, + }, + type: "block", + upper: CatchScope$3, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/abstract.ts b/packages/scope-manager/tests/fixtures/class/declaration/abstract.ts new file mode 100644 index 00000000000..ace940e1c98 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/abstract.ts @@ -0,0 +1,4 @@ +abstract class A { + abstract foo; + abstract bar(a, b); +} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/abstract.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/abstract.ts.shot new file mode 100644 index 00000000000..c49da354130 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/abstract.ts.shot @@ -0,0 +1,108 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration abstract 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"a">, + node: TSEmptyBodyFunctionExpression$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"b">, + node: TSEmptyBodyFunctionExpression$2, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "A" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "A" => Variable$2, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + FunctionScope$3 { + block: TSEmptyBodyFunctionExpression$2, + isStrict: true, + references: Array [], + set: Map { + "arguments" => Variable$3, + "a" => Variable$4, + "b" => Variable$5, + }, + type: "function", + upper: ClassScope$2, + variables: Array [ + Variable$3, + Variable$4, + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/computed-member.ts b/packages/scope-manager/tests/fixtures/class/declaration/computed-member.ts new file mode 100644 index 00000000000..029048eb65d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/computed-member.ts @@ -0,0 +1,6 @@ +const outer1 = 'a'; +const outer2 = 'b'; +class A { + [outer1] = 1; + [outer2]() {} +} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/computed-member.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/computed-member.ts.shot new file mode 100644 index 00000000000..4a41a73b5da --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/computed-member.ts.shot @@ -0,0 +1,144 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration computed-member 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"outer1">, + node: VariableDeclarator$1, + }, + ], + name: "outer1", + references: Array [ + Reference$1 { + identifier: Identifier<"outer1">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$3 { + identifier: Identifier<"outer1">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"outer2">, + node: VariableDeclarator$3, + }, + ], + name: "outer2", + references: Array [ + Reference$2 { + identifier: Identifier<"outer2">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$4, + }, + Reference$4 { + identifier: Identifier<"outer2">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"A">, + node: ClassDeclaration$5, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$4 { + name: Identifier<"A">, + node: ClassDeclaration$5, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "outer1" => Variable$1, + "outer2" => Variable$2, + "A" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + ], + }, + ClassScope$2 { + block: ClassDeclaration$5, + isStrict: true, + references: Array [ + Reference$3, + Reference$4, + ], + set: Map { + "A" => Variable$4, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + FunctionScope$3 { + block: FunctionExpression$7, + isStrict: true, + references: Array [], + set: Map { + "arguments" => Variable$5, + }, + type: "function", + upper: ClassScope$2, + variables: Array [ + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/extends-generic.ts b/packages/scope-manager/tests/fixtures/class/declaration/extends-generic.ts new file mode 100644 index 00000000000..3f367dec277 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/extends-generic.ts @@ -0,0 +1,3 @@ +class A {} +type T = string; +class B extends A {} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/extends-generic.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/extends-generic.ts.shot new file mode 100644 index 00000000000..3a65ed80574 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/extends-generic.ts.shot @@ -0,0 +1,144 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration extends-generic 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$2, + }, + ], + name: "U", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$4 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$4, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [ + ClassNameDefinition$5 { + name: Identifier<"B">, + node: ClassDeclaration$4, + }, + ], + name: "B", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$6 { + defs: Array [ + ClassNameDefinition$6 { + name: Identifier<"B">, + node: ClassDeclaration$4, + }, + ], + name: "B", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "A" => Variable$1, + "T" => Variable$4, + "B" => Variable$5, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + Variable$5, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "A" => Variable$2, + "U" => Variable$3, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ClassScope$3 { + block: ClassDeclaration$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "B" => Variable$6, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$6, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/extends.ts b/packages/scope-manager/tests/fixtures/class/declaration/extends.ts new file mode 100644 index 00000000000..a16946fd696 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/extends.ts @@ -0,0 +1,2 @@ +class A {} +class B extends A {} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/extends.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/extends.ts.shot new file mode 100644 index 00000000000..f2c0ff33aad --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/extends.ts.shot @@ -0,0 +1,108 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration extends 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"B">, + node: ClassDeclaration$2, + }, + ], + name: "B", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$4 { + name: Identifier<"B">, + node: ClassDeclaration$2, + }, + ], + name: "B", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "A" => Variable$1, + "B" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "A" => Variable$2, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ClassScope$3 { + block: ClassDeclaration$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "B" => Variable$4, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-extends.ts b/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-extends.ts new file mode 100644 index 00000000000..2d3b682a2fa --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-extends.ts @@ -0,0 +1 @@ +class Foo extends Bar {} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-extends.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-extends.ts.shot new file mode 100644 index 00000000000..fcf18001d20 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-extends.ts.shot @@ -0,0 +1,89 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration generic-ref-extends 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"A">, + node: TSTypeParameter$2, + }, + ], + name: "A", + references: Array [ + Reference$2 { + identifier: Identifier<"A">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [ + Reference$1 { + identifier: Identifier<"Bar">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + Reference$2, + ], + set: Map { + "Foo" => Variable$2, + "A" => Variable$3, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-implements.ts b/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-implements.ts new file mode 100644 index 00000000000..3944aabaaff --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-implements.ts @@ -0,0 +1 @@ +class Foo implements Bar {} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-implements.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-implements.ts.shot new file mode 100644 index 00000000000..c5178777305 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/generic-ref-implements.ts.shot @@ -0,0 +1,89 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration generic-ref-implements 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"A">, + node: TSTypeParameter$2, + }, + ], + name: "A", + references: Array [ + Reference$2 { + identifier: Identifier<"A">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [ + Reference$1 { + identifier: Identifier<"Bar">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + Reference$2, + ], + set: Map { + "Foo" => Variable$2, + "A" => Variable$3, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/generic.ts b/packages/scope-manager/tests/fixtures/class/declaration/generic.ts new file mode 100644 index 00000000000..bb133f43573 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/generic.ts @@ -0,0 +1,3 @@ +class Foo {} + +type Unresolved = A; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/generic.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/generic.ts.shot new file mode 100644 index 00000000000..9e6adbf4f18 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/generic.ts.shot @@ -0,0 +1,95 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration generic 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"A">, + node: TSTypeParameter$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$4 { + name: Identifier<"Unresolved">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "Unresolved", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "Foo" => Variable$1, + "Unresolved" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$2, + "A" => Variable$3, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/implements-generic.ts b/packages/scope-manager/tests/fixtures/class/declaration/implements-generic.ts new file mode 100644 index 00000000000..f4e6c7cc876 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/implements-generic.ts @@ -0,0 +1,3 @@ +interface A {} +type T = string; +class B implements A {} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/implements-generic.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/implements-generic.ts.shot new file mode 100644 index 00000000000..36b97a022f7 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/implements-generic.ts.shot @@ -0,0 +1,130 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration implements-generic 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"A">, + node: TSInterfaceDeclaration$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"U">, + node: TSTypeParameter$2, + }, + ], + name: "U", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$4 { + name: Identifier<"B">, + node: ClassDeclaration$4, + }, + ], + name: "B", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [ + ClassNameDefinition$5 { + name: Identifier<"B">, + node: ClassDeclaration$4, + }, + ], + name: "B", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "A" => Variable$1, + "T" => Variable$3, + "B" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + Variable$4, + ], + }, + TypeScope$2 { + block: TSInterfaceDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "U" => Variable$2, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ClassScope$3 { + block: ClassDeclaration$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "B" => Variable$5, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/implements.ts b/packages/scope-manager/tests/fixtures/class/declaration/implements.ts new file mode 100644 index 00000000000..8c04767cd50 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/implements.ts @@ -0,0 +1,2 @@ +interface A {} +class B implements A {} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/implements.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/implements.ts.shot new file mode 100644 index 00000000000..33d222e72fa --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/implements.ts.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration implements 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"A">, + node: TSInterfaceDeclaration$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"B">, + node: ClassDeclaration$2, + }, + ], + name: "B", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"B">, + node: ClassDeclaration$2, + }, + ], + name: "B", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "A" => Variable$1, + "B" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ClassScope$2 { + block: ClassDeclaration$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "B" => Variable$3, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/method.ts b/packages/scope-manager/tests/fixtures/class/declaration/method.ts new file mode 100644 index 00000000000..fa102827d1f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/method.ts @@ -0,0 +1,8 @@ +class A { + method(a, [b], { c }, d = 1, e = a, f) { + a; + } +} + +const unresolved1 = f; +const unresolved2 = method; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/method.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/method.ts.shot new file mode 100644 index 00000000000..5e035ce3c75 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/method.ts.shot @@ -0,0 +1,261 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration method 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"a">, + node: FunctionExpression$2, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + }, + Reference$4 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"b">, + node: FunctionExpression$2, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$6 { + defs: Array [ + ParameterDefinition$5 { + name: Identifier<"c">, + node: FunctionExpression$2, + }, + ], + name: "c", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + ParameterDefinition$6 { + name: Identifier<"d">, + node: FunctionExpression$2, + }, + ], + name: "d", + references: Array [ + Reference$1 { + identifier: Identifier<"d">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$7, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$8 { + defs: Array [ + ParameterDefinition$7 { + name: Identifier<"e">, + node: FunctionExpression$2, + }, + ], + name: "e", + references: Array [ + Reference$2 { + identifier: Identifier<"e">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$8, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$9 { + defs: Array [ + ParameterDefinition$8 { + name: Identifier<"f">, + node: FunctionExpression$2, + }, + ], + name: "f", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$10 { + defs: Array [ + VariableDefinition$9 { + name: Identifier<"unresolved1">, + node: VariableDeclarator$4, + }, + ], + name: "unresolved1", + references: Array [ + Reference$5 { + identifier: Identifier<"unresolved1">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$10, + writeExpr: Identifier<"f">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$11 { + defs: Array [ + VariableDefinition$10 { + name: Identifier<"unresolved2">, + node: VariableDeclarator$5, + }, + ], + name: "unresolved2", + references: Array [ + Reference$7 { + identifier: Identifier<"unresolved2">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$11, + writeExpr: Identifier<"method">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$5, + Reference$6 { + identifier: Identifier<"f">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + Reference$7, + Reference$8 { + identifier: Identifier<"method">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "A" => Variable$1, + "unresolved1" => Variable$10, + "unresolved2" => Variable$11, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$10, + Variable$11, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "A" => Variable$2, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + FunctionScope$3 { + block: FunctionExpression$2, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + Reference$4, + ], + set: Map { + "arguments" => Variable$3, + "a" => Variable$4, + "b" => Variable$5, + "c" => Variable$6, + "d" => Variable$7, + "e" => Variable$8, + "f" => Variable$9, + }, + type: "function", + upper: ClassScope$2, + variables: Array [ + Variable$3, + Variable$4, + Variable$5, + Variable$6, + Variable$7, + Variable$8, + Variable$9, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/new.ts b/packages/scope-manager/tests/fixtures/class/declaration/new.ts new file mode 100644 index 00000000000..f4282faaa98 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/new.ts @@ -0,0 +1,2 @@ +class A {} +new A(); diff --git a/packages/scope-manager/tests/fixtures/class/declaration/new.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/new.ts.shot new file mode 100644 index 00000000000..49f13b7fec4 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/new.ts.shot @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration new 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "A" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "A" => Variable$2, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/parameter-properties.ts b/packages/scope-manager/tests/fixtures/class/declaration/parameter-properties.ts new file mode 100644 index 00000000000..b65d60cc500 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/parameter-properties.ts @@ -0,0 +1,16 @@ +const outer = 1; +type Outer = 1; +class A { + constructor( + private a, + private b = 1, + private c = a, + public d = outer, + public e, + readonly f: Outer, + ) { + a; + } +} + +const unresovled = e; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/parameter-properties.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/parameter-properties.ts.shot new file mode 100644 index 00000000000..bd145bbb220 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/parameter-properties.ts.shot @@ -0,0 +1,294 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration parameter-properties 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"outer">, + node: VariableDeclarator$1, + }, + ], + name: "outer", + references: Array [ + Reference$1 { + identifier: Identifier<"outer">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$6 { + identifier: Identifier<"outer">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"Outer">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "Outer", + references: Array [ + Reference$7 { + identifier: Identifier<"Outer">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"A">, + node: ClassDeclaration$4, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$4 { + name: Identifier<"A">, + node: ClassDeclaration$4, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$6 { + defs: Array [ + ParameterDefinition$5 { + name: Identifier<"a">, + node: FunctionExpression$5, + }, + ], + name: "a", + references: Array [ + Reference$4 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$6, + }, + Reference$8 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$6, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + ParameterDefinition$6 { + name: Identifier<"b">, + node: FunctionExpression$5, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$7, + writeExpr: Literal$6, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$8 { + defs: Array [ + ParameterDefinition$7 { + name: Identifier<"c">, + node: FunctionExpression$5, + }, + ], + name: "c", + references: Array [ + Reference$3 { + identifier: Identifier<"c">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$8, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$9 { + defs: Array [ + ParameterDefinition$8 { + name: Identifier<"d">, + node: FunctionExpression$5, + }, + ], + name: "d", + references: Array [ + Reference$5 { + identifier: Identifier<"d">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$9, + writeExpr: Identifier<"outer">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$10 { + defs: Array [ + ParameterDefinition$9 { + name: Identifier<"e">, + node: FunctionExpression$5, + }, + ], + name: "e", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$11 { + defs: Array [ + ParameterDefinition$10 { + name: Identifier<"f">, + node: FunctionExpression$5, + }, + ], + name: "f", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$12 { + defs: Array [ + VariableDefinition$11 { + name: Identifier<"unresovled">, + node: VariableDeclarator$7, + }, + ], + name: "unresovled", + references: Array [ + Reference$9 { + identifier: Identifier<"unresovled">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$12, + writeExpr: Identifier<"e">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$8, + isStrict: false, + references: Array [ + Reference$1, + Reference$9, + Reference$10 { + identifier: Identifier<"e">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "outer" => Variable$1, + "Outer" => Variable$2, + "A" => Variable$3, + "unresovled" => Variable$12, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + Variable$12, + ], + }, + ClassScope$2 { + block: ClassDeclaration$4, + isStrict: true, + references: Array [], + set: Map { + "A" => Variable$4, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + FunctionScope$3 { + block: FunctionExpression$5, + isStrict: true, + references: Array [ + Reference$2, + Reference$3, + Reference$4, + Reference$5, + Reference$6, + Reference$7, + Reference$8, + ], + set: Map { + "arguments" => Variable$5, + "a" => Variable$6, + "b" => Variable$7, + "c" => Variable$8, + "d" => Variable$9, + "e" => Variable$10, + "f" => Variable$11, + }, + type: "function", + upper: ClassScope$2, + variables: Array [ + Variable$5, + Variable$6, + Variable$7, + Variable$8, + Variable$9, + Variable$10, + Variable$11, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/properties-type-annotation.ts b/packages/scope-manager/tests/fixtures/class/declaration/properties-type-annotation.ts new file mode 100644 index 00000000000..824821d682e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/properties-type-annotation.ts @@ -0,0 +1,4 @@ +type T = 1; +class A { + prop: T; +} diff --git a/packages/scope-manager/tests/fixtures/class/declaration/properties-type-annotation.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/properties-type-annotation.ts.shot new file mode 100644 index 00000000000..05e304772d3 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/properties-type-annotation.ts.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration properties-type-annotation 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"A">, + node: ClassDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ClassScope$2 { + block: ClassDeclaration$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "A" => Variable$3, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/properties.ts b/packages/scope-manager/tests/fixtures/class/declaration/properties.ts new file mode 100644 index 00000000000..c047395435a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/properties.ts @@ -0,0 +1,5 @@ +class A { + prop = 1; +} + +const unresolved = prop; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/properties.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/properties.ts.shot new file mode 100644 index 00000000000..5c2974fea4c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/properties.ts.shot @@ -0,0 +1,91 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration properties 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"unresolved">, + node: VariableDeclarator$2, + }, + ], + name: "unresolved", + references: Array [ + Reference$1 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"prop">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + Reference$2 { + identifier: Identifier<"prop">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "A" => Variable$1, + "unresolved" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "A" => Variable$2, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/type-reference.ts b/packages/scope-manager/tests/fixtures/class/declaration/type-reference.ts new file mode 100644 index 00000000000..84d674f5373 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/type-reference.ts @@ -0,0 +1,5 @@ +class A {} + +type T1 = A; +type T2 = typeof A; +const v = A; diff --git a/packages/scope-manager/tests/fixtures/class/declaration/type-reference.ts.shot b/packages/scope-manager/tests/fixtures/class/declaration/type-reference.ts.shot new file mode 100644 index 00000000000..cb68e5aa2f6 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/declaration/type-reference.ts.shot @@ -0,0 +1,135 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class declaration type-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"A">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$4 { + identifier: Identifier<"A">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"T1">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "T1", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$4 { + name: Identifier<"T2">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "T2", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [ + VariableDefinition$5 { + name: Identifier<"v">, + node: VariableDeclarator$4, + }, + ], + name: "v", + references: Array [ + Reference$3 { + identifier: Identifier<"v">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$5, + writeExpr: Identifier<"A">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + Reference$4, + ], + set: Map { + "A" => Variable$1, + "T1" => Variable$3, + "T2" => Variable$4, + "v" => Variable$5, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + Variable$4, + Variable$5, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "A" => Variable$2, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/expression/computed-member.ts b/packages/scope-manager/tests/fixtures/class/expression/computed-member.ts new file mode 100644 index 00000000000..bba58b688ad --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/computed-member.ts @@ -0,0 +1,6 @@ +const outer1 = 'a'; +const outer2 = 'b'; +const A = class { + [outer1] = 1; + [outer2]() {} +}; diff --git a/packages/scope-manager/tests/fixtures/class/expression/computed-member.ts.shot b/packages/scope-manager/tests/fixtures/class/expression/computed-member.ts.shot new file mode 100644 index 00000000000..13327518623 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/computed-member.ts.shot @@ -0,0 +1,138 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class expression computed-member 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"outer1">, + node: VariableDeclarator$1, + }, + ], + name: "outer1", + references: Array [ + Reference$1 { + identifier: Identifier<"outer1">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$4 { + identifier: Identifier<"outer1">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"outer2">, + node: VariableDeclarator$3, + }, + ], + name: "outer2", + references: Array [ + Reference$2 { + identifier: Identifier<"outer2">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$4, + }, + Reference$5 { + identifier: Identifier<"outer2">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"A">, + node: VariableDeclarator$5, + }, + ], + name: "A", + references: Array [ + Reference$3 { + identifier: Identifier<"A">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: ClassExpression$6, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$7, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "outer1" => Variable$1, + "outer2" => Variable$2, + "A" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + ], + }, + ClassScope$2 { + block: ClassExpression$6, + isStrict: true, + references: Array [ + Reference$4, + Reference$5, + ], + set: Map {}, + type: "class", + upper: GlobalScope$1, + variables: Array [], + }, + FunctionScope$3 { + block: FunctionExpression$8, + isStrict: true, + references: Array [], + set: Map { + "arguments" => Variable$4, + }, + type: "function", + upper: ClassScope$2, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/expression/extends.ts b/packages/scope-manager/tests/fixtures/class/expression/extends.ts new file mode 100644 index 00000000000..d4f414804e0 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/extends.ts @@ -0,0 +1,2 @@ +class A {} +const B = class extends A {}; diff --git a/packages/scope-manager/tests/fixtures/class/expression/extends.ts.shot b/packages/scope-manager/tests/fixtures/class/expression/extends.ts.shot new file mode 100644 index 00000000000..578641aa9b1 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/extends.ts.shot @@ -0,0 +1,103 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class expression extends 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [ + Reference$2 { + identifier: Identifier<"A">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"B">, + node: VariableDeclarator$2, + }, + ], + name: "B", + references: Array [ + Reference$1 { + identifier: Identifier<"B">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: ClassExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "A" => Variable$1, + "B" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "A" => Variable$2, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ClassScope$3 { + block: ClassExpression$3, + isStrict: true, + references: Array [ + Reference$2, + ], + set: Map {}, + type: "class", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/expression/method.ts b/packages/scope-manager/tests/fixtures/class/expression/method.ts new file mode 100644 index 00000000000..df973f263b7 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/method.ts @@ -0,0 +1,8 @@ +const A = class { + method(a, [b], { c }, d = 1, e = a, f) { + a; + } +}; + +const unresolved1 = f; +const unresolved2 = method; diff --git a/packages/scope-manager/tests/fixtures/class/expression/method.ts.shot b/packages/scope-manager/tests/fixtures/class/expression/method.ts.shot new file mode 100644 index 00000000000..996e9884ca2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/method.ts.shot @@ -0,0 +1,255 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class expression method 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"A">, + node: VariableDeclarator$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ClassExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$2 { + name: Identifier<"a">, + node: FunctionExpression$3, + }, + ], + name: "a", + references: Array [ + Reference$4 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + }, + Reference$5 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionExpression$3, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"c">, + node: FunctionExpression$3, + }, + ], + name: "c", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$6 { + defs: Array [ + ParameterDefinition$5 { + name: Identifier<"d">, + node: FunctionExpression$3, + }, + ], + name: "d", + references: Array [ + Reference$2 { + identifier: Identifier<"d">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$6, + writeExpr: Literal$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + ParameterDefinition$6 { + name: Identifier<"e">, + node: FunctionExpression$3, + }, + ], + name: "e", + references: Array [ + Reference$3 { + identifier: Identifier<"e">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$7, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$8 { + defs: Array [ + ParameterDefinition$7 { + name: Identifier<"f">, + node: FunctionExpression$3, + }, + ], + name: "f", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$9 { + defs: Array [ + VariableDefinition$8 { + name: Identifier<"unresolved1">, + node: VariableDeclarator$5, + }, + ], + name: "unresolved1", + references: Array [ + Reference$6 { + identifier: Identifier<"unresolved1">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$9, + writeExpr: Identifier<"f">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$10 { + defs: Array [ + VariableDefinition$9 { + name: Identifier<"unresolved2">, + node: VariableDeclarator$6, + }, + ], + name: "unresolved2", + references: Array [ + Reference$8 { + identifier: Identifier<"unresolved2">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$10, + writeExpr: Identifier<"method">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$7, + isStrict: false, + references: Array [ + Reference$1, + Reference$6, + Reference$7 { + identifier: Identifier<"f">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + Reference$8, + Reference$9 { + identifier: Identifier<"method">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "A" => Variable$1, + "unresolved1" => Variable$9, + "unresolved2" => Variable$10, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$9, + Variable$10, + ], + }, + ClassScope$2 { + block: ClassExpression$2, + isStrict: true, + references: Array [], + set: Map {}, + type: "class", + upper: GlobalScope$1, + variables: Array [], + }, + FunctionScope$3 { + block: FunctionExpression$3, + isStrict: true, + references: Array [ + Reference$2, + Reference$3, + Reference$4, + Reference$5, + ], + set: Map { + "arguments" => Variable$2, + "a" => Variable$3, + "b" => Variable$4, + "c" => Variable$5, + "d" => Variable$6, + "e" => Variable$7, + "f" => Variable$8, + }, + type: "function", + upper: ClassScope$2, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + Variable$5, + Variable$6, + Variable$7, + Variable$8, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/expression/new.ts b/packages/scope-manager/tests/fixtures/class/expression/new.ts new file mode 100644 index 00000000000..fffb5e1852a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/new.ts @@ -0,0 +1,2 @@ +const A = class {}; +new A(); diff --git a/packages/scope-manager/tests/fixtures/class/expression/new.ts.shot b/packages/scope-manager/tests/fixtures/class/expression/new.ts.shot new file mode 100644 index 00000000000..0342a721cc2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/new.ts.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class expression new 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"A">, + node: VariableDeclarator$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ClassExpression$2, + }, + Reference$2 { + identifier: Identifier<"A">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "A" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ClassScope$2 { + block: ClassExpression$2, + isStrict: true, + references: Array [], + set: Map {}, + type: "class", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/expression/parameter-properties.ts b/packages/scope-manager/tests/fixtures/class/expression/parameter-properties.ts new file mode 100644 index 00000000000..2c14373275c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/parameter-properties.ts @@ -0,0 +1,16 @@ +const outer = 1; +type Outer = 1; +const A = class { + constructor( + private a, + private b = 1, + private c = a, + public d = outer, + public e, + readonly f: Outer, + ) { + a; + } +}; + +const unresovled = e; diff --git a/packages/scope-manager/tests/fixtures/class/expression/parameter-properties.ts.shot b/packages/scope-manager/tests/fixtures/class/expression/parameter-properties.ts.shot new file mode 100644 index 00000000000..2f6eb319688 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/parameter-properties.ts.shot @@ -0,0 +1,288 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class expression parameter-properties 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"outer">, + node: VariableDeclarator$1, + }, + ], + name: "outer", + references: Array [ + Reference$1 { + identifier: Identifier<"outer">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$7 { + identifier: Identifier<"outer">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"Outer">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "Outer", + references: Array [ + Reference$8 { + identifier: Identifier<"Outer">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"A">, + node: VariableDeclarator$4, + }, + ], + name: "A", + references: Array [ + Reference$2 { + identifier: Identifier<"A">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: ClassExpression$5, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"a">, + node: FunctionExpression$6, + }, + ], + name: "a", + references: Array [ + Reference$5 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$5, + }, + Reference$9 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$5, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$6 { + defs: Array [ + ParameterDefinition$5 { + name: Identifier<"b">, + node: FunctionExpression$6, + }, + ], + name: "b", + references: Array [ + Reference$3 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$6, + writeExpr: Literal$7, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + ParameterDefinition$6 { + name: Identifier<"c">, + node: FunctionExpression$6, + }, + ], + name: "c", + references: Array [ + Reference$4 { + identifier: Identifier<"c">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$7, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$8 { + defs: Array [ + ParameterDefinition$7 { + name: Identifier<"d">, + node: FunctionExpression$6, + }, + ], + name: "d", + references: Array [ + Reference$6 { + identifier: Identifier<"d">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$8, + writeExpr: Identifier<"outer">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$9 { + defs: Array [ + ParameterDefinition$8 { + name: Identifier<"e">, + node: FunctionExpression$6, + }, + ], + name: "e", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$10 { + defs: Array [ + ParameterDefinition$9 { + name: Identifier<"f">, + node: FunctionExpression$6, + }, + ], + name: "f", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$11 { + defs: Array [ + VariableDefinition$10 { + name: Identifier<"unresovled">, + node: VariableDeclarator$8, + }, + ], + name: "unresovled", + references: Array [ + Reference$10 { + identifier: Identifier<"unresovled">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$11, + writeExpr: Identifier<"e">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$9, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$10, + Reference$11 { + identifier: Identifier<"e">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "outer" => Variable$1, + "Outer" => Variable$2, + "A" => Variable$3, + "unresovled" => Variable$11, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + Variable$11, + ], + }, + ClassScope$2 { + block: ClassExpression$5, + isStrict: true, + references: Array [], + set: Map {}, + type: "class", + upper: GlobalScope$1, + variables: Array [], + }, + FunctionScope$3 { + block: FunctionExpression$6, + isStrict: true, + references: Array [ + Reference$3, + Reference$4, + Reference$5, + Reference$6, + Reference$7, + Reference$8, + Reference$9, + ], + set: Map { + "arguments" => Variable$4, + "a" => Variable$5, + "b" => Variable$6, + "c" => Variable$7, + "d" => Variable$8, + "e" => Variable$9, + "f" => Variable$10, + }, + type: "function", + upper: ClassScope$2, + variables: Array [ + Variable$4, + Variable$5, + Variable$6, + Variable$7, + Variable$8, + Variable$9, + Variable$10, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/expression/properties.ts b/packages/scope-manager/tests/fixtures/class/expression/properties.ts new file mode 100644 index 00000000000..49b1efe6297 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/properties.ts @@ -0,0 +1,5 @@ +const A = class { + prop = 1; +}; + +const unresolved = prop; diff --git a/packages/scope-manager/tests/fixtures/class/expression/properties.ts.shot b/packages/scope-manager/tests/fixtures/class/expression/properties.ts.shot new file mode 100644 index 00000000000..4aa6d42b2d2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/properties.ts.shot @@ -0,0 +1,85 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class expression properties 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"A">, + node: VariableDeclarator$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ClassExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"unresolved">, + node: VariableDeclarator$3, + }, + ], + name: "unresolved", + references: Array [ + Reference$2 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Identifier<"prop">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3 { + identifier: Identifier<"prop">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "A" => Variable$1, + "unresolved" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ClassScope$2 { + block: ClassExpression$2, + isStrict: true, + references: Array [], + set: Map {}, + type: "class", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/class/expression/self-reference-super.ts b/packages/scope-manager/tests/fixtures/class/expression/self-reference-super.ts new file mode 100644 index 00000000000..1513a5b0b43 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/self-reference-super.ts @@ -0,0 +1,3 @@ +const A = class A + // this A references the class A, not the variable A + extends A {}; diff --git a/packages/scope-manager/tests/fixtures/class/expression/self-reference-super.ts.shot b/packages/scope-manager/tests/fixtures/class/expression/self-reference-super.ts.shot new file mode 100644 index 00000000000..1901b77dd24 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/class/expression/self-reference-super.ts.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`class expression self-reference-super 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"A">, + node: VariableDeclarator$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ClassExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"A">, + node: ClassExpression$2, + }, + ], + name: "A", + references: Array [ + Reference$2 { + identifier: Identifier<"A">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "A" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ClassScope$2 { + block: ClassExpression$2, + isStrict: true, + references: Array [ + Reference$2, + ], + set: Map { + "A" => Variable$2, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/decorators/accessor.ts b/packages/scope-manager/tests/fixtures/decorators/accessor.ts new file mode 100644 index 00000000000..764ea5e3340 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/accessor.ts @@ -0,0 +1,9 @@ +function decorator() {} +class Foo { + @decorator + get foo() { + return 1; + } + @decorator + set foo() {} +} diff --git a/packages/scope-manager/tests/fixtures/decorators/accessor.ts.shot b/packages/scope-manager/tests/fixtures/decorators/accessor.ts.shot new file mode 100644 index 00000000000..542795da054 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/accessor.ts.shot @@ -0,0 +1,150 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`decorators accessor 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"decorator">, + node: FunctionDeclaration$1, + }, + ], + name: "decorator", + references: Array [ + Reference$1 { + identifier: Identifier<"decorator">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"decorator">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$6 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "decorator" => Variable$1, + "Foo" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ClassScope$3 { + block: ClassDeclaration$2, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "Foo" => Variable$4, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + FunctionScope$4 { + block: FunctionExpression$4, + isStrict: true, + references: Array [], + set: Map { + "arguments" => Variable$5, + }, + type: "function", + upper: ClassScope$3, + variables: Array [ + Variable$5, + ], + }, + FunctionScope$5 { + block: FunctionExpression$5, + isStrict: true, + references: Array [], + set: Map { + "arguments" => Variable$6, + }, + type: "function", + upper: ClassScope$3, + variables: Array [ + Variable$6, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/decorators/class-property.ts b/packages/scope-manager/tests/fixtures/decorators/class-property.ts new file mode 100644 index 00000000000..bbd51c608e5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/class-property.ts @@ -0,0 +1,5 @@ +function decorator() {} +class Foo { + @decorator + foo; +} diff --git a/packages/scope-manager/tests/fixtures/decorators/class-property.ts.shot b/packages/scope-manager/tests/fixtures/decorators/class-property.ts.shot new file mode 100644 index 00000000000..a84bb27badd --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/class-property.ts.shot @@ -0,0 +1,103 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`decorators class-property 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"decorator">, + node: FunctionDeclaration$1, + }, + ], + name: "decorator", + references: Array [ + Reference$1 { + identifier: Identifier<"decorator">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "decorator" => Variable$1, + "Foo" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ClassScope$3 { + block: ClassDeclaration$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$4, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/decorators/class.ts b/packages/scope-manager/tests/fixtures/decorators/class.ts new file mode 100644 index 00000000000..6ee77c77809 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/class.ts @@ -0,0 +1,3 @@ +function decorator() {} +@decorator +class Foo {} diff --git a/packages/scope-manager/tests/fixtures/decorators/class.ts.shot b/packages/scope-manager/tests/fixtures/decorators/class.ts.shot new file mode 100644 index 00000000000..d4a77260876 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/class.ts.shot @@ -0,0 +1,103 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`decorators class 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"decorator">, + node: FunctionDeclaration$1, + }, + ], + name: "decorator", + references: Array [ + Reference$1 { + identifier: Identifier<"decorator">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "decorator" => Variable$1, + "Foo" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ClassScope$3 { + block: ClassDeclaration$2, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$4, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/decorators/method.ts b/packages/scope-manager/tests/fixtures/decorators/method.ts new file mode 100644 index 00000000000..1ef9323c8a4 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/method.ts @@ -0,0 +1,5 @@ +function decorator() {} +class Foo { + @decorator + foo() {} +} diff --git a/packages/scope-manager/tests/fixtures/decorators/method.ts.shot b/packages/scope-manager/tests/fixtures/decorators/method.ts.shot new file mode 100644 index 00000000000..54212a2016e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/method.ts.shot @@ -0,0 +1,123 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`decorators method 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"decorator">, + node: FunctionDeclaration$1, + }, + ], + name: "decorator", + references: Array [ + Reference$1 { + identifier: Identifier<"decorator">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "decorator" => Variable$1, + "Foo" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ClassScope$3 { + block: ClassDeclaration$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$4, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + FunctionScope$4 { + block: FunctionExpression$4, + isStrict: true, + references: Array [], + set: Map { + "arguments" => Variable$5, + }, + type: "function", + upper: ClassScope$3, + variables: Array [ + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/decorators/parameter-property.ts b/packages/scope-manager/tests/fixtures/decorators/parameter-property.ts new file mode 100644 index 00000000000..1b2a5356f7c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/parameter-property.ts @@ -0,0 +1,4 @@ +function decorator() {} +class Foo { + constructor(@decorator readonly a, @decorator readonly b = 1) {} +} diff --git a/packages/scope-manager/tests/fixtures/decorators/parameter-property.ts.shot b/packages/scope-manager/tests/fixtures/decorators/parameter-property.ts.shot new file mode 100644 index 00000000000..636844510a3 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/parameter-property.ts.shot @@ -0,0 +1,168 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`decorators parameter-property 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"decorator">, + node: FunctionDeclaration$1, + }, + ], + name: "decorator", + references: Array [ + Reference$1 { + identifier: Identifier<"decorator">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$3 { + identifier: Identifier<"decorator">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ClassNameDefinition$3 { + name: Identifier<"Foo">, + node: ClassDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$6 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"a">, + node: FunctionExpression$3, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + ParameterDefinition$5 { + name: Identifier<"b">, + node: FunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$7, + writeExpr: Literal$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "decorator" => Variable$1, + "Foo" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ClassScope$3 { + block: ClassDeclaration$2, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$4, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + FunctionScope$4 { + block: FunctionExpression$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "arguments" => Variable$5, + "a" => Variable$6, + "b" => Variable$7, + }, + type: "function", + upper: ClassScope$3, + variables: Array [ + Variable$5, + Variable$6, + Variable$7, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/decorators/parameter.ts b/packages/scope-manager/tests/fixtures/decorators/parameter.ts new file mode 100644 index 00000000000..2b9b32b2bb2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/parameter.ts @@ -0,0 +1,7 @@ +function decorator() {} +function foo( + @decorator a, + @decorator [b], + @decorator { c }, + @decorator d = 1, +) {} diff --git a/packages/scope-manager/tests/fixtures/decorators/parameter.ts.shot b/packages/scope-manager/tests/fixtures/decorators/parameter.ts.shot new file mode 100644 index 00000000000..655435c8dcc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/decorators/parameter.ts.shot @@ -0,0 +1,185 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`decorators parameter 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"decorator">, + node: FunctionDeclaration$1, + }, + ], + name: "decorator", + references: Array [ + Reference$1 { + identifier: Identifier<"decorator">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"decorator">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$3 { + identifier: Identifier<"decorator">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$5 { + identifier: Identifier<"decorator">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"a">, + node: FunctionDeclaration$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$6 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"b">, + node: FunctionDeclaration$2, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + ParameterDefinition$5 { + name: Identifier<"c">, + node: FunctionDeclaration$2, + }, + ], + name: "c", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$8 { + defs: Array [ + ParameterDefinition$6 { + name: Identifier<"d">, + node: FunctionDeclaration$2, + }, + ], + name: "d", + references: Array [ + Reference$4 { + identifier: Identifier<"d">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$8, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "decorator" => Variable$1, + "foo" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + FunctionScope$3 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + Reference$4, + Reference$5, + ], + set: Map { + "arguments" => Variable$4, + "a" => Variable$5, + "b" => Variable$6, + "c" => Variable$7, + "d" => Variable$8, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + Variable$5, + Variable$6, + Variable$7, + Variable$8, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/destructuring/array-assignment.ts b/packages/scope-manager/tests/fixtures/destructuring/array-assignment.ts new file mode 100644 index 00000000000..a0fb37e1edc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/destructuring/array-assignment.ts @@ -0,0 +1,3 @@ +const obj = {}; +let b, c; +[obj.a, b, [c]] = []; diff --git a/packages/scope-manager/tests/fixtures/destructuring/array-assignment.ts.shot b/packages/scope-manager/tests/fixtures/destructuring/array-assignment.ts.shot new file mode 100644 index 00000000000..c6176b720a1 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/destructuring/array-assignment.ts.shot @@ -0,0 +1,101 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`destructuring array-assignment 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"obj">, + node: VariableDeclarator$1, + }, + ], + name: "obj", + references: Array [ + Reference$1 { + identifier: Identifier<"obj">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ObjectExpression$2, + }, + Reference$4 { + identifier: Identifier<"obj">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"b">, + node: VariableDeclarator$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: false, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: ArrayExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"c">, + node: VariableDeclarator$5, + }, + ], + name: "c", + references: Array [ + Reference$3 { + identifier: Identifier<"c">, + init: false, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: ArrayExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + Reference$4, + ], + set: Map { + "obj" => Variable$1, + "b" => Variable$2, + "c" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/destructuring/array.ts b/packages/scope-manager/tests/fixtures/destructuring/array.ts new file mode 100644 index 00000000000..86f9cf6901e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/destructuring/array.ts @@ -0,0 +1 @@ +const [a, b, c, d = 1, [e], [f] = g, ...rest] = []; diff --git a/packages/scope-manager/tests/fixtures/destructuring/array.ts.shot b/packages/scope-manager/tests/fixtures/destructuring/array.ts.shot new file mode 100644 index 00000000000..e474481643c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/destructuring/array.ts.shot @@ -0,0 +1,214 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`destructuring array 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrayExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"b">, + node: VariableDeclarator$1, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: ArrayExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"c">, + node: VariableDeclarator$1, + }, + ], + name: "c", + references: Array [ + Reference$3 { + identifier: Identifier<"c">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: ArrayExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"d">, + node: VariableDeclarator$1, + }, + ], + name: "d", + references: Array [ + Reference$4 { + identifier: Identifier<"d">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Literal$3, + }, + Reference$5 { + identifier: Identifier<"d">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: ArrayExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + VariableDefinition$5 { + name: Identifier<"e">, + node: VariableDeclarator$1, + }, + ], + name: "e", + references: Array [ + Reference$6 { + identifier: Identifier<"e">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$5, + writeExpr: ArrayExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$6 { + defs: Array [ + VariableDefinition$6 { + name: Identifier<"f">, + node: VariableDeclarator$1, + }, + ], + name: "f", + references: Array [ + Reference$7 { + identifier: Identifier<"f">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$6, + writeExpr: Identifier<"g">, + }, + Reference$8 { + identifier: Identifier<"f">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$6, + writeExpr: ArrayExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + VariableDefinition$7 { + name: Identifier<"rest">, + node: VariableDeclarator$1, + }, + ], + name: "rest", + references: Array [ + Reference$9 { + identifier: Identifier<"rest">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$7, + writeExpr: ArrayExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + Reference$4, + Reference$5, + Reference$6, + Reference$7, + Reference$8, + Reference$9, + Reference$10 { + identifier: Identifier<"g">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "a" => Variable$1, + "b" => Variable$2, + "c" => Variable$3, + "d" => Variable$4, + "e" => Variable$5, + "f" => Variable$6, + "rest" => Variable$7, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + Variable$4, + Variable$5, + Variable$6, + Variable$7, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/destructuring/object-assignment.ts b/packages/scope-manager/tests/fixtures/destructuring/object-assignment.ts new file mode 100644 index 00000000000..a2cc7daf8d2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/destructuring/object-assignment.ts @@ -0,0 +1,6 @@ +const obj = {}; +({ + shorthand, + key: value, + hello: { world: obj.a }, +} = object); diff --git a/packages/scope-manager/tests/fixtures/destructuring/object-assignment.ts.shot b/packages/scope-manager/tests/fixtures/destructuring/object-assignment.ts.shot new file mode 100644 index 00000000000..e0fefe1d267 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/destructuring/object-assignment.ts.shot @@ -0,0 +1,75 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`destructuring object-assignment 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"obj">, + node: VariableDeclarator$1, + }, + ], + name: "obj", + references: Array [ + Reference$1 { + identifier: Identifier<"obj">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ObjectExpression$2, + }, + Reference$4 { + identifier: Identifier<"obj">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + Reference$2 { + identifier: Identifier<"shorthand">, + init: false, + isTypeReference: false, + isValueReference: true, + resolved: null, + writeExpr: Identifier<"object">, + }, + Reference$3 { + identifier: Identifier<"value">, + init: false, + isTypeReference: false, + isValueReference: true, + resolved: null, + writeExpr: Identifier<"object">, + }, + Reference$4, + Reference$5 { + identifier: Identifier<"object">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "obj" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/destructuring/object.ts b/packages/scope-manager/tests/fixtures/destructuring/object.ts new file mode 100644 index 00000000000..1b35c309cd4 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/destructuring/object.ts @@ -0,0 +1,6 @@ +const { + shorthand, + key: value, + hello: { world }, + array: [a, b, c, d], +} = object; diff --git a/packages/scope-manager/tests/fixtures/destructuring/object.ts.shot b/packages/scope-manager/tests/fixtures/destructuring/object.ts.shot new file mode 100644 index 00000000000..17617b31258 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/destructuring/object.ts.shot @@ -0,0 +1,196 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`destructuring object 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"shorthand">, + node: VariableDeclarator$1, + }, + ], + name: "shorthand", + references: Array [ + Reference$1 { + identifier: Identifier<"shorthand">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Identifier<"object">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"value">, + node: VariableDeclarator$1, + }, + ], + name: "value", + references: Array [ + Reference$2 { + identifier: Identifier<"value">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Identifier<"object">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"world">, + node: VariableDeclarator$1, + }, + ], + name: "world", + references: Array [ + Reference$3 { + identifier: Identifier<"world">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"object">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$4 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"object">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + VariableDefinition$5 { + name: Identifier<"b">, + node: VariableDeclarator$1, + }, + ], + name: "b", + references: Array [ + Reference$5 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$5, + writeExpr: Identifier<"object">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$6 { + defs: Array [ + VariableDefinition$6 { + name: Identifier<"c">, + node: VariableDeclarator$1, + }, + ], + name: "c", + references: Array [ + Reference$6 { + identifier: Identifier<"c">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$6, + writeExpr: Identifier<"object">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + VariableDefinition$7 { + name: Identifier<"d">, + node: VariableDeclarator$1, + }, + ], + name: "d", + references: Array [ + Reference$7 { + identifier: Identifier<"d">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$7, + writeExpr: Identifier<"object">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + Reference$4, + Reference$5, + Reference$6, + Reference$7, + Reference$8 { + identifier: Identifier<"object">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "shorthand" => Variable$1, + "value" => Variable$2, + "world" => Variable$3, + "a" => Variable$4, + "b" => Variable$5, + "c" => Variable$6, + "d" => Variable$7, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + Variable$4, + Variable$5, + Variable$6, + Variable$7, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/all.ts b/packages/scope-manager/tests/fixtures/export/all.ts new file mode 100644 index 00000000000..05c93176fac --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/all.ts @@ -0,0 +1,4 @@ +//// @sourceType = module + +export * from 'foo'; +export * as bar from 'foo'; diff --git a/packages/scope-manager/tests/fixtures/export/all.ts.shot b/packages/scope-manager/tests/fixtures/export/all.ts.shot new file mode 100644 index 00000000000..a420ebe9cc0 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/all.ts.shot @@ -0,0 +1,27 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export all 1`] = ` +ScopeManager { + variables: Array [], + scopes: Array [ + GlobalScope$1 { + block: Program$1, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$1, + isStrict: true, + references: Array [], + set: Map {}, + type: "module", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/default-type.ts b/packages/scope-manager/tests/fixtures/export/default-type.ts new file mode 100644 index 00000000000..d62a0213891 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/default-type.ts @@ -0,0 +1,4 @@ +//// @sourceType = module + +type T = 1; +export default T; diff --git a/packages/scope-manager/tests/fixtures/export/default-type.ts.shot b/packages/scope-manager/tests/fixtures/export/default-type.ts.shot new file mode 100644 index 00000000000..9c1d1fc17fd --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/default-type.ts.shot @@ -0,0 +1,53 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export default-type 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/default1.ts b/packages/scope-manager/tests/fixtures/export/default1.ts new file mode 100644 index 00000000000..b9427a508f5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/default1.ts @@ -0,0 +1,3 @@ +//// @sourceType = module + +export default function f() {} diff --git a/packages/scope-manager/tests/fixtures/export/default1.ts.shot b/packages/scope-manager/tests/fixtures/export/default1.ts.shot new file mode 100644 index 00000000000..7e8fe1b48b8 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/default1.ts.shot @@ -0,0 +1,64 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export default1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"f">, + node: FunctionDeclaration$1, + }, + ], + name: "f", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$2, + isStrict: true, + references: Array [], + set: Map { + "f" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$3 { + block: FunctionDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "arguments" => Variable$2, + }, + type: "function", + upper: ModuleScope$2, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/default2.ts b/packages/scope-manager/tests/fixtures/export/default2.ts new file mode 100644 index 00000000000..319a863c245 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/default2.ts @@ -0,0 +1,4 @@ +//// @sourceType = module + +const a = 1; +export default a; diff --git a/packages/scope-manager/tests/fixtures/export/default2.ts.shot b/packages/scope-manager/tests/fixtures/export/default2.ts.shot new file mode 100644 index 00000000000..99b0eb60ca5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/default2.ts.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export default2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"a">, + isTypeReference: true, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "a" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/default3.ts b/packages/scope-manager/tests/fixtures/export/default3.ts new file mode 100644 index 00000000000..a5d671a6b31 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/default3.ts @@ -0,0 +1,3 @@ +//// @sourceType = module + +export default 1; diff --git a/packages/scope-manager/tests/fixtures/export/default3.ts.shot b/packages/scope-manager/tests/fixtures/export/default3.ts.shot new file mode 100644 index 00000000000..620d33c9534 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/default3.ts.shot @@ -0,0 +1,27 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export default3 1`] = ` +ScopeManager { + variables: Array [], + scopes: Array [ + GlobalScope$1 { + block: Program$1, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$1, + isStrict: true, + references: Array [], + set: Map {}, + type: "module", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/default4.ts b/packages/scope-manager/tests/fixtures/export/default4.ts new file mode 100644 index 00000000000..8a6fea86b71 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/default4.ts @@ -0,0 +1,3 @@ +//// @sourceType = module + +export default function () {} diff --git a/packages/scope-manager/tests/fixtures/export/default4.ts.shot b/packages/scope-manager/tests/fixtures/export/default4.ts.shot new file mode 100644 index 00000000000..c02248243ec --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/default4.ts.shot @@ -0,0 +1,48 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export default4 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$1, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$1, + isStrict: true, + references: Array [], + set: Map {}, + type: "module", + upper: GlobalScope$1, + variables: Array [], + }, + FunctionScope$3 { + block: FunctionDeclaration$2, + isStrict: true, + references: Array [], + set: Map { + "arguments" => Variable$1, + }, + type: "function", + upper: ModuleScope$2, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/equals1.ts b/packages/scope-manager/tests/fixtures/export/equals1.ts new file mode 100644 index 00000000000..8bab055cb87 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/equals1.ts @@ -0,0 +1,4 @@ +//// @sourceType = module + +const x = 1; +export = x; diff --git a/packages/scope-manager/tests/fixtures/export/equals1.ts.shot b/packages/scope-manager/tests/fixtures/export/equals1.ts.shot new file mode 100644 index 00000000000..c693c590130 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/equals1.ts.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export equals1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "x" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/equals2.ts b/packages/scope-manager/tests/fixtures/export/equals2.ts new file mode 100644 index 00000000000..67d85f90bed --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/equals2.ts @@ -0,0 +1,3 @@ +//// @sourceType = module + +export = 1; diff --git a/packages/scope-manager/tests/fixtures/export/equals2.ts.shot b/packages/scope-manager/tests/fixtures/export/equals2.ts.shot new file mode 100644 index 00000000000..3b83940b97e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/equals2.ts.shot @@ -0,0 +1,27 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export equals2 1`] = ` +ScopeManager { + variables: Array [], + scopes: Array [ + GlobalScope$1 { + block: Program$1, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$1, + isStrict: true, + references: Array [], + set: Map {}, + type: "module", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/named-dual.ts b/packages/scope-manager/tests/fixtures/export/named-dual.ts new file mode 100644 index 00000000000..011ed067a6e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named-dual.ts @@ -0,0 +1,3 @@ +const T = 1; +type T = 1; +export { T }; diff --git a/packages/scope-manager/tests/fixtures/export/named-dual.ts.shot b/packages/scope-manager/tests/fixtures/export/named-dual.ts.shot new file mode 100644 index 00000000000..bf610032f58 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named-dual.ts.shot @@ -0,0 +1,57 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export named-dual 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"T">, + node: VariableDeclarator$1, + }, + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$3, + }, + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "T" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/named-source1.ts b/packages/scope-manager/tests/fixtures/export/named-source1.ts new file mode 100644 index 00000000000..d7354f5d9bc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named-source1.ts @@ -0,0 +1,3 @@ +//// @sourceType = module + +export { x } from 'foo'; diff --git a/packages/scope-manager/tests/fixtures/export/named-source1.ts.shot b/packages/scope-manager/tests/fixtures/export/named-source1.ts.shot new file mode 100644 index 00000000000..7598572fc78 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named-source1.ts.shot @@ -0,0 +1,27 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export named-source1 1`] = ` +ScopeManager { + variables: Array [], + scopes: Array [ + GlobalScope$1 { + block: Program$1, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$1, + isStrict: true, + references: Array [], + set: Map {}, + type: "module", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/named-source2.ts b/packages/scope-manager/tests/fixtures/export/named-source2.ts new file mode 100644 index 00000000000..2630c6db88a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named-source2.ts @@ -0,0 +1,3 @@ +//// @sourceType = module + +export { v as x } from 'foo'; diff --git a/packages/scope-manager/tests/fixtures/export/named-source2.ts.shot b/packages/scope-manager/tests/fixtures/export/named-source2.ts.shot new file mode 100644 index 00000000000..e56a8288c32 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named-source2.ts.shot @@ -0,0 +1,27 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export named-source2 1`] = ` +ScopeManager { + variables: Array [], + scopes: Array [ + GlobalScope$1 { + block: Program$1, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$1, + isStrict: true, + references: Array [], + set: Map {}, + type: "module", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/named-type1.ts b/packages/scope-manager/tests/fixtures/export/named-type1.ts new file mode 100644 index 00000000000..7b0c1fd0878 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named-type1.ts @@ -0,0 +1,3 @@ +//// @sourceType = module + +export type X = 1; diff --git a/packages/scope-manager/tests/fixtures/export/named-type1.ts.shot b/packages/scope-manager/tests/fixtures/export/named-type1.ts.shot new file mode 100644 index 00000000000..f9b193e83db --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named-type1.ts.shot @@ -0,0 +1,44 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export named-type1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"X">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "X", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$2, + isStrict: true, + references: Array [], + set: Map { + "X" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/named1.ts b/packages/scope-manager/tests/fixtures/export/named1.ts new file mode 100644 index 00000000000..e73a99dca55 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named1.ts @@ -0,0 +1,3 @@ +//// @sourceType = module + +export const x = 1; diff --git a/packages/scope-manager/tests/fixtures/export/named1.ts.shot b/packages/scope-manager/tests/fixtures/export/named1.ts.shot new file mode 100644 index 00000000000..b10f6f58a2d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named1.ts.shot @@ -0,0 +1,55 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export named1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "x" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/named2-type.ts b/packages/scope-manager/tests/fixtures/export/named2-type.ts new file mode 100644 index 00000000000..50e977e58ba --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named2-type.ts @@ -0,0 +1,4 @@ +//// @sourceType = module + +type A = 1; +export { A }; diff --git a/packages/scope-manager/tests/fixtures/export/named2-type.ts.shot b/packages/scope-manager/tests/fixtures/export/named2-type.ts.shot new file mode 100644 index 00000000000..6bd10e23f17 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named2-type.ts.shot @@ -0,0 +1,53 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export named2-type 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + isTypeReference: true, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "A" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/named2.ts b/packages/scope-manager/tests/fixtures/export/named2.ts new file mode 100644 index 00000000000..056e74c313b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named2.ts @@ -0,0 +1,4 @@ +//// @sourceType = module + +const a = 1; +export { a }; diff --git a/packages/scope-manager/tests/fixtures/export/named2.ts.shot b/packages/scope-manager/tests/fixtures/export/named2.ts.shot new file mode 100644 index 00000000000..73dd13542c6 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named2.ts.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export named2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"a">, + isTypeReference: true, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "a" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/named3-type.ts b/packages/scope-manager/tests/fixtures/export/named3-type.ts new file mode 100644 index 00000000000..543a0e996f1 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named3-type.ts @@ -0,0 +1,4 @@ +//// @sourceType = module + +type V = 1; +export { V as X }; diff --git a/packages/scope-manager/tests/fixtures/export/named3-type.ts.shot b/packages/scope-manager/tests/fixtures/export/named3-type.ts.shot new file mode 100644 index 00000000000..500935bdd76 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named3-type.ts.shot @@ -0,0 +1,53 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export named3-type 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"V">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "V", + references: Array [ + Reference$1 { + identifier: Identifier<"V">, + isTypeReference: true, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "V" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/named3.ts b/packages/scope-manager/tests/fixtures/export/named3.ts new file mode 100644 index 00000000000..044a7dea2be --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named3.ts @@ -0,0 +1,4 @@ +//// @sourceType = module + +const v = 1; +export { v as x }; diff --git a/packages/scope-manager/tests/fixtures/export/named3.ts.shot b/packages/scope-manager/tests/fixtures/export/named3.ts.shot new file mode 100644 index 00000000000..198603fdebc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/named3.ts.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export named3 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"v">, + node: VariableDeclarator$1, + }, + ], + name: "v", + references: Array [ + Reference$1 { + identifier: Identifier<"v">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"v">, + isTypeReference: true, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "v" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/export/type.ts b/packages/scope-manager/tests/fixtures/export/type.ts new file mode 100644 index 00000000000..7ca93bbfefb --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/type.ts @@ -0,0 +1,5 @@ +//// @sourceType = module + +const T = 1; // unreferenced +type T = 1; +export type { T }; diff --git a/packages/scope-manager/tests/fixtures/export/type.ts.shot b/packages/scope-manager/tests/fixtures/export/type.ts.shot new file mode 100644 index 00000000000..181f5ed6da8 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/export/type.ts.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`export type 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"T">, + node: VariableDeclarator$1, + }, + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$3, + }, + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "T" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-body-shadow.ts b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-body-shadow.ts new file mode 100644 index 00000000000..b932c662abf --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-body-shadow.ts @@ -0,0 +1,5 @@ +let a; +// the default param value is resolved to the outer scope +let foo = (b = a) => { + let a; +}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-body-shadow.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-body-shadow.ts.shot new file mode 100644 index 00000000000..1478c2789fc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-body-shadow.ts.shot @@ -0,0 +1,118 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow default-params readable-ref-body-shadow 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: ArrowFunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: ArrowFunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"a">, + node: VariableDeclarator$4, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "b" => Variable$3, + "a" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-const.ts b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-const.ts new file mode 100644 index 00000000000..57bbb0b4cdb --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-const.ts @@ -0,0 +1,2 @@ +const a = 0; +let foo = (b = a) => {}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-const.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-const.ts.shot new file mode 100644 index 00000000000..504bc63a07f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-const.ts.shot @@ -0,0 +1,113 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow default-params readable-ref-const 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$4 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$3, + }, + ], + name: "foo", + references: Array [ + Reference$2 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: ArrowFunctionExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: ArrowFunctionExpression$4, + }, + ], + name: "b", + references: Array [ + Reference$3 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$4, + isStrict: false, + references: Array [ + Reference$3, + Reference$4, + ], + set: Map { + "b" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-let.ts b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-let.ts new file mode 100644 index 00000000000..4b73fa5e3a6 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-let.ts @@ -0,0 +1,2 @@ +let a; +let foo = (b = a) => {}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-let.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-let.ts.shot new file mode 100644 index 00000000000..e9ce64886bb --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-let.ts.shot @@ -0,0 +1,104 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow default-params readable-ref-let 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: ArrowFunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: ArrowFunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "b" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested-body-shadow.ts b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested-body-shadow.ts new file mode 100644 index 00000000000..1413a2a1534 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested-body-shadow.ts @@ -0,0 +1,8 @@ +let a; +let foo = ( + b = function () { + a; + }, +) => { + let a; +}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested-body-shadow.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested-body-shadow.ts.shot new file mode 100644 index 00000000000..0466d943655 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested-body-shadow.ts.shot @@ -0,0 +1,139 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow default-params readable-ref-nested-body-shadow 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: ArrowFunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: ArrowFunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: FunctionExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$5 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"a">, + node: VariableDeclarator$5, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "b" => Variable$3, + "a" => Variable$5, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$5, + ], + }, + FunctionScope$3 { + block: FunctionExpression$4, + isStrict: false, + references: Array [ + Reference$3, + ], + set: Map { + "arguments" => Variable$4, + }, + type: "function", + upper: FunctionScope$2, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested.ts b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested.ts new file mode 100644 index 00000000000..1f1c08f6c83 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested.ts @@ -0,0 +1,6 @@ +let a; +let foo = ( + b = function () { + return a; + }, +) => {}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested.ts.shot new file mode 100644 index 00000000000..ba9e9641cfe --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-nested.ts.shot @@ -0,0 +1,125 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow default-params readable-ref-nested 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: ArrowFunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: ArrowFunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: FunctionExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "b" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + FunctionScope$3 { + block: FunctionExpression$4, + isStrict: false, + references: Array [ + Reference$3, + ], + set: Map { + "arguments" => Variable$4, + }, + type: "function", + upper: FunctionScope$2, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-param-shadow.ts b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-param-shadow.ts new file mode 100644 index 00000000000..f9a7cf72ccb --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-param-shadow.ts @@ -0,0 +1,3 @@ +let a; +// the default param value is resolved to the parameter +let foo = (b = a, a) => {}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-param-shadow.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-param-shadow.ts.shot new file mode 100644 index 00000000000..b200c1d9d83 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-param-shadow.ts.shot @@ -0,0 +1,118 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow default-params readable-ref-param-shadow 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: ArrowFunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: ArrowFunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"a">, + node: ArrowFunctionExpression$3, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "b" => Variable$3, + "a" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-partial.ts b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-partial.ts new file mode 100644 index 00000000000..6fa7d4698f5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-partial.ts @@ -0,0 +1,2 @@ +let a; +let foo = (b = a.c) => {}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-partial.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-partial.ts.shot new file mode 100644 index 00000000000..8464c51df51 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/readable-ref-partial.ts.shot @@ -0,0 +1,104 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow default-params readable-ref-partial 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: ArrowFunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: ArrowFunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: MemberExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "b" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/writable-ref.ts b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/writable-ref.ts new file mode 100644 index 00000000000..0bc2e3c6114 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/writable-ref.ts @@ -0,0 +1 @@ +let foo = (a, b = 0) => {}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/default-params/writable-ref.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/writable-ref.ts.shot new file mode 100644 index 00000000000..1e52b8daf5f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/default-params/writable-ref.ts.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow default-params writable-ref 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + ParameterDefinition$2 { + name: Identifier<"a">, + node: ArrowFunctionExpression$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: ArrowFunctionExpression$2, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "a" => Variable$2, + "b" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/inherited-scope.ts b/packages/scope-manager/tests/fixtures/functions/arrow/inherited-scope.ts new file mode 100644 index 00000000000..60bbda6ce00 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/inherited-scope.ts @@ -0,0 +1,5 @@ +const parentScoped = 1; + +() => { + parentScoped + 1; +}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/inherited-scope.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/inherited-scope.ts.shot new file mode 100644 index 00000000000..f1c2f84609c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/inherited-scope.ts.shot @@ -0,0 +1,63 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow inherited-scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"parentScoped">, + node: VariableDeclarator$1, + }, + ], + name: "parentScoped", + references: Array [ + Reference$1 { + identifier: Identifier<"parentScoped">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"parentScoped">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "parentScoped" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$4, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map {}, + type: "function", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/no-body.ts b/packages/scope-manager/tests/fixtures/functions/arrow/no-body.ts new file mode 100644 index 00000000000..d24dce0d806 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/no-body.ts @@ -0,0 +1 @@ +a => a; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/no-body.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/no-body.ts.shot new file mode 100644 index 00000000000..a837f9931f0 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/no-body.ts.shot @@ -0,0 +1,53 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow no-body 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ParameterDefinition$1 { + name: Identifier<"a">, + node: ArrowFunctionExpression$1, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$1, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/params.ts b/packages/scope-manager/tests/fixtures/functions/arrow/params.ts new file mode 100644 index 00000000000..29e5351527d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/params.ts @@ -0,0 +1,6 @@ +const outer = 1; +(a, [b], { c }, d = 1, e = a, f = outer, g) => { + a; +}; + +const unresolved = g; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/params.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/params.ts.shot new file mode 100644 index 00000000000..fe084bc9976 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/params.ts.shot @@ -0,0 +1,238 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow params 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"outer">, + node: VariableDeclarator$1, + }, + ], + name: "outer", + references: Array [ + Reference$1 { + identifier: Identifier<"outer">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$6 { + identifier: Identifier<"outer">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + ParameterDefinition$2 { + name: Identifier<"a">, + node: ArrowFunctionExpression$3, + }, + ], + name: "a", + references: Array [ + Reference$4 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + }, + Reference$7 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: ArrowFunctionExpression$3, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"c">, + node: ArrowFunctionExpression$3, + }, + ], + name: "c", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + ParameterDefinition$5 { + name: Identifier<"d">, + node: ArrowFunctionExpression$3, + }, + ], + name: "d", + references: Array [ + Reference$2 { + identifier: Identifier<"d">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$5, + writeExpr: Literal$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$6 { + defs: Array [ + ParameterDefinition$6 { + name: Identifier<"e">, + node: ArrowFunctionExpression$3, + }, + ], + name: "e", + references: Array [ + Reference$3 { + identifier: Identifier<"e">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$6, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + ParameterDefinition$7 { + name: Identifier<"f">, + node: ArrowFunctionExpression$3, + }, + ], + name: "f", + references: Array [ + Reference$5 { + identifier: Identifier<"f">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$7, + writeExpr: Identifier<"outer">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$8 { + defs: Array [ + ParameterDefinition$8 { + name: Identifier<"g">, + node: ArrowFunctionExpression$3, + }, + ], + name: "g", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$9 { + defs: Array [ + VariableDefinition$9 { + name: Identifier<"unresolved">, + node: VariableDeclarator$5, + }, + ], + name: "unresolved", + references: Array [ + Reference$8 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$9, + writeExpr: Identifier<"g">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$1, + Reference$8, + Reference$9 { + identifier: Identifier<"g">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "outer" => Variable$1, + "unresolved" => Variable$9, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$9, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + Reference$4, + Reference$5, + Reference$6, + Reference$7, + ], + set: Map { + "a" => Variable$2, + "b" => Variable$3, + "c" => Variable$4, + "d" => Variable$5, + "e" => Variable$6, + "f" => Variable$7, + "g" => Variable$8, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + Variable$5, + Variable$6, + Variable$7, + Variable$8, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/scope.ts b/packages/scope-manager/tests/fixtures/functions/arrow/scope.ts new file mode 100644 index 00000000000..6588507859c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/scope.ts @@ -0,0 +1,8 @@ +const arrow = () => { + let i = 0; + var j = 20; + + i; +}; + +const unresolved = j; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/scope.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/scope.ts.shot new file mode 100644 index 00000000000..72ab01f0b9e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/scope.ts.shot @@ -0,0 +1,143 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"arrow">, + node: VariableDeclarator$1, + }, + ], + name: "arrow", + references: Array [ + Reference$1 { + identifier: Identifier<"arrow">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"i">, + node: VariableDeclarator$3, + }, + ], + name: "i", + references: Array [ + Reference$2 { + identifier: Identifier<"i">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$4, + }, + Reference$4 { + identifier: Identifier<"i">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"j">, + node: VariableDeclarator$5, + }, + ], + name: "j", + references: Array [ + Reference$3 { + identifier: Identifier<"j">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Literal$6, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"unresolved">, + node: VariableDeclarator$7, + }, + ], + name: "unresolved", + references: Array [ + Reference$5 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"j">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$8, + isStrict: false, + references: Array [ + Reference$1, + Reference$5, + Reference$6 { + identifier: Identifier<"j">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "arrow" => Variable$1, + "unresolved" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + Reference$4, + ], + set: Map { + "i" => Variable$2, + "j" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/body-reference.ts b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/body-reference.ts new file mode 100644 index 00000000000..16d3f36482b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/body-reference.ts @@ -0,0 +1,3 @@ +const foo = () => { + let x: T; +}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/body-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/body-reference.ts.shot new file mode 100644 index 00000000000..0b336fc5a85 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/body-reference.ts.shot @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow type-parameters body-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$3, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"x">, + node: VariableDeclarator$4, + }, + ], + name: "x", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "T" => Variable$2, + "x" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/param-reference.ts b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/param-reference.ts new file mode 100644 index 00000000000..eaa11b78b89 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/param-reference.ts @@ -0,0 +1 @@ +const foo = (a: T) => {}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/param-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/param-reference.ts.shot new file mode 100644 index 00000000000..b610cb39c54 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/param-reference.ts.shot @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow type-parameters param-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + ParameterDefinition$2 { + name: Identifier<"a">, + node: ArrowFunctionExpression$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"T">, + node: TSTypeParameter$3, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "a" => Variable$2, + "T" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/return-value-reference.ts b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/return-value-reference.ts new file mode 100644 index 00000000000..e18d95bc4c3 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/return-value-reference.ts @@ -0,0 +1 @@ +const foo = (): T => {}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/return-value-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/return-value-reference.ts.shot new file mode 100644 index 00000000000..fb8b4b88e1b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/return-value-reference.ts.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow type-parameters return-value-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$3, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "T" => Variable$2, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-param-reference.ts b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-param-reference.ts new file mode 100644 index 00000000000..6a6ca837c15 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-param-reference.ts @@ -0,0 +1 @@ +const foo = () => {}; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-param-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-param-reference.ts.shot new file mode 100644 index 00000000000..ce4e32ff765 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-param-reference.ts.shot @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow type-parameters type-param-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$3, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$4, + }, + ], + name: "U", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "T" => Variable$2, + "U" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-parameter-declaration.ts b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-parameter-declaration.ts new file mode 100644 index 00000000000..c863d3086fd --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-parameter-declaration.ts @@ -0,0 +1,3 @@ +const foo = () => {}; + +type Unresolved = T; diff --git a/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-parameter-declaration.ts.shot b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-parameter-declaration.ts.shot new file mode 100644 index 00000000000..a83255e192d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/arrow/type-parameters/type-parameter-declaration.ts.shot @@ -0,0 +1,91 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions arrow type-parameters type-parameter-declaration 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$3, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"Unresolved">, + node: TSTypeAliasDeclaration$4, + }, + ], + name: "Unresolved", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "foo" => Variable$1, + "Unresolved" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$2, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$2, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-body-shadow.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-body-shadow.ts new file mode 100644 index 00000000000..fbe1e8d1af6 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-body-shadow.ts @@ -0,0 +1,5 @@ +let a; +// the default param value is resolved to the outer scope +function foo(b = a) { + let a; +} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-body-shadow.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-body-shadow.ts.shot new file mode 100644 index 00000000000..bcee2db1431 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-body-shadow.ts.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration default-params readable-ref-body-shadow 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$2 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionDeclaration$2, + }, + ], + name: "b", + references: Array [ + Reference$1 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"a">, + node: VariableDeclarator$3, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + "a" => Variable$5, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-const.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-const.ts new file mode 100644 index 00000000000..8d6ce23c680 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-const.ts @@ -0,0 +1,2 @@ +const a = 0; +function foo(b = a) {} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-const.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-const.ts.shot new file mode 100644 index 00000000000..62c0cf7eafc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-const.ts.shot @@ -0,0 +1,112 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration default-params readable-ref-const 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$3, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionDeclaration$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$3, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-let.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-let.ts new file mode 100644 index 00000000000..6b82f860ad3 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-let.ts @@ -0,0 +1,2 @@ +let a; +function foo(b = a) {} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-let.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-let.ts.shot new file mode 100644 index 00000000000..43cb526af51 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-let.ts.shot @@ -0,0 +1,102 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration default-params readable-ref-let 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$2 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionDeclaration$2, + }, + ], + name: "b", + references: Array [ + Reference$1 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested-body-shadow.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested-body-shadow.ts new file mode 100644 index 00000000000..39cac38f4f5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested-body-shadow.ts @@ -0,0 +1,8 @@ +let a; +function foo( + b = function () { + a; + }, +) { + let a; +} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested-body-shadow.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested-body-shadow.ts.shot new file mode 100644 index 00000000000..14140d27765 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested-body-shadow.ts.shot @@ -0,0 +1,137 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration default-params readable-ref-nested-body-shadow 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$2 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionDeclaration$2, + }, + ], + name: "b", + references: Array [ + Reference$1 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: FunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$6 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"a">, + node: VariableDeclarator$4, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + "a" => Variable$6, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + Variable$6, + ], + }, + FunctionScope$3 { + block: FunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "arguments" => Variable$5, + }, + type: "function", + upper: FunctionScope$2, + variables: Array [ + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested.ts new file mode 100644 index 00000000000..7e27579ed93 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested.ts @@ -0,0 +1,6 @@ +let a; +function foo( + b = function () { + return a; + }, +) {} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested.ts.shot new file mode 100644 index 00000000000..772c0dec0d2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-nested.ts.shot @@ -0,0 +1,123 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration default-params readable-ref-nested 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$2 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionDeclaration$2, + }, + ], + name: "b", + references: Array [ + Reference$1 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: FunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + FunctionScope$3 { + block: FunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "arguments" => Variable$5, + }, + type: "function", + upper: FunctionScope$2, + variables: Array [ + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-param-shadow.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-param-shadow.ts new file mode 100644 index 00000000000..4a091a09d67 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-param-shadow.ts @@ -0,0 +1,3 @@ +let a; +// the default param value is resolved to the parameter +function foo(b = a, a) {} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-param-shadow.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-param-shadow.ts.shot new file mode 100644 index 00000000000..320f10d2361 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-param-shadow.ts.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration default-params readable-ref-param-shadow 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionDeclaration$2, + }, + ], + name: "b", + references: Array [ + Reference$1 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"a">, + node: FunctionDeclaration$2, + }, + ], + name: "a", + references: Array [ + Reference$2 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$5, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + "a" => Variable$5, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-partial.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-partial.ts new file mode 100644 index 00000000000..84945daa740 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-partial.ts @@ -0,0 +1,2 @@ +let a; +function foo(b = a.c) {} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-partial.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-partial.ts.shot new file mode 100644 index 00000000000..a4274c458a4 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/readable-ref-partial.ts.shot @@ -0,0 +1,102 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration default-params readable-ref-partial 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$2 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionDeclaration$2, + }, + ], + name: "b", + references: Array [ + Reference$1 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: MemberExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/writable-ref.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/writable-ref.ts new file mode 100644 index 00000000000..ca81afa1268 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/writable-ref.ts @@ -0,0 +1 @@ +function foo(a, b = 0) {} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/writable-ref.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/writable-ref.ts.shot new file mode 100644 index 00000000000..1063bdb6d56 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/default-params/writable-ref.ts.shot @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration default-params writable-ref 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"foo">, + node: FunctionDeclaration$1, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$2 { + name: Identifier<"a">, + node: FunctionDeclaration$1, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionDeclaration$1, + }, + ], + name: "b", + references: Array [ + Reference$1 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Literal$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$2, + "a" => Variable$3, + "b" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/inherited-scope.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/inherited-scope.ts new file mode 100644 index 00000000000..26b40f7667e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/inherited-scope.ts @@ -0,0 +1,5 @@ +const parentScoped = 1; + +function foo() { + parentScoped + 1; +} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/inherited-scope.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/inherited-scope.ts.shot new file mode 100644 index 00000000000..bf664a1b49f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/inherited-scope.ts.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration inherited-scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"parentScoped">, + node: VariableDeclarator$1, + }, + ], + name: "parentScoped", + references: Array [ + Reference$1 { + identifier: Identifier<"parentScoped">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"parentScoped">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$3, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "parentScoped" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$3, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "arguments" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/name-shadowed-in-body.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/name-shadowed-in-body.ts new file mode 100644 index 00000000000..0e00a3fa9b9 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/name-shadowed-in-body.ts @@ -0,0 +1,5 @@ +function Foo() { + const Foo = 1; +} + +const usage = Foo; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/name-shadowed-in-body.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/name-shadowed-in-body.ts.shot new file mode 100644 index 00000000000..eecc7dacb2d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/name-shadowed-in-body.ts.shot @@ -0,0 +1,113 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration name-shadowed-in-body 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"Foo">, + node: FunctionDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$3 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"Foo">, + node: VariableDeclarator$2, + }, + ], + name: "Foo", + references: Array [ + Reference$1 { + identifier: Identifier<"Foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"usage">, + node: VariableDeclarator$4, + }, + ], + name: "usage", + references: Array [ + Reference$2 { + identifier: Identifier<"usage">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"Foo">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "Foo" => Variable$1, + "usage" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$2, + "Foo" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/overload.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/overload.ts new file mode 100644 index 00000000000..682fecea6e4 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/overload.ts @@ -0,0 +1,4 @@ +function foo(a, b); +function foo(a, b) { + a; +} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/overload.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/overload.ts.shot new file mode 100644 index 00000000000..b6106082105 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/overload.ts.shot @@ -0,0 +1,144 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration overload 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"foo">, + node: TSDeclareFunction$1, + }, + FunctionNameDefinition$4 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$2 { + name: Identifier<"a">, + node: TSDeclareFunction$1, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: TSDeclareFunction$1, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$6 { + defs: Array [ + ParameterDefinition$5 { + name: Identifier<"a">, + node: FunctionDeclaration$2, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$6, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + ParameterDefinition$6 { + name: Identifier<"b">, + node: FunctionDeclaration$2, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: TSDeclareFunction$1, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + "a" => Variable$3, + "b" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + FunctionScope$3 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$5, + "a" => Variable$6, + "b" => Variable$7, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$5, + Variable$6, + Variable$7, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/params.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/params.ts new file mode 100644 index 00000000000..202c4e4a17a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/params.ts @@ -0,0 +1,6 @@ +const outer = 1; +function foo(a, [b], { c }, d = 1, e = a, f = outer, g) { + a; +} + +const unresolved = g; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/params.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/params.ts.shot new file mode 100644 index 00000000000..a1783e6a476 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/params.ts.shot @@ -0,0 +1,261 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration params 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"outer">, + node: VariableDeclarator$1, + }, + ], + name: "outer", + references: Array [ + Reference$1 { + identifier: Identifier<"outer">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$6 { + identifier: Identifier<"outer">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$3, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"a">, + node: FunctionDeclaration$3, + }, + ], + name: "a", + references: Array [ + Reference$4 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + }, + Reference$7 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"b">, + node: FunctionDeclaration$3, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$6 { + defs: Array [ + ParameterDefinition$5 { + name: Identifier<"c">, + node: FunctionDeclaration$3, + }, + ], + name: "c", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + ParameterDefinition$6 { + name: Identifier<"d">, + node: FunctionDeclaration$3, + }, + ], + name: "d", + references: Array [ + Reference$2 { + identifier: Identifier<"d">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$7, + writeExpr: Literal$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$8 { + defs: Array [ + ParameterDefinition$7 { + name: Identifier<"e">, + node: FunctionDeclaration$3, + }, + ], + name: "e", + references: Array [ + Reference$3 { + identifier: Identifier<"e">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$8, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$9 { + defs: Array [ + ParameterDefinition$8 { + name: Identifier<"f">, + node: FunctionDeclaration$3, + }, + ], + name: "f", + references: Array [ + Reference$5 { + identifier: Identifier<"f">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$9, + writeExpr: Identifier<"outer">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$10 { + defs: Array [ + ParameterDefinition$9 { + name: Identifier<"g">, + node: FunctionDeclaration$3, + }, + ], + name: "g", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$11 { + defs: Array [ + VariableDefinition$10 { + name: Identifier<"unresolved">, + node: VariableDeclarator$5, + }, + ], + name: "unresolved", + references: Array [ + Reference$8 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$11, + writeExpr: Identifier<"g">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$1, + Reference$8, + Reference$9 { + identifier: Identifier<"g">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "outer" => Variable$1, + "foo" => Variable$2, + "unresolved" => Variable$11, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$11, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$3, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + Reference$4, + Reference$5, + Reference$6, + Reference$7, + ], + set: Map { + "arguments" => Variable$3, + "a" => Variable$4, + "b" => Variable$5, + "c" => Variable$6, + "d" => Variable$7, + "e" => Variable$8, + "f" => Variable$9, + "g" => Variable$10, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + Variable$5, + Variable$6, + Variable$7, + Variable$8, + Variable$9, + Variable$10, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/scope.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/scope.ts new file mode 100644 index 00000000000..eba6a56b336 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/scope.ts @@ -0,0 +1,8 @@ +function foo() { + let i = 0; + var j = 20; + + i; +} + +const unresolved = j; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/scope.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/scope.ts.shot new file mode 100644 index 00000000000..32faa293018 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/scope.ts.shot @@ -0,0 +1,142 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"foo">, + node: FunctionDeclaration$1, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"i">, + node: VariableDeclarator$2, + }, + ], + name: "i", + references: Array [ + Reference$1 { + identifier: Identifier<"i">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Literal$3, + }, + Reference$3 { + identifier: Identifier<"i">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"j">, + node: VariableDeclarator$4, + }, + ], + name: "j", + references: Array [ + Reference$2 { + identifier: Identifier<"j">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Literal$5, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"unresolved">, + node: VariableDeclarator$6, + }, + ], + name: "unresolved", + references: Array [ + Reference$4 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$5, + writeExpr: Identifier<"j">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$7, + isStrict: false, + references: Array [ + Reference$4, + Reference$5 { + identifier: Identifier<"j">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "foo" => Variable$1, + "unresolved" => Variable$5, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$5, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "arguments" => Variable$2, + "i" => Variable$3, + "j" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/body-reference.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/body-reference.ts new file mode 100644 index 00000000000..109f4ac8f61 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/body-reference.ts @@ -0,0 +1,3 @@ +function foo() { + let x: T; +} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/body-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/body-reference.ts.shot new file mode 100644 index 00000000000..cc1205bc1b0 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/body-reference.ts.shot @@ -0,0 +1,92 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration type-parameters body-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"foo">, + node: FunctionDeclaration$1, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"x">, + node: VariableDeclarator$3, + }, + ], + name: "x", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$2, + "T" => Variable$3, + "x" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/param-reference.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/param-reference.ts new file mode 100644 index 00000000000..bb418f8ac3e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/param-reference.ts @@ -0,0 +1 @@ +function foo(a: T) {} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/param-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/param-reference.ts.shot new file mode 100644 index 00000000000..64508a4590a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/param-reference.ts.shot @@ -0,0 +1,92 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration type-parameters param-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"foo">, + node: FunctionDeclaration$1, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$2 { + name: Identifier<"a">, + node: FunctionDeclaration$1, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$4, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$2, + "a" => Variable$3, + "T" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/return-value-reference.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/return-value-reference.ts new file mode 100644 index 00000000000..76b3ffc19ce --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/return-value-reference.ts @@ -0,0 +1 @@ +function foo(): T {} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/return-value-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/return-value-reference.ts.shot new file mode 100644 index 00000000000..4a66bd02c61 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/return-value-reference.ts.shot @@ -0,0 +1,78 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration type-parameters return-value-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"foo">, + node: FunctionDeclaration$1, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$2, + "T" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-param-reference.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-param-reference.ts new file mode 100644 index 00000000000..5c8d44c2e5a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-param-reference.ts @@ -0,0 +1 @@ +function foo() {} diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-param-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-param-reference.ts.shot new file mode 100644 index 00000000000..4f6614cd024 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-param-reference.ts.shot @@ -0,0 +1,92 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration type-parameters type-param-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"foo">, + node: FunctionDeclaration$1, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$2, + "T" => Variable$3, + "U" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-parameter-declaration.ts b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-parameter-declaration.ts new file mode 100644 index 00000000000..b72b36c6199 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-parameter-declaration.ts @@ -0,0 +1,3 @@ +function foo() {} + +type Unresolved = T; diff --git a/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-parameter-declaration.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-parameter-declaration.ts.shot new file mode 100644 index 00000000000..6d5a11ba077 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-declaration/type-parameters/type-parameter-declaration.ts.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-declaration type-parameters type-parameter-declaration 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"foo">, + node: FunctionDeclaration$1, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"Unresolved">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "Unresolved", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "foo" => Variable$1, + "Unresolved" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + "T" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/anonymous.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/anonymous.ts new file mode 100644 index 00000000000..5c5bd89ac27 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/anonymous.ts @@ -0,0 +1 @@ +const foo = function () {}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/anonymous.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/anonymous.ts.shot new file mode 100644 index 00000000000..8b681e18aab --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/anonymous.ts.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression anonymous 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: FunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionExpression$2, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-body-shadow.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-body-shadow.ts new file mode 100644 index 00000000000..ccaf9cd466a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-body-shadow.ts @@ -0,0 +1,5 @@ +let a; +// the default param value is resolved to the outer scope +let foo = function (b = a) { + let a; +}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-body-shadow.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-body-shadow.ts.shot new file mode 100644 index 00000000000..67aa969da0a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-body-shadow.ts.shot @@ -0,0 +1,127 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression default-params readable-ref-body-shadow 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: FunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"a">, + node: VariableDeclarator$4, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + "a" => Variable$5, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-const.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-const.ts new file mode 100644 index 00000000000..7edcf2fe655 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-const.ts @@ -0,0 +1,2 @@ +const a = 0; +let foo = function (b = a) {}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-const.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-const.ts.shot new file mode 100644 index 00000000000..9d7e9a8bac9 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-const.ts.shot @@ -0,0 +1,122 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression default-params readable-ref-const 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$4 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$3, + }, + ], + name: "foo", + references: Array [ + Reference$2 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: FunctionExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionExpression$4, + }, + ], + name: "b", + references: Array [ + Reference$3 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionExpression$4, + isStrict: false, + references: Array [ + Reference$3, + Reference$4, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-let.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-let.ts new file mode 100644 index 00000000000..33f09d35c2a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-let.ts @@ -0,0 +1,2 @@ +let a; +let foo = function (b = a) {}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-let.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-let.ts.shot new file mode 100644 index 00000000000..5d920422c16 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-let.ts.shot @@ -0,0 +1,113 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression default-params readable-ref-let 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: FunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested-body-shadow.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested-body-shadow.ts new file mode 100644 index 00000000000..2890469243c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested-body-shadow.ts @@ -0,0 +1,8 @@ +let a; +let foo = function ( + b = function () { + a; + }, +) { + let a; +}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested-body-shadow.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested-body-shadow.ts.shot new file mode 100644 index 00000000000..c85e8f43710 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested-body-shadow.ts.shot @@ -0,0 +1,148 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression default-params readable-ref-nested-body-shadow 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: FunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: FunctionExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$6 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"a">, + node: VariableDeclarator$5, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + "a" => Variable$6, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + Variable$6, + ], + }, + FunctionScope$3 { + block: FunctionExpression$4, + isStrict: false, + references: Array [ + Reference$3, + ], + set: Map { + "arguments" => Variable$5, + }, + type: "function", + upper: FunctionScope$2, + variables: Array [ + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested.ts new file mode 100644 index 00000000000..7f8b28bcdfc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested.ts @@ -0,0 +1,6 @@ +let a; +let foo = function ( + b = function () { + return a; + }, +) {}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested.ts.shot new file mode 100644 index 00000000000..c4eec31ea62 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-nested.ts.shot @@ -0,0 +1,134 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression default-params readable-ref-nested 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: FunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: FunctionExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + FunctionScope$3 { + block: FunctionExpression$4, + isStrict: false, + references: Array [ + Reference$3, + ], + set: Map { + "arguments" => Variable$5, + }, + type: "function", + upper: FunctionScope$2, + variables: Array [ + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-param-shadow.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-param-shadow.ts new file mode 100644 index 00000000000..133703ee14d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-param-shadow.ts @@ -0,0 +1,3 @@ +let a; +// the default param value is resolved to the parameter +let foo = function (b = a, a) {}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-param-shadow.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-param-shadow.ts.shot new file mode 100644 index 00000000000..e9024950a3a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-param-shadow.ts.shot @@ -0,0 +1,127 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression default-params readable-ref-param-shadow 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: FunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"a">, + node: FunctionExpression$3, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$5, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + "a" => Variable$5, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + Variable$5, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-partial.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-partial.ts new file mode 100644 index 00000000000..e2ee3848ae1 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-partial.ts @@ -0,0 +1,2 @@ +let a; +let foo = function (b = a.c) {}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-partial.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-partial.ts.shot new file mode 100644 index 00000000000..10bf32900e6 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/readable-ref-partial.ts.shot @@ -0,0 +1,113 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression default-params readable-ref-partial 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"a">, + node: VariableDeclarator$1, + }, + ], + name: "a", + references: Array [ + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$2, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: FunctionExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionExpression$3, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: MemberExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "a" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionExpression$3, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "arguments" => Variable$3, + "b" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/writable-ref.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/writable-ref.ts new file mode 100644 index 00000000000..02170a78993 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/writable-ref.ts @@ -0,0 +1 @@ +let foo = function (a, b = 0) {}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/writable-ref.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/writable-ref.ts.shot new file mode 100644 index 00000000000..d73e3baea61 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/default-params/writable-ref.ts.shot @@ -0,0 +1,105 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression default-params writable-ref 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: FunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$2 { + name: Identifier<"a">, + node: FunctionExpression$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"b">, + node: FunctionExpression$2, + }, + ], + name: "b", + references: Array [ + Reference$2 { + identifier: Identifier<"b">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "arguments" => Variable$2, + "a" => Variable$3, + "b" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/inherited-scope.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/inherited-scope.ts new file mode 100644 index 00000000000..a8967da39ad --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/inherited-scope.ts @@ -0,0 +1,5 @@ +const parentScoped = 1; + +const foo = function () { + parentScoped + 1; +}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/inherited-scope.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/inherited-scope.ts.shot new file mode 100644 index 00000000000..33c62baf6e2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/inherited-scope.ts.shot @@ -0,0 +1,98 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression inherited-scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"parentScoped">, + node: VariableDeclarator$1, + }, + ], + name: "parentScoped", + references: Array [ + Reference$1 { + identifier: Identifier<"parentScoped">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$3 { + identifier: Identifier<"parentScoped">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$3, + }, + ], + name: "foo", + references: Array [ + Reference$2 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: FunctionExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "parentScoped" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionExpression$4, + isStrict: false, + references: Array [ + Reference$3, + ], + set: Map { + "arguments" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/params.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/params.ts new file mode 100644 index 00000000000..8cea8731fbf --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/params.ts @@ -0,0 +1,6 @@ +const outer = 1; +const foo = function (a, [b], { c }, d = 1, e = a, f = outer, g) { + a; +}; + +const unresolved = g; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/params.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/params.ts.shot new file mode 100644 index 00000000000..ba02af4190a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/params.ts.shot @@ -0,0 +1,271 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression params 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"outer">, + node: VariableDeclarator$1, + }, + ], + name: "outer", + references: Array [ + Reference$1 { + identifier: Identifier<"outer">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$7 { + identifier: Identifier<"outer">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"foo">, + node: VariableDeclarator$3, + }, + ], + name: "foo", + references: Array [ + Reference$2 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: FunctionExpression$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"a">, + node: FunctionExpression$4, + }, + ], + name: "a", + references: Array [ + Reference$5 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + }, + Reference$8 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"b">, + node: FunctionExpression$4, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$6 { + defs: Array [ + ParameterDefinition$5 { + name: Identifier<"c">, + node: FunctionExpression$4, + }, + ], + name: "c", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$7 { + defs: Array [ + ParameterDefinition$6 { + name: Identifier<"d">, + node: FunctionExpression$4, + }, + ], + name: "d", + references: Array [ + Reference$3 { + identifier: Identifier<"d">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$7, + writeExpr: Literal$5, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$8 { + defs: Array [ + ParameterDefinition$7 { + name: Identifier<"e">, + node: FunctionExpression$4, + }, + ], + name: "e", + references: Array [ + Reference$4 { + identifier: Identifier<"e">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$8, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$9 { + defs: Array [ + ParameterDefinition$8 { + name: Identifier<"f">, + node: FunctionExpression$4, + }, + ], + name: "f", + references: Array [ + Reference$6 { + identifier: Identifier<"f">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$9, + writeExpr: Identifier<"outer">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$10 { + defs: Array [ + ParameterDefinition$9 { + name: Identifier<"g">, + node: FunctionExpression$4, + }, + ], + name: "g", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$11 { + defs: Array [ + VariableDefinition$10 { + name: Identifier<"unresolved">, + node: VariableDeclarator$6, + }, + ], + name: "unresolved", + references: Array [ + Reference$9 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$11, + writeExpr: Identifier<"g">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$7, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$9, + Reference$10 { + identifier: Identifier<"g">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "outer" => Variable$1, + "foo" => Variable$2, + "unresolved" => Variable$11, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$11, + ], + }, + FunctionScope$2 { + block: FunctionExpression$4, + isStrict: false, + references: Array [ + Reference$3, + Reference$4, + Reference$5, + Reference$6, + Reference$7, + Reference$8, + ], + set: Map { + "arguments" => Variable$3, + "a" => Variable$4, + "b" => Variable$5, + "c" => Variable$6, + "d" => Variable$7, + "e" => Variable$8, + "f" => Variable$9, + "g" => Variable$10, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + Variable$5, + Variable$6, + Variable$7, + Variable$8, + Variable$9, + Variable$10, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/scope.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/scope.ts new file mode 100644 index 00000000000..00da70da31f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/scope.ts @@ -0,0 +1,8 @@ +const foo = function () { + let i = 0; + var j = 20; + + i; +}; + +const unresolved = j; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/scope.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/scope.ts.shot new file mode 100644 index 00000000000..63d7cadad59 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/scope.ts.shot @@ -0,0 +1,152 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: FunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"i">, + node: VariableDeclarator$3, + }, + ], + name: "i", + references: Array [ + Reference$2 { + identifier: Identifier<"i">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Literal$4, + }, + Reference$4 { + identifier: Identifier<"i">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"j">, + node: VariableDeclarator$5, + }, + ], + name: "j", + references: Array [ + Reference$3 { + identifier: Identifier<"j">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Literal$6, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$5 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"unresolved">, + node: VariableDeclarator$7, + }, + ], + name: "unresolved", + references: Array [ + Reference$5 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$5, + writeExpr: Identifier<"j">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$8, + isStrict: false, + references: Array [ + Reference$1, + Reference$5, + Reference$6 { + identifier: Identifier<"j">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "foo" => Variable$1, + "unresolved" => Variable$5, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$5, + ], + }, + FunctionScope$2 { + block: FunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + Reference$4, + ], + set: Map { + "arguments" => Variable$2, + "i" => Variable$3, + "j" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/body-reference.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/body-reference.ts new file mode 100644 index 00000000000..91921492c7c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/body-reference.ts @@ -0,0 +1,3 @@ +const foo = function () { + let x: T; +}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/body-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/body-reference.ts.shot new file mode 100644 index 00000000000..4c5376efab8 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/body-reference.ts.shot @@ -0,0 +1,103 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression type-parameters body-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: FunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$3, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"x">, + node: VariableDeclarator$4, + }, + ], + name: "x", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "arguments" => Variable$2, + "T" => Variable$3, + "x" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/param-reference.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/param-reference.ts new file mode 100644 index 00000000000..bc62c145195 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/param-reference.ts @@ -0,0 +1 @@ +const foo = function (a: T) {}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/param-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/param-reference.ts.shot new file mode 100644 index 00000000000..e2e9f4b7f54 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/param-reference.ts.shot @@ -0,0 +1,103 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression type-parameters param-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: FunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$2 { + name: Identifier<"a">, + node: FunctionExpression$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"T">, + node: TSTypeParameter$3, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$4, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "arguments" => Variable$2, + "a" => Variable$3, + "T" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/return-value-reference.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/return-value-reference.ts new file mode 100644 index 00000000000..a3182e59940 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/return-value-reference.ts @@ -0,0 +1 @@ +const foo = function (): T {}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/return-value-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/return-value-reference.ts.shot new file mode 100644 index 00000000000..7cd987aebe0 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/return-value-reference.ts.shot @@ -0,0 +1,89 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression type-parameters return-value-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: FunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$3, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "arguments" => Variable$2, + "T" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-param-reference.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-param-reference.ts new file mode 100644 index 00000000000..9b759d9bf2f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-param-reference.ts @@ -0,0 +1 @@ +const foo = function () {}; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-param-reference.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-param-reference.ts.shot new file mode 100644 index 00000000000..8e67e27315d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-param-reference.ts.shot @@ -0,0 +1,103 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression type-parameters type-param-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: FunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$3, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$4, + }, + ], + name: "U", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionExpression$2, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "arguments" => Variable$2, + "T" => Variable$3, + "U" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-parameter-declaration.ts b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-parameter-declaration.ts new file mode 100644 index 00000000000..8554e99c45d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-parameter-declaration.ts @@ -0,0 +1,3 @@ +const foo = function () {}; + +type Unresolved = T; diff --git a/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-parameter-declaration.ts.shot b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-parameter-declaration.ts.shot new file mode 100644 index 00000000000..c664f47f132 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/functions/function-expression/type-parameters/type-parameter-declaration.ts.shot @@ -0,0 +1,100 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`functions function-expression type-parameters type-parameter-declaration 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"foo">, + node: VariableDeclarator$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: FunctionExpression$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$3, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"Unresolved">, + node: TSTypeAliasDeclaration$4, + }, + ], + name: "Unresolved", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "foo" => Variable$1, + "Unresolved" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + ], + }, + FunctionScope$2 { + block: FunctionExpression$2, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + "T" => Variable$3, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/global-resolution/module/class.ts b/packages/scope-manager/tests/fixtures/global-resolution/module/class.ts new file mode 100644 index 00000000000..2f3bb079ed7 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/module/class.ts @@ -0,0 +1,3 @@ +//// @sourceType = module +class Foo {} +new Foo(); diff --git a/packages/scope-manager/tests/fixtures/global-resolution/module/class.ts.shot b/packages/scope-manager/tests/fixtures/global-resolution/module/class.ts.shot new file mode 100644 index 00000000000..1af1b3c0d95 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/module/class.ts.shot @@ -0,0 +1,78 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`global-resolution module class 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$1 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ClassScope$3 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$2, + }, + type: "class", + upper: ModuleScope$2, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/global-resolution/module/function.ts b/packages/scope-manager/tests/fixtures/global-resolution/module/function.ts new file mode 100644 index 00000000000..402d7085631 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/module/function.ts @@ -0,0 +1,3 @@ +//// @sourceType = module +function top() {} +top(); diff --git a/packages/scope-manager/tests/fixtures/global-resolution/module/function.ts.shot b/packages/scope-manager/tests/fixtures/global-resolution/module/function.ts.shot new file mode 100644 index 00000000000..3198fa7ec9c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/module/function.ts.shot @@ -0,0 +1,73 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`global-resolution module function 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"top">, + node: FunctionDeclaration$1, + }, + ], + name: "top", + references: Array [ + Reference$1 { + identifier: Identifier<"top">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "top" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$3 { + block: FunctionDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "arguments" => Variable$2, + }, + type: "function", + upper: ModuleScope$2, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-const.ts b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-const.ts new file mode 100644 index 00000000000..71a6093c3b4 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-const.ts @@ -0,0 +1,3 @@ +//// @sourceType = module +const top = () => {}; +top(); diff --git a/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-const.ts.shot b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-const.ts.shot new file mode 100644 index 00000000000..aceb190b8e5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-const.ts.shot @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`global-resolution module variable-decl-const 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"top">, + node: VariableDeclarator$1, + }, + ], + name: "top", + references: Array [ + Reference$1 { + identifier: Identifier<"top">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + Reference$2 { + identifier: Identifier<"top">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "top" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$3 { + block: ArrowFunctionExpression$2, + isStrict: true, + references: Array [], + set: Map {}, + type: "function", + upper: ModuleScope$2, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-let.ts b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-let.ts new file mode 100644 index 00000000000..3be81a8d450 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-let.ts @@ -0,0 +1,3 @@ +//// @sourceType = module +let top = () => {}; +top(); diff --git a/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-let.ts.shot b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-let.ts.shot new file mode 100644 index 00000000000..21a7ba40035 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-let.ts.shot @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`global-resolution module variable-decl-let 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"top">, + node: VariableDeclarator$1, + }, + ], + name: "top", + references: Array [ + Reference$1 { + identifier: Identifier<"top">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + Reference$2 { + identifier: Identifier<"top">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "top" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$3 { + block: ArrowFunctionExpression$2, + isStrict: true, + references: Array [], + set: Map {}, + type: "function", + upper: ModuleScope$2, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-var.ts b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-var.ts new file mode 100644 index 00000000000..32adea4f0a5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-var.ts @@ -0,0 +1,3 @@ +//// @sourceType = module +var top = () => {}; +top(); diff --git a/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-var.ts.shot b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-var.ts.shot new file mode 100644 index 00000000000..2be4f467be8 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/module/variable-decl-var.ts.shot @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`global-resolution module variable-decl-var 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"top">, + node: VariableDeclarator$1, + }, + ], + name: "top", + references: Array [ + Reference$1 { + identifier: Identifier<"top">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + Reference$2 { + identifier: Identifier<"top">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "top" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$3 { + block: ArrowFunctionExpression$2, + isStrict: true, + references: Array [], + set: Map {}, + type: "function", + upper: ModuleScope$2, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/global-resolution/script/class.ts b/packages/scope-manager/tests/fixtures/global-resolution/script/class.ts new file mode 100644 index 00000000000..e2203530d06 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/script/class.ts @@ -0,0 +1,3 @@ +//// @sourceType = script +class Foo {} +new Foo(); diff --git a/packages/scope-manager/tests/fixtures/global-resolution/script/class.ts.shot b/packages/scope-manager/tests/fixtures/global-resolution/script/class.ts.shot new file mode 100644 index 00000000000..a0a7ff849b5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/script/class.ts.shot @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`global-resolution script class 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$1 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$2, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/global-resolution/script/function.ts b/packages/scope-manager/tests/fixtures/global-resolution/script/function.ts new file mode 100644 index 00000000000..08bf2eccd66 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/script/function.ts @@ -0,0 +1,3 @@ +//// @sourceType = script +function top() {} +top(); diff --git a/packages/scope-manager/tests/fixtures/global-resolution/script/function.ts.shot b/packages/scope-manager/tests/fixtures/global-resolution/script/function.ts.shot new file mode 100644 index 00000000000..8d155b60e74 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/script/function.ts.shot @@ -0,0 +1,64 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`global-resolution script function 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"top">, + node: FunctionDeclaration$1, + }, + ], + name: "top", + references: Array [ + Reference$1 { + identifier: Identifier<"top">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "top" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-const.ts b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-const.ts new file mode 100644 index 00000000000..593523f8853 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-const.ts @@ -0,0 +1,3 @@ +//// @sourceType = script +const top = () => {}; +top(); diff --git a/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-const.ts.shot b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-const.ts.shot new file mode 100644 index 00000000000..bf2b3e24131 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-const.ts.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`global-resolution script variable-decl-const 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"top">, + node: VariableDeclarator$1, + }, + ], + name: "top", + references: Array [ + Reference$1 { + identifier: Identifier<"top">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + Reference$2 { + identifier: Identifier<"top">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "top" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "function", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-let.ts b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-let.ts new file mode 100644 index 00000000000..41734e5e5ae --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-let.ts @@ -0,0 +1,3 @@ +//// @sourceType = script +let top = () => {}; +top(); diff --git a/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-let.ts.shot b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-let.ts.shot new file mode 100644 index 00000000000..49d3e89ca9b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-let.ts.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`global-resolution script variable-decl-let 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"top">, + node: VariableDeclarator$1, + }, + ], + name: "top", + references: Array [ + Reference$1 { + identifier: Identifier<"top">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ArrowFunctionExpression$2, + }, + Reference$2 { + identifier: Identifier<"top">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "top" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "function", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-var.ts b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-var.ts new file mode 100644 index 00000000000..7eaa9509c71 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-var.ts @@ -0,0 +1,3 @@ +//// @sourceType = script +var top = () => {}; +top(); diff --git a/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-var.ts.shot b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-var.ts.shot new file mode 100644 index 00000000000..8d421cc889c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/global-resolution/script/variable-decl-var.ts.shot @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`global-resolution script variable-decl-var 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"top">, + node: VariableDeclarator$1, + }, + ], + name: "top", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [ + Reference$1 { + identifier: Identifier<"top">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: null, + writeExpr: ArrowFunctionExpression$3, + }, + Reference$2 { + identifier: Identifier<"top">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "top" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + FunctionScope$2 { + block: ArrowFunctionExpression$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "function", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/implicit/implicit1.ts b/packages/scope-manager/tests/fixtures/implicit/implicit1.ts new file mode 100644 index 00000000000..89a08efd821 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/implicit/implicit1.ts @@ -0,0 +1 @@ +const x = y; diff --git a/packages/scope-manager/tests/fixtures/implicit/implicit1.ts.shot b/packages/scope-manager/tests/fixtures/implicit/implicit1.ts.shot new file mode 100644 index 00000000000..5566bb4962d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/implicit/implicit1.ts.shot @@ -0,0 +1,52 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`implicit implicit1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Identifier<"y">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [ + Reference$1, + Reference$2 { + identifier: Identifier<"y">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "x" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/import/default.ts b/packages/scope-manager/tests/fixtures/import/default.ts new file mode 100644 index 00000000000..9f5bc0795e5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/default.ts @@ -0,0 +1,6 @@ +//// @sourceType = module + +import v from 'foo'; + +v; +type T = v; diff --git a/packages/scope-manager/tests/fixtures/import/default.ts.shot b/packages/scope-manager/tests/fixtures/import/default.ts.shot new file mode 100644 index 00000000000..0b4010ddb55 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/default.ts.shot @@ -0,0 +1,74 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`import default 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ImportBindingDefinition$1 { + name: Identifier<"v">, + node: ImportDefaultSpecifier$1, + }, + ], + name: "v", + references: Array [ + Reference$1 { + identifier: Identifier<"v">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"v">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "v" => Variable$1, + "T" => Variable$2, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/import/equals1.ts b/packages/scope-manager/tests/fixtures/import/equals1.ts new file mode 100644 index 00000000000..808ef4b2a26 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/equals1.ts @@ -0,0 +1,5 @@ +//// @sourceType = module + +import foo = require('a'); + +foo; diff --git a/packages/scope-manager/tests/fixtures/import/equals1.ts.shot b/packages/scope-manager/tests/fixtures/import/equals1.ts.shot new file mode 100644 index 00000000000..727353a50aa --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/equals1.ts.shot @@ -0,0 +1,53 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`import equals1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ImportBindingDefinition$1 { + name: Identifier<"foo">, + node: TSImportEqualsDeclaration$1, + }, + ], + name: "foo", + references: Array [ + Reference$1 { + identifier: Identifier<"foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "foo" => Variable$1, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/import/equals2.ts b/packages/scope-manager/tests/fixtures/import/equals2.ts new file mode 100644 index 00000000000..63ac5327dc0 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/equals2.ts @@ -0,0 +1,4 @@ +//// @sourceType = module + +const x = 1; +import foo = x; diff --git a/packages/scope-manager/tests/fixtures/import/equals2.ts.shot b/packages/scope-manager/tests/fixtures/import/equals2.ts.shot new file mode 100644 index 00000000000..2c624a8b496 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/equals2.ts.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`import equals2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + ImportBindingDefinition$2 { + name: Identifier<"foo">, + node: TSImportEqualsDeclaration$3, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "x" => Variable$1, + "foo" => Variable$2, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/import/named-alias.ts b/packages/scope-manager/tests/fixtures/import/named-alias.ts new file mode 100644 index 00000000000..cde3625337f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/named-alias.ts @@ -0,0 +1,6 @@ +//// @sourceType = module + +import { v as t } from 'foo'; + +t; +type T = t; diff --git a/packages/scope-manager/tests/fixtures/import/named-alias.ts.shot b/packages/scope-manager/tests/fixtures/import/named-alias.ts.shot new file mode 100644 index 00000000000..e69921218eb --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/named-alias.ts.shot @@ -0,0 +1,74 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`import named-alias 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ImportBindingDefinition$1 { + name: Identifier<"t">, + node: ImportSpecifier$1, + }, + ], + name: "t", + references: Array [ + Reference$1 { + identifier: Identifier<"t">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"t">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "t" => Variable$1, + "T" => Variable$2, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/import/named.ts b/packages/scope-manager/tests/fixtures/import/named.ts new file mode 100644 index 00000000000..4b4b1ae7a52 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/named.ts @@ -0,0 +1,6 @@ +//// @sourceType = module + +import { v } from 'foo'; + +v; +type T = v; diff --git a/packages/scope-manager/tests/fixtures/import/named.ts.shot b/packages/scope-manager/tests/fixtures/import/named.ts.shot new file mode 100644 index 00000000000..9196f214a1f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/named.ts.shot @@ -0,0 +1,74 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`import named 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ImportBindingDefinition$1 { + name: Identifier<"v">, + node: ImportSpecifier$1, + }, + ], + name: "v", + references: Array [ + Reference$1 { + identifier: Identifier<"v">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"v">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "v" => Variable$1, + "T" => Variable$2, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/import/namespace.ts b/packages/scope-manager/tests/fixtures/import/namespace.ts new file mode 100644 index 00000000000..695704b6b99 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/namespace.ts @@ -0,0 +1,6 @@ +//// @sourceType = module + +import * as v from 'foo'; + +v; +type T = v; diff --git a/packages/scope-manager/tests/fixtures/import/namespace.ts.shot b/packages/scope-manager/tests/fixtures/import/namespace.ts.shot new file mode 100644 index 00000000000..f917798fa96 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/namespace.ts.shot @@ -0,0 +1,74 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`import namespace 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ImportBindingDefinition$1 { + name: Identifier<"v">, + node: ImportNamespaceSpecifier$1, + }, + ], + name: "v", + references: Array [ + Reference$1 { + identifier: Identifier<"v">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"v">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "v" => Variable$1, + "T" => Variable$2, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/import/type-default.ts b/packages/scope-manager/tests/fixtures/import/type-default.ts new file mode 100644 index 00000000000..1001c549f93 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/type-default.ts @@ -0,0 +1,6 @@ +//// @sourceType = module + +import type T from 'foo'; + +type Ref = T; +const unresolved = T; diff --git a/packages/scope-manager/tests/fixtures/import/type-default.ts.shot b/packages/scope-manager/tests/fixtures/import/type-default.ts.shot new file mode 100644 index 00000000000..c87d387f051 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/type-default.ts.shot @@ -0,0 +1,97 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`import type-default 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ImportBindingDefinition$1 { + name: Identifier<"T">, + node: ImportDefaultSpecifier$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"Ref">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "Ref", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"unresolved">, + node: VariableDeclarator$3, + }, + ], + name: "unresolved", + references: Array [ + Reference$2 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"T">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + Reference$3 { + identifier: Identifier<"T">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "T" => Variable$1, + "Ref" => Variable$2, + "unresolved" => Variable$3, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/import/type-named.ts b/packages/scope-manager/tests/fixtures/import/type-named.ts new file mode 100644 index 00000000000..1b73102379a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/type-named.ts @@ -0,0 +1,6 @@ +//// @sourceType = module + +import type { T } from 'foo'; + +type Ref = T; +const unresovled = T; diff --git a/packages/scope-manager/tests/fixtures/import/type-named.ts.shot b/packages/scope-manager/tests/fixtures/import/type-named.ts.shot new file mode 100644 index 00000000000..f9d1987b465 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/import/type-named.ts.shot @@ -0,0 +1,97 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`import type-named 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ImportBindingDefinition$1 { + name: Identifier<"T">, + node: ImportSpecifier$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"Ref">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "Ref", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"unresovled">, + node: VariableDeclarator$3, + }, + ], + name: "unresovled", + references: Array [ + Reference$2 { + identifier: Identifier<"unresovled">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"T">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + Reference$3 { + identifier: Identifier<"T">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "T" => Variable$1, + "Ref" => Variable$2, + "unresovled" => Variable$3, + }, + type: "module", + upper: GlobalScope$1, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/member-expression/member-expression.ts b/packages/scope-manager/tests/fixtures/member-expression/member-expression.ts new file mode 100644 index 00000000000..fb7b5f96a87 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/member-expression/member-expression.ts @@ -0,0 +1,7 @@ +const x = {}; + +x.a; +x.a.b.c.d; +x['a']; +x?.a.b.c; +x?.['a']; diff --git a/packages/scope-manager/tests/fixtures/member-expression/member-expression.ts.shot b/packages/scope-manager/tests/fixtures/member-expression/member-expression.ts.shot new file mode 100644 index 00000000000..cd8e9f3daee --- /dev/null +++ b/packages/scope-manager/tests/fixtures/member-expression/member-expression.ts.shot @@ -0,0 +1,81 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`member-expression member-expression 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: ObjectExpression$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$3 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$4 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$5 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$6 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + Reference$4, + Reference$5, + Reference$6, + ], + set: Map { + "x" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/new-expression/new-expression.ts b/packages/scope-manager/tests/fixtures/new-expression/new-expression.ts new file mode 100644 index 00000000000..c73b7061e58 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/new-expression/new-expression.ts @@ -0,0 +1,4 @@ +class Foo {} +const a = 1; + +new Foo(a); diff --git a/packages/scope-manager/tests/fixtures/new-expression/new-expression.ts.shot b/packages/scope-manager/tests/fixtures/new-expression/new-expression.ts.shot new file mode 100644 index 00000000000..6a3c79a9929 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/new-expression/new-expression.ts.shot @@ -0,0 +1,100 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`new-expression new-expression 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$2 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"a">, + node: VariableDeclarator$2, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Literal$3, + }, + Reference$3 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "Foo" => Variable$1, + "a" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$2, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/new-expression/type-parameters1.ts b/packages/scope-manager/tests/fixtures/new-expression/type-parameters1.ts new file mode 100644 index 00000000000..79d9b7bc28b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/new-expression/type-parameters1.ts @@ -0,0 +1,2 @@ +type T = 1; +new Foo(); diff --git a/packages/scope-manager/tests/fixtures/new-expression/type-parameters1.ts.shot b/packages/scope-manager/tests/fixtures/new-expression/type-parameters1.ts.shot new file mode 100644 index 00000000000..716d0d925c7 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/new-expression/type-parameters1.ts.shot @@ -0,0 +1,50 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`new-expression type-parameters1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [ + Reference$1 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + Reference$2, + ], + set: Map { + "T" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/new-expression/type-parameters2.ts b/packages/scope-manager/tests/fixtures/new-expression/type-parameters2.ts new file mode 100644 index 00000000000..ab111acb79d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/new-expression/type-parameters2.ts @@ -0,0 +1,2 @@ +const T = 1; +new Foo(); // should not resolve to value diff --git a/packages/scope-manager/tests/fixtures/new-expression/type-parameters2.ts.shot b/packages/scope-manager/tests/fixtures/new-expression/type-parameters2.ts.shot new file mode 100644 index 00000000000..ec6b7fdd57c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/new-expression/type-parameters2.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`new-expression type-parameters2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"T">, + node: VariableDeclarator$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + Reference$2 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + Reference$3 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "T" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-enum/external-ref.ts b/packages/scope-manager/tests/fixtures/ts-enum/external-ref.ts new file mode 100644 index 00000000000..3e4a51bc1ac --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/external-ref.ts @@ -0,0 +1,5 @@ +enum Foo { + a = 1, +} + +Foo.a; diff --git a/packages/scope-manager/tests/fixtures/ts-enum/external-ref.ts.shot b/packages/scope-manager/tests/fixtures/ts-enum/external-ref.ts.shot new file mode 100644 index 00000000000..c6740c3007b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/external-ref.ts.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-enum external-ref 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSEnumNameDefinition$1 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$1 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TSEnumNameDefinition$2 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TSEnumMemberDefinition$3 { + name: Identifier<"a">, + node: TSEnumMember$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TSEnumScope$2 { + block: TSEnumDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$2, + "a" => Variable$3, + }, + type: "tsEnum", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-enum/literal-member-ref.ts b/packages/scope-manager/tests/fixtures/ts-enum/literal-member-ref.ts new file mode 100644 index 00000000000..4d6233bf122 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/literal-member-ref.ts @@ -0,0 +1,4 @@ +enum Foo { + 'a' = 1, + b = a, +} diff --git a/packages/scope-manager/tests/fixtures/ts-enum/literal-member-ref.ts.shot b/packages/scope-manager/tests/fixtures/ts-enum/literal-member-ref.ts.shot new file mode 100644 index 00000000000..97b82b51463 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/literal-member-ref.ts.shot @@ -0,0 +1,97 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-enum literal-member-ref 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSEnumNameDefinition$1 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TSEnumNameDefinition$2 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TSEnumMemberDefinition$3 { + name: Literal$2, + node: TSEnumMember$3, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TSEnumMemberDefinition$4 { + name: Identifier<"b">, + node: TSEnumMember$4, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TSEnumScope$2 { + block: TSEnumDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$2, + "a" => Variable$3, + "b" => Variable$4, + }, + type: "tsEnum", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-enum/literal-member.ts b/packages/scope-manager/tests/fixtures/ts-enum/literal-member.ts new file mode 100644 index 00000000000..06bc6e600aa --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/literal-member.ts @@ -0,0 +1,3 @@ +enum Foo { + 'a' = 1, +} diff --git a/packages/scope-manager/tests/fixtures/ts-enum/literal-member.ts.shot b/packages/scope-manager/tests/fixtures/ts-enum/literal-member.ts.shot new file mode 100644 index 00000000000..3f4f338384b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/literal-member.ts.shot @@ -0,0 +1,74 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-enum literal-member 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSEnumNameDefinition$1 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TSEnumNameDefinition$2 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TSEnumMemberDefinition$3 { + name: Literal$2, + node: TSEnumMember$3, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TSEnumScope$2 { + block: TSEnumDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$2, + "a" => Variable$3, + }, + type: "tsEnum", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-enum/member-ref.ts b/packages/scope-manager/tests/fixtures/ts-enum/member-ref.ts new file mode 100644 index 00000000000..e08824e129c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/member-ref.ts @@ -0,0 +1,4 @@ +enum Foo { + a = 1, + b = a, +} diff --git a/packages/scope-manager/tests/fixtures/ts-enum/member-ref.ts.shot b/packages/scope-manager/tests/fixtures/ts-enum/member-ref.ts.shot new file mode 100644 index 00000000000..e322d2f16d6 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/member-ref.ts.shot @@ -0,0 +1,97 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-enum member-ref 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSEnumNameDefinition$1 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TSEnumNameDefinition$2 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TSEnumMemberDefinition$3 { + name: Identifier<"a">, + node: TSEnumMember$2, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TSEnumMemberDefinition$4 { + name: Identifier<"b">, + node: TSEnumMember$3, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TSEnumScope$2 { + block: TSEnumDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$2, + "a" => Variable$3, + "b" => Variable$4, + }, + type: "tsEnum", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-enum/scope.ts b/packages/scope-manager/tests/fixtures/ts-enum/scope.ts new file mode 100644 index 00000000000..da1321ea5ad --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/scope.ts @@ -0,0 +1,5 @@ +enum Foo { + a, +} + +const unresolved = a; diff --git a/packages/scope-manager/tests/fixtures/ts-enum/scope.ts.shot b/packages/scope-manager/tests/fixtures/ts-enum/scope.ts.shot new file mode 100644 index 00000000000..c8042fc7253 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/scope.ts.shot @@ -0,0 +1,105 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-enum scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSEnumNameDefinition$1 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TSEnumNameDefinition$2 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TSEnumMemberDefinition$3 { + name: Identifier<"a">, + node: TSEnumMember$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"unresolved">, + node: VariableDeclarator$3, + }, + ], + name: "unresolved", + references: Array [ + Reference$1 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"a">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2 { + identifier: Identifier<"a">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "Foo" => Variable$1, + "unresolved" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + ], + }, + TSEnumScope$2 { + block: TSEnumDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$2, + "a" => Variable$3, + }, + type: "tsEnum", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-enum/self-ref.ts b/packages/scope-manager/tests/fixtures/ts-enum/self-ref.ts new file mode 100644 index 00000000000..ada23ec5d81 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/self-ref.ts @@ -0,0 +1,4 @@ +enum Foo { + a = 1, + b = Foo.a, +} diff --git a/packages/scope-manager/tests/fixtures/ts-enum/self-ref.ts.shot b/packages/scope-manager/tests/fixtures/ts-enum/self-ref.ts.shot new file mode 100644 index 00000000000..38321018f14 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-enum/self-ref.ts.shot @@ -0,0 +1,97 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-enum self-ref 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSEnumNameDefinition$1 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TSEnumNameDefinition$2 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$1 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TSEnumMemberDefinition$3 { + name: Identifier<"a">, + node: TSEnumMember$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TSEnumMemberDefinition$4 { + name: Identifier<"b">, + node: TSEnumMember$3, + }, + ], + name: "b", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TSEnumScope$2 { + block: TSEnumDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$2, + "a" => Variable$3, + "b" => Variable$4, + }, + type: "tsEnum", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/class-namespace.ts b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/class-namespace.ts new file mode 100644 index 00000000000..0649b9eb775 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/class-namespace.ts @@ -0,0 +1,7 @@ +class Foo {} + +namespace Foo { + export const x = 1; +} + +const usage = Foo; diff --git a/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/class-namespace.ts.shot b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/class-namespace.ts.shot new file mode 100644 index 00000000000..5bcc14e374a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/class-namespace.ts.shot @@ -0,0 +1,133 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-module declaration-merging class-namespace 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ClassNameDefinition$1 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + TSModuleNameDefinition$3 { + name: Identifier<"Foo">, + node: TSModuleDeclaration$2, + }, + ], + name: "Foo", + references: Array [ + Reference$3 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + ClassNameDefinition$2 { + name: Identifier<"Foo">, + node: ClassDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"x">, + node: VariableDeclarator$3, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Literal$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + VariableDefinition$5 { + name: Identifier<"usage">, + node: VariableDeclarator$5, + }, + ], + name: "usage", + references: Array [ + Reference$2 { + identifier: Identifier<"usage">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"Foo">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "Foo" => Variable$1, + "usage" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + ], + }, + ClassScope$2 { + block: ClassDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$2, + }, + type: "class", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + TSModuleScope$3 { + block: TSModuleDeclaration$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "x" => Variable$3, + }, + type: "tsModule", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/function-namespace.ts b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/function-namespace.ts new file mode 100644 index 00000000000..5cf4f0a95f8 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/function-namespace.ts @@ -0,0 +1,7 @@ +function Foo() {} + +namespace Foo { + export const x = 1; +} + +const usage = Foo; diff --git a/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/function-namespace.ts.shot b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/function-namespace.ts.shot new file mode 100644 index 00000000000..494c00bd87a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/function-namespace.ts.shot @@ -0,0 +1,128 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-module declaration-merging function-namespace 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + FunctionNameDefinition$1 { + name: Identifier<"Foo">, + node: FunctionDeclaration$1, + }, + TSModuleNameDefinition$2 { + name: Identifier<"Foo">, + node: TSModuleDeclaration$2, + }, + ], + name: "Foo", + references: Array [ + Reference$3 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"x">, + node: VariableDeclarator$3, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Literal$4, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$4 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"usage">, + node: VariableDeclarator$5, + }, + ], + name: "usage", + references: Array [ + Reference$2 { + identifier: Identifier<"usage">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Identifier<"Foo">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "Foo" => Variable$1, + "usage" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$1, + isStrict: false, + references: Array [], + set: Map { + "arguments" => Variable$2, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + TSModuleScope$3 { + block: TSModuleDeclaration$2, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "x" => Variable$3, + }, + type: "tsModule", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/namespace-variable.ts b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/namespace-variable.ts new file mode 100644 index 00000000000..1bf8e4c1588 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/namespace-variable.ts @@ -0,0 +1,5 @@ +namespace Foo {} + +const Foo = 1; + +const usage = Foo; diff --git a/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/namespace-variable.ts.shot b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/namespace-variable.ts.shot new file mode 100644 index 00000000000..3f3d6ca1cf1 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/declaration-merging/namespace-variable.ts.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-module declaration-merging namespace-variable 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSModuleNameDefinition$1 { + name: Identifier<"Foo">, + node: TSModuleDeclaration$1, + }, + VariableDefinition$2 { + name: Identifier<"Foo">, + node: VariableDeclarator$2, + }, + ], + name: "Foo", + references: Array [ + Reference$1 { + identifier: Identifier<"Foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$3, + }, + Reference$3 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"usage">, + node: VariableDeclarator$4, + }, + ], + name: "usage", + references: Array [ + Reference$2 { + identifier: Identifier<"usage">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Identifier<"Foo">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "Foo" => Variable$1, + "usage" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + TSModuleScope$2 { + block: TSModuleDeclaration$1, + isStrict: true, + references: Array [], + set: Map {}, + type: "tsModule", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-module/external-ref.ts b/packages/scope-manager/tests/fixtures/ts-module/external-ref.ts new file mode 100644 index 00000000000..e47c0fd35d5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/external-ref.ts @@ -0,0 +1,5 @@ +module Foo { + export const x = 1; +} + +Foo.x; diff --git a/packages/scope-manager/tests/fixtures/ts-module/external-ref.ts.shot b/packages/scope-manager/tests/fixtures/ts-module/external-ref.ts.shot new file mode 100644 index 00000000000..56dfb9474d6 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/external-ref.ts.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-module external-ref 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSModuleNameDefinition$1 { + name: Identifier<"Foo">, + node: TSModuleDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$2 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"x">, + node: VariableDeclarator$2, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$2, + ], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TSModuleScope$2 { + block: TSModuleDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "x" => Variable$2, + }, + type: "tsModule", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-module/import.ts b/packages/scope-manager/tests/fixtures/ts-module/import.ts new file mode 100644 index 00000000000..62cedcc5daf --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/import.ts @@ -0,0 +1,5 @@ +//// @sourceType = module + +declare module 'foo' { + import { bar } from 'mod'; +} diff --git a/packages/scope-manager/tests/fixtures/ts-module/import.ts.shot b/packages/scope-manager/tests/fixtures/ts-module/import.ts.shot new file mode 100644 index 00000000000..7ab8ac5e37a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/import.ts.shot @@ -0,0 +1,53 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-module import 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + ImportBindingDefinition$1 { + name: Identifier<"bar">, + node: ImportSpecifier$1, + }, + ], + name: "bar", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map {}, + type: "global", + upper: null, + variables: Array [], + }, + ModuleScope$2 { + block: Program$2, + isStrict: true, + references: Array [], + set: Map {}, + type: "module", + upper: GlobalScope$1, + variables: Array [], + }, + TSModuleScope$3 { + block: TSModuleDeclaration$3, + isStrict: true, + references: Array [], + set: Map { + "bar" => Variable$1, + }, + type: "tsModule", + upper: ModuleScope$2, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-module/name-shadowed-in-body.ts b/packages/scope-manager/tests/fixtures/ts-module/name-shadowed-in-body.ts new file mode 100644 index 00000000000..3e8b7d7bc81 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/name-shadowed-in-body.ts @@ -0,0 +1,5 @@ +namespace Foo { + export const Foo = 1; +} + +const usage = Foo; diff --git a/packages/scope-manager/tests/fixtures/ts-module/name-shadowed-in-body.ts.shot b/packages/scope-manager/tests/fixtures/ts-module/name-shadowed-in-body.ts.shot new file mode 100644 index 00000000000..85f59e91e59 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/name-shadowed-in-body.ts.shot @@ -0,0 +1,104 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-module name-shadowed-in-body 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSModuleNameDefinition$1 { + name: Identifier<"Foo">, + node: TSModuleDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$3 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"Foo">, + node: VariableDeclarator$2, + }, + ], + name: "Foo", + references: Array [ + Reference$1 { + identifier: Identifier<"Foo">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"usage">, + node: VariableDeclarator$4, + }, + ], + name: "usage", + references: Array [ + Reference$2 { + identifier: Identifier<"usage">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"Foo">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "Foo" => Variable$1, + "usage" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + TSModuleScope$2 { + block: TSModuleDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$2, + }, + type: "tsModule", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-module/namespace.ts b/packages/scope-manager/tests/fixtures/ts-module/namespace.ts new file mode 100644 index 00000000000..c84fa735053 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/namespace.ts @@ -0,0 +1,7 @@ +namespace Foo { + export const x = 1; + Foo.x; +} + +const unresolved = x; +Foo.x; diff --git a/packages/scope-manager/tests/fixtures/ts-module/namespace.ts.shot b/packages/scope-manager/tests/fixtures/ts-module/namespace.ts.shot new file mode 100644 index 00000000000..bd1a4d3c2e5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/namespace.ts.shot @@ -0,0 +1,117 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-module namespace 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSModuleNameDefinition$1 { + name: Identifier<"Foo">, + node: TSModuleDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$2 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + Reference$5 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"x">, + node: VariableDeclarator$2, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"unresolved">, + node: VariableDeclarator$4, + }, + ], + name: "unresolved", + references: Array [ + Reference$3 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"x">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$3, + Reference$4 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + Reference$5, + ], + set: Map { + "Foo" => Variable$1, + "unresolved" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + TSModuleScope$2 { + block: TSModuleDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "x" => Variable$2, + }, + type: "tsModule", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-module/scope.ts b/packages/scope-manager/tests/fixtures/ts-module/scope.ts new file mode 100644 index 00000000000..c1a2669446f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/scope.ts @@ -0,0 +1,5 @@ +module Foo { + const x = 1; +} + +const unresolved = x; diff --git a/packages/scope-manager/tests/fixtures/ts-module/scope.ts.shot b/packages/scope-manager/tests/fixtures/ts-module/scope.ts.shot new file mode 100644 index 00000000000..a17040e0281 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/scope.ts.shot @@ -0,0 +1,102 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-module scope 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSModuleNameDefinition$1 { + name: Identifier<"Foo">, + node: TSModuleDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"x">, + node: VariableDeclarator$2, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + VariableDefinition$3 { + name: Identifier<"unresolved">, + node: VariableDeclarator$4, + }, + ], + name: "unresolved", + references: Array [ + Reference$2 { + identifier: Identifier<"unresolved">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"x">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$2, + Reference$3 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: null, + }, + ], + set: Map { + "Foo" => Variable$1, + "unresolved" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + TSModuleScope$2 { + block: TSModuleDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "x" => Variable$2, + }, + type: "tsModule", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/ts-module/self-ref.ts b/packages/scope-manager/tests/fixtures/ts-module/self-ref.ts new file mode 100644 index 00000000000..e94a766b419 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/self-ref.ts @@ -0,0 +1,4 @@ +module Foo { + export const x = 1; + Foo.x; +} diff --git a/packages/scope-manager/tests/fixtures/ts-module/self-ref.ts.shot b/packages/scope-manager/tests/fixtures/ts-module/self-ref.ts.shot new file mode 100644 index 00000000000..7e49d3b7ea0 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/ts-module/self-ref.ts.shot @@ -0,0 +1,79 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ts-module self-ref 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSModuleNameDefinition$1 { + name: Identifier<"Foo">, + node: TSModuleDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$2 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"x">, + node: VariableDeclarator$2, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TSModuleScope$2 { + block: TSModuleDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "x" => Variable$2, + }, + type: "tsModule", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/parameter-array-destructure.ts b/packages/scope-manager/tests/fixtures/type-annotation/parameter-array-destructure.ts new file mode 100644 index 00000000000..ce717cd0a41 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/parameter-array-destructure.ts @@ -0,0 +1,2 @@ +type T = []; +function foo([a]: T) {} diff --git a/packages/scope-manager/tests/fixtures/type-annotation/parameter-array-destructure.ts.shot b/packages/scope-manager/tests/fixtures/type-annotation/parameter-array-destructure.ts.shot new file mode 100644 index 00000000000..fc38d7a41b5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/parameter-array-destructure.ts.shot @@ -0,0 +1,92 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-annotation parameter-array-destructure 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"a">, + node: FunctionDeclaration$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$3, + "a" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/parameter-default.ts b/packages/scope-manager/tests/fixtures/type-annotation/parameter-default.ts new file mode 100644 index 00000000000..61c1836be6e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/parameter-default.ts @@ -0,0 +1,2 @@ +type T = 1; +function foo(a: T = 1) {} diff --git a/packages/scope-manager/tests/fixtures/type-annotation/parameter-default.ts.shot b/packages/scope-manager/tests/fixtures/type-annotation/parameter-default.ts.shot new file mode 100644 index 00000000000..2fd8f742467 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/parameter-default.ts.shot @@ -0,0 +1,102 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-annotation parameter-default 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"a">, + node: FunctionDeclaration$2, + }, + ], + name: "a", + references: Array [ + Reference$1 { + identifier: Identifier<"a">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$4, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arguments" => Variable$3, + "a" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/parameter-object-destructure.ts b/packages/scope-manager/tests/fixtures/type-annotation/parameter-object-destructure.ts new file mode 100644 index 00000000000..04824de3762 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/parameter-object-destructure.ts @@ -0,0 +1,2 @@ +type T = {}; +function foo({ a }: T) {} diff --git a/packages/scope-manager/tests/fixtures/type-annotation/parameter-object-destructure.ts.shot b/packages/scope-manager/tests/fixtures/type-annotation/parameter-object-destructure.ts.shot new file mode 100644 index 00000000000..9a572fd5b2e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/parameter-object-destructure.ts.shot @@ -0,0 +1,92 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-annotation parameter-object-destructure 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"a">, + node: FunctionDeclaration$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$3, + "a" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/parameter-rest.ts b/packages/scope-manager/tests/fixtures/type-annotation/parameter-rest.ts new file mode 100644 index 00000000000..426fcd70450 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/parameter-rest.ts @@ -0,0 +1,2 @@ +type T = 1; +function foo(...a: T[]) {} diff --git a/packages/scope-manager/tests/fixtures/type-annotation/parameter-rest.ts.shot b/packages/scope-manager/tests/fixtures/type-annotation/parameter-rest.ts.shot new file mode 100644 index 00000000000..d50adae94c1 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/parameter-rest.ts.shot @@ -0,0 +1,92 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-annotation parameter-rest 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"a">, + node: FunctionDeclaration$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$3, + "a" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/parameter.ts b/packages/scope-manager/tests/fixtures/type-annotation/parameter.ts new file mode 100644 index 00000000000..53fd1a252db --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/parameter.ts @@ -0,0 +1,2 @@ +type T = 1; +function foo(a: T) {} diff --git a/packages/scope-manager/tests/fixtures/type-annotation/parameter.ts.shot b/packages/scope-manager/tests/fixtures/type-annotation/parameter.ts.shot new file mode 100644 index 00000000000..a699082ede2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/parameter.ts.shot @@ -0,0 +1,92 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-annotation parameter 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + FunctionNameDefinition$2 { + name: Identifier<"foo">, + node: FunctionDeclaration$2, + }, + ], + name: "foo", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [], + name: "arguments", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"a">, + node: FunctionDeclaration$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionScope$2 { + block: FunctionDeclaration$2, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arguments" => Variable$3, + "a" => Variable$4, + }, + type: "function", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/variable-array-destructure.ts b/packages/scope-manager/tests/fixtures/type-annotation/variable-array-destructure.ts new file mode 100644 index 00000000000..d40a8608f14 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/variable-array-destructure.ts @@ -0,0 +1,2 @@ +type T = []; +const [x]: T = []; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/variable-array-destructure.ts.shot b/packages/scope-manager/tests/fixtures/type-annotation/variable-array-destructure.ts.shot new file mode 100644 index 00000000000..71f9aff4ce2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/variable-array-destructure.ts.shot @@ -0,0 +1,68 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-annotation variable-array-destructure 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"x">, + node: VariableDeclarator$2, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: ArrayExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "T" => Variable$1, + "x" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/variable-const.ts b/packages/scope-manager/tests/fixtures/type-annotation/variable-const.ts new file mode 100644 index 00000000000..7b61add80b1 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/variable-const.ts @@ -0,0 +1,2 @@ +type T = 1; +const x: T = 1; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/variable-const.ts.shot b/packages/scope-manager/tests/fixtures/type-annotation/variable-const.ts.shot new file mode 100644 index 00000000000..e16be05289d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/variable-const.ts.shot @@ -0,0 +1,68 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-annotation variable-const 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"x">, + node: VariableDeclarator$2, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "T" => Variable$1, + "x" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/variable-let.ts b/packages/scope-manager/tests/fixtures/type-annotation/variable-let.ts new file mode 100644 index 00000000000..d6b0d69dbbe --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/variable-let.ts @@ -0,0 +1,2 @@ +type T = 1; +let x: T; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/variable-let.ts.shot b/packages/scope-manager/tests/fixtures/type-annotation/variable-let.ts.shot new file mode 100644 index 00000000000..6a73fc87d10 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/variable-let.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-annotation variable-let 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"x">, + node: VariableDeclarator$2, + }, + ], + name: "x", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$1, + "x" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/variable-object-destructure.ts b/packages/scope-manager/tests/fixtures/type-annotation/variable-object-destructure.ts new file mode 100644 index 00000000000..a0a18b23ab9 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/variable-object-destructure.ts @@ -0,0 +1,2 @@ +type T = {}; +const { x }: T = {}; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/variable-object-destructure.ts.shot b/packages/scope-manager/tests/fixtures/type-annotation/variable-object-destructure.ts.shot new file mode 100644 index 00000000000..3ac3f6962d9 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/variable-object-destructure.ts.shot @@ -0,0 +1,68 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-annotation variable-object-destructure 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"x">, + node: VariableDeclarator$2, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: ObjectExpression$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "T" => Variable$1, + "x" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/variable-var.ts b/packages/scope-manager/tests/fixtures/type-annotation/variable-var.ts new file mode 100644 index 00000000000..4423625dc4c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/variable-var.ts @@ -0,0 +1,2 @@ +type T = 1; +var x: T; diff --git a/packages/scope-manager/tests/fixtures/type-annotation/variable-var.ts.shot b/packages/scope-manager/tests/fixtures/type-annotation/variable-var.ts.shot new file mode 100644 index 00000000000..5ffad66774b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-annotation/variable-var.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-annotation variable-var 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"x">, + node: VariableDeclarator$2, + }, + ], + name: "x", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$1, + "x" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-assertion/angle-bracket.ts b/packages/scope-manager/tests/fixtures/type-assertion/angle-bracket.ts new file mode 100644 index 00000000000..c5b90146e65 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-assertion/angle-bracket.ts @@ -0,0 +1,4 @@ +const x = 1; +type T = 1; + +x; diff --git a/packages/scope-manager/tests/fixtures/type-assertion/angle-bracket.ts.shot b/packages/scope-manager/tests/fixtures/type-assertion/angle-bracket.ts.shot new file mode 100644 index 00000000000..f385c548d89 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-assertion/angle-bracket.ts.shot @@ -0,0 +1,75 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-assertion angle-bracket 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "T", + references: Array [ + Reference$3 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "x" => Variable$1, + "T" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-assertion/as.ts b/packages/scope-manager/tests/fixtures/type-assertion/as.ts new file mode 100644 index 00000000000..55284491ea5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-assertion/as.ts @@ -0,0 +1,4 @@ +const x = 1; +type T = 1; + +x as T; diff --git a/packages/scope-manager/tests/fixtures/type-assertion/as.ts.shot b/packages/scope-manager/tests/fixtures/type-assertion/as.ts.shot new file mode 100644 index 00000000000..a51c42b04ad --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-assertion/as.ts.shot @@ -0,0 +1,75 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-assertion as 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "T", + references: Array [ + Reference$3 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "x" => Variable$1, + "T" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/conditional1.ts b/packages/scope-manager/tests/fixtures/type-declaration/conditional1.ts new file mode 100644 index 00000000000..c39bc79c281 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/conditional1.ts @@ -0,0 +1,3 @@ +type T = U extends infer V ? V : never; + +type Unresolved = V; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/conditional1.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/conditional1.ts.shot new file mode 100644 index 00000000000..05de4a1f931 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/conditional1.ts.shot @@ -0,0 +1,123 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration conditional1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"U">, + node: TSTypeParameter$2, + }, + ], + name: "U", + references: Array [ + Reference$1 { + identifier: Identifier<"U">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"V">, + node: TSTypeParameter$3, + }, + ], + name: "V", + references: Array [ + Reference$2 { + identifier: Identifier<"V">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$4 { + name: Identifier<"Unresolved">, + node: TSTypeAliasDeclaration$4, + }, + ], + name: "Unresolved", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$3 { + identifier: Identifier<"V">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "T" => Variable$1, + "Unresolved" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + ], + }, + TypeScope$2 { + block: TSTypeAliasDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "U" => Variable$2, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ConditionalTypeScope$3 { + block: TSConditionalType$6, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "V" => Variable$3, + }, + type: "conditionalType", + upper: TypeScope$2, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/conditional2.ts b/packages/scope-manager/tests/fixtures/type-declaration/conditional2.ts new file mode 100644 index 00000000000..4fac34237bc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/conditional2.ts @@ -0,0 +1,3 @@ +type T = never extends infer U ? U : never; + +type Unresolved = U; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/conditional2.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/conditional2.ts.shot new file mode 100644 index 00000000000..dbeda86a224 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/conditional2.ts.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration conditional2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"U">, + node: TSTypeParameter$2, + }, + ], + name: "U", + references: Array [ + Reference$1 { + identifier: Identifier<"U">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"Unresolved">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "Unresolved", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$2 { + identifier: Identifier<"U">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "T" => Variable$1, + "Unresolved" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + ConditionalTypeScope$2 { + block: TSConditionalType$5, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "U" => Variable$2, + }, + type: "conditionalType", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/dual-type-value.ts b/packages/scope-manager/tests/fixtures/type-declaration/dual-type-value.ts new file mode 100644 index 00000000000..0dc8ae8036b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/dual-type-value.ts @@ -0,0 +1,5 @@ +const dual = 1; +type dual = number; + +type reference1 = dual; +const reference2 = dual; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/dual-type-value.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/dual-type-value.ts.shot new file mode 100644 index 00000000000..8d127b17ef2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/dual-type-value.ts.shot @@ -0,0 +1,102 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration dual-type-value 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"dual">, + node: VariableDeclarator$1, + }, + TypeDefinition$2 { + name: Identifier<"dual">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "dual", + references: Array [ + Reference$1 { + identifier: Identifier<"dual">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$3, + }, + Reference$2 { + identifier: Identifier<"dual">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + Reference$4 { + identifier: Identifier<"dual">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"reference1">, + node: TSTypeAliasDeclaration$4, + }, + ], + name: "reference1", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + VariableDefinition$4 { + name: Identifier<"reference2">, + node: VariableDeclarator$5, + }, + ], + name: "reference2", + references: Array [ + Reference$3 { + identifier: Identifier<"reference2">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + writeExpr: Identifier<"dual">, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + Reference$4, + ], + set: Map { + "dual" => Variable$1, + "reference1" => Variable$2, + "reference2" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics1.ts b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics1.ts new file mode 100644 index 00000000000..c71eeeecae9 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics1.ts @@ -0,0 +1,2 @@ +type T = 1; +type A = new (arg: U) => T; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics1.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics1.ts.shot new file mode 100644 index 00000000000..206d26b1b25 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics1.ts.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration function constructor-generics1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [ + Reference$1 { + identifier: Identifier<"U">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"arg">, + node: TSConstructorType$4, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + TypeScope$2 { + block: TSTypeAliasDeclaration$2, + isStrict: true, + references: Array [], + set: Map { + "U" => Variable$3, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + FunctionTypeScope$3 { + block: TSConstructorType$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arg" => Variable$4, + }, + type: "functionType", + upper: TypeScope$2, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics2.ts b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics2.ts new file mode 100644 index 00000000000..2c62bffa9db --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics2.ts @@ -0,0 +1,2 @@ +type T = 1; +type A = new (arg: U) => T; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics2.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics2.ts.shot new file mode 100644 index 00000000000..c8504114c20 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor-generics2.ts.shot @@ -0,0 +1,105 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration function constructor-generics2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [ + Reference$1 { + identifier: Identifier<"U">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"arg">, + node: TSConstructorType$4, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionTypeScope$2 { + block: TSConstructorType$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "U" => Variable$3, + "arg" => Variable$4, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/constructor.ts b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor.ts new file mode 100644 index 00000000000..9e64f174e3d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor.ts @@ -0,0 +1,2 @@ +type T = 1; +type A = new (arg: T) => T; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/constructor.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor.ts.shot new file mode 100644 index 00000000000..5a450ec959e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/constructor.ts.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration function constructor 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"arg">, + node: TSConstructorType$3, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionTypeScope$2 { + block: TSConstructorType$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arg" => Variable$3, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics1.ts b/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics1.ts new file mode 100644 index 00000000000..f44fdb06c8b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics1.ts @@ -0,0 +1,2 @@ +type T = 1; +type A = (arg: U) => T; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics1.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics1.ts.shot new file mode 100644 index 00000000000..7bf926b5598 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics1.ts.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration function function-generics1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [ + Reference$1 { + identifier: Identifier<"U">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"arg">, + node: TSFunctionType$4, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + TypeScope$2 { + block: TSTypeAliasDeclaration$2, + isStrict: true, + references: Array [], + set: Map { + "U" => Variable$3, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + FunctionTypeScope$3 { + block: TSFunctionType$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arg" => Variable$4, + }, + type: "functionType", + upper: TypeScope$2, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics2.ts b/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics2.ts new file mode 100644 index 00000000000..97d8378f61f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics2.ts @@ -0,0 +1,2 @@ +type T = 1; +type A = (arg: U) => T; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics2.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics2.ts.shot new file mode 100644 index 00000000000..9d53bfd6687 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/function-generics2.ts.shot @@ -0,0 +1,105 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration function function-generics2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [ + Reference$1 { + identifier: Identifier<"U">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"arg">, + node: TSFunctionType$4, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionTypeScope$2 { + block: TSFunctionType$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "U" => Variable$3, + "arg" => Variable$4, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/function1.ts b/packages/scope-manager/tests/fixtures/type-declaration/function/function1.ts new file mode 100644 index 00000000000..038fbb18159 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/function1.ts @@ -0,0 +1,2 @@ +type T = 1; +type A = (arg: T) => T; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/function1.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/function/function1.ts.shot new file mode 100644 index 00000000000..e61e964d90f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/function1.ts.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration function function1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"arg">, + node: TSFunctionType$3, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionTypeScope$2 { + block: TSFunctionType$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arg" => Variable$3, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/function2.ts b/packages/scope-manager/tests/fixtures/type-declaration/function/function2.ts new file mode 100644 index 00000000000..da53e79f421 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/function2.ts @@ -0,0 +1,3 @@ +const arg = 1; +// the typeof references the parameter, not the variable +type A = (arg: string) => typeof arg; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/function/function2.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/function/function2.ts.shot new file mode 100644 index 00000000000..4551de619d8 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/function/function2.ts.shot @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration function function2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"arg">, + node: VariableDeclarator$1, + }, + ], + name: "arg", + references: Array [ + Reference$1 { + identifier: Identifier<"arg">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"arg">, + node: TSFunctionType$4, + }, + ], + name: "arg", + references: Array [ + Reference$2 { + identifier: Identifier<"arg">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$3, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "arg" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionTypeScope$2 { + block: TSFunctionType$4, + isStrict: true, + references: Array [ + Reference$2, + ], + set: Map { + "arg" => Variable$3, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/index-access1.ts b/packages/scope-manager/tests/fixtures/type-declaration/index-access1.ts new file mode 100644 index 00000000000..544ae215884 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/index-access1.ts @@ -0,0 +1,2 @@ +type T = { a: string }; +type A = T['a']; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/index-access1.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/index-access1.ts.shot new file mode 100644 index 00000000000..11dd9cf80ee --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/index-access1.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration index-access1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/index-access2.ts b/packages/scope-manager/tests/fixtures/type-declaration/index-access2.ts new file mode 100644 index 00000000000..6831f20e3fb --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/index-access2.ts @@ -0,0 +1,3 @@ +type T = { a: string }; +type K = 'a'; +type A = T[K]; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/index-access2.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/index-access2.ts.shot new file mode 100644 index 00000000000..7e1fbfe453b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/index-access2.ts.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration index-access2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"K">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "K", + references: Array [ + Reference$1 { + identifier: Identifier<"K">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "T" => Variable$1, + "K" => Variable$2, + "A" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/index-access3.ts b/packages/scope-manager/tests/fixtures/type-declaration/index-access3.ts new file mode 100644 index 00000000000..76706d3507c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/index-access3.ts @@ -0,0 +1,3 @@ +type T = { a: string }; +const k = 'a'; +type A = T[typeof k]; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/index-access3.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/index-access3.ts.shot new file mode 100644 index 00000000000..1a9adea4e15 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/index-access3.ts.shot @@ -0,0 +1,89 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration index-access3 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$3 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + VariableDefinition$2 { + name: Identifier<"k">, + node: VariableDeclarator$2, + }, + ], + name: "k", + references: Array [ + Reference$1 { + identifier: Identifier<"k">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + writeExpr: Literal$3, + }, + Reference$2 { + identifier: Identifier<"k">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$4, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "T" => Variable$1, + "k" => Variable$2, + "A" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage1.ts b/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage1.ts new file mode 100644 index 00000000000..d2ce3f9de50 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage1.ts @@ -0,0 +1,2 @@ +interface Parent {} +interface Foo extends Parent {} diff --git a/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage1.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage1.ts.shot new file mode 100644 index 00000000000..451d7d954fb --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage1.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration interface-heritage1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"Parent">, + node: TSInterfaceDeclaration$1, + }, + ], + name: "Parent", + references: Array [ + Reference$1 { + identifier: Identifier<"Parent">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"Foo">, + node: TSInterfaceDeclaration$2, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "Parent" => Variable$1, + "Foo" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage2.ts b/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage2.ts new file mode 100644 index 00000000000..72bc4fe8e8c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage2.ts @@ -0,0 +1,5 @@ +type unreferenced = {}; +namespace Member { + export type unreferenced = {}; +} +interface Foo extends Member.unreferenced {} diff --git a/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage2.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage2.ts.shot new file mode 100644 index 00000000000..15a3c7533f8 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/interface-heritage2.ts.shot @@ -0,0 +1,97 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration interface-heritage2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"unreferenced">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "unreferenced", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TSModuleNameDefinition$2 { + name: Identifier<"Member">, + node: TSModuleDeclaration$2, + }, + ], + name: "Member", + references: Array [ + Reference$1 { + identifier: Identifier<"Member">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"unreferenced">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "unreferenced", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$4 { + name: Identifier<"Foo">, + node: TSInterfaceDeclaration$4, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "unreferenced" => Variable$1, + "Member" => Variable$2, + "Foo" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$4, + ], + }, + TSModuleScope$2 { + block: TSModuleDeclaration$2, + isStrict: true, + references: Array [], + set: Map { + "unreferenced" => Variable$3, + }, + type: "tsModule", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/interface1.ts b/packages/scope-manager/tests/fixtures/type-declaration/interface1.ts new file mode 100644 index 00000000000..fda122177f4 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/interface1.ts @@ -0,0 +1,3 @@ +interface A { + a: string; +} diff --git a/packages/scope-manager/tests/fixtures/type-declaration/interface1.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/interface1.ts.shot new file mode 100644 index 00000000000..d9529e5c0b9 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/interface1.ts.shot @@ -0,0 +1,35 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration interface1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"A">, + node: TSInterfaceDeclaration$1, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map { + "A" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/interface2.ts b/packages/scope-manager/tests/fixtures/type-declaration/interface2.ts new file mode 100644 index 00000000000..60a78f19e07 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/interface2.ts @@ -0,0 +1,2 @@ +interface A {} +type B = A; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/interface2.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/interface2.ts.shot new file mode 100644 index 00000000000..2cc593bc60f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/interface2.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration interface2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"A">, + node: TSInterfaceDeclaration$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"B">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "B", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "A" => Variable$1, + "B" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts b/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts new file mode 100644 index 00000000000..a91c6ae6840 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts @@ -0,0 +1,2 @@ +type T = Record; +type A = { [k in string]: T[k] }; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts.shot new file mode 100644 index 00000000000..69fe517525d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/mapped.ts.shot @@ -0,0 +1,98 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration mapped 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$3 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"k">, + node: TSTypeParameter$3, + }, + ], + name: "k", + references: Array [ + Reference$2 { + identifier: Identifier<"k">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1 { + identifier: Identifier<"Record">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + MappedTypeScope$2 { + block: TSMappedType$5, + isStrict: true, + references: Array [ + Reference$2, + Reference$3, + ], + set: Map { + "k" => Variable$3, + }, + type: "mappedType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/qualified-name.ts b/packages/scope-manager/tests/fixtures/type-declaration/qualified-name.ts new file mode 100644 index 00000000000..f0fd0249f95 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/qualified-name.ts @@ -0,0 +1,2 @@ +type T = 1; +type A = T.B; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/qualified-name.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/qualified-name.ts.shot new file mode 100644 index 00000000000..e4424533b55 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/qualified-name.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration qualified-name 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/call-generics.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/call-generics.ts new file mode 100644 index 00000000000..ceeabc8cfce --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/call-generics.ts @@ -0,0 +1,4 @@ +type T = 1; +type A = { + (arg: U): T; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/call-generics.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/call-generics.ts.shot new file mode 100644 index 00000000000..b8beef31153 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/call-generics.ts.shot @@ -0,0 +1,105 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures call-generics 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [ + Reference$1 { + identifier: Identifier<"U">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"arg">, + node: TSCallSignatureDeclaration$4, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionTypeScope$2 { + block: TSCallSignatureDeclaration$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "U" => Variable$3, + "arg" => Variable$4, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/call.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/call.ts new file mode 100644 index 00000000000..519af46a1bc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/call.ts @@ -0,0 +1,4 @@ +type T = 1; +type A = { + (arg: T): T; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/call.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/call.ts.shot new file mode 100644 index 00000000000..c04665da4cc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/call.ts.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures call 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"arg">, + node: TSCallSignatureDeclaration$3, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionTypeScope$2 { + block: TSCallSignatureDeclaration$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arg" => Variable$3, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct-generics.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct-generics.ts new file mode 100644 index 00000000000..0f8d05ff462 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct-generics.ts @@ -0,0 +1,4 @@ +type T = 1; +type A = { + new (arg: U): T; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct-generics.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct-generics.ts.shot new file mode 100644 index 00000000000..04a560a8f84 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct-generics.ts.shot @@ -0,0 +1,105 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures construct-generics 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [ + Reference$1 { + identifier: Identifier<"U">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"arg">, + node: TSConstructSignatureDeclaration$4, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionTypeScope$2 { + block: TSConstructSignatureDeclaration$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "U" => Variable$3, + "arg" => Variable$4, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct.ts new file mode 100644 index 00000000000..f5af306ccae --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct.ts @@ -0,0 +1,4 @@ +type T = 1; +type A = { + new (arg: T): T; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct.ts.shot new file mode 100644 index 00000000000..e5b84ef904b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/construct.ts.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures construct 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"arg">, + node: TSConstructSignatureDeclaration$3, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionTypeScope$2 { + block: TSConstructSignatureDeclaration$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arg" => Variable$3, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/index-sig.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/index-sig.ts new file mode 100644 index 00000000000..d3b3732aabc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/index-sig.ts @@ -0,0 +1,2 @@ +type T = 1; +type A = { [k: string]: T }; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/index-sig.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/index-sig.ts.shot new file mode 100644 index 00000000000..a3d633bbb56 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/index-sig.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures index-sig 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name.ts new file mode 100644 index 00000000000..386039f97f3 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name.ts @@ -0,0 +1,5 @@ +const x = 'b'; +type T = 1; +type A = { + [x](arg: T): T; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name.ts.shot new file mode 100644 index 00000000000..9a40c25a233 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name.ts.shot @@ -0,0 +1,122 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures method-computed-name 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "T", + references: Array [ + Reference$3 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + Reference$4 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$4, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"arg">, + node: TSMethodSignature$5, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$6, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "x" => Variable$1, + "T" => Variable$2, + "A" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + ], + }, + FunctionTypeScope$2 { + block: TSMethodSignature$5, + isStrict: true, + references: Array [ + Reference$3, + Reference$4, + ], + set: Map { + "arg" => Variable$4, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name2.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name2.ts new file mode 100644 index 00000000000..d12d5a6c507 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name2.ts @@ -0,0 +1,6 @@ +enum Foo { + a, +} +type A = { + [Foo.a](): 1; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name2.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name2.ts.shot new file mode 100644 index 00000000000..b72995c6332 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-computed-name2.ts.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures method-computed-name2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSEnumNameDefinition$1 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$1 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TSEnumNameDefinition$2 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TSEnumMemberDefinition$3 { + name: Identifier<"a">, + node: TSEnumMember$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$4 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$1, + "A" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + ], + }, + TSEnumScope$2 { + block: TSEnumDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$2, + "a" => Variable$3, + }, + type: "tsEnum", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + FunctionTypeScope$3 { + block: TSMethodSignature$5, + isStrict: true, + references: Array [], + set: Map {}, + type: "functionType", + upper: GlobalScope$1, + variables: Array [], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-generics.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-generics.ts new file mode 100644 index 00000000000..d7d80fac737 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-generics.ts @@ -0,0 +1,4 @@ +type T = 1; +type A = { + a(arg: T): U; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-generics.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-generics.ts.shot new file mode 100644 index 00000000000..2fd5d05e771 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method-generics.ts.shot @@ -0,0 +1,105 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures method-generics 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [ + Reference$2 { + identifier: Identifier<"U">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + ParameterDefinition$4 { + name: Identifier<"arg">, + node: TSMethodSignature$4, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionTypeScope$2 { + block: TSMethodSignature$4, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "U" => Variable$3, + "arg" => Variable$4, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/method.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method.ts new file mode 100644 index 00000000000..6f171c0a180 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method.ts @@ -0,0 +1,4 @@ +type T = 1; +type A = { + a(arg: T): T; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/method.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method.ts.shot new file mode 100644 index 00000000000..ddea7676262 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/method.ts.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures method 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + ParameterDefinition$3 { + name: Identifier<"arg">, + node: TSMethodSignature$3, + }, + ], + name: "arg", + references: Array [], + isValueVariable: true, + isTypeVariable: false, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + FunctionTypeScope$2 { + block: TSMethodSignature$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "arg" => Variable$3, + }, + type: "functionType", + upper: GlobalScope$1, + variables: Array [ + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name.ts new file mode 100644 index 00000000000..dfe5e6b0fbe --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name.ts @@ -0,0 +1,5 @@ +const x = 'b'; +type T = 1; +type A = { + [x]: T; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name.ts.shot new file mode 100644 index 00000000000..aecf762a6e7 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name.ts.shot @@ -0,0 +1,89 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures property-computed-name 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "T", + references: Array [ + Reference$3 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$4, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "x" => Variable$1, + "T" => Variable$2, + "A" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name2.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name2.ts new file mode 100644 index 00000000000..e99b74a54d9 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name2.ts @@ -0,0 +1,6 @@ +enum Foo { + a, +} +type A = { + [Foo.a]: 1; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name2.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name2.ts.shot new file mode 100644 index 00000000000..93f348861c4 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property-computed-name2.ts.shot @@ -0,0 +1,97 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures property-computed-name2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TSEnumNameDefinition$1 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [ + Reference$1 { + identifier: Identifier<"Foo">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TSEnumNameDefinition$2 { + name: Identifier<"Foo">, + node: TSEnumDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TSEnumMemberDefinition$3 { + name: Identifier<"a">, + node: TSEnumMember$2, + }, + ], + name: "a", + references: Array [], + isValueVariable: true, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$4 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "Foo" => Variable$1, + "A" => Variable$4, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$4, + ], + }, + TSEnumScope$2 { + block: TSEnumDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "Foo" => Variable$2, + "a" => Variable$3, + }, + type: "tsEnum", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/property.ts b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property.ts new file mode 100644 index 00000000000..8ba711e3c2d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property.ts @@ -0,0 +1,4 @@ +type T = 1; +type A = { + a: T; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/signatures/property.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property.ts.shot new file mode 100644 index 00000000000..5739114d3ce --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/signatures/property.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration signatures property 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/tuple-rest.ts b/packages/scope-manager/tests/fixtures/type-declaration/tuple-rest.ts new file mode 100644 index 00000000000..65c675d09ad --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/tuple-rest.ts @@ -0,0 +1,2 @@ +type T = 1; +type A = [...T]; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/tuple-rest.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/tuple-rest.ts.shot new file mode 100644 index 00000000000..d78524f98b1 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/tuple-rest.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration tuple-rest 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/tuple.ts b/packages/scope-manager/tests/fixtures/type-declaration/tuple.ts new file mode 100644 index 00000000000..87df28769c3 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/tuple.ts @@ -0,0 +1,2 @@ +type T = 1; +type A = [T]; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/tuple.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/tuple.ts.shot new file mode 100644 index 00000000000..eb7274090b8 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/tuple.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration tuple 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/body-reference.ts b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/body-reference.ts new file mode 100644 index 00000000000..9482bcd0ab5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/body-reference.ts @@ -0,0 +1,3 @@ +interface Foo { + prop: T; +} diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/body-reference.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/body-reference.ts.shot new file mode 100644 index 00000000000..d4e1736e34e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/body-reference.ts.shot @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type-parameters interface body-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"Foo">, + node: TSInterfaceDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TypeScope$2 { + block: TSInterfaceDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$2, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/extends-reference.ts b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/extends-reference.ts new file mode 100644 index 00000000000..a1f64ae23e2 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/extends-reference.ts @@ -0,0 +1,2 @@ +interface A {} +interface Foo extends A {} diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/extends-reference.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/extends-reference.ts.shot new file mode 100644 index 00000000000..1eeccea3118 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/extends-reference.ts.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type-parameters interface extends-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"A">, + node: TSInterfaceDeclaration$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"Foo">, + node: TSInterfaceDeclaration$3, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$4 { + defs: Array [ + TypeDefinition$4 { + name: Identifier<"T">, + node: TSTypeParameter$4, + }, + ], + name: "T", + references: Array [ + Reference$2 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$4, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [], + set: Map { + "A" => Variable$1, + "Foo" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + TypeScope$2 { + block: TSInterfaceDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "T" => Variable$2, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + TypeScope$3 { + block: TSInterfaceDeclaration$3, + isStrict: true, + references: Array [ + Reference$1, + Reference$2, + ], + set: Map { + "T" => Variable$4, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$4, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-param-reference.ts b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-param-reference.ts new file mode 100644 index 00000000000..e4e7cb258f4 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-param-reference.ts @@ -0,0 +1 @@ +interface Foo {} diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-param-reference.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-param-reference.ts.shot new file mode 100644 index 00000000000..569563efa38 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-param-reference.ts.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type-parameters interface type-param-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"Foo">, + node: TSInterfaceDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TypeScope$2 { + block: TSInterfaceDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$2, + "U" => Variable$3, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration-extends.ts b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration-extends.ts new file mode 100644 index 00000000000..d666577cf4e --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration-extends.ts @@ -0,0 +1 @@ +interface Foo {} diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration-extends.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration-extends.ts.shot new file mode 100644 index 00000000000..4545ed7d0c5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration-extends.ts.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type-parameters interface type-parameter-declaration-extends 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"Foo">, + node: TSInterfaceDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TypeScope$2 { + block: TSInterfaceDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$2, + "U" => Variable$3, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration.ts b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration.ts new file mode 100644 index 00000000000..169cb6c15d4 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration.ts @@ -0,0 +1,3 @@ +interface Foo {} + +type Unresolved = T; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration.ts.shot new file mode 100644 index 00000000000..a5579bf088f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/interface/type-parameter-declaration.ts.shot @@ -0,0 +1,81 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type-parameters interface type-parameter-declaration 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"Foo">, + node: TSInterfaceDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"Unresolved">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "Unresolved", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "Foo" => Variable$1, + "Unresolved" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + TypeScope$2 { + block: TSInterfaceDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "T" => Variable$2, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/body-reference.ts b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/body-reference.ts new file mode 100644 index 00000000000..2fb7debbef5 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/body-reference.ts @@ -0,0 +1 @@ +type Foo = T; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/body-reference.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/body-reference.ts.shot new file mode 100644 index 00000000000..1098cbfa5db --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/body-reference.ts.shot @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type-parameters type-decl body-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"Foo">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TypeScope$2 { + block: TSTypeAliasDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$2, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-param-reference.ts b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-param-reference.ts new file mode 100644 index 00000000000..b752327ba1f --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-param-reference.ts @@ -0,0 +1 @@ +type Foo = 1; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-param-reference.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-param-reference.ts.shot new file mode 100644 index 00000000000..989871fd714 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-param-reference.ts.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type-parameters type-decl type-param-reference 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"Foo">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TypeScope$2 { + block: TSTypeAliasDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$2, + "U" => Variable$3, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.ts b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.ts new file mode 100644 index 00000000000..46db3056d0d --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.ts @@ -0,0 +1 @@ +type Foo = {}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.ts.shot new file mode 100644 index 00000000000..fe6857747be --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration-extends.ts.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type-parameters type-decl type-parameter-declaration-extends 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"Foo">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$2, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"U">, + node: TSTypeParameter$3, + }, + ], + name: "U", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [], + set: Map { + "Foo" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + TypeScope$2 { + block: TSTypeAliasDeclaration$1, + isStrict: true, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$2, + "U" => Variable$3, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration.ts b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration.ts new file mode 100644 index 00000000000..6e931a3482b --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration.ts @@ -0,0 +1,3 @@ +type Foo = 1; + +type Unresolved = T; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration.ts.shot new file mode 100644 index 00000000000..22bc9f4fd22 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/type-decl/type-parameter-declaration.ts.shot @@ -0,0 +1,81 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type-parameters type-decl type-parameter-declaration 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"Foo">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "Foo", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeParameter$2, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"Unresolved">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "Unresolved", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "Foo" => Variable$1, + "Unresolved" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$3, + ], + }, + TypeScope$2 { + block: TSTypeAliasDeclaration$1, + isStrict: true, + references: Array [], + set: Map { + "T" => Variable$2, + }, + type: "type", + upper: GlobalScope$1, + variables: Array [ + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-query.ts b/packages/scope-manager/tests/fixtures/type-declaration/type-query.ts new file mode 100644 index 00000000000..6fde05debc9 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-query.ts @@ -0,0 +1,3 @@ +const x = 1; +type T = typeof x; +type Unresolved = x; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-query.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type-query.ts.shot new file mode 100644 index 00000000000..73af4d407eb --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type-query.ts.shot @@ -0,0 +1,87 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type-query 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isTypeReference: false, + isValueReference: true, + resolved: Variable$1, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"Unresolved">, + node: TSTypeAliasDeclaration$4, + }, + ], + name: "Unresolved", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$5, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3 { + identifier: Identifier<"x">, + isTypeReference: true, + isValueReference: false, + resolved: null, + }, + ], + set: Map { + "x" => Variable$1, + "T" => Variable$2, + "Unresolved" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + Variable$3, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type1.ts b/packages/scope-manager/tests/fixtures/type-declaration/type1.ts new file mode 100644 index 00000000000..0d6d62642cc --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type1.ts @@ -0,0 +1 @@ +type T = 1; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type1.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type1.ts.shot new file mode 100644 index 00000000000..9328ce21e14 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type1.ts.shot @@ -0,0 +1,35 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type1 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$2, + isStrict: false, + references: Array [], + set: Map { + "T" => Variable$1, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type2.ts b/packages/scope-manager/tests/fixtures/type-declaration/type2.ts new file mode 100644 index 00000000000..a22d5844b3a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type2.ts @@ -0,0 +1,2 @@ +type A = 1; +type B = A; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type2.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type2.ts.shot new file mode 100644 index 00000000000..aab4fcea029 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type2.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type2 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "A", + references: Array [ + Reference$1 { + identifier: Identifier<"A">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"B">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "B", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "A" => Variable$1, + "B" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type3.ts b/packages/scope-manager/tests/fixtures/type-declaration/type3.ts new file mode 100644 index 00000000000..1180d2a09b6 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type3.ts @@ -0,0 +1,5 @@ +type T = 1; +type A = { + b: string; + c: T; +}; diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type3.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type3.ts.shot new file mode 100644 index 00000000000..f37d0a68a2c --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-declaration/type3.ts.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-declaration type3 1`] = ` +ScopeManager { + variables: Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "T", + references: Array [ + Reference$1 { + identifier: Identifier<"T">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$1, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"A">, + node: TSTypeAliasDeclaration$2, + }, + ], + name: "A", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$3, + isStrict: false, + references: Array [ + Reference$1, + ], + set: Map { + "T" => Variable$1, + "A" => Variable$2, + }, + type: "global", + upper: null, + variables: Array [ + Variable$1, + Variable$2, + ], + }, + ], +} +`; diff --git a/packages/scope-manager/tests/lib.test.ts b/packages/scope-manager/tests/lib.test.ts new file mode 100644 index 00000000000..57b908777a8 --- /dev/null +++ b/packages/scope-manager/tests/lib.test.ts @@ -0,0 +1,25 @@ +import { parseAndAnalyze } from './util'; +import { ImplicitLibVariable } from '../src'; + +describe('implicit lib definitions', () => { + it('should define no implicit variables if provided an empty array', () => { + const { scopeManager } = parseAndAnalyze('', { + lib: [], + }); + + const variables = scopeManager.variables; + expect(variables.length).toBe(0); + }); + + it('should define implicit variables', () => { + const { scopeManager } = parseAndAnalyze('', { + lib: ['es2015'], + }); + + const variables = scopeManager.variables; + expect(variables.length).toBeGreaterThan(0); + + const variable = variables[0]; + expect(variable).toBeInstanceOf(ImplicitLibVariable); + }); +}); diff --git a/packages/scope-manager/tests/types/reference-type.test.ts b/packages/scope-manager/tests/types/reference-type.test.ts new file mode 100644 index 00000000000..585f29a15a5 --- /dev/null +++ b/packages/scope-manager/tests/types/reference-type.test.ts @@ -0,0 +1,196 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { getSpecificNode, parseAndAnalyze } from '../util'; + +describe('referencing a type - positive', () => { + it('records a reference when a type is referenced from a type', () => { + const { ast, scopeManager } = parseAndAnalyze(` + type TypeDecl = string; + type OtherType = TypeDecl; + `); + const node = getSpecificNode( + ast, + AST_NODE_TYPES.TSTypeAliasDeclaration, + n => n.id.name === 'TypeDecl', + ); + const variable = scopeManager.getDeclaredVariables(node)[0]; + + expect(variable.references).toHaveLength(1); + const referencingNode = getSpecificNode( + ast, + AST_NODE_TYPES.TSTypeAliasDeclaration, + n => n.id.name === 'OtherType', + ); + expect(variable.references[0].identifier.parent?.parent).toBe( + referencingNode, + ); + }); + + it('records a reference when a dual value-type is referenced from a type', () => { + const { ast, scopeManager } = parseAndAnalyze(` + class Class {} + type Type = Class; + `); + const node = getSpecificNode(ast, AST_NODE_TYPES.ClassDeclaration); + const variable = scopeManager.getDeclaredVariables(node)[0]; + + expect(variable.references).toHaveLength(1); + const referencingNode = getSpecificNode( + ast, + AST_NODE_TYPES.TSTypeAliasDeclaration, + ); + expect(variable.references[0].identifier.parent?.parent).toBe( + referencingNode, + ); + }); + + it('records a reference when a generic type parameter is referenced from its type', () => { + const { ast, scopeManager } = parseAndAnalyze(` + type TypeDecl = TypeParam; + `); + const node = getSpecificNode(ast, AST_NODE_TYPES.TSTypeParameter); + const variable = scopeManager.getDeclaredVariables(node)[0]; + + expect(variable.references).toHaveLength(1); + const referencingNode = getSpecificNode( + ast, + AST_NODE_TYPES.TSTypeReference, + ); + expect(variable.references[0].identifier.parent).toBe(referencingNode); + }); + + it('records references when a name has both a type and a variable definition', () => { + const { ast, scopeManager } = parseAndAnalyze(` + const dual = 1; + type dual = number; + + type reference1 = dual; + const reference2 = dual; + `); + const node = getSpecificNode( + ast, + AST_NODE_TYPES.VariableDeclarator, + n => n.id.type === AST_NODE_TYPES.Identifier && n.id.name === 'dual', + ); + const variable = scopeManager.getDeclaredVariables(node)[0]; + + // it should merge the defs into a single variable + expect(variable.defs).toHaveLength(2); + + expect(variable.references).toHaveLength(3); + + // first ref is the definition of the variable + expect(variable.references[0].identifier.parent).toBe(node); + // second ref is the type reference + const referencingTypeNode = getSpecificNode( + ast, + AST_NODE_TYPES.TSTypeAliasDeclaration, + n => n.id.name === 'reference1', + ); + expect(variable.references[1].identifier.parent?.parent).toBe( + referencingTypeNode, + ); + // third ref is the variable reference + const referencingVariableNode = getSpecificNode( + ast, + AST_NODE_TYPES.VariableDeclarator, + n => + n.id.type === AST_NODE_TYPES.Identifier && n.id.name === 'reference2', + ); + expect(variable.references[2].identifier.parent).toBe( + referencingVariableNode, + ); + }); + + it('records value and type references to imported variables', () => { + const { ast, scopeManager } = parseAndAnalyze( + ` + import { foo } from 'module'; + const test = foo; + type Test = foo; + `, + 'module', + ); + const node = getSpecificNode(ast, AST_NODE_TYPES.ImportSpecifier); + const variable = scopeManager.getDeclaredVariables(node)[0]; + expect(variable.references).toHaveLength(2); + // first reference is from the variable + const variableDecl = getSpecificNode( + ast, + AST_NODE_TYPES.VariableDeclarator, + ); + expect(variable.references[0].identifier.parent).toBe(variableDecl); + // second reference is from the type + const typeRef = getSpecificNode(ast, AST_NODE_TYPES.TSTypeReference); + expect(variable.references[1].identifier.parent).toBe(typeRef); + }); + + it('records a reference when a value is referenced from a typeof predicate', () => { + const { ast, scopeManager } = parseAndAnalyze(` + const value = 1; + type Type = typeof value; + `); + const node = getSpecificNode(ast, AST_NODE_TYPES.VariableDeclarator); + const variable = scopeManager.getDeclaredVariables(node)[0]; + + expect(variable.references).toHaveLength(2); + // first ref is the definition of the variable + expect(variable.references[0].identifier.parent).toBe(node); + // second ref is the predicate reference + const referencingNode = getSpecificNode( + ast, + AST_NODE_TYPES.TSTypeAliasDeclaration, + ); + expect(variable.references[1].identifier.parent?.parent).toBe( + referencingNode, + ); + }); +}); + +describe('referencing a type - negative', () => { + it('does not record a reference when a value is referenced from a type without a typeof predicate', () => { + const { ast, scopeManager } = parseAndAnalyze(` + const value = 1; + type Type = value; + `); + const node = getSpecificNode(ast, AST_NODE_TYPES.VariableDeclarator); + const variable = scopeManager.getDeclaredVariables(node)[0]; + + // variables declare a reference to themselves if they have an initialization + // so there should be one reference from the declaration itself + expect(variable.references).toHaveLength(1); + expect(variable.references[0].identifier.parent).toBe(node); + }); + + it('does not record a reference when a type is referenced from a value', () => { + const { ast, scopeManager } = parseAndAnalyze(` + type Type = 1; + const value = Type; + `); + const node = getSpecificNode(ast, AST_NODE_TYPES.TSTypeAliasDeclaration); + const variable = scopeManager.getDeclaredVariables(node)[0]; + expect(variable.references).toHaveLength(0); + }); + + it('does not record a reference when a type is referenced from outside its declaring type', () => { + const { ast, scopeManager } = parseAndAnalyze(` + type TypeDecl = T; + type Other = TypeParam; + `); + const node = getSpecificNode(ast, AST_NODE_TYPES.TSTypeParameter); + const variable = scopeManager.getDeclaredVariables(node)[0]; + expect(variable.references).toHaveLength(0); + }); + + it('does not record a reference when a type import is referenced from a value', () => { + const { ast, scopeManager } = parseAndAnalyze( + ` + import type { foo } from 'module'; + const test = foo; + `, + 'module', + ); + const node = getSpecificNode(ast, AST_NODE_TYPES.ImportSpecifier); + const variable = scopeManager.getDeclaredVariables(node)[0]; + expect(variable.references).toHaveLength(0); + }); +}); diff --git a/packages/scope-manager/tests/types/variable-definition.test.ts b/packages/scope-manager/tests/types/variable-definition.test.ts new file mode 100644 index 00000000000..12ab0f92822 --- /dev/null +++ b/packages/scope-manager/tests/types/variable-definition.test.ts @@ -0,0 +1,109 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { getSpecificNode, parseAndAnalyze } from '../util'; + +describe('variable definition', () => { + it('defines a variable for a type declaration', () => { + const { ast, scopeManager } = parseAndAnalyze(` + type TypeDecl = string; + `); + const node = getSpecificNode(ast, AST_NODE_TYPES.TSTypeAliasDeclaration); + expect(scopeManager.getDeclaredVariables(node)).toMatchInlineSnapshot(` + Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"TypeDecl">, + node: TSTypeAliasDeclaration$1, + }, + ], + name: "TypeDecl", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ] + `); + }); + + it('defines a variable for an interface definition', () => { + const { ast, scopeManager } = parseAndAnalyze(` + interface InterfaceDecl { + prop: string; + } + `); + const node = getSpecificNode(ast, AST_NODE_TYPES.TSInterfaceDeclaration); + expect(scopeManager.getDeclaredVariables(node)).toMatchInlineSnapshot(` + Array [ + Variable$1 { + defs: Array [ + TypeDefinition$1 { + name: Identifier<"InterfaceDecl">, + node: TSInterfaceDeclaration$1, + }, + ], + name: "InterfaceDecl", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ] + `); + }); + + it('defines a variable for a generic type', () => { + const { ast, scopeManager } = parseAndAnalyze(` + type TypeDecl = string; + `); + const node = getSpecificNode(ast, AST_NODE_TYPES.TSTypeParameter); + expect(scopeManager.getDeclaredVariables(node)).toMatchInlineSnapshot(` + Array [ + Variable$2 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"TypeParam">, + node: TSTypeParameter$1, + }, + ], + name: "TypeParam", + references: Array [], + isValueVariable: false, + isTypeVariable: true, + }, + ] + `); + }); + + it('defines a variable for an inferred generic type', () => { + const { ast, scopeManager } = parseAndAnalyze(` + type TypeDecl = TypeParam extends Foo ? Inferred : never; + `); + const node = getSpecificNode( + ast, + AST_NODE_TYPES.TSInferType, + n => n.typeParameter, + ); + expect(scopeManager.getDeclaredVariables(node)).toMatchInlineSnapshot(` + Array [ + Variable$3 { + defs: Array [ + TypeDefinition$3 { + name: Identifier<"Inferred">, + node: TSTypeParameter$1, + }, + ], + name: "Inferred", + references: Array [ + Reference$3 { + identifier: Identifier<"Inferred">, + isTypeReference: true, + isValueReference: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ] + `); + }); +}); diff --git a/packages/scope-manager/tests/util/expect.ts b/packages/scope-manager/tests/util/expect.ts new file mode 100644 index 00000000000..0057af9f85c --- /dev/null +++ b/packages/scope-manager/tests/util/expect.ts @@ -0,0 +1,138 @@ +import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/types'; +import { + CatchClauseDefinition, + ClassNameDefinition, + Definition, + DefinitionType, + FunctionNameDefinition, + ImplicitGlobalVariableDefinition, + ImportBindingDefinition, + ParameterDefinition, + VariableDefinition, +} from '../../src/definition'; +import { + BlockScope, + CatchScope, + ClassScope, + ForScope, + FunctionExpressionNameScope, + FunctionScope, + GlobalScope, + ModuleScope, + Scope, + ScopeType, + SwitchScope, + WithScope, +} from '../../src/scope'; + +////////////////// +// EXPECT SCOPE // +////////////////// + +function expectToBeBlockScope(scope: Scope): asserts scope is BlockScope { + expect(scope.type).toBe(ScopeType.block); +} +function expectToBeCatchScope(scope: Scope): asserts scope is CatchScope { + expect(scope.type).toBe(ScopeType.catch); +} +function expectToBeClassScope(scope: Scope): asserts scope is ClassScope { + expect(scope.type).toBe(ScopeType.class); +} +function expectToBeForScope(scope: Scope): asserts scope is ForScope { + expect(scope.type).toBe(ScopeType.for); +} +function expectToBeFunctionScope(scope: Scope): asserts scope is FunctionScope { + expect(scope.type).toBe(ScopeType.function); +} +function expectToBeFunctionExpressionNameScope( + scope: Scope, +): asserts scope is FunctionExpressionNameScope { + expect(scope.type).toBe(ScopeType.functionExpressionName); +} +function expectToBeGlobalScope(scope: Scope): asserts scope is GlobalScope { + expect(scope.type).toBe(ScopeType.global); +} +function expectToBeModuleScope(scope: Scope): asserts scope is ModuleScope { + expect(scope.type).toBe(ScopeType.module); +} +function expectToBeSwitchScope(scope: Scope): asserts scope is SwitchScope { + expect(scope.type).toBe(ScopeType.switch); +} +function expectToBeWithScope(scope: Scope): asserts scope is WithScope { + expect(scope.type).toBe(ScopeType.with); +} + +export { + expectToBeBlockScope, + expectToBeCatchScope, + expectToBeClassScope, + expectToBeForScope, + expectToBeFunctionExpressionNameScope, + expectToBeFunctionScope, + expectToBeGlobalScope, + expectToBeModuleScope, + expectToBeSwitchScope, + expectToBeWithScope, +}; + +/////////////////////// +// EXPECT DEFINITION // +/////////////////////// + +function expectToBeCatchClauseDefinition( + def: Definition, +): asserts def is CatchClauseDefinition { + expect(def.type).toBe(DefinitionType.CatchClause); +} +function expectToBeClassNameDefinition( + def: Definition, +): asserts def is ClassNameDefinition { + expect(def.type).toBe(DefinitionType.ClassName); +} +function expectToBeFunctionNameDefinition( + def: Definition, +): asserts def is FunctionNameDefinition { + expect(def.type).toBe(DefinitionType.FunctionName); +} +function expectToBeImplicitGlobalVariableDefinition( + def: Definition, +): asserts def is ImplicitGlobalVariableDefinition { + expect(def.type).toBe(DefinitionType.ImplicitGlobalVariable); +} +function expectToBeImportBindingDefinition( + def: Definition, +): asserts def is ImportBindingDefinition { + expect(def.type).toBe(DefinitionType.ImportBinding); +} +function expectToBeParameterDefinition( + def: Definition, +): asserts def is ParameterDefinition { + expect(def.type).toBe(DefinitionType.Parameter); +} +function expectToBeVariableDefinition( + def: Definition, +): asserts def is VariableDefinition { + expect(def.type).toBe(DefinitionType.Variable); +} + +export { + expectToBeCatchClauseDefinition, + expectToBeClassNameDefinition, + expectToBeFunctionNameDefinition, + expectToBeImplicitGlobalVariableDefinition, + expectToBeImportBindingDefinition, + expectToBeParameterDefinition, + expectToBeVariableDefinition, +}; + +///////////////// +// EXPECT MISC // +///////////////// + +function expectToBeIdentifier( + node: TSESTree.Node | null | undefined, +): asserts node is TSESTree.Identifier { + expect(node?.type).toBe(AST_NODE_TYPES.Identifier); +} + +export { expectToBeIdentifier }; diff --git a/packages/scope-manager/tests/util/getSpecificNode.ts b/packages/scope-manager/tests/util/getSpecificNode.ts new file mode 100644 index 00000000000..d20ab14ff58 --- /dev/null +++ b/packages/scope-manager/tests/util/getSpecificNode.ts @@ -0,0 +1,52 @@ +import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/types'; +import { simpleTraverse } from '@typescript-eslint/typescript-estree'; + +function getSpecificNode< + TSelector extends AST_NODE_TYPES, + TNode extends Extract +>(ast: TSESTree.Node, selector: TSelector): TNode; +function getSpecificNode< + TSelector extends AST_NODE_TYPES, + TNode extends Extract +>( + ast: TSESTree.Node, + selector: TSelector, + cb: (node: TNode) => boolean | null | undefined, +): TNode; +function getSpecificNode< + TSelector extends AST_NODE_TYPES, + TNode extends Extract, + TReturnType extends TSESTree.Node +>( + ast: TSESTree.Node, + selector: TSelector, + cb: (node: TNode) => TReturnType | null | undefined, +): TReturnType; + +function getSpecificNode( + ast: TSESTree.Node, + selector: AST_NODE_TYPES, + cb?: (node: TSESTree.Node) => TSESTree.Node | boolean | null | undefined, +): TSESTree.Node { + let node: TSESTree.Node | null | undefined = null; + simpleTraverse( + ast, + { + [selector](n) { + const res = cb ? cb(n) : n; + if (res) { + // the callback shouldn't match multiple nodes or else tests may behave weirdly + expect(node).toBeFalsy(); + node = typeof res === 'boolean' ? n : res; + } + }, + }, + true, + ); + + // should have found at least one node + expect(node).not.toBeFalsy(); + return node!; +} + +export { getSpecificNode }; diff --git a/packages/scope-manager/tests/util/index.ts b/packages/scope-manager/tests/util/index.ts new file mode 100644 index 00000000000..295dda41ae7 --- /dev/null +++ b/packages/scope-manager/tests/util/index.ts @@ -0,0 +1,3 @@ +export * from './expect'; +export * from './getSpecificNode'; +export * from './parse'; diff --git a/packages/scope-manager/tests/util/parse.ts b/packages/scope-manager/tests/util/parse.ts new file mode 100644 index 00000000000..98505579636 --- /dev/null +++ b/packages/scope-manager/tests/util/parse.ts @@ -0,0 +1,66 @@ +import * as tseslint from '@typescript-eslint/typescript-estree'; +import { ParserOptions } from '@typescript-eslint/types'; +import { analyze, AnalyzeOptions } from '../../src/analyze'; + +type SourceType = AnalyzeOptions['sourceType']; + +const DEFAULT_PARSER_OPTIONS = { + // the analyser requires ranges to work + range: true, +}; +const DEFAULT_ANALYZE_OPTIONS = { + // include no libs so we don't pollute tests + lib: [], +}; + +function parse( + code: string, + sourceTypeOrParserOptions: + | SourceType + | ParserOptions = DEFAULT_PARSER_OPTIONS, +): ReturnType { + return tseslint.parse(code, { + ...DEFAULT_PARSER_OPTIONS, + ...(typeof sourceTypeOrParserOptions === 'string' + ? { + sourceType: sourceTypeOrParserOptions, + } + : sourceTypeOrParserOptions), + }); +} + +interface ParseAndAnalyze { + ast: ReturnType; + scopeManager: ReturnType; +} +function parseAndAnalyze(code: string, sourceType: SourceType): ParseAndAnalyze; +function parseAndAnalyze( + code: string, + analyzeOptions?: AnalyzeOptions, + parserOptions?: ParserOptions, +): ParseAndAnalyze; +function parseAndAnalyze( + code: string, + sourceTypeOrAnalyzeOption: + | SourceType + | AnalyzeOptions = DEFAULT_ANALYZE_OPTIONS, + parserOptions: ParserOptions = DEFAULT_PARSER_OPTIONS, +): ParseAndAnalyze { + const sourceType = + typeof sourceTypeOrAnalyzeOption === 'string' + ? sourceTypeOrAnalyzeOption + : sourceTypeOrAnalyzeOption.sourceType; + const ast = parse(code, { sourceType, ...parserOptions }); + + const analyzeOptions = { + ...DEFAULT_ANALYZE_OPTIONS, + ...(typeof sourceTypeOrAnalyzeOption === 'string' + ? { sourceType } + : sourceTypeOrAnalyzeOption), + }; + const scopeManager = analyze(ast, analyzeOptions); + + return { ast, scopeManager }; +} + +export { parse, parseAndAnalyze, AnalyzeOptions }; diff --git a/packages/scope-manager/tests/util/serializers/DefinitionBase.ts b/packages/scope-manager/tests/util/serializers/DefinitionBase.ts new file mode 100644 index 00000000000..a65781553d1 --- /dev/null +++ b/packages/scope-manager/tests/util/serializers/DefinitionBase.ts @@ -0,0 +1,20 @@ +import { createSerializer } from './baseSerializer'; +import { DefinitionBase } from '../../../src/definition/DefinitionBase'; + +// hacking around the fact that you can't use abstract classes generically +// eslint-disable-next-line @typescript-eslint/no-explicit-any +class DefinitionInstance extends DefinitionBase { + isTypeDefinition = false; + isVariableDefinition = false; +} +const serializer = createSerializer( + DefinitionBase, + [ + // + 'name', + 'node', + ], + DefinitionInstance, +); + +export { serializer }; diff --git a/packages/scope-manager/tests/util/serializers/Reference.ts b/packages/scope-manager/tests/util/serializers/Reference.ts new file mode 100644 index 00000000000..ea083870297 --- /dev/null +++ b/packages/scope-manager/tests/util/serializers/Reference.ts @@ -0,0 +1,13 @@ +import { createSerializer } from './baseSerializer'; +import { Reference } from '../../../src/referencer/Reference'; + +const serializer = createSerializer(Reference, [ + 'identifier', + 'init', + 'isTypeReference', + 'isValueReference', + 'resolved', + 'writeExpr', +]); + +export { serializer }; diff --git a/packages/scope-manager/tests/util/serializers/ScopeBase.ts b/packages/scope-manager/tests/util/serializers/ScopeBase.ts new file mode 100644 index 00000000000..fea57627e81 --- /dev/null +++ b/packages/scope-manager/tests/util/serializers/ScopeBase.ts @@ -0,0 +1,22 @@ +import { createSerializer } from './baseSerializer'; +import { ScopeBase } from '../../../src/scope/ScopeBase'; + +// hacking around the fact that you can't use abstract classes generically +// eslint-disable-next-line @typescript-eslint/no-explicit-any +class ScopeInstance extends ScopeBase {} +const serializer = createSerializer( + ScopeBase, + [ + // + 'block', + 'isStrict', + 'references', + 'set', + 'type', + 'upper', + 'variables', + ], + ScopeInstance, +); + +export { serializer }; diff --git a/packages/scope-manager/tests/util/serializers/ScopeManager.ts b/packages/scope-manager/tests/util/serializers/ScopeManager.ts new file mode 100644 index 00000000000..4b10150f179 --- /dev/null +++ b/packages/scope-manager/tests/util/serializers/ScopeManager.ts @@ -0,0 +1,10 @@ +import { createSerializer } from './baseSerializer'; +import { ScopeManager } from '../../../src/ScopeManager'; + +const serializer = createSerializer(ScopeManager, [ + // purposely put variables first + 'variables', + 'scopes', +]); + +export { serializer }; diff --git a/packages/scope-manager/tests/util/serializers/TSESTreeNode.ts b/packages/scope-manager/tests/util/serializers/TSESTreeNode.ts new file mode 100644 index 00000000000..4611ddcce73 --- /dev/null +++ b/packages/scope-manager/tests/util/serializers/TSESTreeNode.ts @@ -0,0 +1,50 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/types'; +import { NewPlugin } from 'pretty-format'; +import { createIdGenerator } from '../../../src/ID'; + +const EXCLUDED_KEYS = new Set([ + // prevent cycles + 'parent', + // type is printed in front of the object + 'type', + // locations are just noise + 'range', + 'loc', +]); + +const generator = createIdGenerator(); +type Node = Record & { type: AST_NODE_TYPES }; +const SEEN_NODES = new Map(); + +const serializer: NewPlugin = { + test(val): boolean { + return ( + val && + typeof val === 'object' && + // make sure it's not one of the classes from the package + Object.getPrototypeOf(val) === Object.prototype && + 'type' in val && + val.type in AST_NODE_TYPES + ); + }, + serialize(node: Node): string { + if (node.type === AST_NODE_TYPES.Identifier) { + return `Identifier<"${node.name}">`; + } + + const keys = Object.keys(node).filter(k => !EXCLUDED_KEYS.has(k)); + if (keys.length === 0) { + return `${node.type}`; + } + + if (SEEN_NODES.has(node)) { + return `${node.type}$${SEEN_NODES.get(node)}`; + } + + const id = generator(); + SEEN_NODES.set(node, id); + return `${node.type}$${id}`; + }, +}; + +export { serializer }; diff --git a/packages/scope-manager/tests/util/serializers/Variable.ts b/packages/scope-manager/tests/util/serializers/Variable.ts new file mode 100644 index 00000000000..55dbe2fa9b8 --- /dev/null +++ b/packages/scope-manager/tests/util/serializers/Variable.ts @@ -0,0 +1,13 @@ +import { createSerializer } from './baseSerializer'; +import { Variable } from '../../../src/variable'; + +const serializer = createSerializer(Variable, [ + // + 'defs', + 'name', + 'references', + 'isValueVariable', + 'isTypeVariable', +]); + +export { serializer }; diff --git a/packages/scope-manager/tests/util/serializers/baseSerializer.ts b/packages/scope-manager/tests/util/serializers/baseSerializer.ts new file mode 100644 index 00000000000..df8ba1fba11 --- /dev/null +++ b/packages/scope-manager/tests/util/serializers/baseSerializer.ts @@ -0,0 +1,78 @@ +import { NewPlugin } from 'pretty-format'; + +type ConstructorSignature = new (...args: never) => unknown; + +function createSerializer( + type: TConstructor, + keys: (keyof InstanceType)[], +): NewPlugin; +// A hack of signature to enable this to work with abstract classes +function createSerializer( + abstractConstructor: unknown, + keys: (keyof InstanceType)[], + instanceConstructorThatsNeverUsed: TConstructor, +): NewPlugin; + +function createSerializer( + type: TConstructor, + keys: (keyof InstanceType)[], +): NewPlugin { + const SEEN_THINGS = new Set(); + + return { + test(val): boolean { + return val instanceof type; + }, + serialize( + thing: Record & { $id?: number }, + config, + indentation, + depth, + refs, + printer, + ): string { + const id = thing.$id != null ? `$${thing.$id}` : ''; + // If `type` is a base class, we should print out the name of the subclass + const constructorName = Object.getPrototypeOf(thing).constructor.name; + + const name = `${constructorName}${id}`; + + if (thing.$id) { + if (SEEN_THINGS.has(thing)) { + return `${name}`; + } + SEEN_THINGS.add(thing); + } + + const outputLines = []; + const childIndentation = indentation + config.indent; + for (const key of keys) { + let value = thing[key as string]; + if (value === undefined) { + continue; + } + if (typeof value === 'function') { + value = value.call(thing); + } + + outputLines.push( + `${childIndentation}${key}: ${printer( + value, + config, + childIndentation, + depth, + refs, + )},`, + ); + } + + outputLines.unshift(`${name} {`); + outputLines.push(`${indentation}}`); + + const out = outputLines.join('\n'); + return out; + }, + }; +} + +export { createSerializer }; diff --git a/packages/scope-manager/tests/util/serializers/index.ts b/packages/scope-manager/tests/util/serializers/index.ts new file mode 100644 index 00000000000..d2e024d7f6c --- /dev/null +++ b/packages/scope-manager/tests/util/serializers/index.ts @@ -0,0 +1,28 @@ +import { addSerializer } from 'jest-specific-snapshot'; +import * as DefinitionBase from './DefinitionBase'; +import * as Reference from './Reference'; +import * as ScopeBase from './ScopeBase'; +import * as ScopeManager from './ScopeManager'; +import * as TSESTreeNode from './TSESTreeNode'; +import * as Variable from './Variable'; +import { resetIds } from '../../../src/ID'; + +const serializers = [ + DefinitionBase.serializer, + Reference.serializer, + ScopeBase.serializer, + ScopeManager.serializer, + TSESTreeNode.serializer, + Variable.serializer, +]; + +for (const serializer of serializers) { + // the jest types are wrong here + expect.addSnapshotSerializer(serializer); + addSerializer(serializer); +} + +// make sure the snapshots are isolated from one another +beforeEach(() => { + resetIds(); +}); diff --git a/packages/scope-manager/tools/generate-lib.ts b/packages/scope-manager/tools/generate-lib.ts new file mode 100644 index 00000000000..b1e4048d592 --- /dev/null +++ b/packages/scope-manager/tools/generate-lib.ts @@ -0,0 +1,216 @@ +import { TSESTree, AST_TOKEN_TYPES } from '@typescript-eslint/types'; +import * as fs from 'fs'; +import * as path from 'path'; +import { format, resolveConfig } from 'prettier'; +import rimraf from 'rimraf'; +import * as ts from 'typescript'; +import { ScopeManager, Variable } from '../src'; +import { parseAndAnalyze } from '../tests/util/parse'; + +const libMap = new Map(ts.libMap); +// add the "full" libs as well - these are used by the default config resolution system +for (const [lib] of ts.libMap) { + if ( + (/^es2\d{3}$/.test(lib) || lib === 'esnext') && + // there's no "full" lib for es2015 + lib !== 'es2015' + ) { + libMap.set(`${lib}.full`, `lib.${lib}.full.d.ts`); + } +} +// the base lib used when the target is unknown +libMap.set('lib', 'lib.d.ts'); + +function addAutoGeneratedComment(code: string[]): string { + return [ + '// THIS CODE WAS AUTOMATICALLY GENERATED', + '// DO NOT EDIT THIS CODE BY HAND', + '// YOU CAN REGENERATE IT USING yarn generate:lib', + '', + ...code, + ].join('\n'); +} + +const PRETTIER_CONFIG = resolveConfig.sync(__dirname); +const TS_LIB_FOLDER = path.resolve( + __dirname, + '..', + '..', + '..', + 'node_modules', + 'typescript', + 'lib', +); +const OUTPUT_FOLDER = path.resolve(__dirname, '..', 'src', 'lib'); +const TYPES_FILE = path.resolve( + __dirname, + '..', + '..', + 'types', + 'src', + 'lib.ts', +); + +function formatCode(code: string[]): string { + return format(addAutoGeneratedComment(code), { + parser: 'typescript', + ...PRETTIER_CONFIG, + }); +} + +function sanitize(name: string): string { + return name.replace(/\./g, '_'); +} + +function getVariablesFromScope(scopeManager: ScopeManager): Variable[] { + const scope = scopeManager.globalScope!.childScopes[0]; + const variables: Variable[] = []; + for (const variable of scope.variables) { + if (variable.isTypeVariable) { + variables.push(variable); + } + } + + return variables; +} + +const REFERENCE_REGEX = /\/ /; +function getReferences( + ast: TSESTree.Program & { comments?: TSESTree.Comment[] }, +): Set { + const comments = ast.comments!.filter( + c => + c.type === AST_TOKEN_TYPES.Line && + c.value.startsWith('/ 0) { + code.unshift(...imports, ''); + } + + // mark all of the variables + const variables = getVariablesFromScope(scopeManager); + for (const variable of variables) { + code.push( + `'${variable.name}': ${JSON.stringify({ + eslintImplicitGlobalSetting: 'readonly', + isTypeVariable: variable.isTypeVariable, + isValueVariable: variable.isValueVariable, + name: variable.name, + writeable: false, + })},`, + ); + } + code.push('} as Record;'); + + const formattedCode = formatCode(code); + fs.writeFileSync(path.join(OUTPUT_FOLDER, `${libName}.ts`), formattedCode); + + console.log( + 'Wrote', + variables.length, + 'variables, and', + references.size, + 'references for', + libName, + ); + } + + // generate and write a barrel file + const barrelImports = []; // use a separate way so everything is in the same order + const barrelCode = ['', `const lib = {`]; + for (const lib of libMap.keys()) { + const name = sanitize(lib); + if (name === 'lib') { + barrelImports.push(`import { lib as libBase } from './${lib}'`); + barrelCode.push(`'${lib}': libBase,`); + } else { + barrelImports.push(`import { ${name} } from './${lib}'`); + barrelCode.push(lib === name ? `${lib},` : `'${lib}': ${name},`); + } + } + barrelCode.unshift(...barrelImports); + barrelCode.push('} as const;'); + + barrelCode.push('', 'export { lib };'); + + const formattedBarrelCode = formatCode(barrelCode); + + fs.writeFileSync(path.join(OUTPUT_FOLDER, 'index.ts'), formattedBarrelCode); + console.log('Wrote barrel file'); + + // generate a string union type for the lib names + + const libUnionCode = [ + `type Lib = ${Array.from(libMap.keys()) + .map(k => `'${k}'`) + .join(' | ')};`, + '', + 'export { Lib };', + ]; + const formattedLibUnionCode = formatCode(libUnionCode); + + fs.writeFileSync(TYPES_FILE, formattedLibUnionCode); + console.log('Wrote Lib union type file'); +} + +main(); diff --git a/packages/scope-manager/tsconfig.build.json b/packages/scope-manager/tsconfig.build.json new file mode 100644 index 00000000000..a67b4c6cfeb --- /dev/null +++ b/packages/scope-manager/tsconfig.build.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./dist", + "rootDir": "./src", + "resolveJsonModule": true + }, + "include": ["src", "typings"], + "exclude": ["tests/fixtures"], + "references": [ + { "path": "../types/tsconfig.build.json" }, + { "path": "../typescript-estree/tsconfig.build.json" }, + { "path": "../visitor-keys/tsconfig.build.json" } + ] +} diff --git a/packages/scope-manager/tsconfig.json b/packages/scope-manager/tsconfig.json new file mode 100644 index 00000000000..9cea515ba6b --- /dev/null +++ b/packages/scope-manager/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.build.json", + "compilerOptions": { + "composite": false, + "rootDir": "." + }, + "include": ["src", "typings", "tests", "tools"] +} diff --git a/packages/scope-manager/typings/typescript.d.ts b/packages/scope-manager/typings/typescript.d.ts new file mode 100644 index 00000000000..354cbeefda4 --- /dev/null +++ b/packages/scope-manager/typings/typescript.d.ts @@ -0,0 +1,13 @@ +import 'typescript'; + +// aliasing because the TS namespace annoyingly declares its own Map type +type StringMap = Map; +declare module 'typescript' { + /** + * Map of available libraries + * + * The key is the key used in compilerOptions.lib + * The value is the file name + */ + const libMap: StringMap; +} diff --git a/packages/types/package.json b/packages/types/package.json index 22591b557c9..5d4ad4fd9ca 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -31,6 +31,7 @@ "build": "tsc -b tsconfig.build.json", "clean": "tsc -b tsconfig.build.json --clean", "format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore", + "generate:lib": "../../node_modules/.bin/ts-node --files --transpile-only ../scope-manager/tools/generate-lib.ts", "lint": "eslint . --ext .js,.ts --ignore-path='../../.eslintignore'", "test": "jest --coverage", "typecheck": "tsc -p tsconfig.json --noEmit" diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 94bbdfab66d..59df48302df 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -1,4 +1,5 @@ export { AST_NODE_TYPES } from './ast-node-types'; export { AST_TOKEN_TYPES } from './ast-token-types'; +export * from './lib'; export * from './parser-options'; export * as TSESTree from './ts-estree'; diff --git a/packages/types/src/lib.ts b/packages/types/src/lib.ts new file mode 100644 index 00000000000..cbae36be6a2 --- /dev/null +++ b/packages/types/src/lib.ts @@ -0,0 +1,64 @@ +// THIS CODE WAS AUTOMATICALLY GENERATED +// DO NOT EDIT THIS CODE BY HAND +// YOU CAN REGENERATE IT USING yarn generate:lib + +type Lib = + | 'es5' + | 'es6' + | 'es2015' + | 'es7' + | 'es2016' + | 'es2017' + | 'es2018' + | 'es2019' + | 'es2020' + | 'esnext' + | 'dom' + | 'dom.iterable' + | 'webworker' + | 'webworker.importscripts' + | 'scripthost' + | 'es2015.core' + | 'es2015.collection' + | 'es2015.generator' + | 'es2015.iterable' + | 'es2015.promise' + | 'es2015.proxy' + | 'es2015.reflect' + | 'es2015.symbol' + | 'es2015.symbol.wellknown' + | 'es2016.array.include' + | 'es2017.object' + | 'es2017.sharedmemory' + | 'es2017.string' + | 'es2017.intl' + | 'es2017.typedarrays' + | 'es2018.asyncgenerator' + | 'es2018.asynciterable' + | 'es2018.intl' + | 'es2018.promise' + | 'es2018.regexp' + | 'es2019.array' + | 'es2019.object' + | 'es2019.string' + | 'es2019.symbol' + | 'es2020.bigint' + | 'es2020.promise' + | 'es2020.string' + | 'es2020.symbol.wellknown' + | 'esnext.array' + | 'esnext.symbol' + | 'esnext.asynciterable' + | 'esnext.intl' + | 'esnext.bigint' + | 'esnext.string' + | 'esnext.promise' + | 'es2016.full' + | 'es2017.full' + | 'es2018.full' + | 'es2019.full' + | 'es2020.full' + | 'esnext.full' + | 'lib'; + +export { Lib }; diff --git a/packages/types/src/parser-options.ts b/packages/types/src/parser-options.ts index 61eacf440c7..c9623688e16 100644 --- a/packages/types/src/parser-options.ts +++ b/packages/types/src/parser-options.ts @@ -1,3 +1,5 @@ +import { Lib } from './lib'; + type DebugLevel = boolean | ('typescript-eslint' | 'eslint' | 'typescript')[]; type EcmaVersion = @@ -19,14 +21,17 @@ type EcmaVersion = type SourceType = 'script' | 'module'; interface ParserOptions { - comment?: boolean; ecmaFeatures?: { globalReturn?: boolean; jsx?: boolean; }; ecmaVersion?: EcmaVersion; - // typescript-eslint specific + // scope-manager specific + lib?: Lib[]; + + // typescript-estree specific + comment?: boolean; debugLevel?: DebugLevel; errorOnTypeScriptSyntacticAndSemanticIssues?: boolean; errorOnUnknownASTType?: boolean; diff --git a/packages/types/src/ts-estree.ts b/packages/types/src/ts-estree.ts index 9c1e14bd5b4..f268a38257b 100644 --- a/packages/types/src/ts-estree.ts +++ b/packages/types/src/ts-estree.ts @@ -331,6 +331,13 @@ export type DeclarationStatement = | TSNamespaceExportDeclaration | TSTypeAliasDeclaration | TSEnumDeclaration; +export type DestructuringPattern = + | Identifier + | ObjectPattern + | ArrayPattern + | RestElement + | AssignmentPattern + | MemberExpression; export type EntityName = Identifier | TSQualifiedName; export type ExportDeclaration = | ClassDeclaration @@ -347,6 +354,7 @@ export type Expression = | AssignmentExpression | BinaryExpression | ConditionalExpression + | ImportExpression | JSXClosingElement | JSXClosingFragment | JSXExpressionContainer @@ -360,11 +368,7 @@ export type Expression = | SpreadElement | TSAsExpression | TSUnaryExpression - | YieldExpression - | ImportExpression; -export type ExpressionWithTypeArguments = - | TSClassImplements - | TSInterfaceHeritage; + | YieldExpression; export type ForInitialiser = Expression | VariableDeclaration; export type ImportClause = | ImportDefaultSpecifier @@ -429,19 +433,12 @@ export type OptionalMemberExpression = | OptionalMemberExpressionComputedName | OptionalMemberExpressionNonComputedName; export type Parameter = - | AssignmentPattern - | RestElement | ArrayPattern - | ObjectPattern - | Identifier - | TSParameterProperty; -export type DestructuringPattern = + | AssignmentPattern | Identifier | ObjectPattern - | ArrayPattern | RestElement - | AssignmentPattern - | MemberExpression; + | TSParameterProperty; export type PrimaryExpression = | ArrayExpression | ArrayPattern @@ -514,12 +511,10 @@ export type TypeElement = | TSMethodSignature | TSPropertySignature; export type TypeNode = - | ThisExpression | TSAnyKeyword | TSArrayType | TSBigIntKeyword | TSBooleanKeyword - | TSClassImplements | TSConditionalType | TSConstructorType | TSFunctionType @@ -575,7 +570,7 @@ interface ClassDeclarationBase extends BaseNode { id: Identifier | null; body: ClassBody; superClass: LeftHandSideExpression | null; - implements?: ExpressionWithTypeArguments[]; + implements?: TSClassImplements[]; abstract?: boolean; declare?: boolean; decorators?: Decorator[]; @@ -1422,7 +1417,7 @@ export interface TSIndexSignature extends BaseNode { export interface TSInferType extends BaseNode { type: AST_NODE_TYPES.TSInferType; - typeParameter: TSTypeParameterDeclaration; + typeParameter: TSTypeParameter; } export interface TSInterfaceDeclaration extends BaseNode { @@ -1430,8 +1425,8 @@ export interface TSInterfaceDeclaration extends BaseNode { body: TSInterfaceBody; id: Identifier; typeParameters?: TSTypeParameterDeclaration; - extends?: ExpressionWithTypeArguments[]; - implements?: ExpressionWithTypeArguments[]; + extends?: TSInterfaceHeritage[]; + implements?: TSInterfaceHeritage[]; decorators?: Decorator[]; abstract?: boolean; declare?: boolean; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 2a6db370570..3f53b4c8205 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -2477,8 +2477,8 @@ export class Converter { } if (interfaceHeritageClauses.length > 0) { - const interfaceExtends: TSESTree.ExpressionWithTypeArguments[] = []; - const interfaceImplements: TSESTree.ExpressionWithTypeArguments[] = []; + const interfaceExtends: TSESTree.TSInterfaceHeritage[] = []; + const interfaceImplements: TSESTree.TSInterfaceHeritage[] = []; for (const heritageClause of interfaceHeritageClauses) { if (heritageClause.token === SyntaxKind.ExtendsKeyword) { diff --git a/packages/typescript-estree/src/simple-traverse.ts b/packages/typescript-estree/src/simple-traverse.ts index 1a25187ab26..4d4ddaa5f18 100644 --- a/packages/typescript-estree/src/simple-traverse.ts +++ b/packages/typescript-estree/src/simple-traverse.ts @@ -9,28 +9,46 @@ function isValidNode(x: any): x is TSESTree.Node { function getVisitorKeysForNode( allVisitorKeys: typeof visitorKeys, node: TSESTree.Node, -): readonly string[] { +): readonly (keyof TSESTree.Node)[] { const keys = allVisitorKeys[node.type]; - return keys ?? []; + return (keys ?? []) as never; } -interface SimpleTraverseOptions { - enter: (node: TSESTree.Node, parent: TSESTree.Node | undefined) => void; -} +type SimpleTraverseOptions = + | { + enter: (node: TSESTree.Node, parent: TSESTree.Node | undefined) => void; + } + | { + [key: string]: ( + node: TSESTree.Node, + parent: TSESTree.Node | undefined, + ) => void; + }; class SimpleTraverser { - private allVisitorKeys = visitorKeys; - private enter: SimpleTraverseOptions['enter']; + private readonly allVisitorKeys = visitorKeys; + private readonly selectors: SimpleTraverseOptions; + private readonly setParentPointers: boolean; - constructor({ enter }: SimpleTraverseOptions) { - this.enter = enter; + constructor(selectors: SimpleTraverseOptions, setParentPointers = false) { + this.selectors = selectors; + this.setParentPointers = setParentPointers; } traverse(node: unknown, parent: TSESTree.Node | undefined): void { if (!isValidNode(node)) { return; } - this.enter(node, parent); + + if (this.setParentPointers) { + node.parent = parent; + } + + if ('enter' in this.selectors) { + this.selectors.enter(node, parent); + } else if (node.type in this.selectors) { + this.selectors[node.type](node, parent); + } const keys = getVisitorKeysForNode(this.allVisitorKeys, node); if (keys.length < 1) { @@ -38,7 +56,7 @@ class SimpleTraverser { } for (const key of keys) { - const childOrChildren = node[key as keyof TSESTree.Node]; + const childOrChildren = node[key]; if (Array.isArray(childOrChildren)) { for (const child of childOrChildren) { @@ -54,6 +72,10 @@ class SimpleTraverser { export function simpleTraverse( startingNode: TSESTree.Node, options: SimpleTraverseOptions, + setParentPointers = false, ): void { - new SimpleTraverser(options).traverse(startingNode, undefined); + new SimpleTraverser(options, setParentPointers).traverse( + startingNode, + undefined, + ); } diff --git a/tests/integration/docker-compose.yml b/tests/integration/docker-compose.yml index 69f2e157f01..abe82a67cfb 100644 --- a/tests/integration/docker-compose.yml +++ b/tests/integration/docker-compose.yml @@ -23,6 +23,8 @@ services: - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - /usr/types/visitor-keys + - ../../packages/scope-manager/:/usr/scope-manager + - /usr/types/scope-manager # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/typescript-and-tslint-plugins-together:/usr/linked @@ -46,6 +48,8 @@ services: - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - /usr/types/visitor-keys + - ../../packages/scope-manager/:/usr/scope-manager + - /usr/types/scope-manager # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/vue-sfc:/usr/linked @@ -69,6 +73,8 @@ services: - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - /usr/types/visitor-keys + - ../../packages/scope-manager/:/usr/scope-manager + - /usr/types/scope-manager # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/vue-jsx:/usr/linked @@ -92,6 +98,8 @@ services: - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - /usr/types/visitor-keys + - ../../packages/scope-manager/:/usr/scope-manager + - /usr/types/scope-manager # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/recommended-does-not-require-program:/usr/linked @@ -115,6 +123,8 @@ services: - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - /usr/types/visitor-keys + - ../../packages/scope-manager/:/usr/scope-manager + - /usr/types/scope-manager # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/markdown:/usr/linked @@ -138,5 +148,7 @@ services: - /usr/types/tests - ../../packages/visitor-keys/:/usr/visitor-keys - /usr/types/visitor-keys + - ../../packages/scope-manager/:/usr/scope-manager + - /usr/types/scope-manager # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - ./fixtures/eslint-v6:/usr/linked diff --git a/tests/integration/fixtures/eslint-v6/test.sh b/tests/integration/fixtures/eslint-v6/test.sh index 9f392c3687d..ab184f9ceb1 100755 --- a/tests/integration/fixtures/eslint-v6/test.sh +++ b/tests/integration/fixtures/eslint-v6/test.sh @@ -11,6 +11,7 @@ npm install eslint@6.0.0 # Use the local volumes for our own packages npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) +npm install $(npm pack /usr/scope-manager | tail -1) npm install $(npm pack /usr/typescript-estree | tail -1) npm install $(npm pack /usr/parser | tail -1) npm install $(npm pack /usr/experimental-utils | tail -1) diff --git a/tests/integration/fixtures/markdown/test.sh b/tests/integration/fixtures/markdown/test.sh index 77dd83eaa21..30cd435eaac 100755 --- a/tests/integration/fixtures/markdown/test.sh +++ b/tests/integration/fixtures/markdown/test.sh @@ -10,6 +10,7 @@ npm install # Use the local volumes for our own packages npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) +npm install $(npm pack /usr/scope-manager | tail -1) npm install $(npm pack /usr/typescript-estree | tail -1) npm install $(npm pack /usr/parser | tail -1) npm install $(npm pack /usr/experimental-utils | tail -1) diff --git a/tests/integration/fixtures/recommended-does-not-require-program/test.sh b/tests/integration/fixtures/recommended-does-not-require-program/test.sh index 4db9f0c4491..cfe4d0e6d57 100755 --- a/tests/integration/fixtures/recommended-does-not-require-program/test.sh +++ b/tests/integration/fixtures/recommended-does-not-require-program/test.sh @@ -10,6 +10,7 @@ npm install # Use the local volumes for our own packages npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) +npm install $(npm pack /usr/scope-manager | tail -1) npm install $(npm pack /usr/typescript-estree | tail -1) npm install $(npm pack /usr/parser | tail -1) npm install $(npm pack /usr/experimental-utils | tail -1) diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh index bb0389abea2..6abbeb42aa6 100755 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh @@ -10,6 +10,7 @@ npm install # Use the local volumes for our own packages npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) +npm install $(npm pack /usr/scope-manager | tail -1) npm install $(npm pack /usr/typescript-estree | tail -1) npm install $(npm pack /usr/parser | tail -1) npm install $(npm pack /usr/experimental-utils | tail -1) diff --git a/tests/integration/fixtures/vue-jsx/test.sh b/tests/integration/fixtures/vue-jsx/test.sh index 71932d4e7ae..96376fb0f83 100755 --- a/tests/integration/fixtures/vue-jsx/test.sh +++ b/tests/integration/fixtures/vue-jsx/test.sh @@ -10,6 +10,7 @@ npm install # Use the local volumes for our own packages npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) +npm install $(npm pack /usr/scope-manager | tail -1) npm install $(npm pack /usr/typescript-estree | tail -1) npm install $(npm pack /usr/parser | tail -1) npm install $(npm pack /usr/experimental-utils | tail -1) diff --git a/tests/integration/fixtures/vue-sfc/test.sh b/tests/integration/fixtures/vue-sfc/test.sh index 71932d4e7ae..96376fb0f83 100755 --- a/tests/integration/fixtures/vue-sfc/test.sh +++ b/tests/integration/fixtures/vue-sfc/test.sh @@ -10,6 +10,7 @@ npm install # Use the local volumes for our own packages npm install $(npm pack /usr/types | tail -1) npm install $(npm pack /usr/visitor-keys | tail -1) +npm install $(npm pack /usr/scope-manager | tail -1) npm install $(npm pack /usr/typescript-estree | tail -1) npm install $(npm pack /usr/parser | tail -1) npm install $(npm pack /usr/experimental-utils | tail -1) diff --git a/yarn.lock b/yarn.lock index 337037083ad..f8a10181b05 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1549,6 +1549,14 @@ resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g== +"@types/glob@*": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.2.tgz#06ca26521353a545d94a0adc74f38a59d232c987" + integrity sha512-VgNIkxK+j7Nz5P7jvUZlRvhuPSmsEfS03b0alKcq5V/STUKAa3Plemsn5mrQUO7am6OErJ4rhGEGJbACclrtRA== + dependencies: + "@types/minimatch" "*" + "@types/node" "*" + "@types/glob@^7.1.1": version "7.1.1" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575" @@ -1590,7 +1598,14 @@ "@types/istanbul-lib-coverage" "*" "@types/istanbul-lib-report" "*" -"@types/jest@^25.2.1": +"@types/jest-specific-snapshot@^0.5.4": + version "0.5.4" + resolved "https://registry.yarnpkg.com/@types/jest-specific-snapshot/-/jest-specific-snapshot-0.5.4.tgz#997364c39a59ddeff0ee790a19415e79dd061d1e" + integrity sha512-1qISn4fH8wkOOPFEx+uWRRjw6m/pP/It3OHLm8Ee1KQpO7Z9ZGYDtWPU5AgK05UXsNTAgOK+dPQvJKGdy9E/1g== + dependencies: + "@types/jest" "*" + +"@types/jest@*", "@types/jest@^25.2.1": version "25.2.1" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-25.2.1.tgz#9544cd438607955381c1bdbdb97767a249297db5" integrity sha512-msra1bCaAeEdkSyA0CZ6gW1ukMIvZ5YoJkdXw/qhQdsuuDlFTcEUrUw8CLCPt2rVRUfXlClVvK2gvPs9IokZaA== @@ -1623,7 +1638,19 @@ resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6" integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= -"@types/node@*", "@types/node@>= 8", "@types/node@^13.13.5": +"@types/mkdirp@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-1.0.0.tgz#16ce0eabe4a9a3afe64557ad0ee6886ec3d32927" + integrity sha512-ONFY9//bCEr3DWKON3iDv/Q8LXnhaYYaNDeFSN0AtO5o4sLf9F0pstJKKKjQhXE0kJEeHs8eR6SAsROhhc2Csw== + dependencies: + "@types/node" "*" + +"@types/node@*", "@types/node@>= 8": + version "12.12.7" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.7.tgz#01e4ea724d9e3bd50d90c11fd5980ba317d8fa11" + integrity sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w== + +"@types/node@^13.13.5": version "13.13.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.5.tgz#96ec3b0afafd64a4ccea9107b75bf8489f0e5765" integrity sha512-3ySmiBYJPqgjiHA7oEaIo2Rzz0HrOZ7yrNO5HWyaE5q0lQ3BppDZ3N53Miz8bw2I7gh1/zir2MGVZBvpb1zq9g== @@ -1648,6 +1675,14 @@ resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.0.0.tgz#dc85454b953178cc6043df5208b9e949b54a3bc4" integrity sha512-/rM+sWiuOZ5dvuVzV37sUuklsbg+JPOP8d+nNFlo2ZtfpzPiPvh1/gc8liWOLBqe+sR+ZM7guPaIcTt6UZTo7Q== +"@types/rimraf@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-3.0.0.tgz#b9d03f090ece263671898d57bb7bb007023ac19f" + integrity sha512-7WhJ0MdpFgYQPXlF4Dx+DhgvlPCfz/x5mHaeDQAKhcenvQP1KCpLQ18JklAqeGMYSAT2PxLpzd0g2/HE7fj7hQ== + dependencies: + "@types/glob" "*" + "@types/node" "*" + "@types/semver@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.1.0.tgz#c8c630d4c18cd326beff77404887596f96408408" @@ -5378,7 +5413,7 @@ jest-serializer@^25.5.0: dependencies: graceful-fs "^4.2.4" -jest-snapshot@^25.5.1: +jest-snapshot@^25.1.0, jest-snapshot@^25.5.1: version "25.5.1" resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-25.5.1.tgz#1a2a576491f9961eb8d00c2e5fd479bc28e5ff7f" integrity sha512-C02JE1TUe64p2v1auUJ2ze5vcuv32tkv9PyhEb318e8XOKF7MOyXdJ7kdjbvrp3ChPLU2usI7Rjxs97Dj5P0uQ== @@ -5399,6 +5434,13 @@ jest-snapshot@^25.5.1: pretty-format "^25.5.0" semver "^6.3.0" +jest-specific-snapshot@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/jest-specific-snapshot/-/jest-specific-snapshot-3.0.0.tgz#c203a6bccc572832aea0278feeaa3350567a306f" + integrity sha512-dMEDxj762XleVVUYnxHbRypWOxRwV3HsolUZugISyFu8jE6Xz58TkeKeXxRfT9oG6U8zxPggrH+1MSNVyLwGqg== + dependencies: + jest-snapshot "^25.1.0" + jest-util@^25.5.0: version "25.5.0" resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-25.5.0.tgz#31c63b5d6e901274d264a4fec849230aa3fa35b0" @@ -5910,7 +5952,7 @@ make-dir@^2.1.0: pify "^4.0.1" semver "^5.6.0" -make-dir@^3.0.0: +make-dir@^3.0.0, make-dir@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== @@ -7538,6 +7580,13 @@ retry@^0.10.0: resolved "https://registry.yarnpkg.com/retry/-/retry-0.10.1.tgz#e76388d217992c252750241d3d3956fed98d8ff4" integrity sha1-52OI0heZLCUnUCQdPTlW/tmNj/Q= +rimraf@*, rimraf@^3.0.0, rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== + dependencies: + glob "^7.1.3" + rimraf@2.6.3: version "2.6.3" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" @@ -7552,13 +7601,6 @@ rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.2, rimraf@^2.6.3: dependencies: glob "^7.1.3" -rimraf@^3.0.0, rimraf@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" - integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== - dependencies: - glob "^7.1.3" - rsvp@^4.8.4: version "4.8.5" resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"