From 58be6e0e60d2471adffc52c56cd56378b7122a8a Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 4 Feb 2019 02:31:42 +0100 Subject: [PATCH 01/13] refactor(parser): add ast types to parser --- packages/parser/src/analyze-scope.ts | 282 ++++++++---------- packages/parser/src/parser.ts | 10 +- packages/parser/src/typings.d.ts | 270 ++++++++--------- .../typescript-estree/src/parser-options.ts | 10 +- packages/typescript-estree/src/parser.ts | 10 +- packages/typescript-estree/src/typedefs.ts | 3 +- 6 files changed, 267 insertions(+), 318 deletions(-) diff --git a/packages/parser/src/analyze-scope.ts b/packages/parser/src/analyze-scope.ts index 2e8ae2e0a3cd..cd04898e2ee7 100644 --- a/packages/parser/src/analyze-scope.ts +++ b/packages/parser/src/analyze-scope.ts @@ -11,7 +11,7 @@ import { PatternVisitorCallback, PatternVisitorOptions } from 'eslint-scope/lib/options'; -import { Node } from 'estree'; +import { es } from '@typescript-eslint/typescript-estree'; /** * Define the override function of `Scope#__define` for global augmentation. @@ -35,7 +35,7 @@ class EnumScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: es.Node | null ) { // @ts-ignore super(scopeManager, 'enum', upperScope, block, false); @@ -51,7 +51,7 @@ class PatternVisitor extends OriginalPatternVisitor { super(options, rootPattern, callback); } - Identifier(node: any) { + Identifier(node: es.Identifier): void { super.Identifier(node); if (node.decorators) { this.rightHandNodes.push(...node.decorators); @@ -61,27 +61,29 @@ class PatternVisitor extends OriginalPatternVisitor { } } - ArrayPattern(node: any) { + ArrayPattern(node: es.ArrayPattern): void { node.elements.forEach(this.visit, this); - if (node.decorators) { - this.rightHandNodes.push(...node.decorators); + // TODO: there is no decorators in definition of ArrayPattern + if ((node as any).decorators) { + this.rightHandNodes.push(...(node as any).decorators); } if (node.typeAnnotation) { this.rightHandNodes.push(node.typeAnnotation); } } - ObjectPattern(node: any) { + ObjectPattern(node: es.ObjectPattern): void { node.properties.forEach(this.visit, this); - if (node.decorators) { - this.rightHandNodes.push(...node.decorators); + // TODO: there is no decorators in definition of ObjectPattern + if ((node as any).decorators) { + this.rightHandNodes.push(...(node as any).decorators); } if (node.typeAnnotation) { this.rightHandNodes.push(node.typeAnnotation); } } - RestElement(node: any) { + RestElement(node: es.RestElement): void { super.RestElement(node); if (node.typeAnnotation) { this.rightHandNodes.push(node.typeAnnotation); @@ -99,16 +101,15 @@ class Referencer extends OriginalReferencer { /** * Override to use PatternVisitor we overrode. - * @param {Identifier} node The Identifier node to visit. - * @param {Object} [options] The flag to visit right-hand side nodes. - * @param {Function} callback The callback function for left-hand side nodes. - * @returns {void} + * @param node The Identifier node to visit. + * @param [options] The flag to visit right-hand side nodes. + * @param callback The callback function for left-hand side nodes. */ - visitPattern( - node: any, + visitPattern( + node: T, options: PatternVisitorOptions, callback: PatternVisitorCallback - ) { + ): void { if (!node) { return; } @@ -130,10 +131,14 @@ class Referencer extends OriginalReferencer { /** * Override. * Visit `node.typeParameters` and `node.returnType` additionally to find `typeof` expressions. - * @param {FunctionDeclaration|FunctionExpression|ArrowFunctionExpression} node The function node to visit. - * @returns {void} - */ - visitFunction(node: any) { + * @param node The function node to visit. + */ + visitFunction( + node: + | es.FunctionDeclaration + | es.FunctionExpression + | es.ArrowFunctionExpression + ): void { const { type, id, typeParameters, params, returnType, body } = node; const scopeManager = this.scopeManager; const upperScope = this.currentScope(); @@ -189,10 +194,12 @@ class Referencer extends OriginalReferencer { this.visit(returnType); // Process the body. - if (body.type === 'BlockStatement') { - this.visitChildren(body); - } else { - this.visit(body); + if (body) { + if (body.type === 'BlockStatement') { + this.visitChildren(body); + } else { + this.visit(body); + } } // Close the function scope. @@ -202,10 +209,9 @@ class Referencer extends OriginalReferencer { /** * Override. * Visit decorators. - * @param {ClassDeclaration|ClassExpression} node The class node to visit. - * @returns {void} + * @param node The class node to visit. */ - visitClass(node: any) { + visitClass(node: es.ClassDeclaration | es.ClassExpression): void { this.visitDecorators(node.decorators); const upperTypeMode = this.typeMode; @@ -214,7 +220,7 @@ class Referencer extends OriginalReferencer { this.visit(node.superTypeParameters); } if (node.implements) { - this.visit(node.implements); + node.implements.forEach(this.visit, this); } this.typeMode = upperTypeMode; @@ -223,10 +229,13 @@ class Referencer extends OriginalReferencer { /** * Visit typeParameters. - * @param {*} node The node to visit. - * @returns {void} + * @param node The node to visit. */ - visitTypeParameters(node: any) { + visitTypeParameters(node: { + typeParameters?: + | es.TSTypeParameterDeclaration + | es.TSTypeParameterInstantiation; + }): void { if (node.typeParameters) { const upperTypeMode = this.typeMode; this.typeMode = true; @@ -238,7 +247,7 @@ class Referencer extends OriginalReferencer { /** * Override. */ - JSXOpeningElement(node: any) { + JSXOpeningElement(node: es.JSXOpeningElement): void { this.visit(node.name); this.visitTypeParameters(node); node.attributes.forEach(this.visit, this); @@ -247,10 +256,9 @@ class Referencer extends OriginalReferencer { /** * Override. * Don't create the reference object in the type mode. - * @param {Identifier} node The Identifier node to visit. - * @returns {void} + * @param node The Identifier node to visit. */ - Identifier(node: any) { + Identifier(node: es.Identifier): void { this.visitDecorators(node.decorators); if (!this.typeMode) { @@ -263,20 +271,20 @@ class Referencer extends OriginalReferencer { /** * Override. * Visit decorators. - * @param {MethodDefinition} node The MethodDefinition node to visit. - * @returns {void} + * @param node The MethodDefinition node to visit. */ - MethodDefinition(node: any) { + MethodDefinition( + node: es.MethodDefinition | es.TSAbstractMethodDefinition + ): void { this.visitDecorators(node.decorators); super.MethodDefinition(node); } /** * Don't create the reference object for the key if not computed. - * @param {ClassProperty} node The ClassProperty node to visit. - * @returns {void} + * @param node The ClassProperty node to visit. */ - ClassProperty(node: any) { + ClassProperty(node: es.ClassProperty | es.TSAbstractClassProperty): void { const upperTypeMode = this.typeMode; const { computed, decorators, key, typeAnnotation, value } = node; @@ -295,10 +303,9 @@ class Referencer extends OriginalReferencer { /** * Visit new expression. - * @param {NewExpression} node The NewExpression node to visit. - * @returns {void} + * @param node The NewExpression node to visit. */ - NewExpression(node: any) { + NewExpression(node: es.NewExpression): void { this.visitTypeParameters(node); this.visit(node.callee); if (node.arguments) { @@ -309,10 +316,9 @@ class Referencer extends OriginalReferencer { /** * Override. * Visit call expression. - * @param {CallExpression} node The CallExpression node to visit. - * @returns {void} + * @param node The CallExpression node to visit. */ - CallExpression(node: any) { + CallExpression(node: es.CallExpression): void { this.visitTypeParameters(node); this.visit(node.callee); @@ -324,10 +330,9 @@ class Referencer extends OriginalReferencer { /** * Define the variable of this function declaration only once. * Because to avoid confusion of `no-redeclare` rule by overloading. - * @param {TSDeclareFunction} node The TSDeclareFunction node to visit. - * @returns {void} + * @param node The TSDeclareFunction node to visit. */ - TSDeclareFunction(node: any) { + TSDeclareFunction(node: es.TSDeclareFunction): void { const upperTypeMode = this.typeMode; const scope = this.currentScope(); const { id, typeParameters, params, returnType } = node; @@ -355,10 +360,9 @@ class Referencer extends OriginalReferencer { /** * Create reference objects for the references in parameters and return type. - * @param {TSEmptyBodyFunctionExpression} node The TSEmptyBodyFunctionExpression node to visit. - * @returns {void} + * @param node The TSEmptyBodyFunctionExpression node to visit. */ - TSEmptyBodyFunctionExpression(node: any) { + TSEmptyBodyFunctionExpression(node: es.FunctionExpression): void { const upperTypeMode = this.typeMode; const { typeParameters, params, returnType } = node; @@ -372,39 +376,35 @@ class Referencer extends OriginalReferencer { /** * Don't make variable because it declares only types. * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. - * @param {TSInterfaceDeclaration} node The TSInterfaceDeclaration node to visit. - * @returns {void} + * @param node The TSInterfaceDeclaration node to visit. */ - TSInterfaceDeclaration(node: any) { + TSInterfaceDeclaration(node: es.TSInterfaceDeclaration): void { this.visitTypeNodes(node); } /** * Don't make variable because it declares only types. * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. - * @param {TSClassImplements} node The TSClassImplements node to visit. - * @returns {void} + * @param node The TSClassImplements node to visit. */ - TSClassImplements(node: any) { + TSClassImplements(node: es.TSClassImplements): void { this.visitTypeNodes(node); } /** * Don't make variable because it declares only types. * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. - * @param {TSIndexSignature} node The TSIndexSignature node to visit. - * @returns {void} + * @param node The TSIndexSignature node to visit. */ - TSIndexSignature(node: any) { + TSIndexSignature(node: es.TSIndexSignature): void { this.visitTypeNodes(node); } /** * Visit type assertion. - * @param {TSTypeAssertion} node The TSTypeAssertion node to visit. - * @returns {void} + * @param node The TSTypeAssertion node to visit. */ - TSTypeAssertion(node: any) { + TSTypeAssertion(node: es.TSTypeAssertion): void { if (this.typeMode) { this.visit(node.typeAnnotation); } else { @@ -418,10 +418,9 @@ class Referencer extends OriginalReferencer { /** * Visit as expression. - * @param {TSAsExpression} node The TSAsExpression node to visit. - * @returns {void} + * @param node The TSAsExpression node to visit. */ - TSAsExpression(node: any) { + TSAsExpression(node: es.TSAsExpression): void { this.visit(node.expression); if (this.typeMode) { @@ -435,28 +434,25 @@ class Referencer extends OriginalReferencer { /** * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. - * @param {TSTypeAnnotation} node The TSTypeAnnotation node to visit. - * @returns {void} + * @param node The TSTypeAnnotation node to visit. */ - TSTypeAnnotation(node: any) { + TSTypeAnnotation(node: es.TSTypeAnnotation): void { this.visitTypeNodes(node); } /** * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. - * @param {TSTypeParameterDeclaration} node The TSTypeParameterDeclaration node to visit. - * @returns {void} + * @param node The TSTypeParameterDeclaration node to visit. */ - TSTypeParameterDeclaration(node: any) { + TSTypeParameterDeclaration(node: es.TSTypeParameterDeclaration): void { this.visitTypeNodes(node); } /** * Create reference objects for the references in `typeof` expression. - * @param {TSTypeQuery} node The TSTypeQuery node to visit. - * @returns {void} + * @param node The TSTypeQuery node to visit. */ - TSTypeQuery(node: any) { + TSTypeQuery(node: es.TSTypeQuery): void { if (this.typeMode) { this.typeMode = false; this.visitChildren(node); @@ -467,124 +463,109 @@ class Referencer extends OriginalReferencer { } /** - * @param {TSTypeParameter} node The TSTypeParameter node to visit. - * @returns {void} + * @param node The TSTypeParameter node to visit. */ - TSTypeParameter(node: any) { + TSTypeParameter(node: es.TSTypeParameter): void { this.visitTypeNodes(node); } /** - * @param {TSInferType} node The TSInferType node to visit. - * @returns {void} + * @param node The TSInferType node to visit. */ - TSInferType(node: any) { + TSInferType(node: es.TSInferType): void { this.visitTypeNodes(node); } /** - * @param {TSTypeReference} node The TSTypeReference node to visit. - * @returns {void} + * @param node The TSTypeReference node to visit. */ - TSTypeReference(node: any) { + TSTypeReference(node: es.TSTypeReference): void { this.visitTypeNodes(node); } /** - * @param {TSTypeLiteral} node The TSTypeLiteral node to visit. - * @returns {void} + * @param node The TSTypeLiteral node to visit. */ - TSTypeLiteral(node: any) { + TSTypeLiteral(node: es.TSTypeLiteral): void { this.visitTypeNodes(node); } /** - * @param {TSLiteralType} node The TSLiteralType node to visit. - * @returns {void} + * @param node The TSLiteralType node to visit. */ - TSLiteralType(node: any) { + TSLiteralType(node: es.TSLiteralType): void { this.visitTypeNodes(node); } /** - * @param {TSIntersectionType} node The TSIntersectionType node to visit. - * @returns {void} + * @param node The TSIntersectionType node to visit. */ - TSIntersectionType(node: any) { + TSIntersectionType(node: es.TSIntersectionType): void { this.visitTypeNodes(node); } /** - * @param {TSConditionalType} node The TSConditionalType node to visit. - * @returns {void} + * @param node The TSConditionalType node to visit. */ - TSConditionalType(node: any) { + TSConditionalType(node: es.TSConditionalType): void { this.visitTypeNodes(node); } /** - * @param {TSIndexedAccessType} node The TSIndexedAccessType node to visit. - * @returns {void} + * @param node The TSIndexedAccessType node to visit. */ - TSIndexedAccessType(node: any) { + TSIndexedAccessType(node: es.TSIndexedAccessType): void { this.visitTypeNodes(node); } /** - * @param {TSMappedType} node The TSMappedType node to visit. - * @returns {void} + * @param node The TSMappedType node to visit. */ - TSMappedType(node: any) { + TSMappedType(node: es.TSMappedType): void { this.visitTypeNodes(node); } /** - * @param {TSOptionalType} node The TSOptionalType node to visit. - * @returns {void} + * @param node The TSOptionalType node to visit. */ - TSOptionalType(node: any) { + TSOptionalType(node: es.TSOptionalType): void { this.visitTypeNodes(node); } /** - * @param {TSParenthesizedType} node The TSParenthesizedType node to visit. - * @returns {void} + * @param node The TSParenthesizedType node to visit. */ - TSParenthesizedType(node: any) { + TSParenthesizedType(node: es.TSParenthesizedType): void { this.visitTypeNodes(node); } /** - * @param {TSRestType} node The TSRestType node to visit. - * @returns {void} + * @param node The TSRestType node to visit. */ - TSRestType(node: any) { + TSRestType(node: es.TSRestType): void { this.visitTypeNodes(node); } /** - * @param {TSTupleType} node The TSTupleType node to visit. - * @returns {void} + * @param node The TSTupleType node to visit. */ - TSTupleType(node: any) { + TSTupleType(node: es.TSTupleType): void { this.visitTypeNodes(node); } /** * Create reference objects for the object part. (This is `obj.prop`) - * @param {TSQualifiedName} node The TSQualifiedName node to visit. - * @returns {void} + * @param node The TSQualifiedName node to visit. */ - TSQualifiedName(node: any) { + TSQualifiedName(node: es.TSQualifiedName): void { this.visit(node.left); } /** * Create reference objects for the references in computed keys. - * @param {TSPropertySignature} node The TSPropertySignature node to visit. - * @returns {void} + * @param node The TSPropertySignature node to visit. */ - TSPropertySignature(node: any) { + TSPropertySignature(node: es.TSPropertySignature): void { const upperTypeMode = this.typeMode; const { computed, key, typeAnnotation, initializer } = node; @@ -604,10 +585,9 @@ class Referencer extends OriginalReferencer { /** * Create reference objects for the references in computed keys. - * @param {TSMethodSignature} node The TSMethodSignature node to visit. - * @returns {void} + * @param node The TSMethodSignature node to visit. */ - TSMethodSignature(node: any) { + TSMethodSignature(node: es.TSMethodSignature): void { const upperTypeMode = this.typeMode; const { computed, key, typeParameters, params, returnType } = node; @@ -641,10 +621,9 @@ class Referencer extends OriginalReferencer { * A = a // a is above constant. * } * - * @param {TSEnumDeclaration} node The TSEnumDeclaration node to visit. - * @returns {void} + * @param node The TSEnumDeclaration node to visit. */ - TSEnumDeclaration(node: any) { + TSEnumDeclaration(node: es.TSEnumDeclaration): void { const { id, members } = node; const scopeManager = this.scopeManager; const scope = this.currentScope(); @@ -664,10 +643,9 @@ class Referencer extends OriginalReferencer { * Create variable object for the enum member and create reference object for the initializer. * And visit the initializer. * - * @param {TSEnumMember} node The TSEnumMember node to visit. - * @returns {void} + * @param node The TSEnumMember node to visit. */ - TSEnumMember(node: any) { + TSEnumMember(node: es.TSEnumMember): void { const { id, initializer } = node; const scope = this.currentScope(); @@ -680,10 +658,9 @@ class Referencer extends OriginalReferencer { /** * Create the variable object for the module name, and visit children. - * @param {TSModuleDeclaration} node The TSModuleDeclaration node to visit. - * @returns {void} + * @param node The TSModuleDeclaration node to visit. */ - TSModuleDeclaration(node: any) { + TSModuleDeclaration(node: es.TSModuleDeclaration): void { const scope = this.currentScope(); const { id, body } = node; @@ -701,7 +678,7 @@ class Referencer extends OriginalReferencer { this.visit(body); } - TSTypeAliasDeclaration(node: any) { + TSTypeAliasDeclaration(node: es.TSTypeAliasDeclaration): void { this.typeMode = true; this.visitChildren(node); this.typeMode = false; @@ -709,28 +686,26 @@ class Referencer extends OriginalReferencer { /** * Process the module block. - * @param {TSModuleBlock} node The TSModuleBlock node to visit. - * @returns {void} + * @param node The TSModuleBlock node to visit. */ - TSModuleBlock(node: any) { + TSModuleBlock(node: es.TSModuleBlock): void { this.scopeManager.__nestBlockScope(node); this.visitChildren(node); this.close(node); } - TSAbstractClassProperty(node: any) { + TSAbstractClassProperty(node: es.TSAbstractClassProperty): void { this.ClassProperty(node); } - TSAbstractMethodDefinition(node: any) { + TSAbstractMethodDefinition(node: es.TSAbstractMethodDefinition): void { this.MethodDefinition(node); } /** * Process import equal declaration - * @param {TSImportEqualsDeclaration} node The TSImportEqualsDeclaration node to visit. - * @returns {void} + * @param node The TSImportEqualsDeclaration node to visit. */ - TSImportEqualsDeclaration(node: any) { + TSImportEqualsDeclaration(node: es.TSImportEqualsDeclaration): void { const { id, moduleReference } = node; if (id && id.type === 'Identifier') { this.currentScope().__define( @@ -745,10 +720,9 @@ class Referencer extends OriginalReferencer { * Process the global augmentation. * 1. Set the global scope as the current scope. * 2. Configure the global scope to set `variable.eslintUsed = true` for all defined variables. This means `no-unused-vars` doesn't warn those. - * @param {TSModuleDeclaration} node The TSModuleDeclaration node to visit. - * @returns {void} + * @param node The TSModuleDeclaration node to visit. */ - visitGlobalAugmentation(node: any) { + visitGlobalAugmentation(node: es.TSModuleDeclaration): void { const scopeManager = this.scopeManager; const currentScope = this.currentScope(); const globalScope = scopeManager.globalScope; @@ -758,8 +732,8 @@ class Referencer extends OriginalReferencer { scopeManager.__currentScope = globalScope; // Skip TSModuleBlock to avoid to create that block scope. - for (const moduleItem of node.body.body) { - this.visit(moduleItem); + if (node.body && node.body.type === 'TSModuleBlock') { + node.body.body.forEach(this.visit, this); } scopeManager.__currentScope = currentScope; @@ -768,10 +742,9 @@ class Referencer extends OriginalReferencer { /** * Process decorators. - * @param {Decorator[]|undefined} decorators The decorator nodes to visit. - * @returns {void} + * @param decorators The decorator nodes to visit. */ - visitDecorators(decorators?: any[]) { + visitDecorators(decorators?: es.Decorator[]): void { if (decorators) { decorators.forEach(this.visit, this); } @@ -779,10 +752,9 @@ class Referencer extends OriginalReferencer { /** * Process all child of type nodes - * @param {any} node node to be processed - * @returns {void} + * @param node node to be processed */ - visitTypeNodes(node: any) { + visitTypeNodes(node: es.Node): void { if (this.typeMode) { this.visitChildren(node); } else { diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 2dd32b383625..30e86117b618 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -2,21 +2,15 @@ import traverser from 'eslint/lib/util/traverser'; import { AST_NODE_TYPES, parseAndGenerateServices, - ParserOptions as ParserOptionsTsESTree + ParserOptions as ParserOptionsTsESTree, + ParserServices } from '@typescript-eslint/typescript-estree'; import { analyzeScope } from './analyze-scope'; import { ParserOptions } from './parser-options'; import { visitorKeys } from './visitor-keys'; -import { Program } from 'typescript'; const packageJSON = require('../package.json'); -interface ParserServices { - program: Program | undefined; - esTreeNodeToTSNodeMap: WeakMap | undefined; - tsNodeToESTreeNodeMap: WeakMap | undefined; -} - interface ParseForESLintResult { ast: any; services: ParserServices; diff --git a/packages/parser/src/typings.d.ts b/packages/parser/src/typings.d.ts index 08f92526c823..be5510d53caf 100644 --- a/packages/parser/src/typings.d.ts +++ b/packages/parser/src/typings.d.ts @@ -2,6 +2,7 @@ // Project: http://github.com/eslint/eslint-scope // Definitions by: Armano declare module 'eslint-scope/lib/options' { + import { es } from '@typescript-eslint/typescript-estree'; export type PatternVisitorCallback = (pattern: any, info: any) => void; export interface PatternVisitorOptions { @@ -9,76 +10,73 @@ declare module 'eslint-scope/lib/options' { } export abstract class Visitor { - visitChildren(node: Node): void; - visit(node: Node): void; + visitChildren(node?: T): void; + visit(node?: T): void; } } declare module 'eslint-scope/lib/variable' { - import * as eslint from 'eslint'; - import { Identifier } from 'estree'; + import { es } from '@typescript-eslint/typescript-estree'; import Reference from 'eslint-scope/lib/reference'; + import { Definition } from 'eslint-scope/lib/definition'; - class Variable implements eslint.Scope.Variable { + export default class Variable { name: string; - identifiers: Identifier[]; + identifiers: es.Identifier[]; references: Reference[]; - defs: eslint.Scope.Definition[]; + defs: Definition[]; } - export default Variable; } declare module 'eslint-scope/lib/definition' { - import { Identifier, Node } from 'estree'; + import { es } from '@typescript-eslint/typescript-estree'; - class Definition { + export class Definition { type: string; - name: Identifier; - node: Node; - parent?: Node | null; + name: es.BindingName; + node: es.Node; + parent?: es.Node | null; index?: number | null; kind?: string | null; constructor( type: string, - name: Identifier, - node: Node, - parent?: Node | null, + name: es.BindingName | es.PropertyName, + node: es.Node, + parent?: es.Node | null, index?: number | null, kind?: string | null ); } - class ParameterDefinition extends Definition { + export class ParameterDefinition extends Definition { rest?: boolean; constructor( - name: Identifier, - node: Node, + name: es.BindingName | es.PropertyName, + node: es.Node, index?: number | null, rest?: boolean ); } - - export { ParameterDefinition, Definition }; } declare module 'eslint-scope/lib/pattern-visitor' { import ScopeManager from 'eslint-scope/lib/scope-manager'; - import { Node } from 'estree'; + import { es } from '@typescript-eslint/typescript-estree'; import { PatternVisitorCallback, PatternVisitorOptions, Visitor } from 'eslint-scope/lib/options'; - class PatternVisitor extends Visitor { + export default class PatternVisitor extends Visitor { protected options: any; protected scopeManager: ScopeManager; - protected parent?: Node; - public rightHandNodes: Node[]; + protected parent?: es.Node; + public rightHandNodes: es.Node[]; - static isPattern(node: Node): boolean; + static isPattern(node: es.Node): boolean; constructor( options: PatternVisitorOptions, @@ -86,41 +84,39 @@ declare module 'eslint-scope/lib/pattern-visitor' { callback: PatternVisitorCallback ); - Identifier(pattern: Node): void; - Property(property: Node): void; - ArrayPattern(pattern: Node): void; - AssignmentPattern(pattern: Node): void; - RestElement(pattern: Node): void; - MemberExpression(node: Node): void; - SpreadElement(node: Node): void; - ArrayExpression(node: Node): void; - AssignmentExpression(node: Node): void; - CallExpression(node: Node): void; + Identifier(pattern: es.Node): void; + Property(property: es.Node): void; + ArrayPattern(pattern: es.Node): void; + AssignmentPattern(pattern: es.Node): void; + RestElement(pattern: es.Node): void; + MemberExpression(node: es.Node): void; + SpreadElement(node: es.Node): void; + ArrayExpression(node: es.Node): void; + AssignmentExpression(node: es.Node): void; + CallExpression(node: es.Node): void; } - - export default PatternVisitor; } declare module 'eslint-scope/lib/referencer' { import { Scope } from 'eslint-scope/lib/scope'; import ScopeManager from 'eslint-scope/lib/scope-manager'; - import { Node } from 'estree'; + import { es } from '@typescript-eslint/typescript-estree'; import { PatternVisitorCallback, PatternVisitorOptions, Visitor } from 'eslint-scope/lib/options'; - class Referencer extends Visitor { + export default class Referencer extends Visitor { protected isInnerMethodDefinition: boolean; protected options: any; protected scopeManager: ScopeManager; - protected parent?: Node; + protected parent?: es.Node; constructor(options: any, scopeManager: ScopeManager); currentScope(): Scope; - close(node: Node): void; + close(node: es.Node): void; pushInnerMethodDefinition(isInnerMethodDefinition: boolean): boolean; popInnerMethodDefinition(isInnerMethodDefinition: boolean): void; @@ -131,66 +127,63 @@ declare module 'eslint-scope/lib/referencer' { init: boolean ): void; visitPattern( - node: Node, + node: es.Node, options: PatternVisitorOptions, callback: PatternVisitorCallback ): void; - visitFunction(node: Node): void; - visitClass(node: Node): void; - visitProperty(node: Node): void; - visitForIn(node: Node): void; + visitFunction(node: es.Node): void; + visitClass(node: es.Node): void; + visitProperty(node: es.Node): void; + visitForIn(node: es.Node): void; visitVariableDeclaration( variableTargetScope: any, type: any, - node: Node, + node: es.Node, index: any ): void; - AssignmentExpression(node: Node): void; - CatchClause(node: Node): void; - Program(node: Node): void; - Identifier(node: Node): void; - UpdateExpression(node: Node): void; - MemberExpression(node: Node): void; - Property(node: Node): void; - MethodDefinition(node: Node): void; + AssignmentExpression(node: es.Node): void; + CatchClause(node: es.Node): void; + Program(node: es.Node): void; + Identifier(node: es.Node): void; + UpdateExpression(node: es.Node): void; + MemberExpression(node: es.Node): void; + Property(node: es.Node): void; + MethodDefinition(node: es.Node): void; BreakStatement(): void; ContinueStatement(): void; - LabeledStatement(node: Node): void; - ForStatement(node: Node): void; - ClassExpression(node: Node): void; - ClassDeclaration(node: Node): void; - CallExpression(node: Node): void; - BlockStatement(node: Node): void; + LabeledStatement(node: es.Node): void; + ForStatement(node: es.Node): void; + ClassExpression(node: es.Node): void; + ClassDeclaration(node: es.Node): void; + CallExpression(node: es.Node): void; + BlockStatement(node: es.Node): void; ThisExpression(): void; - WithStatement(node: Node): void; - VariableDeclaration(node: Node): void; - SwitchStatement(node: Node): void; - FunctionDeclaration(node: Node): void; - FunctionExpression(node: Node): void; - ForOfStatement(node: Node): void; - ForInStatement(node: Node): void; - ArrowFunctionExpression(node: Node): void; - ImportDeclaration(node: Node): void; - visitExportDeclaration(node: Node): void; - ExportDeclaration(node: Node): void; - ExportNamedDeclaration(node: Node): void; - ExportSpecifier(node: Node): void; + WithStatement(node: es.Node): void; + VariableDeclaration(node: es.Node): void; + SwitchStatement(node: es.Node): void; + FunctionDeclaration(node: es.Node): void; + FunctionExpression(node: es.Node): void; + ForOfStatement(node: es.Node): void; + ForInStatement(node: es.Node): void; + ArrowFunctionExpression(node: es.Node): void; + ImportDeclaration(node: es.Node): void; + visitExportDeclaration(node: es.Node): void; + ExportDeclaration(node: es.Node): void; + ExportNamedDeclaration(node: es.Node): void; + ExportSpecifier(node: es.Node): void; MetaProperty(): void; } - - export default Referencer; } declare module 'eslint-scope/lib/scope' { - import * as eslint from 'eslint'; - import { Node } from 'estree'; + import { es } from '@typescript-eslint/typescript-estree'; import Reference from 'eslint-scope/lib/reference'; import Variable from 'eslint-scope/lib/variable'; import ScopeManager from 'eslint-scope/lib/scope-manager'; import { Definition } from 'eslint-scope/lib/definition'; - type ScopeType = + export type ScopeType = | 'block' | 'catch' | 'class' @@ -203,13 +196,13 @@ declare module 'eslint-scope/lib/scope' { | 'with' | 'TDZ'; - class Scope implements eslint.Scope.Scope { + export class Scope { type: ScopeType; isStrict: boolean; upper: Scope | null; childScopes: Scope[]; variableScope: Scope; - block: Node; + block: es.Node; variables: Variable[]; set: Map; references: Reference[]; @@ -221,7 +214,7 @@ declare module 'eslint-scope/lib/scope' { scopeManager: ScopeManager, type: ScopeType, upperScope: Scope | null, - block: Node | null, + block: es.Node | null, isMethodDefinition: boolean ); @@ -234,7 +227,7 @@ declare module 'eslint-scope/lib/scope' { __isValidResolution(ref: any, variable: any): boolean; __resolve(ref: any): boolean; __delegateToUpperScope(ref: any): void; - __addDeclaredVariablesOfNode(variable: any, node: Node): void; + __addDeclaredVariablesOfNode(variable: any, node: es.Node): void; __defineGeneric( name: any, set: any, @@ -243,12 +236,12 @@ declare module 'eslint-scope/lib/scope' { def: Definition ): void; - __define(node: Node, def: Definition): void; + __define(node: es.Node, def: Definition): void; __referencing( - node: Node, + node: es.Node, assign: number, - writeExpr: Node, + writeExpr: es.Node, maybeImplicitGlobal: any, partial: any, init: any @@ -263,7 +256,7 @@ declare module 'eslint-scope/lib/scope' { * @param {Espree.Identifier} ident - identifier to be resolved. * @returns {Reference} reference */ - resolve(ident: Node): Reference; + resolve(ident: es.Node): Reference; /** * returns this scope is static @@ -289,109 +282,94 @@ declare module 'eslint-scope/lib/scope' { isUsedName(name: any): boolean; } - class GlobalScope extends Scope { - constructor(scopeManager: ScopeManager, block: Node | null); + export class GlobalScope extends Scope { + constructor(scopeManager: ScopeManager, block: es.Node | null); } - class ModuleScope extends Scope { + export class ModuleScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: es.Node | null ); } - class FunctionExpressionNameScope extends Scope { + export class FunctionExpressionNameScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: es.Node | null ); } - class CatchScope extends Scope { + export class CatchScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: es.Node | null ); } - class WithScope extends Scope { + export class WithScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: es.Node | null ); } - class BlockScope extends Scope { + export class BlockScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: es.Node | null ); } - class SwitchScope extends Scope { + export class SwitchScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: es.Node | null ); } - class FunctionScope extends Scope { + export class FunctionScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null, + block: es.Node | null, isMethodDefinition: boolean ); } - class ForScope extends Scope { + export class ForScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: es.Node | null ); } - class ClassScope extends Scope { + export class ClassScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: Node | null + block: es.Node | null ); } - - export { - Scope, - GlobalScope, - ModuleScope, - FunctionExpressionNameScope, - CatchScope, - WithScope, - BlockScope, - SwitchScope, - FunctionScope, - ForScope, - ClassScope - }; } declare module 'eslint-scope/lib/reference' { - import * as eslint from 'eslint'; - import { Identifier, Node } from 'estree'; + import { es } from '@typescript-eslint/typescript-estree'; import { Scope } from 'eslint-scope/lib/scope'; import Variable from 'eslint-scope/lib/variable'; - class Reference implements eslint.Scope.Reference { - identifier: Identifier; + export default class Reference { + identifier: es.Identifier; from: Scope; resolved: Variable | null; - writeExpr: Node | null; + writeExpr: es.Node | null; init: boolean; isWrite(): boolean; @@ -404,15 +382,14 @@ declare module 'eslint-scope/lib/reference' { static WRITE: 0x2; static RW: 0x3; } - export default Reference; } declare module 'eslint-scope/lib/scope-manager' { - import * as eslint from 'eslint'; + import { es } from '@typescript-eslint/typescript-estree'; import { Scope } from 'eslint-scope/lib/scope'; import Variable from 'eslint-scope/lib/variable'; - interface ScopeManagerOptions { + export interface ScopeManagerOptions { directive?: boolean; optimistic?: boolean; ignoreEval?: boolean; @@ -422,7 +399,7 @@ declare module 'eslint-scope/lib/scope-manager' { ecmaVersion?: number; } - class ScopeManager implements eslint.Scope.ScopeManager { + export default class ScopeManager { __options: ScopeManagerOptions; __currentScope: Scope; scopes: Scope[]; @@ -439,29 +416,28 @@ declare module 'eslint-scope/lib/scope-manager' { isStrictModeSupported(): boolean; // Returns appropriate scope for this node. - __get(node: Node): Scope; - getDeclaredVariables(node: {}): Variable[]; - acquire(node: {}, inner?: boolean): Scope | null; - acquireAll(node: Node): Scope | null; - release(node: Node, inner?: boolean): Scope | null; + __get(node: es.Node): Scope; + getDeclaredVariables(node: es.Node): Variable[]; + acquire(node: es.Node, inner?: boolean): Scope | null; + acquireAll(node: es.Node): Scope | null; + release(node: es.Node, inner?: boolean): Scope | null; attach(): void; detach(): void; __nestScope(scope: Scope): Scope; - __nestGlobalScope(node: Node): Scope; - __nestBlockScope(node: Node): Scope; - __nestFunctionScope(node: Node, isMethodDefinition: boolean): Scope; - __nestForScope(node: Node): Scope; - __nestCatchScope(node: Node): Scope; - __nestWithScope(node: Node): Scope; - __nestClassScope(node: Node): Scope; - __nestSwitchScope(node: Node): Scope; - __nestModuleScope(node: Node): Scope; - __nestFunctionExpressionNameScope(node: Node): Scope; + __nestGlobalScope(node: es.Node): Scope; + __nestBlockScope(node: es.Node): Scope; + __nestFunctionScope(node: es.Node, isMethodDefinition: boolean): Scope; + __nestForScope(node: es.Node): Scope; + __nestCatchScope(node: es.Node): Scope; + __nestWithScope(node: es.Node): Scope; + __nestClassScope(node: es.Node): Scope; + __nestSwitchScope(node: es.Node): Scope; + __nestModuleScope(node: es.Node): Scope; + __nestFunctionExpressionNameScope(node: es.Node): Scope; __isES6(): boolean; } - export default ScopeManager; } declare module 'eslint-scope' { diff --git a/packages/typescript-estree/src/parser-options.ts b/packages/typescript-estree/src/parser-options.ts index a838db4af139..4a1c67679e4a 100644 --- a/packages/typescript-estree/src/parser-options.ts +++ b/packages/typescript-estree/src/parser-options.ts @@ -1,4 +1,6 @@ -import { Token, Comment } from './typedefs'; +import { Program } from 'typescript'; +import { Token, Comment, Node } from './typedefs'; +import { TSNode } from "./ts-nodes"; export interface Extra { errorOnUnknownASTType: boolean; @@ -33,3 +35,9 @@ export interface ParserOptions { tsconfigRootDir?: string; extraFileExtensions?: string[]; } + +export interface ParserServices { + program?: Program; + esTreeNodeToTSNodeMap?: WeakMap; + tsNodeToESTreeNodeMap?: WeakMap; +} diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 3c9680df06d4..fdd258c72c64 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -15,7 +15,7 @@ import convert from './ast-converter'; import { convertError } from './convert'; import { firstDefined } from './node-utils'; import * as es from './typedefs'; -import { Extra, ParserOptions } from './parser-options'; +import { Extra, ParserOptions, ParserServices } from './parser-options'; import { getFirstSemanticOrSyntacticError } from './semantic-errors'; const packageJSON = require('../package.json'); @@ -276,11 +276,7 @@ type AST = es.Program & interface ParseAndGenerateServicesResult { ast: AST; - services: { - program: ts.Program | undefined; - esTreeNodeToTSNodeMap: WeakMap | undefined; - tsNodeToESTreeNodeMap: WeakMap | undefined; - }; + services: ParserServices; } //------------------------------------------------------------------------------ @@ -417,3 +413,5 @@ export function parseAndGenerateServices< export { AST_NODE_TYPES } from './ast-node-types'; export { ParserOptions }; +export { ParserServices }; +export { es }; diff --git a/packages/typescript-estree/src/typedefs.ts b/packages/typescript-estree/src/typedefs.ts index 140ed6e09a49..bf683e859440 100644 --- a/packages/typescript-estree/src/typedefs.ts +++ b/packages/typescript-estree/src/typedefs.ts @@ -715,6 +715,7 @@ export interface Identifier extends BaseNode { name: string; typeAnnotation?: TSTypeAnnotation; optional?: boolean; + decorators?: Decorator[]; } export interface IfStatement extends BaseNode { @@ -1175,7 +1176,7 @@ export interface TSModuleBlock extends BaseNode { export interface TSModuleDeclaration extends BaseNode { type: AST_NODE_TYPES.TSModuleDeclaration; id: Identifier | Literal; - body?: TSModuleBlock | Identifier; + body?: TSModuleBlock | TSModuleDeclaration; global?: boolean; declare?: boolean; modifiers?: Modifier[]; From f99f7c7e06f8c035ebe0610e637b7efa068bc1fc Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 4 Feb 2019 03:03:21 +0100 Subject: [PATCH 02/13] test(ts-estree): add non null assertions --- packages/typescript-estree/tests/lib/semanticInfo.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/typescript-estree/tests/lib/semanticInfo.ts b/packages/typescript-estree/tests/lib/semanticInfo.ts index a164288ceb0f..531ab1a34d54 100644 --- a/packages/typescript-estree/tests/lib/semanticInfo.ts +++ b/packages/typescript-estree/tests/lib/semanticInfo.ts @@ -123,10 +123,10 @@ describe('semanticInfo', () => { arrayBoundName ); expect(tsArrayBoundName).toBeDefined(); - checkNumberArrayType(checker, tsArrayBoundName); + checkNumberArrayType(checker, tsArrayBoundName!); expect( - parseResult.services.tsNodeToESTreeNodeMap!.get(tsArrayBoundName) + parseResult.services.tsNodeToESTreeNodeMap!.get(tsArrayBoundName!) ).toBe(arrayBoundName); }); @@ -149,9 +149,9 @@ describe('semanticInfo', () => { ); expect(tsBoundName).toBeDefined(); - checkNumberArrayType(checker, tsBoundName); + checkNumberArrayType(checker, tsBoundName!); - expect(parseResult.services.tsNodeToESTreeNodeMap!.get(tsBoundName)).toBe( + expect(parseResult.services.tsNodeToESTreeNodeMap!.get(tsBoundName!)).toBe( boundName ); }); From dc7837b66149bb60c2610e4d9d518fc570ac24d1 Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 4 Feb 2019 03:09:50 +0100 Subject: [PATCH 03/13] chore(ts-estree): fix formatting --- packages/typescript-estree/src/parser-options.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typescript-estree/src/parser-options.ts b/packages/typescript-estree/src/parser-options.ts index 4a1c67679e4a..699eb76ef92d 100644 --- a/packages/typescript-estree/src/parser-options.ts +++ b/packages/typescript-estree/src/parser-options.ts @@ -1,6 +1,6 @@ import { Program } from 'typescript'; import { Token, Comment, Node } from './typedefs'; -import { TSNode } from "./ts-nodes"; +import { TSNode } from './ts-nodes'; export interface Extra { errorOnUnknownASTType: boolean; From ac67fff4ff1b6a882eb5c3d3184a8fff8adc7f72 Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 4 Feb 2019 03:22:15 +0100 Subject: [PATCH 04/13] chore(parser): improve type of visit and visitChildren --- packages/parser/src/analyze-scope.ts | 10 ++++------ packages/parser/src/typings.d.ts | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/parser/src/analyze-scope.ts b/packages/parser/src/analyze-scope.ts index cd04898e2ee7..1d8280d62caa 100644 --- a/packages/parser/src/analyze-scope.ts +++ b/packages/parser/src/analyze-scope.ts @@ -194,12 +194,10 @@ class Referencer extends OriginalReferencer { this.visit(returnType); // Process the body. - if (body) { - if (body.type === 'BlockStatement') { - this.visitChildren(body); - } else { - this.visit(body); - } + if (body && body.type === 'BlockStatement') { + this.visitChildren(body); + } else { + this.visit(body); } // Close the function scope. diff --git a/packages/parser/src/typings.d.ts b/packages/parser/src/typings.d.ts index be5510d53caf..b6ccdd19ee82 100644 --- a/packages/parser/src/typings.d.ts +++ b/packages/parser/src/typings.d.ts @@ -10,8 +10,8 @@ declare module 'eslint-scope/lib/options' { } export abstract class Visitor { - visitChildren(node?: T): void; - visit(node?: T): void; + visitChildren(node?: T): void; + visit(node?: T): void; } } From 677d7f48b94ee24c0a3f2295e7ef8c0c61aef636 Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 4 Feb 2019 20:39:24 +0100 Subject: [PATCH 05/13] test(parser): add test cases for parameters with decorators --- packages/parser/src/analyze-scope.ts | 23 +- packages/parser/src/parser.ts | 5 +- .../lib/__snapshots__/typescript.ts.snap | 4763 ++++++++++++----- .../parameter-array-pattern-decorator.src.ts | 3 + .../parameter-object-pattern-decorator.src.ts | 3 + .../parameter-rest-element-decorator.src.ts | 3 + packages/typescript-estree/src/typedefs.ts | 3 + .../tests/ast-alignment/fixtures-to-test.ts | 9 +- .../semantic-diagnostics-enabled.ts.snap | 6 + .../lib/__snapshots__/typescript.ts.snap | 4760 +++++++++++----- 10 files changed, 6763 insertions(+), 2815 deletions(-) create mode 100644 packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-array-pattern-decorator.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-object-pattern-decorator.src.ts create mode 100644 packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-rest-element-decorator.src.ts diff --git a/packages/parser/src/analyze-scope.ts b/packages/parser/src/analyze-scope.ts index 1d8280d62caa..e3c5fc8da50b 100644 --- a/packages/parser/src/analyze-scope.ts +++ b/packages/parser/src/analyze-scope.ts @@ -63,9 +63,8 @@ class PatternVisitor extends OriginalPatternVisitor { ArrayPattern(node: es.ArrayPattern): void { node.elements.forEach(this.visit, this); - // TODO: there is no decorators in definition of ArrayPattern - if ((node as any).decorators) { - this.rightHandNodes.push(...(node as any).decorators); + if (node.decorators) { + this.rightHandNodes.push(...node.decorators); } if (node.typeAnnotation) { this.rightHandNodes.push(node.typeAnnotation); @@ -74,9 +73,8 @@ class PatternVisitor extends OriginalPatternVisitor { ObjectPattern(node: es.ObjectPattern): void { node.properties.forEach(this.visit, this); - // TODO: there is no decorators in definition of ObjectPattern - if ((node as any).decorators) { - this.rightHandNodes.push(...(node as any).decorators); + if (node.decorators) { + this.rightHandNodes.push(...node.decorators); } if (node.typeAnnotation) { this.rightHandNodes.push(node.typeAnnotation); @@ -85,6 +83,9 @@ class PatternVisitor extends OriginalPatternVisitor { RestElement(node: es.RestElement): void { super.RestElement(node); + if (node.decorators) { + this.rightHandNodes.push(...node.decorators); + } if (node.typeAnnotation) { this.rightHandNodes.push(node.typeAnnotation); } @@ -306,9 +307,8 @@ class Referencer extends OriginalReferencer { NewExpression(node: es.NewExpression): void { this.visitTypeParameters(node); this.visit(node.callee); - if (node.arguments) { - node.arguments.forEach(this.visit, this); - } + + node.arguments.forEach(this.visit, this); } /** @@ -320,9 +320,8 @@ class Referencer extends OriginalReferencer { this.visitTypeParameters(node); this.visit(node.callee); - if (node.arguments) { - node.arguments.forEach(this.visit, this); - } + + node.arguments.forEach(this.visit, this); } /** diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 30e86117b618..7f1b812d6f8f 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -3,7 +3,8 @@ import { AST_NODE_TYPES, parseAndGenerateServices, ParserOptions as ParserOptionsTsESTree, - ParserServices + ParserServices, + es } from '@typescript-eslint/typescript-estree'; import { analyzeScope } from './analyze-scope'; import { ParserOptions } from './parser-options'; @@ -12,7 +13,7 @@ import { visitorKeys } from './visitor-keys'; const packageJSON = require('../package.json'); interface ParseForESLintResult { - ast: any; + ast: es.Program; services: ParserServices; visitorKeys: typeof visitorKeys; scopeManager: ReturnType; diff --git a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap index f57d7523a358..70a846a9ad3c 100644 --- a/packages/parser/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/parser/tests/lib/__snapshots__/typescript.ts.snap @@ -82288,7 +82288,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-constructor.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-array-pattern-decorator.src 1`] = ` Object { "body": Array [ Object { @@ -82299,198 +82299,55 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 15, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, - "name": "constructor", + "name": "bar", "range": Array [ - 20, - 31, + 14, + 17, ], "type": "Identifier", }, - "kind": "constructor", + "kind": "method", "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 113, + 14, + 49, ], "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [ - Object { - "expression": Object { - "left": Object { - "computed": false, - "loc": Object { - "end": Object { - "column": 18, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "object": Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 81, - 85, - ], - "type": "ThisExpression", - }, - "property": Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 3, - }, - "start": Object { - "column": 13, - "line": 3, - }, - }, - "name": "title", - "range": Array [ - 86, - 91, - ], - "type": "Identifier", - }, - "range": Array [ - 81, - 91, - ], - "type": "MemberExpression", - }, - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "operator": "=", - "range": Array [ - 81, - 106, - ], - "right": Object { - "computed": false, - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "object": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "name": "config", - "range": Array [ - 94, - 100, - ], - "type": "Identifier", - }, - "property": Object { - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 28, - "line": 3, - }, - }, - "name": "title", - "range": Array [ - 101, - 106, - ], - "type": "Identifier", - }, - "range": Array [ - 94, - 106, - ], - "type": "MemberExpression", - }, - "type": "AssignmentExpression", - }, - "loc": Object { - "end": Object { - "column": 34, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 81, - 107, - ], - "type": "ExpressionStatement", - }, - ], + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 55, + "column": 35, "line": 2, }, }, "range": Array [ - 71, - 113, + 47, + 49, ], "type": "BlockStatement", }, @@ -82499,11 +82356,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 15, + "column": 5, "line": 2, }, }, @@ -82516,146 +82373,148 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, + "column": 19, "line": 2, }, "start": Object { - "column": 24, + "column": 15, "line": 2, }, }, - "name": "APP_CONFIG", "range": Array [ - 40, - 50, + 27, + 31, ], - "type": "Identifier", + "raw": "true", + "type": "Literal", + "value": true, }, ], "callee": Object { "loc": Object { "end": Object { - "column": 23, + "column": 14, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, - "name": "Inject", + "name": "special", "range": Array [ - 33, - 39, + 19, + 26, ], "type": "Identifier", }, "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, "range": Array [ - 33, - 51, + 19, + 32, ], "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 16, + "column": 6, "line": 2, }, }, "range": Array [ + 18, 32, - 51, ], "type": "Decorator", }, ], + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + ], "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 36, + "column": 21, "line": 2, }, }, - "name": "config", "range": Array [ - 52, - 69, + 33, + 45, ], - "type": "Identifier", + "type": "ArrayPattern", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 42, + "column": 28, "line": 2, }, }, "range": Array [ - 58, - 69, + 40, + 45, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 44, + "column": 30, "line": 2, }, }, "range": Array [ - 60, - 69, + 42, + 45, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 53, - "line": 2, - }, - "start": Object { - "column": 44, - "line": 2, - }, - }, - "name": "AppConfig", - "range": Array [ - 60, - 69, - ], - "type": "Identifier", - }, + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 31, - 113, + 17, + 49, ], "type": "FunctionExpression", }, @@ -82664,23 +82523,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 115, + 10, + 51, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -82688,17 +82547,17 @@ Object { "line": 1, }, }, - "name": "Service", + "name": "Foo", "range": Array [ 6, - 13, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -82707,7 +82566,7 @@ Object { }, "range": Array [ 0, - 115, + 51, ], "superClass": null, "type": "ClassDeclaration", @@ -82717,7 +82576,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -82726,7 +82585,7 @@ Object { }, "range": Array [ 0, - 116, + 52, ], "sourceType": "module", "tokens": Array [ @@ -82751,7 +82610,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -82761,25 +82620,25 @@ Object { }, "range": Array [ 6, - 13, + 9, ], "type": "Identifier", - "value": "Service", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 11, "line": 1, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 15, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -82787,35 +82646,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 31, + 14, + 17, ], "type": "Identifier", - "value": "constructor", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 6, "line": 2, }, "start": Object { - "column": 15, + "column": 5, "line": 2, }, }, "range": Array [ - 31, - 32, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -82823,17 +82682,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 17, + "column": 7, "line": 2, }, "start": Object { - "column": 16, + "column": 6, "line": 2, }, }, "range": Array [ - 32, - 33, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -82841,35 +82700,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 23, + "column": 14, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, "range": Array [ - 33, - 39, + 19, + 26, ], "type": "Identifier", - "value": "Inject", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 15, "line": 2, }, "start": Object { - "column": 23, + "column": 14, "line": 2, }, }, "range": Array [ - 39, - 40, + 26, + 27, ], "type": "Punctuator", "value": "(", @@ -82877,35 +82736,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, + "column": 19, "line": 2, }, "start": Object { - "column": 24, + "column": 15, "line": 2, }, }, "range": Array [ - 40, - 50, + 27, + 31, ], - "type": "Identifier", - "value": "APP_CONFIG", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 34, + "column": 19, "line": 2, }, }, "range": Array [ - 50, - 51, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -82913,251 +82772,2244 @@ Object { Object { "loc": Object { "end": Object { - "column": 42, + "column": 22, "line": 2, }, "start": Object { - "column": 36, + "column": 21, "line": 2, }, }, "range": Array [ - 52, - 58, + 33, + 34, ], - "type": "Identifier", - "value": "config", + "type": "Punctuator", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 43, + "column": 26, "line": 2, }, "start": Object { - "column": 42, + "column": 23, "line": 2, }, }, "range": Array [ - 58, - 59, + 35, + 38, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 53, + "column": 28, "line": 2, }, "start": Object { - "column": 44, + "column": 27, "line": 2, }, }, "range": Array [ - 60, - 69, + 39, + 40, ], - "type": "Identifier", - "value": "AppConfig", + "type": "Punctuator", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 54, + "column": 29, "line": 2, }, "start": Object { - "column": 53, + "column": 28, "line": 2, }, }, "range": Array [ - 69, - 70, + 40, + 41, ], "type": "Punctuator", - "value": ")", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 56, + "column": 33, "line": 2, }, "start": Object { - "column": 55, + "column": 30, "line": 2, }, }, "range": Array [ - 71, - 72, + 42, + 45, ], - "type": "Punctuator", - "value": "{", + "type": "Identifier", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 12, - "line": 3, + "column": 34, + "line": 2, }, "start": Object { - "column": 8, - "line": 3, + "column": 33, + "line": 2, }, }, "range": Array [ - 81, - 85, + 45, + 46, ], - "type": "Keyword", - "value": "this", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 13, - "line": 3, + "column": 36, + "line": 2, }, "start": Object { - "column": 12, - "line": 3, + "column": 35, + "line": 2, }, }, "range": Array [ - 85, - 86, + 47, + 48, ], "type": "Punctuator", - "value": ".", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 18, - "line": 3, + "column": 37, + "line": 2, }, "start": Object { - "column": 13, - "line": 3, + "column": 36, + "line": 2, }, }, "range": Array [ - 86, - 91, + 48, + 49, ], - "type": "Identifier", - "value": "title", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 1, "line": 3, }, "start": Object { - "column": 19, + "column": 0, "line": 3, }, }, "range": Array [ - 92, - 93, + 50, + 51, ], "type": "Punctuator", - "value": "=", + "value": "}", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-constructor.src 1`] = ` +Object { + "body": Array [ Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 3, - }, - "start": Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "constructor", + "range": Array [ + 20, + 31, + ], + "type": "Identifier", + }, + "kind": "constructor", + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 20, + 113, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "expression": Object { + "left": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 85, + ], + "type": "ThisExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "name": "title", + "range": Array [ + 86, + 91, + ], + "type": "Identifier", + }, + "range": Array [ + 81, + 91, + ], + "type": "MemberExpression", + }, + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "operator": "=", + "range": Array [ + 81, + 106, + ], + "right": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "name": "config", + "range": Array [ + 94, + 100, + ], + "type": "Identifier", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 28, + "line": 3, + }, + }, + "name": "title", + "range": Array [ + 101, + 106, + ], + "type": "Identifier", + }, + "range": Array [ + 94, + 106, + ], + "type": "MemberExpression", + }, + "type": "AssignmentExpression", + }, + "loc": Object { + "end": Object { + "column": 34, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 107, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 55, + "line": 2, + }, + }, + "range": Array [ + 71, + 113, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "name": "APP_CONFIG", + "range": Array [ + 40, + 50, + ], + "type": "Identifier", + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "name": "Inject", + "range": Array [ + 33, + 39, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 33, + 51, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 32, + 51, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "name": "config", + "range": Array [ + 52, + 69, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "range": Array [ + 58, + 69, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "range": Array [ + 60, + 69, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "name": "AppConfig", + "range": Array [ + 60, + 69, + ], + "type": "Identifier", + }, + }, + }, + }, + ], + "range": Array [ + 31, + 113, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 115, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Service", + "range": Array [ + 6, + 13, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 115, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 6, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 116, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 13, + ], + "type": "Identifier", + "value": "Service", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 20, + 31, + ], + "type": "Identifier", + "value": "constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 33, + 39, + ], + "type": "Identifier", + "value": "Inject", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 40, + 50, + ], + "type": "Identifier", + "value": "APP_CONFIG", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 34, + "line": 2, + }, + }, + "range": Array [ + 50, + 51, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 52, + 58, + ], + "type": "Identifier", + "value": "config", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "range": Array [ + 58, + 59, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "range": Array [ + 60, + 69, + ], + "type": "Identifier", + "value": "AppConfig", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 2, + }, + "start": Object { + "column": 53, + "line": 2, + }, + }, + "range": Array [ + 69, + 70, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 2, + }, + "start": Object { + "column": 55, + "line": 2, + }, + }, + "range": Array [ + 71, + 72, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 85, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "range": Array [ + 85, + 86, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "range": Array [ + 86, + 91, + ], + "type": "Identifier", + "value": "title", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 92, + 93, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "range": Array [ + 94, + 100, + ], + "type": "Identifier", + "value": "config", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 3, + }, + "start": Object { + "column": 27, + "line": 3, + }, + }, + "range": Array [ + 100, + 101, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 28, + "line": 3, + }, + }, + "range": Array [ + 101, + 106, + ], + "type": "Identifier", + "value": "title", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 106, + 107, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 114, + 115, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 16, + 19, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 16, + 50, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 48, + 50, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 29, + 33, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 21, + 28, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 34, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 34, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "baz", + "range": Array [ + 35, + 46, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 26, + "line": 2, + }, + }, + "range": Array [ + 38, + 46, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 40, + 46, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 19, + 50, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 52, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 52, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 53, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 16, + 19, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 28, + ], + "type": "Identifier", + "value": "special", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 29, + 33, + ], + "type": "Boolean", + "value": "true", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { "column": 21, + "line": 2, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + "value": "baz", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 26, + "line": 2, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 40, + 46, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 34, + "line": 2, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 37, + "line": 2, + }, + }, + "range": Array [ + 49, + 50, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 51, + 52, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 29, + 32, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 22, + 63, + ], + "static": true, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 43, + "line": 2, + }, + }, + "range": Array [ + 61, + 63, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 42, + 46, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 34, + 41, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 34, + 47, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 33, + 47, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "name": "baz", + "range": Array [ + 48, + 59, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 33, + "line": 2, + }, + }, + "range": Array [ + 51, + 59, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 35, + "line": 2, + }, + }, + "range": Array [ + 53, + 59, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 32, + 63, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 65, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "StaticFoo", + "range": Array [ + 6, + 15, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, "line": 3, }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 65, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "comments": Array [], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 66, + ], + "sourceType": "module", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 15, + ], + "type": "Identifier", + "value": "StaticFoo", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "Keyword", + "value": "static", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 29, + 32, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 34, + 41, + ], + "type": "Identifier", + "value": "special", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, }, "range": Array [ - 94, - 100, + 41, + 42, ], - "type": "Identifier", - "value": "config", + "type": "Punctuator", + "value": "(", }, Object { "loc": Object { "end": Object { "column": 28, - "line": 3, + "line": 2, }, "start": Object { - "column": 27, - "line": 3, + "column": 24, + "line": 2, }, }, "range": Array [ - 100, - 101, + 42, + 46, + ], + "type": "Boolean", + "value": "true", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 46, + 47, ], "type": "Punctuator", - "value": ".", + "value": ")", }, Object { "loc": Object { "end": Object { "column": 33, - "line": 3, + "line": 2, }, "start": Object { - "column": 28, - "line": 3, + "column": 30, + "line": 2, }, }, "range": Array [ - 101, - 106, + 48, + 51, ], "type": "Identifier", - "value": "title", + "value": "baz", }, Object { "loc": Object { "end": Object { "column": 34, - "line": 3, + "line": 2, }, "start": Object { "column": 33, - "line": 3, + "line": 2, }, }, "range": Array [ - 106, - 107, + 51, + 52, ], "type": "Punctuator", - "value": ";", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 41, + "line": 2, }, "start": Object { - "column": 4, - "line": 4, + "column": 35, + "line": 2, }, }, "range": Array [ - 112, - 113, + 53, + 59, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 2, + }, + "start": Object { + "column": 41, + "line": 2, + }, + }, + "range": Array [ + 59, + 60, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 2, + }, + "start": Object { + "column": 43, + "line": 2, + }, + }, + "range": Array [ + 61, + 62, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "range": Array [ + 62, + 63, ], "type": "Punctuator", "value": "}", @@ -83166,16 +85018,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 114, - 115, + 64, + 65, ], "type": "Punctuator", "value": "}", @@ -83185,7 +85037,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-instance-member.src 1`] = ` Object { "body": Array [ Object { @@ -83196,7 +85048,7 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 7, + "column": 9, "line": 2, }, "start": Object { @@ -83204,18 +85056,18 @@ Object { "line": 2, }, }, - "name": "bar", + "name": "greet", "range": Array [ - 16, - 19, + 20, + 25, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { "column": 4, @@ -83223,28 +85075,138 @@ Object { }, }, "range": Array [ - 16, - 50, + 20, + 95, ], "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [], + "body": Array [ + Object { + "argument": Object { + "left": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 67, + 75, + ], + "raw": "\\"Hello \\"", + "type": "Literal", + "value": "Hello ", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 67, + 82, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": "name", + "range": Array [ + 78, + 82, + ], + "type": "Identifier", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 67, + 88, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 85, + 88, + ], + "raw": "\\"!\\"", + "type": "Literal", + "value": "!", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 60, + 89, + ], + "type": "ReturnStatement", + }, + ], "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 36, + "column": 34, "line": 2, }, }, "range": Array [ - 48, 50, + 95, ], "type": "BlockStatement", }, @@ -83253,11 +85215,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 7, + "column": 9, "line": 2, }, }, @@ -83266,133 +85228,95 @@ Object { "decorators": Array [ Object { "expression": Object { - "arguments": Array [ - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 2, - }, - "start": Object { - "column": 17, - "line": 2, - }, - }, - "range": Array [ - 29, - 33, - ], - "raw": "true", - "type": "Literal", - "value": true, - }, - ], - "callee": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 2, - }, - "start": Object { - "column": 9, - "line": 2, - }, - }, - "name": "special", - "range": Array [ - 21, - 28, - ], - "type": "Identifier", - }, "loc": Object { "end": Object { - "column": 22, + "column": 19, "line": 2, }, "start": Object { - "column": 9, + "column": 11, "line": 2, }, }, + "name": "required", "range": Array [ - 21, - 34, + 27, + 35, ], - "type": "CallExpression", + "type": "Identifier", }, "loc": Object { "end": Object { - "column": 22, + "column": 19, "line": 2, }, "start": Object { - "column": 8, + "column": 10, "line": 2, }, }, "range": Array [ - 20, - 34, + 26, + 35, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 23, + "column": 20, "line": 2, }, }, - "name": "baz", + "name": "name", "range": Array [ - 35, - 46, + 36, + 48, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 26, + "column": 24, "line": 2, }, }, "range": Array [ - 38, - 46, + 40, + 48, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 28, + "column": 26, "line": 2, }, }, "range": Array [ - 40, - 46, + 42, + 48, ], - "type": "TSNumberKeyword", + "type": "TSStringKeyword", }, }, }, ], "range": Array [ - 19, - 50, + 25, + 95, ], "type": "FunctionExpression", }, @@ -83401,23 +85325,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { - "column": 10, + "column": 14, "line": 1, }, }, "range": Array [ - 10, - 52, + 14, + 97, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 9, + "column": 13, "line": 1, }, "start": Object { @@ -83425,17 +85349,17 @@ Object { "line": 1, }, }, - "name": "Foo", + "name": "Greeter", "range": Array [ 6, - 9, + 13, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, @@ -83444,7 +85368,7 @@ Object { }, "range": Array [ 0, - 52, + 97, ], "superClass": null, "type": "ClassDeclaration", @@ -83454,7 +85378,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 4, + "line": 6, }, "start": Object { "column": 0, @@ -83463,7 +85387,7 @@ Object { }, "range": Array [ 0, - 53, + 98, ], "sourceType": "module", "tokens": Array [ @@ -83488,7 +85412,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 13, "line": 1, }, "start": Object { @@ -83498,25 +85422,25 @@ Object { }, "range": Array [ 6, - 9, + 13, ], "type": "Identifier", - "value": "Foo", + "value": "Greeter", }, Object { "loc": Object { "end": Object { - "column": 11, + "column": 15, "line": 1, }, "start": Object { - "column": 10, + "column": 14, "line": 1, }, }, "range": Array [ - 10, - 11, + 14, + 15, ], "type": "Punctuator", "value": "{", @@ -83524,7 +85448,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 7, + "column": 9, "line": 2, }, "start": Object { @@ -83533,26 +85457,26 @@ Object { }, }, "range": Array [ - 16, - 19, + 20, + 25, ], "type": "Identifier", - "value": "bar", + "value": "greet", }, Object { "loc": Object { "end": Object { - "column": 8, + "column": 10, "line": 2, }, "start": Object { - "column": 7, + "column": 9, "line": 2, }, }, "range": Array [ - 19, - 20, + 25, + 26, ], "type": "Punctuator", "value": "(", @@ -83560,17 +85484,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 11, "line": 2, }, "start": Object { - "column": 8, + "column": 10, "line": 2, }, }, "range": Array [ - 20, - 21, + 26, + 27, ], "type": "Punctuator", "value": "@", @@ -83578,179 +85502,251 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 19, "line": 2, }, "start": Object { - "column": 9, + "column": 11, "line": 2, }, }, "range": Array [ - 21, - 28, + 27, + 35, ], "type": "Identifier", - "value": "special", + "value": "required", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 24, + "line": 2, + }, + "start": Object { + "column": 20, + "line": 2, + }, + }, + "range": Array [ + 36, + 40, + ], + "type": "Identifier", + "value": "name", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 40, + 41, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 2, + }, + "start": Object { + "column": 26, + "line": 2, + }, + }, + "range": Array [ + 42, + 48, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 2, + }, + "start": Object { + "column": 32, + "line": 2, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, "line": 2, }, "start": Object { - "column": 16, + "column": 34, "line": 2, }, }, "range": Array [ - 28, - 29, + 50, + 51, ], "type": "Punctuator", - "value": "(", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 21, - "line": 2, + "column": 14, + "line": 3, }, "start": Object { - "column": 17, - "line": 2, + "column": 8, + "line": 3, }, }, "range": Array [ - 29, - 33, + 60, + 66, ], - "type": "Boolean", - "value": "true", + "type": "Keyword", + "value": "return", }, Object { "loc": Object { "end": Object { - "column": 22, - "line": 2, + "column": 23, + "line": 3, }, "start": Object { - "column": 21, - "line": 2, + "column": 15, + "line": 3, }, }, "range": Array [ - 33, - 34, + 67, + 75, ], - "type": "Punctuator", - "value": ")", + "type": "String", + "value": "\\"Hello \\"", }, Object { "loc": Object { "end": Object { - "column": 26, - "line": 2, + "column": 25, + "line": 3, }, "start": Object { - "column": 23, - "line": 2, + "column": 24, + "line": 3, }, }, "range": Array [ - 35, - 38, + 76, + 77, ], - "type": "Identifier", - "value": "baz", + "type": "Punctuator", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 27, - "line": 2, + "column": 30, + "line": 3, }, "start": Object { "column": 26, - "line": 2, + "line": 3, }, }, "range": Array [ - 38, - 39, + 78, + 82, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "name", }, Object { "loc": Object { "end": Object { - "column": 34, - "line": 2, + "column": 32, + "line": 3, }, "start": Object { - "column": 28, - "line": 2, + "column": 31, + "line": 3, }, }, "range": Array [ - 40, - 46, + 83, + 84, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 35, - "line": 2, + "column": 36, + "line": 3, }, "start": Object { - "column": 34, - "line": 2, + "column": 33, + "line": 3, }, }, "range": Array [ - 46, - 47, + 85, + 88, ], - "type": "Punctuator", - "value": ")", + "type": "String", + "value": "\\"!\\"", }, Object { "loc": Object { "end": Object { "column": 37, - "line": 2, + "line": 3, }, "start": Object { "column": 36, - "line": 2, + "line": 3, }, }, "range": Array [ - 48, - 49, + 88, + 89, ], "type": "Punctuator", - "value": "{", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 37, - "line": 2, + "column": 4, + "line": 4, }, }, "range": Array [ - 49, - 50, + 94, + 95, ], "type": "Punctuator", "value": "}", @@ -83759,16 +85755,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, - "line": 3, + "line": 5, }, }, "range": Array [ - 51, - 52, + 96, + 97, ], "type": "Punctuator", "value": "}", @@ -83778,7 +85774,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-static-member.src 1`] = ` Object { "body": Array [ Object { @@ -83789,7 +85785,7 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 2, }, "start": Object { @@ -83797,18 +85793,18 @@ Object { "line": 2, }, }, - "name": "bar", + "name": "greet", "range": Array [ - 29, - 32, + 33, + 38, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { "column": 4, @@ -83816,28 +85812,138 @@ Object { }, }, "range": Array [ - 22, - 63, + 26, + 108, ], "static": true, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [], + "body": Array [ + Object { + "argument": Object { + "left": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 80, + 88, + ], + "raw": "\\"Hello \\"", + "type": "Literal", + "value": "Hello ", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 80, + 95, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": "name", + "range": Array [ + 91, + 95, + ], + "type": "Identifier", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 80, + 101, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 98, + 101, + ], + "raw": "\\"!\\"", + "type": "Literal", + "value": "!", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 73, + 102, + ], + "type": "ReturnStatement", + }, + ], "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 43, + "column": 41, "line": 2, }, }, "range": Array [ - 61, 63, + 108, ], "type": "BlockStatement", }, @@ -83846,11 +85952,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 14, + "column": 16, "line": 2, }, }, @@ -83859,133 +85965,95 @@ Object { "decorators": Array [ Object { "expression": Object { - "arguments": Array [ - Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 2, - }, - "start": Object { - "column": 24, - "line": 2, - }, - }, - "range": Array [ - 42, - 46, - ], - "raw": "true", - "type": "Literal", - "value": true, - }, - ], - "callee": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "name": "special", - "range": Array [ - 34, - 41, - ], - "type": "Identifier", - }, "loc": Object { "end": Object { - "column": 29, + "column": 26, "line": 2, }, "start": Object { - "column": 16, + "column": 18, "line": 2, }, }, + "name": "required", "range": Array [ - 34, - 47, + 40, + 48, ], - "type": "CallExpression", + "type": "Identifier", }, "loc": Object { "end": Object { - "column": 29, + "column": 26, "line": 2, }, "start": Object { - "column": 15, + "column": 17, "line": 2, }, }, "range": Array [ - 33, - 47, + 39, + 48, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 30, + "column": 27, "line": 2, }, }, - "name": "baz", + "name": "name", "range": Array [ - 48, - 59, + 49, + 61, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 33, + "column": 31, "line": 2, }, }, "range": Array [ - 51, - 59, + 53, + 61, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 35, + "column": 33, "line": 2, }, }, "range": Array [ - 53, - 59, + 55, + 61, ], - "type": "TSNumberKeyword", + "type": "TSStringKeyword", }, }, }, ], "range": Array [ - 32, - 63, + 38, + 108, ], "type": "FunctionExpression", }, @@ -83994,23 +86062,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { - "column": 16, + "column": 20, "line": 1, }, }, "range": Array [ - 16, - 65, + 20, + 110, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 15, + "column": 19, "line": 1, }, "start": Object { @@ -84018,17 +86086,17 @@ Object { "line": 1, }, }, - "name": "StaticFoo", + "name": "StaticGreeter", "range": Array [ 6, - 15, + 19, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, @@ -84037,7 +86105,7 @@ Object { }, "range": Array [ 0, - 65, + 110, ], "superClass": null, "type": "ClassDeclaration", @@ -84047,7 +86115,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 4, + "line": 6, }, "start": Object { "column": 0, @@ -84056,7 +86124,7 @@ Object { }, "range": Array [ 0, - 66, + 111, ], "sourceType": "module", "tokens": Array [ @@ -84081,7 +86149,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 19, "line": 1, }, "start": Object { @@ -84091,25 +86159,25 @@ Object { }, "range": Array [ 6, - 15, + 19, ], "type": "Identifier", - "value": "StaticFoo", + "value": "StaticGreeter", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 21, "line": 1, }, "start": Object { - "column": 16, + "column": 20, "line": 1, }, }, "range": Array [ - 16, - 17, + 20, + 21, ], "type": "Punctuator", "value": "{", @@ -84126,8 +86194,8 @@ Object { }, }, "range": Array [ - 22, - 28, + 26, + 32, ], "type": "Keyword", "value": "static", @@ -84135,7 +86203,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 2, }, "start": Object { @@ -84144,26 +86212,26 @@ Object { }, }, "range": Array [ - 29, - 32, + 33, + 38, ], "type": "Identifier", - "value": "bar", + "value": "greet", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 17, "line": 2, }, "start": Object { - "column": 14, + "column": 16, "line": 2, }, }, "range": Array [ - 32, - 33, + 38, + 39, ], "type": "Punctuator", "value": "(", @@ -84171,17 +86239,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 18, "line": 2, }, "start": Object { - "column": 15, + "column": 17, "line": 2, }, }, "range": Array [ - 33, - 34, + 39, + 40, ], "type": "Punctuator", "value": "@", @@ -84189,71 +86257,89 @@ Object { Object { "loc": Object { "end": Object { - "column": 23, + "column": 26, "line": 2, }, "start": Object { - "column": 16, + "column": 18, "line": 2, }, }, "range": Array [ - 34, - 41, + 40, + 48, ], "type": "Identifier", - "value": "special", + "value": "required", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 31, "line": 2, }, "start": Object { - "column": 23, + "column": 27, "line": 2, }, }, "range": Array [ - 41, - 42, + 49, + 53, + ], + "type": "Identifier", + "value": "name", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "range": Array [ + 53, + 54, ], "type": "Punctuator", - "value": "(", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 39, "line": 2, }, "start": Object { - "column": 24, + "column": 33, "line": 2, }, }, "range": Array [ - 42, - 46, + 55, + 61, ], - "type": "Boolean", - "value": "true", + "type": "Identifier", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 29, + "column": 40, "line": 2, }, "start": Object { - "column": 28, + "column": 39, "line": 2, }, }, "range": Array [ - 46, - 47, + 61, + 62, ], "type": "Punctuator", "value": ")", @@ -84261,304 +86347,248 @@ Object { Object { "loc": Object { "end": Object { - "column": 33, + "column": 42, "line": 2, }, "start": Object { - "column": 30, + "column": 41, "line": 2, }, }, "range": Array [ - 48, - 51, + 63, + 64, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 73, + 79, ], - "type": "Identifier", - "value": "baz", + "type": "Keyword", + "value": "return", }, Object { "loc": Object { "end": Object { - "column": 34, - "line": 2, + "column": 23, + "line": 3, }, "start": Object { - "column": 33, - "line": 2, + "column": 15, + "line": 3, }, }, "range": Array [ - 51, - 52, + 80, + 88, ], - "type": "Punctuator", - "value": ":", + "type": "String", + "value": "\\"Hello \\"", }, Object { "loc": Object { "end": Object { - "column": 41, - "line": 2, + "column": 25, + "line": 3, }, "start": Object { - "column": 35, - "line": 2, + "column": 24, + "line": 3, }, }, "range": Array [ - 53, - 59, + 89, + 90, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 42, - "line": 2, + "column": 30, + "line": 3, }, "start": Object { - "column": 41, - "line": 2, + "column": 26, + "line": 3, }, }, "range": Array [ - 59, - 60, + 91, + 95, ], - "type": "Punctuator", - "value": ")", + "type": "Identifier", + "value": "name", }, Object { "loc": Object { "end": Object { - "column": 44, - "line": 2, + "column": 32, + "line": 3, }, "start": Object { - "column": 43, - "line": 2, + "column": 31, + "line": 3, }, }, "range": Array [ - 61, - 62, + 96, + 97, ], "type": "Punctuator", - "value": "{", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 36, + "line": 3, }, "start": Object { - "column": 44, - "line": 2, + "column": 33, + "line": 3, }, }, "range": Array [ - 62, - 63, + 98, + 101, ], - "type": "Punctuator", - "value": "}", + "type": "String", + "value": "\\"!\\"", }, Object { "loc": Object { "end": Object { - "column": 1, + "column": 37, "line": 3, }, "start": Object { - "column": 0, + "column": 36, "line": 3, }, }, "range": Array [ - 64, - 65, - ], - "type": "Punctuator", - "value": "}", - }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-instance-member.src 1`] = ` -Object { - "body": Array [ - Object { - "body": Object { - "body": Array [ - Object { - "computed": false, - "key": Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "name": "greet", - "range": Array [ - 20, - 25, - ], - "type": "Identifier", - }, - "kind": "method", - "loc": Object { - "end": Object { - "column": 5, - "line": 4, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "range": Array [ - 20, - 95, - ], - "static": false, - "type": "MethodDefinition", - "value": Object { - "async": false, - "body": Object { - "body": Array [ - Object { - "argument": Object { - "left": Object { - "left": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "range": Array [ - 67, - 75, - ], - "raw": "\\"Hello \\"", - "type": "Literal", - "value": "Hello ", - }, - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 67, - 82, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 26, - "line": 3, - }, - }, - "name": "name", - "range": Array [ - 78, - 82, - ], - "type": "Identifier", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 67, - 88, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 85, - 88, - ], - "raw": "\\"!\\"", - "type": "Literal", - "value": "!", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 60, - 89, - ], - "type": "ReturnStatement", - }, - ], + 101, + 102, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "range": Array [ + 107, + 108, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 109, + 110, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-object-pattern-decorator.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 49, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 34, + "column": 35, "line": 2, }, }, "range": Array [ - 50, - 95, + 47, + 49, ], "type": "BlockStatement", }, @@ -84567,11 +86597,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 9, + "column": 5, "line": 2, }, }, @@ -84580,95 +86610,191 @@ Object { "decorators": Array [ Object { "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 31, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 19, + 26, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 2, }, "start": Object { - "column": 11, + "column": 7, "line": 2, }, }, - "name": "required", "range": Array [ - 27, - 35, + 19, + 32, ], - "type": "Identifier", + "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 2, }, "start": Object { - "column": 10, + "column": 6, "line": 2, }, }, "range": Array [ - 26, - 35, + 18, + 32, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 20, + "column": 21, "line": 2, }, }, - "name": "name", + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "method": false, + "range": Array [ + 35, + 38, + ], + "shorthand": true, + "type": "Property", + "value": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + }, + ], "range": Array [ - 36, - 48, + 33, + 45, ], - "type": "Identifier", + "type": "ObjectPattern", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 24, + "column": 28, "line": 2, }, }, "range": Array [ 40, - 48, + 45, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 26, + "column": 30, "line": 2, }, }, "range": Array [ 42, - 48, + 45, ], - "type": "TSStringKeyword", + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 25, - 95, + 17, + 49, ], "type": "FunctionExpression", }, @@ -84677,23 +86803,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 97, + 10, + 51, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -84701,17 +86827,17 @@ Object { "line": 1, }, }, - "name": "Greeter", + "name": "Foo", "range": Array [ 6, - 13, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -84720,7 +86846,7 @@ Object { }, "range": Array [ 0, - 97, + 51, ], "superClass": null, "type": "ClassDeclaration", @@ -84730,7 +86856,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -84739,7 +86865,7 @@ Object { }, "range": Array [ 0, - 98, + 52, ], "sourceType": "module", "tokens": Array [ @@ -84764,7 +86890,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -84774,25 +86900,25 @@ Object { }, "range": Array [ 6, - 13, + 9, ], "type": "Identifier", - "value": "Greeter", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 11, "line": 1, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 15, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -84800,35 +86926,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 25, + 14, + 17, ], "type": "Identifier", - "value": "greet", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 6, "line": 2, }, "start": Object { - "column": 9, + "column": 5, "line": 2, }, }, "range": Array [ - 25, - 26, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -84836,17 +86962,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 11, + "column": 7, "line": 2, }, "start": Object { - "column": 10, + "column": 6, "line": 2, }, }, "range": Array [ - 26, - 27, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -84854,89 +86980,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, - "line": 2, - }, - "start": Object { - "column": 11, - "line": 2, - }, - }, - "range": Array [ - 27, - 35, - ], - "type": "Identifier", - "value": "required", - }, - Object { - "loc": Object { - "end": Object { - "column": 24, + "column": 14, "line": 2, }, "start": Object { - "column": 20, + "column": 7, "line": 2, }, }, "range": Array [ - 36, - 40, + 19, + 26, ], "type": "Identifier", - "value": "name", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 15, "line": 2, }, "start": Object { - "column": 24, + "column": 14, "line": 2, }, }, "range": Array [ - 40, - 41, + 26, + 27, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 32, + "column": 19, "line": 2, }, "start": Object { - "column": 26, + "column": 15, "line": 2, }, }, "range": Array [ - 42, - 48, + 27, + 31, ], - "type": "Identifier", - "value": "string", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 33, + "column": 20, "line": 2, }, "start": Object { - "column": 32, + "column": 19, "line": 2, }, }, "range": Array [ - 48, - 49, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -84944,17 +87052,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 35, + "column": 22, "line": 2, }, "start": Object { - "column": 34, + "column": 21, "line": 2, }, }, "range": Array [ - 50, - 51, + 33, + 34, ], "type": "Punctuator", "value": "{", @@ -84962,143 +87070,125 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, - "line": 3, + "column": 26, + "line": 2, }, "start": Object { - "column": 8, - "line": 3, + "column": 23, + "line": 2, }, }, "range": Array [ - 60, - 66, + 35, + 38, ], - "type": "Keyword", - "value": "return", + "type": "Identifier", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 3, + "column": 28, + "line": 2, }, "start": Object { - "column": 15, - "line": 3, + "column": 27, + "line": 2, }, }, "range": Array [ - 67, - 75, + 39, + 40, ], - "type": "String", - "value": "\\"Hello \\"", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 25, - "line": 3, + "column": 29, + "line": 2, }, "start": Object { - "column": 24, - "line": 3, + "column": 28, + "line": 2, }, }, "range": Array [ - 76, - 77, + 40, + 41, ], "type": "Punctuator", - "value": "+", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 30, - "line": 3, + "column": 33, + "line": 2, }, "start": Object { - "column": 26, - "line": 3, + "column": 30, + "line": 2, }, }, "range": Array [ - 78, - 82, + 42, + 45, ], "type": "Identifier", - "value": "name", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 32, - "line": 3, + "column": 34, + "line": 2, }, "start": Object { - "column": 31, - "line": 3, + "column": 33, + "line": 2, }, }, "range": Array [ - 83, - 84, + 45, + 46, ], "type": "Punctuator", - "value": "+", + "value": ")", }, Object { "loc": Object { "end": Object { "column": 36, - "line": 3, + "line": 2, }, "start": Object { - "column": 33, - "line": 3, + "column": 35, + "line": 2, }, }, "range": Array [ - 85, - 88, + 47, + 48, ], - "type": "String", - "value": "\\"!\\"", + "type": "Punctuator", + "value": "{", }, Object { "loc": Object { "end": Object { "column": 37, - "line": 3, + "line": 2, }, "start": Object { "column": 36, - "line": 3, - }, - }, - "range": Array [ - 88, - 89, - ], - "type": "Punctuator", - "value": ";", - }, - Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 4, - }, - "start": Object { - "column": 4, - "line": 4, + "line": 2, }, }, "range": Array [ - 94, - 95, + 48, + 49, ], "type": "Punctuator", "value": "}", @@ -85107,16 +87197,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 96, - 97, + 50, + 51, ], "type": "Punctuator", "value": "}", @@ -85126,7 +87216,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-static-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-rest-element-decorator.src 1`] = ` Object { "body": Array [ Object { @@ -85137,165 +87227,55 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 16, + "column": 5, "line": 2, }, "start": Object { - "column": 11, + "column": 2, "line": 2, }, }, - "name": "greet", + "name": "bar", "range": Array [ - 33, - 38, + 14, + 17, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 26, - 108, + 14, + 48, ], - "static": true, + "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [ - Object { - "argument": Object { - "left": Object { - "left": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "range": Array [ - 80, - 88, - ], - "raw": "\\"Hello \\"", - "type": "Literal", - "value": "Hello ", - }, - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 80, - 95, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 26, - "line": 3, - }, - }, - "name": "name", - "range": Array [ - 91, - 95, - ], - "type": "Identifier", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 80, - 101, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 98, - 101, - ], - "raw": "\\"!\\"", - "type": "Literal", - "value": "!", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 73, - 102, - ], - "type": "ReturnStatement", - }, - ], + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 41, + "column": 34, "line": 2, }, }, "range": Array [ - 63, - 108, + 46, + 48, ], "type": "BlockStatement", }, @@ -85304,108 +87284,163 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 16, + "column": 5, "line": 2, }, }, "params": Array [ Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "name": "foo", + "range": Array [ + 36, + 39, + ], + "type": "Identifier", + }, "decorators": Array [ Object { "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 31, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 19, + 26, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 26, + "column": 20, "line": 2, }, "start": Object { - "column": 18, + "column": 7, "line": 2, }, }, - "name": "required", "range": Array [ - 40, - 48, + 19, + 32, ], - "type": "Identifier", + "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 26, + "column": 20, "line": 2, }, "start": Object { - "column": 17, + "column": 6, "line": 2, }, }, "range": Array [ - 39, - 48, + 18, + 32, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 27, + "column": 6, "line": 2, }, }, - "name": "name", "range": Array [ - 49, - 61, + 18, + 44, ], - "type": "Identifier", + "type": "RestElement", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 31, + "column": 27, "line": 2, }, }, "range": Array [ - 53, - 61, + 39, + 44, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 33, + "column": 29, "line": 2, }, }, "range": Array [ - 55, - 61, + 41, + 44, ], - "type": "TSStringKeyword", + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 38, - 108, + 17, + 48, ], "type": "FunctionExpression", }, @@ -85414,23 +87449,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 20, + "column": 10, "line": 1, }, }, "range": Array [ - 20, - 110, + 10, + 50, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 19, + "column": 9, "line": 1, }, "start": Object { @@ -85438,17 +87473,17 @@ Object { "line": 1, }, }, - "name": "StaticGreeter", + "name": "Foo", "range": Array [ 6, - 19, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -85457,7 +87492,7 @@ Object { }, "range": Array [ 0, - 110, + 50, ], "superClass": null, "type": "ClassDeclaration", @@ -85467,7 +87502,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -85476,7 +87511,7 @@ Object { }, "range": Array [ 0, - 111, + 51, ], "sourceType": "module", "tokens": Array [ @@ -85501,7 +87536,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, + "column": 9, "line": 1, }, "start": Object { @@ -85511,25 +87546,25 @@ Object { }, "range": Array [ 6, - 19, + 9, ], "type": "Identifier", - "value": "StaticGreeter", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 11, "line": 1, }, "start": Object { - "column": 20, + "column": 10, "line": 1, }, }, "range": Array [ - 20, - 21, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -85537,53 +87572,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 10, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "range": Array [ - 26, - 32, - ], - "type": "Keyword", - "value": "static", - }, - Object { - "loc": Object { - "end": Object { - "column": 16, + "column": 5, "line": 2, }, "start": Object { - "column": 11, + "column": 2, "line": 2, }, }, "range": Array [ - 33, - 38, + 14, + 17, ], "type": "Identifier", - "value": "greet", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 6, "line": 2, }, "start": Object { - "column": 16, + "column": 5, "line": 2, }, }, "range": Array [ - 38, - 39, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -85591,17 +87608,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 18, + "column": 7, "line": 2, }, "start": Object { - "column": 17, + "column": 6, "line": 2, }, }, "range": Array [ - 39, - 40, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -85609,89 +87626,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 26, - "line": 2, - }, - "start": Object { - "column": 18, - "line": 2, - }, - }, - "range": Array [ - 40, - 48, - ], - "type": "Identifier", - "value": "required", - }, - Object { - "loc": Object { - "end": Object { - "column": 31, + "column": 14, "line": 2, }, "start": Object { - "column": 27, + "column": 7, "line": 2, }, }, "range": Array [ - 49, - 53, + 19, + 26, ], "type": "Identifier", - "value": "name", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 32, + "column": 15, "line": 2, }, "start": Object { - "column": 31, + "column": 14, "line": 2, }, }, "range": Array [ - 53, - 54, + 26, + 27, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 39, + "column": 19, "line": 2, }, "start": Object { - "column": 33, + "column": 15, "line": 2, }, }, "range": Array [ - 55, - 61, + 27, + 31, ], - "type": "Identifier", - "value": "string", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 20, "line": 2, }, "start": Object { - "column": 39, + "column": 19, "line": 2, }, }, "range": Array [ - 61, - 62, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -85699,161 +87698,125 @@ Object { Object { "loc": Object { "end": Object { - "column": 42, + "column": 24, "line": 2, }, "start": Object { - "column": 41, + "column": 21, "line": 2, }, }, "range": Array [ - 63, - 64, + 33, + 36, ], "type": "Punctuator", - "value": "{", - }, - Object { - "loc": Object { - "end": Object { - "column": 14, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 73, - 79, - ], - "type": "Keyword", - "value": "return", + "value": "...", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 3, + "column": 27, + "line": 2, }, "start": Object { - "column": 15, - "line": 3, + "column": 24, + "line": 2, }, }, "range": Array [ - 80, - 88, + 36, + 39, ], - "type": "String", - "value": "\\"Hello \\"", + "type": "Identifier", + "value": "foo", }, Object { "loc": Object { "end": Object { - "column": 25, - "line": 3, + "column": 28, + "line": 2, }, "start": Object { - "column": 24, - "line": 3, + "column": 27, + "line": 2, }, }, "range": Array [ - 89, - 90, + 39, + 40, ], "type": "Punctuator", - "value": "+", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 30, - "line": 3, + "column": 32, + "line": 2, }, "start": Object { - "column": 26, - "line": 3, + "column": 29, + "line": 2, }, }, "range": Array [ - 91, - 95, + 41, + 44, ], "type": "Identifier", - "value": "name", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 32, - "line": 3, + "column": 33, + "line": 2, }, "start": Object { - "column": 31, - "line": 3, + "column": 32, + "line": 2, }, }, "range": Array [ - 96, - 97, + 44, + 45, ], "type": "Punctuator", - "value": "+", - }, - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 98, - 101, - ], - "type": "String", - "value": "\\"!\\"", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 37, - "line": 3, + "column": 35, + "line": 2, }, "start": Object { - "column": 36, - "line": 3, + "column": 34, + "line": 2, }, }, "range": Array [ - 101, - 102, + 46, + 47, ], "type": "Punctuator", - "value": ";", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 4, - "line": 4, + "column": 35, + "line": 2, }, }, "range": Array [ - 107, - 108, + 47, + 48, ], "type": "Punctuator", "value": "}", @@ -85862,16 +87825,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 109, - 110, + 49, + 50, ], "type": "Punctuator", "value": "}", diff --git a/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-array-pattern-decorator.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-array-pattern-decorator.src.ts new file mode 100644 index 000000000000..81dfc005fc92 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-array-pattern-decorator.src.ts @@ -0,0 +1,3 @@ +class Foo { + bar(@special(true) [ bar ]: any) {} +} diff --git a/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-object-pattern-decorator.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-object-pattern-decorator.src.ts new file mode 100644 index 000000000000..dc9133b3deaf --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-object-pattern-decorator.src.ts @@ -0,0 +1,3 @@ +class Foo { + bar(@special(true) { bar }: any) {} +} diff --git a/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-rest-element-decorator.src.ts b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-rest-element-decorator.src.ts new file mode 100644 index 000000000000..35b2ac60bc94 --- /dev/null +++ b/packages/shared-fixtures/fixtures/typescript/decorators/parameter-decorators/parameter-rest-element-decorator.src.ts @@ -0,0 +1,3 @@ +class Foo { + bar(@special(true) ...foo: any) {} +} diff --git a/packages/typescript-estree/src/typedefs.ts b/packages/typescript-estree/src/typedefs.ts index bf683e859440..6083550af5ec 100644 --- a/packages/typescript-estree/src/typedefs.ts +++ b/packages/typescript-estree/src/typedefs.ts @@ -541,6 +541,7 @@ export interface ArrayPattern extends BaseNode { elements: Expression[]; typeAnnotation?: TSTypeAnnotation; optional?: boolean; + decorators?: Decorator[]; } export interface ArrowFunctionExpression extends BaseNode { @@ -876,6 +877,7 @@ export interface ObjectPattern extends BaseNode { properties: ObjectLiteralElementLike[]; typeAnnotation?: TSTypeAnnotation; optional?: boolean; + decorators?: Decorator[]; } export interface Program extends BaseNode { @@ -903,6 +905,7 @@ export interface RestElement extends BaseNode { typeAnnotation?: TSTypeAnnotation; optional?: boolean; value?: AssignmentPattern; + decorators?: Decorator[]; } export interface ReturnStatement extends BaseNode { diff --git a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts index ede45e93fcda..c76940f2d293 100644 --- a/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts +++ b/packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts @@ -401,7 +401,14 @@ tester.addFixturePatternConfig('typescript/decorators/method-decorators', { fileType: 'ts' }); tester.addFixturePatternConfig('typescript/decorators/parameter-decorators', { - fileType: 'ts' + fileType: 'ts', + ignore: [ + /** + * babel does not support decorators on array and rest parameters + */ + 'parameter-array-pattern-decorator', + 'parameter-rest-element-decorator' + ] }); tester.addFixturePatternConfig('typescript/decorators/property-decorators', { fileType: 'ts' diff --git a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap index 842757edb3df..552ffe9b1fa7 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap @@ -2236,6 +2236,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/method-decorators/method-decorator-static-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-array-pattern-decorator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-decorator-constructor.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; @@ -2246,6 +2248,10 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-decorator-static-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-object-pattern-decorator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + +exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/parameter-decorators/parameter-rest-element-decorator.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; + exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/property-decorators/property-decorator-factory-instance-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/decorators/property-decorators/property-decorator-factory-static-member.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`; diff --git a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap index 0c1e0c5afe60..0cbc469863ee 100644 --- a/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap +++ b/packages/typescript-estree/tests/lib/__snapshots__/typescript.ts.snap @@ -81613,7 +81613,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-constructor.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-array-pattern-decorator.src 1`] = ` Object { "body": Array [ Object { @@ -81624,198 +81624,55 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 15, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, - "name": "constructor", + "name": "bar", "range": Array [ - 20, - 31, + 14, + 17, ], "type": "Identifier", }, - "kind": "constructor", + "kind": "method", "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 113, + 14, + 49, ], "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [ - Object { - "expression": Object { - "left": Object { - "computed": false, - "loc": Object { - "end": Object { - "column": 18, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "object": Object { - "loc": Object { - "end": Object { - "column": 12, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 81, - 85, - ], - "type": "ThisExpression", - }, - "property": Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 3, - }, - "start": Object { - "column": 13, - "line": 3, - }, - }, - "name": "title", - "range": Array [ - 86, - 91, - ], - "type": "Identifier", - }, - "range": Array [ - 81, - 91, - ], - "type": "MemberExpression", - }, - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "operator": "=", - "range": Array [ - 81, - 106, - ], - "right": Object { - "computed": false, - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "object": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 3, - }, - "start": Object { - "column": 21, - "line": 3, - }, - }, - "name": "config", - "range": Array [ - 94, - 100, - ], - "type": "Identifier", - }, - "property": Object { - "loc": Object { - "end": Object { - "column": 33, - "line": 3, - }, - "start": Object { - "column": 28, - "line": 3, - }, - }, - "name": "title", - "range": Array [ - 101, - 106, - ], - "type": "Identifier", - }, - "range": Array [ - 94, - 106, - ], - "type": "MemberExpression", - }, - "type": "AssignmentExpression", - }, - "loc": Object { - "end": Object { - "column": 34, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 81, - 107, - ], - "type": "ExpressionStatement", - }, - ], + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 55, + "column": 35, "line": 2, }, }, "range": Array [ - 71, - 113, + 47, + 49, ], "type": "BlockStatement", }, @@ -81824,11 +81681,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 15, + "column": 5, "line": 2, }, }, @@ -81841,146 +81698,148 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, + "column": 19, "line": 2, }, "start": Object { - "column": 24, + "column": 15, "line": 2, }, }, - "name": "APP_CONFIG", "range": Array [ - 40, - 50, + 27, + 31, ], - "type": "Identifier", + "raw": "true", + "type": "Literal", + "value": true, }, ], "callee": Object { "loc": Object { "end": Object { - "column": 23, + "column": 14, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, - "name": "Inject", + "name": "special", "range": Array [ - 33, - 39, + 19, + 26, ], "type": "Identifier", }, "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, "range": Array [ - 33, - 51, + 19, + 32, ], "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 16, + "column": 6, "line": 2, }, }, "range": Array [ + 18, 32, - 51, ], "type": "Decorator", }, ], + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + ], "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 36, + "column": 21, "line": 2, }, }, - "name": "config", "range": Array [ - 52, - 69, + 33, + 45, ], - "type": "Identifier", + "type": "ArrayPattern", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 42, + "column": 28, "line": 2, }, }, "range": Array [ - 58, - 69, + 40, + 45, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 53, + "column": 33, "line": 2, }, "start": Object { - "column": 44, + "column": 30, "line": 2, }, }, "range": Array [ - 60, - 69, + 42, + 45, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 53, - "line": 2, - }, - "start": Object { - "column": 44, - "line": 2, - }, - }, - "name": "AppConfig", - "range": Array [ - 60, - 69, - ], - "type": "Identifier", - }, + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 31, - 113, + 17, + 49, ], "type": "FunctionExpression", }, @@ -81989,23 +81848,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 115, + 10, + 51, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -82013,17 +81872,17 @@ Object { "line": 1, }, }, - "name": "Service", + "name": "Foo", "range": Array [ 6, - 13, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -82032,7 +81891,7 @@ Object { }, "range": Array [ 0, - 115, + 51, ], "superClass": null, "type": "ClassDeclaration", @@ -82041,7 +81900,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -82050,7 +81909,7 @@ Object { }, "range": Array [ 0, - 116, + 52, ], "sourceType": "script", "tokens": Array [ @@ -82075,7 +81934,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -82085,25 +81944,25 @@ Object { }, "range": Array [ 6, - 13, + 9, ], "type": "Identifier", - "value": "Service", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 11, "line": 1, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 15, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -82111,35 +81970,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 31, + 14, + 17, ], "type": "Identifier", - "value": "constructor", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 6, "line": 2, }, "start": Object { - "column": 15, + "column": 5, "line": 2, }, }, "range": Array [ - 31, - 32, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -82147,17 +82006,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 17, + "column": 7, "line": 2, }, "start": Object { - "column": 16, + "column": 6, "line": 2, }, }, "range": Array [ - 32, - 33, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -82165,35 +82024,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 23, + "column": 14, "line": 2, }, "start": Object { - "column": 17, + "column": 7, "line": 2, }, }, "range": Array [ - 33, - 39, + 19, + 26, ], "type": "Identifier", - "value": "Inject", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 15, "line": 2, }, "start": Object { - "column": 23, + "column": 14, "line": 2, }, }, "range": Array [ - 39, - 40, + 26, + 27, ], "type": "Punctuator", "value": "(", @@ -82201,35 +82060,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 34, + "column": 19, "line": 2, }, "start": Object { - "column": 24, + "column": 15, "line": 2, }, }, "range": Array [ - 40, - 50, + 27, + 31, ], - "type": "Identifier", - "value": "APP_CONFIG", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 35, + "column": 20, "line": 2, }, "start": Object { - "column": 34, + "column": 19, "line": 2, }, }, "range": Array [ - 50, - 51, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -82237,251 +82096,2241 @@ Object { Object { "loc": Object { "end": Object { - "column": 42, + "column": 22, "line": 2, }, "start": Object { - "column": 36, + "column": 21, "line": 2, }, }, "range": Array [ - 52, - 58, + 33, + 34, ], - "type": "Identifier", - "value": "config", + "type": "Punctuator", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 43, + "column": 26, "line": 2, }, "start": Object { - "column": 42, + "column": 23, "line": 2, }, }, "range": Array [ - 58, - 59, + 35, + 38, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 53, + "column": 28, "line": 2, }, "start": Object { - "column": 44, + "column": 27, "line": 2, }, }, "range": Array [ - 60, - 69, + 39, + 40, ], - "type": "Identifier", - "value": "AppConfig", + "type": "Punctuator", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 54, + "column": 29, "line": 2, }, "start": Object { - "column": 53, + "column": 28, "line": 2, }, }, "range": Array [ - 69, - 70, + 40, + 41, ], "type": "Punctuator", - "value": ")", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 56, + "column": 33, "line": 2, }, "start": Object { - "column": 55, + "column": 30, "line": 2, }, }, "range": Array [ - 71, - 72, + 42, + 45, ], - "type": "Punctuator", - "value": "{", + "type": "Identifier", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 12, - "line": 3, + "column": 34, + "line": 2, }, "start": Object { - "column": 8, - "line": 3, + "column": 33, + "line": 2, }, }, "range": Array [ - 81, - 85, + 45, + 46, ], - "type": "Keyword", - "value": "this", + "type": "Punctuator", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 13, - "line": 3, + "column": 36, + "line": 2, }, "start": Object { - "column": 12, - "line": 3, + "column": 35, + "line": 2, }, }, "range": Array [ - 85, - 86, + 47, + 48, ], "type": "Punctuator", - "value": ".", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 18, - "line": 3, + "column": 37, + "line": 2, }, "start": Object { - "column": 13, - "line": 3, + "column": 36, + "line": 2, }, }, "range": Array [ - 86, - 91, + 48, + 49, ], - "type": "Identifier", - "value": "title", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 20, + "column": 1, "line": 3, }, "start": Object { - "column": 19, + "column": 0, "line": 3, }, }, "range": Array [ - 92, - 93, + 50, + 51, ], "type": "Punctuator", - "value": "=", + "value": "}", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-constructor.src 1`] = ` +Object { + "body": Array [ Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 3, - }, - "start": Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "constructor", + "range": Array [ + 20, + 31, + ], + "type": "Identifier", + }, + "kind": "constructor", + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 20, + 113, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "expression": Object { + "left": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 85, + ], + "type": "ThisExpression", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "name": "title", + "range": Array [ + 86, + 91, + ], + "type": "Identifier", + }, + "range": Array [ + 81, + 91, + ], + "type": "MemberExpression", + }, + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "operator": "=", + "range": Array [ + 81, + 106, + ], + "right": Object { + "computed": false, + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "object": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "name": "config", + "range": Array [ + 94, + 100, + ], + "type": "Identifier", + }, + "property": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 28, + "line": 3, + }, + }, + "name": "title", + "range": Array [ + 101, + 106, + ], + "type": "Identifier", + }, + "range": Array [ + 94, + 106, + ], + "type": "MemberExpression", + }, + "type": "AssignmentExpression", + }, + "loc": Object { + "end": Object { + "column": 34, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 107, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 55, + "line": 2, + }, + }, + "range": Array [ + 71, + 113, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "name": "APP_CONFIG", + "range": Array [ + 40, + 50, + ], + "type": "Identifier", + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "name": "Inject", + "range": Array [ + 33, + 39, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 33, + 51, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 32, + 51, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "name": "config", + "range": Array [ + 52, + 69, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "range": Array [ + 58, + 69, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "range": Array [ + 60, + 69, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "name": "AppConfig", + "range": Array [ + 60, + 69, + ], + "type": "Identifier", + }, + }, + }, + }, + ], + "range": Array [ + 31, + 113, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 115, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Service", + "range": Array [ + 6, + 13, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 115, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 6, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 116, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 13, + ], + "type": "Identifier", + "value": "Service", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 20, + 31, + ], + "type": "Identifier", + "value": "constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 33, + 39, + ], + "type": "Identifier", + "value": "Inject", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 40, + 50, + ], + "type": "Identifier", + "value": "APP_CONFIG", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 34, + "line": 2, + }, + }, + "range": Array [ + 50, + 51, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 52, + 58, + ], + "type": "Identifier", + "value": "config", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 2, + }, + "start": Object { + "column": 42, + "line": 2, + }, + }, + "range": Array [ + 58, + 59, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "range": Array [ + 60, + 69, + ], + "type": "Identifier", + "value": "AppConfig", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 2, + }, + "start": Object { + "column": 53, + "line": 2, + }, + }, + "range": Array [ + 69, + 70, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 2, + }, + "start": Object { + "column": 55, + "line": 2, + }, + }, + "range": Array [ + 71, + 72, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 81, + 85, + ], + "type": "Keyword", + "value": "this", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "range": Array [ + 85, + 86, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 3, + }, + "start": Object { + "column": 13, + "line": 3, + }, + }, + "range": Array [ + 86, + 91, + ], + "type": "Identifier", + "value": "title", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 3, + }, + "start": Object { + "column": 19, + "line": 3, + }, + }, + "range": Array [ + 92, + 93, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 3, + }, + "start": Object { + "column": 21, + "line": 3, + }, + }, + "range": Array [ + 94, + 100, + ], + "type": "Identifier", + "value": "config", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 3, + }, + "start": Object { + "column": 27, + "line": 3, + }, + }, + "range": Array [ + 100, + 101, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 3, + }, + "start": Object { + "column": 28, + "line": 3, + }, + }, + "range": Array [ + 101, + 106, + ], + "type": "Identifier", + "value": "title", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 106, + 107, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "range": Array [ + 112, + 113, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 114, + 115, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 16, + 19, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 16, + 50, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 48, + 50, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 29, + 33, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 21, + 28, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 34, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 34, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "baz", + "range": Array [ + 35, + 46, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 26, + "line": 2, + }, + }, + "range": Array [ + 38, + 46, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 40, + 46, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 19, + 50, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 52, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 52, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 53, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 9, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 16, + 19, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 21, + 28, + ], + "type": "Identifier", + "value": "special", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 17, + "line": 2, + }, + }, + "range": Array [ + 29, + 33, + ], + "type": "Boolean", + "value": "true", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 2, + }, + "start": Object { "column": 21, + "line": 2, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + "value": "baz", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 26, + "line": 2, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 40, + 46, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 2, + }, + "start": Object { + "column": 34, + "line": 2, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 36, + "line": 2, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 2, + }, + "start": Object { + "column": 37, + "line": 2, + }, + }, + "range": Array [ + 49, + 50, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 51, + 52, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 29, + 32, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 22, + 63, + ], + "static": true, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 43, + "line": 2, + }, + }, + "range": Array [ + 61, + 63, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "params": Array [ + Object { + "decorators": Array [ + Object { + "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 42, + 46, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 34, + 41, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 34, + 47, + ], + "type": "CallExpression", + }, + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 33, + 47, + ], + "type": "Decorator", + }, + ], + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 30, + "line": 2, + }, + }, + "name": "baz", + "range": Array [ + 48, + 59, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 33, + "line": 2, + }, + }, + "range": Array [ + 51, + 59, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 2, + }, + "start": Object { + "column": 35, + "line": 2, + }, + }, + "range": Array [ + 53, + 59, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 32, + 63, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 65, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "StaticFoo", + "range": Array [ + 6, + 15, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, "line": 3, }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 65, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 66, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 15, + ], + "type": "Identifier", + "value": "StaticFoo", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "Keyword", + "value": "static", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 29, + 32, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "@", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 34, + 41, + ], + "type": "Identifier", + "value": "special", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, }, "range": Array [ - 94, - 100, + 41, + 42, ], - "type": "Identifier", - "value": "config", + "type": "Punctuator", + "value": "(", }, Object { "loc": Object { "end": Object { "column": 28, - "line": 3, + "line": 2, }, "start": Object { - "column": 27, - "line": 3, + "column": 24, + "line": 2, }, }, "range": Array [ - 100, - 101, + 42, + 46, + ], + "type": "Boolean", + "value": "true", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 2, + }, + "start": Object { + "column": 28, + "line": 2, + }, + }, + "range": Array [ + 46, + 47, ], "type": "Punctuator", - "value": ".", + "value": ")", }, Object { "loc": Object { "end": Object { "column": 33, - "line": 3, + "line": 2, }, "start": Object { - "column": 28, - "line": 3, + "column": 30, + "line": 2, }, }, "range": Array [ - 101, - 106, + 48, + 51, ], "type": "Identifier", - "value": "title", + "value": "baz", }, Object { "loc": Object { "end": Object { "column": 34, - "line": 3, + "line": 2, }, "start": Object { "column": 33, - "line": 3, + "line": 2, }, }, "range": Array [ - 106, - 107, + 51, + 52, ], "type": "Punctuator", - "value": ";", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 41, + "line": 2, }, "start": Object { - "column": 4, - "line": 4, + "column": 35, + "line": 2, }, }, "range": Array [ - 112, - 113, + 53, + 59, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 2, + }, + "start": Object { + "column": 41, + "line": 2, + }, + }, + "range": Array [ + 59, + 60, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 2, + }, + "start": Object { + "column": 43, + "line": 2, + }, + }, + "range": Array [ + 61, + 62, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 2, + }, + "start": Object { + "column": 44, + "line": 2, + }, + }, + "range": Array [ + 62, + 63, ], "type": "Punctuator", "value": "}", @@ -82490,16 +84339,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 114, - 115, + 64, + 65, ], "type": "Punctuator", "value": "}", @@ -82509,7 +84358,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-instance-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-instance-member.src 1`] = ` Object { "body": Array [ Object { @@ -82520,7 +84369,7 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 7, + "column": 9, "line": 2, }, "start": Object { @@ -82528,18 +84377,18 @@ Object { "line": 2, }, }, - "name": "bar", + "name": "greet", "range": Array [ - 16, - 19, + 20, + 25, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { "column": 4, @@ -82547,28 +84396,138 @@ Object { }, }, "range": Array [ - 16, - 50, + 20, + 95, ], "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [], + "body": Array [ + Object { + "argument": Object { + "left": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 67, + 75, + ], + "raw": "\\"Hello \\"", + "type": "Literal", + "value": "Hello ", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 67, + 82, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": "name", + "range": Array [ + 78, + 82, + ], + "type": "Identifier", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 67, + 88, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 85, + 88, + ], + "raw": "\\"!\\"", + "type": "Literal", + "value": "!", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 60, + 89, + ], + "type": "ReturnStatement", + }, + ], "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 36, + "column": 34, "line": 2, }, }, "range": Array [ - 48, 50, + 95, ], "type": "BlockStatement", }, @@ -82577,11 +84536,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 7, + "column": 9, "line": 2, }, }, @@ -82590,133 +84549,95 @@ Object { "decorators": Array [ Object { "expression": Object { - "arguments": Array [ - Object { - "loc": Object { - "end": Object { - "column": 21, - "line": 2, - }, - "start": Object { - "column": 17, - "line": 2, - }, - }, - "range": Array [ - 29, - 33, - ], - "raw": "true", - "type": "Literal", - "value": true, - }, - ], - "callee": Object { - "loc": Object { - "end": Object { - "column": 16, - "line": 2, - }, - "start": Object { - "column": 9, - "line": 2, - }, - }, - "name": "special", - "range": Array [ - 21, - 28, - ], - "type": "Identifier", - }, "loc": Object { "end": Object { - "column": 22, + "column": 19, "line": 2, }, "start": Object { - "column": 9, + "column": 11, "line": 2, }, }, + "name": "required", "range": Array [ - 21, - 34, + 27, + 35, ], - "type": "CallExpression", + "type": "Identifier", }, "loc": Object { "end": Object { - "column": 22, + "column": 19, "line": 2, }, "start": Object { - "column": 8, + "column": 10, "line": 2, }, }, "range": Array [ - 20, - 34, + 26, + 35, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 23, + "column": 20, "line": 2, }, }, - "name": "baz", + "name": "name", "range": Array [ - 35, - 46, + 36, + 48, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 26, + "column": 24, "line": 2, }, }, "range": Array [ - 38, - 46, + 40, + 48, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 34, + "column": 32, "line": 2, }, "start": Object { - "column": 28, + "column": 26, "line": 2, }, }, "range": Array [ - 40, - 46, + 42, + 48, ], - "type": "TSNumberKeyword", + "type": "TSStringKeyword", }, }, }, ], "range": Array [ - 19, - 50, + 25, + 95, ], "type": "FunctionExpression", }, @@ -82725,23 +84646,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { - "column": 10, + "column": 14, "line": 1, }, }, "range": Array [ - 10, - 52, + 14, + 97, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 9, + "column": 13, "line": 1, }, "start": Object { @@ -82749,17 +84670,17 @@ Object { "line": 1, }, }, - "name": "Foo", + "name": "Greeter", "range": Array [ 6, - 9, + 13, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, @@ -82768,7 +84689,7 @@ Object { }, "range": Array [ 0, - 52, + 97, ], "superClass": null, "type": "ClassDeclaration", @@ -82777,7 +84698,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 4, + "line": 6, }, "start": Object { "column": 0, @@ -82786,7 +84707,7 @@ Object { }, "range": Array [ 0, - 53, + 98, ], "sourceType": "script", "tokens": Array [ @@ -82811,7 +84732,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 13, "line": 1, }, "start": Object { @@ -82821,25 +84742,25 @@ Object { }, "range": Array [ 6, - 9, + 13, ], "type": "Identifier", - "value": "Foo", + "value": "Greeter", }, Object { "loc": Object { "end": Object { - "column": 11, + "column": 15, "line": 1, }, "start": Object { - "column": 10, + "column": 14, "line": 1, }, }, "range": Array [ - 10, - 11, + 14, + 15, ], "type": "Punctuator", "value": "{", @@ -82847,7 +84768,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 7, + "column": 9, "line": 2, }, "start": Object { @@ -82856,26 +84777,26 @@ Object { }, }, "range": Array [ - 16, - 19, + 20, + 25, ], "type": "Identifier", - "value": "bar", + "value": "greet", }, Object { "loc": Object { "end": Object { - "column": 8, + "column": 10, "line": 2, }, "start": Object { - "column": 7, + "column": 9, "line": 2, }, }, "range": Array [ - 19, - 20, + 25, + 26, ], "type": "Punctuator", "value": "(", @@ -82883,17 +84804,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 11, "line": 2, }, "start": Object { - "column": 8, + "column": 10, "line": 2, }, }, "range": Array [ - 20, - 21, + 26, + 27, ], "type": "Punctuator", "value": "@", @@ -82901,179 +84822,251 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 19, "line": 2, }, "start": Object { - "column": 9, + "column": 11, "line": 2, }, }, "range": Array [ - 21, - 28, + 27, + 35, ], "type": "Identifier", - "value": "special", + "value": "required", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 24, + "line": 2, + }, + "start": Object { + "column": 20, + "line": 2, + }, + }, + "range": Array [ + 36, + 40, + ], + "type": "Identifier", + "value": "name", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "range": Array [ + 40, + 41, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 2, + }, + "start": Object { + "column": 26, + "line": 2, + }, + }, + "range": Array [ + 42, + 48, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 2, + }, + "start": Object { + "column": 32, + "line": 2, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, "line": 2, }, "start": Object { - "column": 16, + "column": 34, "line": 2, }, }, "range": Array [ - 28, - 29, + 50, + 51, ], "type": "Punctuator", - "value": "(", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 21, - "line": 2, + "column": 14, + "line": 3, }, "start": Object { - "column": 17, - "line": 2, + "column": 8, + "line": 3, }, }, "range": Array [ - 29, - 33, + 60, + 66, ], - "type": "Boolean", - "value": "true", + "type": "Keyword", + "value": "return", }, Object { "loc": Object { "end": Object { - "column": 22, - "line": 2, + "column": 23, + "line": 3, }, "start": Object { - "column": 21, - "line": 2, + "column": 15, + "line": 3, }, }, "range": Array [ - 33, - 34, + 67, + 75, ], - "type": "Punctuator", - "value": ")", + "type": "String", + "value": "\\"Hello \\"", }, Object { "loc": Object { "end": Object { - "column": 26, - "line": 2, + "column": 25, + "line": 3, }, "start": Object { - "column": 23, - "line": 2, + "column": 24, + "line": 3, }, }, "range": Array [ - 35, - 38, + 76, + 77, ], - "type": "Identifier", - "value": "baz", + "type": "Punctuator", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 27, - "line": 2, + "column": 30, + "line": 3, }, "start": Object { "column": 26, - "line": 2, + "line": 3, }, }, "range": Array [ - 38, - 39, + 78, + 82, ], - "type": "Punctuator", - "value": ":", + "type": "Identifier", + "value": "name", }, Object { "loc": Object { "end": Object { - "column": 34, - "line": 2, + "column": 32, + "line": 3, }, "start": Object { - "column": 28, - "line": 2, + "column": 31, + "line": 3, }, }, "range": Array [ - 40, - 46, + 83, + 84, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 35, - "line": 2, + "column": 36, + "line": 3, }, "start": Object { - "column": 34, - "line": 2, + "column": 33, + "line": 3, }, }, "range": Array [ - 46, - 47, + 85, + 88, ], - "type": "Punctuator", - "value": ")", + "type": "String", + "value": "\\"!\\"", }, Object { "loc": Object { "end": Object { "column": 37, - "line": 2, + "line": 3, }, "start": Object { "column": 36, - "line": 2, + "line": 3, }, }, "range": Array [ - 48, - 49, + 88, + 89, ], "type": "Punctuator", - "value": "{", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 38, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 37, - "line": 2, + "column": 4, + "line": 4, }, }, "range": Array [ - 49, - 50, + 94, + 95, ], "type": "Punctuator", "value": "}", @@ -83082,16 +85075,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, - "line": 3, + "line": 5, }, }, "range": Array [ - 51, - 52, + 96, + 97, ], "type": "Punctuator", "value": "}", @@ -83101,7 +85094,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-decorator-static-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-static-member.src 1`] = ` Object { "body": Array [ Object { @@ -83112,7 +85105,7 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 2, }, "start": Object { @@ -83120,18 +85113,18 @@ Object { "line": 2, }, }, - "name": "bar", + "name": "greet", "range": Array [ - 29, - 32, + 33, + 38, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { "column": 4, @@ -83139,28 +85132,138 @@ Object { }, }, "range": Array [ - 22, - 63, + 26, + 108, ], "static": true, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [], + "body": Array [ + Object { + "argument": Object { + "left": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 80, + 88, + ], + "raw": "\\"Hello \\"", + "type": "Literal", + "value": "Hello ", + }, + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 80, + 95, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "name": "name", + "range": Array [ + 91, + 95, + ], + "type": "Identifier", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 80, + 101, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, + }, + }, + "range": Array [ + 98, + 101, + ], + "raw": "\\"!\\"", + "type": "Literal", + "value": "!", + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 37, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 73, + 102, + ], + "type": "ReturnStatement", + }, + ], "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 43, + "column": 41, "line": 2, }, }, "range": Array [ - 61, 63, + 108, ], "type": "BlockStatement", }, @@ -83169,11 +85272,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 5, + "line": 4, }, "start": Object { - "column": 14, + "column": 16, "line": 2, }, }, @@ -83182,133 +85285,95 @@ Object { "decorators": Array [ Object { "expression": Object { - "arguments": Array [ - Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 2, - }, - "start": Object { - "column": 24, - "line": 2, - }, - }, - "range": Array [ - 42, - 46, - ], - "raw": "true", - "type": "Literal", - "value": true, - }, - ], - "callee": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 2, - }, - "start": Object { - "column": 16, - "line": 2, - }, - }, - "name": "special", - "range": Array [ - 34, - 41, - ], - "type": "Identifier", - }, "loc": Object { "end": Object { - "column": 29, + "column": 26, "line": 2, }, "start": Object { - "column": 16, + "column": 18, "line": 2, }, }, + "name": "required", "range": Array [ - 34, - 47, + 40, + 48, ], - "type": "CallExpression", + "type": "Identifier", }, "loc": Object { "end": Object { - "column": 29, + "column": 26, "line": 2, }, "start": Object { - "column": 15, + "column": 17, "line": 2, }, }, "range": Array [ - 33, - 47, + 39, + 48, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 30, + "column": 27, "line": 2, }, }, - "name": "baz", + "name": "name", "range": Array [ - 48, - 59, + 49, + 61, ], "type": "Identifier", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 33, + "column": 31, "line": 2, }, }, "range": Array [ - 51, - 59, + 53, + 61, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 41, + "column": 39, "line": 2, }, "start": Object { - "column": 35, + "column": 33, "line": 2, }, }, "range": Array [ - 53, - 59, + 55, + 61, ], - "type": "TSNumberKeyword", + "type": "TSStringKeyword", }, }, }, ], "range": Array [ - 32, - 63, + 38, + 108, ], "type": "FunctionExpression", }, @@ -83317,23 +85382,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { - "column": 16, + "column": 20, "line": 1, }, }, "range": Array [ - 16, - 65, + 20, + 110, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 15, + "column": 19, "line": 1, }, "start": Object { @@ -83341,17 +85406,17 @@ Object { "line": 1, }, }, - "name": "StaticFoo", + "name": "StaticGreeter", "range": Array [ 6, - 15, + 19, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 3, + "line": 5, }, "start": Object { "column": 0, @@ -83360,7 +85425,7 @@ Object { }, "range": Array [ 0, - 65, + 110, ], "superClass": null, "type": "ClassDeclaration", @@ -83369,7 +85434,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 4, + "line": 6, }, "start": Object { "column": 0, @@ -83378,7 +85443,7 @@ Object { }, "range": Array [ 0, - 66, + 111, ], "sourceType": "script", "tokens": Array [ @@ -83403,7 +85468,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 19, "line": 1, }, "start": Object { @@ -83413,25 +85478,25 @@ Object { }, "range": Array [ 6, - 15, + 19, ], "type": "Identifier", - "value": "StaticFoo", + "value": "StaticGreeter", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 21, "line": 1, }, "start": Object { - "column": 16, + "column": 20, "line": 1, }, }, "range": Array [ - 16, - 17, + 20, + 21, ], "type": "Punctuator", "value": "{", @@ -83448,8 +85513,8 @@ Object { }, }, "range": Array [ - 22, - 28, + 26, + 32, ], "type": "Keyword", "value": "static", @@ -83457,7 +85522,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, + "column": 16, "line": 2, }, "start": Object { @@ -83466,26 +85531,26 @@ Object { }, }, "range": Array [ - 29, - 32, + 33, + 38, ], "type": "Identifier", - "value": "bar", + "value": "greet", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 17, "line": 2, }, "start": Object { - "column": 14, + "column": 16, "line": 2, }, }, "range": Array [ - 32, - 33, + 38, + 39, ], "type": "Punctuator", "value": "(", @@ -83493,17 +85558,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 16, + "column": 18, "line": 2, }, "start": Object { - "column": 15, + "column": 17, "line": 2, }, }, "range": Array [ - 33, - 34, + 39, + 40, ], "type": "Punctuator", "value": "@", @@ -83511,71 +85576,89 @@ Object { Object { "loc": Object { "end": Object { - "column": 23, + "column": 26, "line": 2, }, "start": Object { - "column": 16, + "column": 18, "line": 2, }, }, "range": Array [ - 34, - 41, + 40, + 48, ], "type": "Identifier", - "value": "special", + "value": "required", }, Object { "loc": Object { "end": Object { - "column": 24, + "column": 31, "line": 2, }, "start": Object { - "column": 23, + "column": 27, "line": 2, }, }, "range": Array [ - 41, - 42, + 49, + 53, + ], + "type": "Identifier", + "value": "name", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 2, + }, + "start": Object { + "column": 31, + "line": 2, + }, + }, + "range": Array [ + 53, + 54, ], "type": "Punctuator", - "value": "(", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 28, + "column": 39, "line": 2, }, "start": Object { - "column": 24, + "column": 33, "line": 2, }, }, "range": Array [ - 42, - 46, + 55, + 61, ], - "type": "Boolean", - "value": "true", + "type": "Identifier", + "value": "string", }, Object { "loc": Object { "end": Object { - "column": 29, + "column": 40, "line": 2, }, "start": Object { - "column": 28, + "column": 39, "line": 2, }, }, "range": Array [ - 46, - 47, + 61, + 62, ], "type": "Punctuator", "value": ")", @@ -83583,304 +85666,248 @@ Object { Object { "loc": Object { "end": Object { - "column": 33, + "column": 42, "line": 2, }, "start": Object { - "column": 30, + "column": 41, "line": 2, }, }, "range": Array [ - 48, - 51, + 63, + 64, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 73, + 79, ], - "type": "Identifier", - "value": "baz", + "type": "Keyword", + "value": "return", }, Object { "loc": Object { "end": Object { - "column": 34, - "line": 2, + "column": 23, + "line": 3, }, "start": Object { - "column": 33, - "line": 2, + "column": 15, + "line": 3, }, }, "range": Array [ - 51, - 52, + 80, + 88, ], - "type": "Punctuator", - "value": ":", + "type": "String", + "value": "\\"Hello \\"", }, Object { "loc": Object { "end": Object { - "column": 41, - "line": 2, + "column": 25, + "line": 3, }, "start": Object { - "column": 35, - "line": 2, + "column": 24, + "line": 3, }, }, "range": Array [ - 53, - 59, + 89, + 90, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 42, - "line": 2, + "column": 30, + "line": 3, }, "start": Object { - "column": 41, - "line": 2, + "column": 26, + "line": 3, }, }, "range": Array [ - 59, - 60, + 91, + 95, ], - "type": "Punctuator", - "value": ")", + "type": "Identifier", + "value": "name", }, Object { "loc": Object { "end": Object { - "column": 44, - "line": 2, + "column": 32, + "line": 3, }, "start": Object { - "column": 43, - "line": 2, + "column": 31, + "line": 3, }, }, "range": Array [ - 61, - 62, + 96, + 97, ], "type": "Punctuator", - "value": "{", + "value": "+", }, Object { "loc": Object { "end": Object { - "column": 45, - "line": 2, + "column": 36, + "line": 3, }, "start": Object { - "column": 44, - "line": 2, + "column": 33, + "line": 3, }, }, "range": Array [ - 62, - 63, + 98, + 101, ], - "type": "Punctuator", - "value": "}", + "type": "String", + "value": "\\"!\\"", }, Object { "loc": Object { "end": Object { - "column": 1, + "column": 37, "line": 3, }, "start": Object { - "column": 0, + "column": 36, "line": 3, }, }, "range": Array [ - 64, - 65, - ], - "type": "Punctuator", - "value": "}", - }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-instance-member.src 1`] = ` -Object { - "body": Array [ - Object { - "body": Object { - "body": Array [ - Object { - "computed": false, - "key": Object { - "loc": Object { - "end": Object { - "column": 9, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "name": "greet", - "range": Array [ - 20, - 25, - ], - "type": "Identifier", - }, - "kind": "method", - "loc": Object { - "end": Object { - "column": 5, - "line": 4, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "range": Array [ - 20, - 95, - ], - "static": false, - "type": "MethodDefinition", - "value": Object { - "async": false, - "body": Object { - "body": Array [ - Object { - "argument": Object { - "left": Object { - "left": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "range": Array [ - 67, - 75, - ], - "raw": "\\"Hello \\"", - "type": "Literal", - "value": "Hello ", - }, - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 67, - 82, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 26, - "line": 3, - }, - }, - "name": "name", - "range": Array [ - 78, - 82, - ], - "type": "Identifier", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 67, - 88, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 85, - 88, - ], - "raw": "\\"!\\"", - "type": "Literal", - "value": "!", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 60, - 89, - ], - "type": "ReturnStatement", - }, - ], + 101, + 102, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "range": Array [ + 107, + 108, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 109, + 110, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/decorators/parameter-decorators/parameter-object-pattern-decorator.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 14, + 17, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 37, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 14, + 49, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 34, + "column": 35, "line": 2, }, }, "range": Array [ - 50, - 95, + 47, + 49, ], "type": "BlockStatement", }, @@ -83889,11 +85916,11 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 37, + "line": 2, }, "start": Object { - "column": 9, + "column": 5, "line": 2, }, }, @@ -83902,95 +85929,191 @@ Object { "decorators": Array [ Object { "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 31, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 19, + 26, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 2, }, "start": Object { - "column": 11, + "column": 7, "line": 2, }, }, - "name": "required", "range": Array [ - 27, - 35, + 19, + 32, ], - "type": "Identifier", + "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 19, + "column": 20, "line": 2, }, "start": Object { - "column": 10, + "column": 6, "line": 2, }, }, "range": Array [ - 26, - 35, + 18, + 32, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 20, + "column": 21, "line": 2, }, }, - "name": "name", + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "method": false, + "range": Array [ + 35, + 38, + ], + "shorthand": true, + "type": "Property", + "value": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 23, + "line": 2, + }, + }, + "name": "bar", + "range": Array [ + 35, + 38, + ], + "type": "Identifier", + }, + }, + ], "range": Array [ - 36, - 48, + 33, + 45, ], - "type": "Identifier", + "type": "ObjectPattern", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 24, + "column": 28, "line": 2, }, }, "range": Array [ 40, - 48, + 45, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 32, + "column": 33, "line": 2, }, "start": Object { - "column": 26, + "column": 30, "line": 2, }, }, "range": Array [ 42, - 48, + 45, ], - "type": "TSStringKeyword", + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 25, - 95, + 17, + 49, ], "type": "FunctionExpression", }, @@ -83999,23 +86122,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 97, + 10, + 51, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -84023,17 +86146,17 @@ Object { "line": 1, }, }, - "name": "Greeter", + "name": "Foo", "range": Array [ 6, - 13, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -84042,7 +86165,7 @@ Object { }, "range": Array [ 0, - 97, + 51, ], "superClass": null, "type": "ClassDeclaration", @@ -84051,7 +86174,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -84060,7 +86183,7 @@ Object { }, "range": Array [ 0, - 98, + 52, ], "sourceType": "script", "tokens": Array [ @@ -84085,7 +86208,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 13, + "column": 9, "line": 1, }, "start": Object { @@ -84095,25 +86218,25 @@ Object { }, "range": Array [ 6, - 13, + 9, ], "type": "Identifier", - "value": "Greeter", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 11, "line": 1, }, "start": Object { - "column": 14, + "column": 10, "line": 1, }, }, "range": Array [ - 14, - 15, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -84121,35 +86244,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 9, + "column": 5, "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 20, - 25, + 14, + 17, ], "type": "Identifier", - "value": "greet", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 10, + "column": 6, "line": 2, }, "start": Object { - "column": 9, + "column": 5, "line": 2, }, }, "range": Array [ - 25, - 26, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -84157,17 +86280,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 11, + "column": 7, "line": 2, }, "start": Object { - "column": 10, + "column": 6, "line": 2, }, }, "range": Array [ - 26, - 27, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -84175,89 +86298,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, - "line": 2, - }, - "start": Object { - "column": 11, - "line": 2, - }, - }, - "range": Array [ - 27, - 35, - ], - "type": "Identifier", - "value": "required", - }, - Object { - "loc": Object { - "end": Object { - "column": 24, + "column": 14, "line": 2, }, "start": Object { - "column": 20, + "column": 7, "line": 2, }, }, "range": Array [ - 36, - 40, + 19, + 26, ], "type": "Identifier", - "value": "name", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 25, + "column": 15, "line": 2, }, "start": Object { - "column": 24, + "column": 14, "line": 2, }, }, "range": Array [ - 40, - 41, + 26, + 27, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 32, + "column": 19, "line": 2, }, "start": Object { - "column": 26, + "column": 15, "line": 2, }, }, "range": Array [ - 42, - 48, + 27, + 31, ], - "type": "Identifier", - "value": "string", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 33, + "column": 20, "line": 2, }, "start": Object { - "column": 32, + "column": 19, "line": 2, }, }, "range": Array [ - 48, - 49, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -84265,17 +86370,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 35, + "column": 22, "line": 2, }, "start": Object { - "column": 34, + "column": 21, "line": 2, }, }, "range": Array [ - 50, - 51, + 33, + 34, ], "type": "Punctuator", "value": "{", @@ -84283,143 +86388,125 @@ Object { Object { "loc": Object { "end": Object { - "column": 14, - "line": 3, + "column": 26, + "line": 2, }, "start": Object { - "column": 8, - "line": 3, + "column": 23, + "line": 2, }, }, "range": Array [ - 60, - 66, + 35, + 38, ], - "type": "Keyword", - "value": "return", + "type": "Identifier", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 3, + "column": 28, + "line": 2, }, "start": Object { - "column": 15, - "line": 3, + "column": 27, + "line": 2, }, }, "range": Array [ - 67, - 75, + 39, + 40, ], - "type": "String", - "value": "\\"Hello \\"", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 25, - "line": 3, + "column": 29, + "line": 2, }, "start": Object { - "column": 24, - "line": 3, + "column": 28, + "line": 2, }, }, "range": Array [ - 76, - 77, + 40, + 41, ], "type": "Punctuator", - "value": "+", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 30, - "line": 3, + "column": 33, + "line": 2, }, "start": Object { - "column": 26, - "line": 3, + "column": 30, + "line": 2, }, }, "range": Array [ - 78, - 82, + 42, + 45, ], "type": "Identifier", - "value": "name", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 32, - "line": 3, + "column": 34, + "line": 2, }, "start": Object { - "column": 31, - "line": 3, + "column": 33, + "line": 2, }, }, "range": Array [ - 83, - 84, + 45, + 46, ], "type": "Punctuator", - "value": "+", + "value": ")", }, Object { "loc": Object { "end": Object { "column": 36, - "line": 3, + "line": 2, }, "start": Object { - "column": 33, - "line": 3, + "column": 35, + "line": 2, }, }, "range": Array [ - 85, - 88, + 47, + 48, ], - "type": "String", - "value": "\\"!\\"", + "type": "Punctuator", + "value": "{", }, Object { "loc": Object { "end": Object { "column": 37, - "line": 3, + "line": 2, }, "start": Object { "column": 36, - "line": 3, - }, - }, - "range": Array [ - 88, - 89, - ], - "type": "Punctuator", - "value": ";", - }, - Object { - "loc": Object { - "end": Object { - "column": 5, - "line": 4, - }, - "start": Object { - "column": 4, - "line": 4, + "line": 2, }, }, "range": Array [ - 94, - 95, + 48, + 49, ], "type": "Punctuator", "value": "}", @@ -84428,16 +86515,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 96, - 97, + 50, + 51, ], "type": "Punctuator", "value": "}", @@ -84447,7 +86534,7 @@ Object { } `; -exports[`typescript fixtures/decorators/parameter-decorators/parameter-decorator-static-member.src 1`] = ` +exports[`typescript fixtures/decorators/parameter-decorators/parameter-rest-element-decorator.src 1`] = ` Object { "body": Array [ Object { @@ -84458,165 +86545,55 @@ Object { "key": Object { "loc": Object { "end": Object { - "column": 16, + "column": 5, "line": 2, }, "start": Object { - "column": 11, + "column": 2, "line": 2, }, }, - "name": "greet", + "name": "bar", "range": Array [ - 33, - 38, + 14, + 17, ], "type": "Identifier", }, "kind": "method", "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 4, + "column": 2, "line": 2, }, }, "range": Array [ - 26, - 108, + 14, + 48, ], - "static": true, + "static": false, "type": "MethodDefinition", "value": Object { "async": false, "body": Object { - "body": Array [ - Object { - "argument": Object { - "left": Object { - "left": Object { - "loc": Object { - "end": Object { - "column": 23, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "range": Array [ - 80, - 88, - ], - "raw": "\\"Hello \\"", - "type": "Literal", - "value": "Hello ", - }, - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 80, - 95, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 30, - "line": 3, - }, - "start": Object { - "column": 26, - "line": 3, - }, - }, - "name": "name", - "range": Array [ - 91, - 95, - ], - "type": "Identifier", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 15, - "line": 3, - }, - }, - "operator": "+", - "range": Array [ - 80, - 101, - ], - "right": Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 98, - 101, - ], - "raw": "\\"!\\"", - "type": "Literal", - "value": "!", - }, - "type": "BinaryExpression", - }, - "loc": Object { - "end": Object { - "column": 37, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 73, - 102, - ], - "type": "ReturnStatement", - }, - ], + "body": Array [], "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 41, + "column": 34, "line": 2, }, }, "range": Array [ - 63, - 108, + 46, + 48, ], "type": "BlockStatement", }, @@ -84625,108 +86602,163 @@ Object { "id": null, "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 16, + "column": 5, "line": 2, }, }, "params": Array [ Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 2, + }, + "start": Object { + "column": 24, + "line": 2, + }, + }, + "name": "foo", + "range": Array [ + 36, + 39, + ], + "type": "Identifier", + }, "decorators": Array [ Object { "expression": Object { + "arguments": Array [ + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 2, + }, + "start": Object { + "column": 15, + "line": 2, + }, + }, + "range": Array [ + 27, + 31, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + ], + "callee": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "name": "special", + "range": Array [ + 19, + 26, + ], + "type": "Identifier", + }, "loc": Object { "end": Object { - "column": 26, + "column": 20, "line": 2, }, "start": Object { - "column": 18, + "column": 7, "line": 2, }, }, - "name": "required", "range": Array [ - 40, - 48, + 19, + 32, ], - "type": "Identifier", + "type": "CallExpression", }, "loc": Object { "end": Object { - "column": 26, + "column": 20, "line": 2, }, "start": Object { - "column": 17, + "column": 6, "line": 2, }, }, "range": Array [ - 39, - 48, + 18, + 32, ], "type": "Decorator", }, ], "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 27, + "column": 6, "line": 2, }, }, - "name": "name", "range": Array [ - 49, - 61, + 18, + 44, ], - "type": "Identifier", + "type": "RestElement", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 31, + "column": 27, "line": 2, }, }, "range": Array [ - 53, - 61, + 39, + 44, ], "type": "TSTypeAnnotation", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 39, + "column": 32, "line": 2, }, "start": Object { - "column": 33, + "column": 29, "line": 2, }, }, "range": Array [ - 55, - 61, + 41, + 44, ], - "type": "TSStringKeyword", + "type": "TSAnyKeyword", }, }, }, ], "range": Array [ - 38, - 108, + 17, + 48, ], "type": "FunctionExpression", }, @@ -84735,23 +86767,23 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { - "column": 20, + "column": 10, "line": 1, }, }, "range": Array [ - 20, - 110, + 10, + 50, ], "type": "ClassBody", }, "id": Object { "loc": Object { "end": Object { - "column": 19, + "column": 9, "line": 1, }, "start": Object { @@ -84759,17 +86791,17 @@ Object { "line": 1, }, }, - "name": "StaticGreeter", + "name": "Foo", "range": Array [ 6, - 19, + 9, ], "type": "Identifier", }, "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, @@ -84778,7 +86810,7 @@ Object { }, "range": Array [ 0, - 110, + 50, ], "superClass": null, "type": "ClassDeclaration", @@ -84787,7 +86819,7 @@ Object { "loc": Object { "end": Object { "column": 0, - "line": 6, + "line": 4, }, "start": Object { "column": 0, @@ -84796,7 +86828,7 @@ Object { }, "range": Array [ 0, - 111, + 51, ], "sourceType": "script", "tokens": Array [ @@ -84821,7 +86853,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 19, + "column": 9, "line": 1, }, "start": Object { @@ -84831,25 +86863,25 @@ Object { }, "range": Array [ 6, - 19, + 9, ], "type": "Identifier", - "value": "StaticGreeter", + "value": "Foo", }, Object { "loc": Object { "end": Object { - "column": 21, + "column": 11, "line": 1, }, "start": Object { - "column": 20, + "column": 10, "line": 1, }, }, "range": Array [ - 20, - 21, + 10, + 11, ], "type": "Punctuator", "value": "{", @@ -84857,53 +86889,35 @@ Object { Object { "loc": Object { "end": Object { - "column": 10, - "line": 2, - }, - "start": Object { - "column": 4, - "line": 2, - }, - }, - "range": Array [ - 26, - 32, - ], - "type": "Keyword", - "value": "static", - }, - Object { - "loc": Object { - "end": Object { - "column": 16, + "column": 5, "line": 2, }, "start": Object { - "column": 11, + "column": 2, "line": 2, }, }, "range": Array [ - 33, - 38, + 14, + 17, ], "type": "Identifier", - "value": "greet", + "value": "bar", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 6, "line": 2, }, "start": Object { - "column": 16, + "column": 5, "line": 2, }, }, "range": Array [ - 38, - 39, + 17, + 18, ], "type": "Punctuator", "value": "(", @@ -84911,17 +86925,17 @@ Object { Object { "loc": Object { "end": Object { - "column": 18, + "column": 7, "line": 2, }, "start": Object { - "column": 17, + "column": 6, "line": 2, }, }, "range": Array [ - 39, - 40, + 18, + 19, ], "type": "Punctuator", "value": "@", @@ -84929,89 +86943,71 @@ Object { Object { "loc": Object { "end": Object { - "column": 26, - "line": 2, - }, - "start": Object { - "column": 18, - "line": 2, - }, - }, - "range": Array [ - 40, - 48, - ], - "type": "Identifier", - "value": "required", - }, - Object { - "loc": Object { - "end": Object { - "column": 31, + "column": 14, "line": 2, }, "start": Object { - "column": 27, + "column": 7, "line": 2, }, }, "range": Array [ - 49, - 53, + 19, + 26, ], "type": "Identifier", - "value": "name", + "value": "special", }, Object { "loc": Object { "end": Object { - "column": 32, + "column": 15, "line": 2, }, "start": Object { - "column": 31, + "column": 14, "line": 2, }, }, "range": Array [ - 53, - 54, + 26, + 27, ], "type": "Punctuator", - "value": ":", + "value": "(", }, Object { "loc": Object { "end": Object { - "column": 39, + "column": 19, "line": 2, }, "start": Object { - "column": 33, + "column": 15, "line": 2, }, }, "range": Array [ - 55, - 61, + 27, + 31, ], - "type": "Identifier", - "value": "string", + "type": "Boolean", + "value": "true", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 20, "line": 2, }, "start": Object { - "column": 39, + "column": 19, "line": 2, }, }, "range": Array [ - 61, - 62, + 31, + 32, ], "type": "Punctuator", "value": ")", @@ -85019,161 +87015,125 @@ Object { Object { "loc": Object { "end": Object { - "column": 42, + "column": 24, "line": 2, }, "start": Object { - "column": 41, + "column": 21, "line": 2, }, }, "range": Array [ - 63, - 64, + 33, + 36, ], "type": "Punctuator", - "value": "{", - }, - Object { - "loc": Object { - "end": Object { - "column": 14, - "line": 3, - }, - "start": Object { - "column": 8, - "line": 3, - }, - }, - "range": Array [ - 73, - 79, - ], - "type": "Keyword", - "value": "return", + "value": "...", }, Object { "loc": Object { "end": Object { - "column": 23, - "line": 3, + "column": 27, + "line": 2, }, "start": Object { - "column": 15, - "line": 3, + "column": 24, + "line": 2, }, }, "range": Array [ - 80, - 88, + 36, + 39, ], - "type": "String", - "value": "\\"Hello \\"", + "type": "Identifier", + "value": "foo", }, Object { "loc": Object { "end": Object { - "column": 25, - "line": 3, + "column": 28, + "line": 2, }, "start": Object { - "column": 24, - "line": 3, + "column": 27, + "line": 2, }, }, "range": Array [ - 89, - 90, + 39, + 40, ], "type": "Punctuator", - "value": "+", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 30, - "line": 3, + "column": 32, + "line": 2, }, "start": Object { - "column": 26, - "line": 3, + "column": 29, + "line": 2, }, }, "range": Array [ - 91, - 95, + 41, + 44, ], "type": "Identifier", - "value": "name", + "value": "any", }, Object { "loc": Object { "end": Object { - "column": 32, - "line": 3, + "column": 33, + "line": 2, }, "start": Object { - "column": 31, - "line": 3, + "column": 32, + "line": 2, }, }, "range": Array [ - 96, - 97, + 44, + 45, ], "type": "Punctuator", - "value": "+", - }, - Object { - "loc": Object { - "end": Object { - "column": 36, - "line": 3, - }, - "start": Object { - "column": 33, - "line": 3, - }, - }, - "range": Array [ - 98, - 101, - ], - "type": "String", - "value": "\\"!\\"", + "value": ")", }, Object { "loc": Object { "end": Object { - "column": 37, - "line": 3, + "column": 35, + "line": 2, }, "start": Object { - "column": 36, - "line": 3, + "column": 34, + "line": 2, }, }, "range": Array [ - 101, - 102, + 46, + 47, ], "type": "Punctuator", - "value": ";", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 5, - "line": 4, + "column": 36, + "line": 2, }, "start": Object { - "column": 4, - "line": 4, + "column": 35, + "line": 2, }, }, "range": Array [ - 107, - 108, + 47, + 48, ], "type": "Punctuator", "value": "}", @@ -85182,16 +87142,16 @@ Object { "loc": Object { "end": Object { "column": 1, - "line": 5, + "line": 3, }, "start": Object { "column": 0, - "line": 5, + "line": 3, }, }, "range": Array [ - 109, - 110, + 49, + 50, ], "type": "Punctuator", "value": "}", From 6267ef2dd3dac99a018a087b531cf775aa6303dc Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 4 Feb 2019 20:46:25 +0100 Subject: [PATCH 06/13] test(parser): fix types in tests --- packages/parser/tests/lib/basics.ts | 2 +- packages/parser/tests/lib/tsx.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/parser/tests/lib/basics.ts b/packages/parser/tests/lib/basics.ts index a433e83ad426..bb9b103b3249 100644 --- a/packages/parser/tests/lib/basics.ts +++ b/packages/parser/tests/lib/basics.ts @@ -32,7 +32,7 @@ export const Price: React.SFC = function Price(props) {} } }; - linter.defineParser('@typescript-eslint/parser', parser); + linter.defineParser('@typescript-eslint/parser', parser as any); linter.defineRule('test', { create(context: any) { return { diff --git a/packages/parser/tests/lib/tsx.ts b/packages/parser/tests/lib/tsx.ts index a18278e80458..604cf415acc1 100644 --- a/packages/parser/tests/lib/tsx.ts +++ b/packages/parser/tests/lib/tsx.ts @@ -29,7 +29,7 @@ describe('TSX', () => { describe("if the filename ends with '.tsx', enable jsx option automatically.", () => { const linter = new Linter(); - linter.defineParser('@typescript-eslint/parser', parser); + linter.defineParser('@typescript-eslint/parser', parser as any); it('filePath was not provided', () => { const code = 'const element = '; From 87b871668fe33a81ebe8d1642cf1b075492ded24 Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 4 Feb 2019 22:34:38 +0100 Subject: [PATCH 07/13] fix(plugin-tslint): add ParserServices types --- packages/eslint-plugin-tslint/src/index.ts | 10 +--------- packages/parser/src/parser.ts | 2 +- packages/parser/tests/lib/basics.ts | 2 +- packages/parser/tests/lib/tsx.ts | 2 +- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/eslint-plugin-tslint/src/index.ts b/packages/eslint-plugin-tslint/src/index.ts index 78e946af6294..76642f491fe3 100644 --- a/packages/eslint-plugin-tslint/src/index.ts +++ b/packages/eslint-plugin-tslint/src/index.ts @@ -3,20 +3,12 @@ import memoize from 'lodash.memoize'; import { Configuration, RuleSeverity } from 'tslint'; import { Program } from 'typescript'; import { CustomLinter } from './custom-linter'; +import { ParserServices } from "@typescript-eslint/typescript-estree"; //------------------------------------------------------------------------------ // Plugin Definition //------------------------------------------------------------------------------ -/** - * @todo share types between packages - */ -interface ParserServices { - program: Program | undefined; - esTreeNodeToTSNodeMap: WeakMap | undefined; - tsNodeToESTreeNodeMap: WeakMap | undefined; -} - type RawRuleConfig = | null | undefined diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 4a7f85edf7d9..28d7435cec4c 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -13,7 +13,7 @@ import { visitorKeys } from './visitor-keys'; const packageJSON = require('../package.json'); interface ParseForESLintResult { - ast: es.Program; + ast: any; services: ParserServices; visitorKeys: typeof visitorKeys; scopeManager: ReturnType; diff --git a/packages/parser/tests/lib/basics.ts b/packages/parser/tests/lib/basics.ts index bb9b103b3249..a433e83ad426 100644 --- a/packages/parser/tests/lib/basics.ts +++ b/packages/parser/tests/lib/basics.ts @@ -32,7 +32,7 @@ export const Price: React.SFC = function Price(props) {} } }; - linter.defineParser('@typescript-eslint/parser', parser as any); + linter.defineParser('@typescript-eslint/parser', parser); linter.defineRule('test', { create(context: any) { return { diff --git a/packages/parser/tests/lib/tsx.ts b/packages/parser/tests/lib/tsx.ts index 604cf415acc1..a18278e80458 100644 --- a/packages/parser/tests/lib/tsx.ts +++ b/packages/parser/tests/lib/tsx.ts @@ -29,7 +29,7 @@ describe('TSX', () => { describe("if the filename ends with '.tsx', enable jsx option automatically.", () => { const linter = new Linter(); - linter.defineParser('@typescript-eslint/parser', parser as any); + linter.defineParser('@typescript-eslint/parser', parser); it('filePath was not provided', () => { const code = 'const element = '; From 55c8b7bb0017182467e9c7d5d89f8222c632b843 Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 4 Feb 2019 23:10:55 +0100 Subject: [PATCH 08/13] chore(parser): remove @types/estree from devDependencies --- packages/eslint-plugin-tslint/src/index.ts | 2 +- packages/parser/package.json | 1 - yarn.lock | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/eslint-plugin-tslint/src/index.ts b/packages/eslint-plugin-tslint/src/index.ts index 76642f491fe3..f2ae0e55efd3 100644 --- a/packages/eslint-plugin-tslint/src/index.ts +++ b/packages/eslint-plugin-tslint/src/index.ts @@ -3,7 +3,7 @@ import memoize from 'lodash.memoize'; import { Configuration, RuleSeverity } from 'tslint'; import { Program } from 'typescript'; import { CustomLinter } from './custom-linter'; -import { ParserServices } from "@typescript-eslint/typescript-estree"; +import { ParserServices } from '@typescript-eslint/typescript-estree'; //------------------------------------------------------------------------------ // Plugin Definition diff --git a/packages/parser/package.json b/packages/parser/package.json index 26de602491a7..8cadc1c74159 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -43,7 +43,6 @@ "devDependencies": { "@types/eslint": "^4.16.5", "@types/eslint-visitor-keys": "^1.0.0", - "@types/estree": "^0.0.39", "@typescript-eslint/shared-fixtures": "1.2.0" } } diff --git a/yarn.lock b/yarn.lock index 51d8518fb375..537bb30ceb84 100644 --- a/yarn.lock +++ b/yarn.lock @@ -816,7 +816,7 @@ "@types/estree" "*" "@types/json-schema" "*" -"@types/estree@*", "@types/estree@^0.0.39": +"@types/estree@*": version "0.0.39" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== From d2125802ed23ac2310692d5e1ca8b7b93b967b88 Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 5 Feb 2019 22:24:35 +0100 Subject: [PATCH 09/13] refactor(parser): update names to match eslint-plugin --- packages/parser/src/analyze-scope.ts | 2 +- .../src/{typings.d.ts => eslint-scope.d.ts} | 207 +++++++++--------- packages/parser/src/parser.ts | 4 +- .../typescript-estree/src/parser-options.ts | 10 +- packages/typescript-estree/src/parser.ts | 10 +- 5 files changed, 121 insertions(+), 112 deletions(-) rename packages/parser/src/{typings.d.ts => eslint-scope.d.ts} (63%) diff --git a/packages/parser/src/analyze-scope.ts b/packages/parser/src/analyze-scope.ts index e3c5fc8da50b..918c0cb35c5f 100644 --- a/packages/parser/src/analyze-scope.ts +++ b/packages/parser/src/analyze-scope.ts @@ -11,7 +11,7 @@ import { PatternVisitorCallback, PatternVisitorOptions } from 'eslint-scope/lib/options'; -import { es } from '@typescript-eslint/typescript-estree'; +import { TSESTree as es } from '@typescript-eslint/typescript-estree'; /** * Define the override function of `Scope#__define` for global augmentation. diff --git a/packages/parser/src/typings.d.ts b/packages/parser/src/eslint-scope.d.ts similarity index 63% rename from packages/parser/src/typings.d.ts rename to packages/parser/src/eslint-scope.d.ts index b6ccdd19ee82..28de7f8c759e 100644 --- a/packages/parser/src/typings.d.ts +++ b/packages/parser/src/eslint-scope.d.ts @@ -2,7 +2,7 @@ // Project: http://github.com/eslint/eslint-scope // Definitions by: Armano declare module 'eslint-scope/lib/options' { - import { es } from '@typescript-eslint/typescript-estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; export type PatternVisitorCallback = (pattern: any, info: any) => void; export interface PatternVisitorOptions { @@ -10,40 +10,42 @@ declare module 'eslint-scope/lib/options' { } export abstract class Visitor { - visitChildren(node?: T): void; - visit(node?: T): void; + visitChildren( + node?: T + ): void; + visit(node?: T): void; } } declare module 'eslint-scope/lib/variable' { - import { es } from '@typescript-eslint/typescript-estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import Reference from 'eslint-scope/lib/reference'; import { Definition } from 'eslint-scope/lib/definition'; export default class Variable { name: string; - identifiers: es.Identifier[]; + identifiers: TSESTree.Identifier[]; references: Reference[]; defs: Definition[]; } } declare module 'eslint-scope/lib/definition' { - import { es } from '@typescript-eslint/typescript-estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; export class Definition { type: string; - name: es.BindingName; - node: es.Node; - parent?: es.Node | null; + name: TSESTree.BindingName; + node: TSESTree.Node; + parent?: TSESTree.Node | null; index?: number | null; kind?: string | null; constructor( type: string, - name: es.BindingName | es.PropertyName, - node: es.Node, - parent?: es.Node | null, + name: TSESTree.BindingName | TSESTree.PropertyName, + node: TSESTree.Node, + parent?: TSESTree.Node | null, index?: number | null, kind?: string | null ); @@ -53,8 +55,8 @@ declare module 'eslint-scope/lib/definition' { rest?: boolean; constructor( - name: es.BindingName | es.PropertyName, - node: es.Node, + name: TSESTree.BindingName | TSESTree.PropertyName, + node: TSESTree.Node, index?: number | null, rest?: boolean ); @@ -63,7 +65,7 @@ declare module 'eslint-scope/lib/definition' { declare module 'eslint-scope/lib/pattern-visitor' { import ScopeManager from 'eslint-scope/lib/scope-manager'; - import { es } from '@typescript-eslint/typescript-estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import { PatternVisitorCallback, PatternVisitorOptions, @@ -73,10 +75,10 @@ declare module 'eslint-scope/lib/pattern-visitor' { export default class PatternVisitor extends Visitor { protected options: any; protected scopeManager: ScopeManager; - protected parent?: es.Node; - public rightHandNodes: es.Node[]; + protected parent?: TSESTree.Node; + public rightHandNodes: TSESTree.Node[]; - static isPattern(node: es.Node): boolean; + static isPattern(node: TSESTree.Node): boolean; constructor( options: PatternVisitorOptions, @@ -84,23 +86,23 @@ declare module 'eslint-scope/lib/pattern-visitor' { callback: PatternVisitorCallback ); - Identifier(pattern: es.Node): void; - Property(property: es.Node): void; - ArrayPattern(pattern: es.Node): void; - AssignmentPattern(pattern: es.Node): void; - RestElement(pattern: es.Node): void; - MemberExpression(node: es.Node): void; - SpreadElement(node: es.Node): void; - ArrayExpression(node: es.Node): void; - AssignmentExpression(node: es.Node): void; - CallExpression(node: es.Node): void; + Identifier(pattern: TSESTree.Node): void; + Property(property: TSESTree.Node): void; + ArrayPattern(pattern: TSESTree.Node): void; + AssignmentPattern(pattern: TSESTree.Node): void; + RestElement(pattern: TSESTree.Node): void; + MemberExpression(node: TSESTree.Node): void; + SpreadElement(node: TSESTree.Node): void; + ArrayExpression(node: TSESTree.Node): void; + AssignmentExpression(node: TSESTree.Node): void; + CallExpression(node: TSESTree.Node): void; } } declare module 'eslint-scope/lib/referencer' { import { Scope } from 'eslint-scope/lib/scope'; import ScopeManager from 'eslint-scope/lib/scope-manager'; - import { es } from '@typescript-eslint/typescript-estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import { PatternVisitorCallback, PatternVisitorOptions, @@ -111,12 +113,12 @@ declare module 'eslint-scope/lib/referencer' { protected isInnerMethodDefinition: boolean; protected options: any; protected scopeManager: ScopeManager; - protected parent?: es.Node; + protected parent?: TSESTree.Node; constructor(options: any, scopeManager: ScopeManager); currentScope(): Scope; - close(node: es.Node): void; + close(node: TSESTree.Node): void; pushInnerMethodDefinition(isInnerMethodDefinition: boolean): boolean; popInnerMethodDefinition(isInnerMethodDefinition: boolean): void; @@ -127,57 +129,57 @@ declare module 'eslint-scope/lib/referencer' { init: boolean ): void; visitPattern( - node: es.Node, + node: TSESTree.Node, options: PatternVisitorOptions, callback: PatternVisitorCallback ): void; - visitFunction(node: es.Node): void; - visitClass(node: es.Node): void; - visitProperty(node: es.Node): void; - visitForIn(node: es.Node): void; + visitFunction(node: TSESTree.Node): void; + visitClass(node: TSESTree.Node): void; + visitProperty(node: TSESTree.Node): void; + visitForIn(node: TSESTree.Node): void; visitVariableDeclaration( variableTargetScope: any, type: any, - node: es.Node, + node: TSESTree.Node, index: any ): void; - AssignmentExpression(node: es.Node): void; - CatchClause(node: es.Node): void; - Program(node: es.Node): void; - Identifier(node: es.Node): void; - UpdateExpression(node: es.Node): void; - MemberExpression(node: es.Node): void; - Property(node: es.Node): void; - MethodDefinition(node: es.Node): void; + AssignmentExpression(node: TSESTree.Node): void; + CatchClause(node: TSESTree.Node): void; + Program(node: TSESTree.Node): void; + Identifier(node: TSESTree.Node): void; + UpdateExpression(node: TSESTree.Node): void; + MemberExpression(node: TSESTree.Node): void; + Property(node: TSESTree.Node): void; + MethodDefinition(node: TSESTree.Node): void; BreakStatement(): void; ContinueStatement(): void; - LabeledStatement(node: es.Node): void; - ForStatement(node: es.Node): void; - ClassExpression(node: es.Node): void; - ClassDeclaration(node: es.Node): void; - CallExpression(node: es.Node): void; - BlockStatement(node: es.Node): void; + LabeledStatement(node: TSESTree.Node): void; + ForStatement(node: TSESTree.Node): void; + ClassExpression(node: TSESTree.Node): void; + ClassDeclaration(node: TSESTree.Node): void; + CallExpression(node: TSESTree.Node): void; + BlockStatement(node: TSESTree.Node): void; ThisExpression(): void; - WithStatement(node: es.Node): void; - VariableDeclaration(node: es.Node): void; - SwitchStatement(node: es.Node): void; - FunctionDeclaration(node: es.Node): void; - FunctionExpression(node: es.Node): void; - ForOfStatement(node: es.Node): void; - ForInStatement(node: es.Node): void; - ArrowFunctionExpression(node: es.Node): void; - ImportDeclaration(node: es.Node): void; - visitExportDeclaration(node: es.Node): void; - ExportDeclaration(node: es.Node): void; - ExportNamedDeclaration(node: es.Node): void; - ExportSpecifier(node: es.Node): void; + WithStatement(node: TSESTree.Node): void; + VariableDeclaration(node: TSESTree.Node): void; + SwitchStatement(node: TSESTree.Node): void; + FunctionDeclaration(node: TSESTree.Node): void; + FunctionExpression(node: TSESTree.Node): void; + ForOfStatement(node: TSESTree.Node): void; + ForInStatement(node: TSESTree.Node): void; + ArrowFunctionExpression(node: TSESTree.Node): void; + ImportDeclaration(node: TSESTree.Node): void; + visitExportDeclaration(node: TSESTree.Node): void; + ExportDeclaration(node: TSESTree.Node): void; + ExportNamedDeclaration(node: TSESTree.Node): void; + ExportSpecifier(node: TSESTree.Node): void; MetaProperty(): void; } } declare module 'eslint-scope/lib/scope' { - import { es } from '@typescript-eslint/typescript-estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import Reference from 'eslint-scope/lib/reference'; import Variable from 'eslint-scope/lib/variable'; import ScopeManager from 'eslint-scope/lib/scope-manager'; @@ -202,7 +204,7 @@ declare module 'eslint-scope/lib/scope' { upper: Scope | null; childScopes: Scope[]; variableScope: Scope; - block: es.Node; + block: TSESTree.Node; variables: Variable[]; set: Map; references: Reference[]; @@ -214,7 +216,7 @@ declare module 'eslint-scope/lib/scope' { scopeManager: ScopeManager, type: ScopeType, upperScope: Scope | null, - block: es.Node | null, + block: TSESTree.Node | null, isMethodDefinition: boolean ); @@ -227,7 +229,7 @@ declare module 'eslint-scope/lib/scope' { __isValidResolution(ref: any, variable: any): boolean; __resolve(ref: any): boolean; __delegateToUpperScope(ref: any): void; - __addDeclaredVariablesOfNode(variable: any, node: es.Node): void; + __addDeclaredVariablesOfNode(variable: any, node: TSESTree.Node): void; __defineGeneric( name: any, set: any, @@ -236,12 +238,12 @@ declare module 'eslint-scope/lib/scope' { def: Definition ): void; - __define(node: es.Node, def: Definition): void; + __define(node: TSESTree.Node, def: Definition): void; __referencing( - node: es.Node, + node: TSESTree.Node, assign: number, - writeExpr: es.Node, + writeExpr: TSESTree.Node, maybeImplicitGlobal: any, partial: any, init: any @@ -256,7 +258,7 @@ declare module 'eslint-scope/lib/scope' { * @param {Espree.Identifier} ident - identifier to be resolved. * @returns {Reference} reference */ - resolve(ident: es.Node): Reference; + resolve(ident: TSESTree.Node): Reference; /** * returns this scope is static @@ -283,14 +285,14 @@ declare module 'eslint-scope/lib/scope' { } export class GlobalScope extends Scope { - constructor(scopeManager: ScopeManager, block: es.Node | null); + constructor(scopeManager: ScopeManager, block: TSESTree.Node | null); } export class ModuleScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: es.Node | null + block: TSESTree.Node | null ); } @@ -298,7 +300,7 @@ declare module 'eslint-scope/lib/scope' { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: es.Node | null + block: TSESTree.Node | null ); } @@ -306,7 +308,7 @@ declare module 'eslint-scope/lib/scope' { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: es.Node | null + block: TSESTree.Node | null ); } @@ -314,7 +316,7 @@ declare module 'eslint-scope/lib/scope' { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: es.Node | null + block: TSESTree.Node | null ); } @@ -322,7 +324,7 @@ declare module 'eslint-scope/lib/scope' { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: es.Node | null + block: TSESTree.Node | null ); } @@ -330,7 +332,7 @@ declare module 'eslint-scope/lib/scope' { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: es.Node | null + block: TSESTree.Node | null ); } @@ -338,7 +340,7 @@ declare module 'eslint-scope/lib/scope' { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: es.Node | null, + block: TSESTree.Node | null, isMethodDefinition: boolean ); } @@ -347,7 +349,7 @@ declare module 'eslint-scope/lib/scope' { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: es.Node | null + block: TSESTree.Node | null ); } @@ -355,21 +357,21 @@ declare module 'eslint-scope/lib/scope' { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: es.Node | null + block: TSESTree.Node | null ); } } declare module 'eslint-scope/lib/reference' { - import { es } from '@typescript-eslint/typescript-estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import { Scope } from 'eslint-scope/lib/scope'; import Variable from 'eslint-scope/lib/variable'; export default class Reference { - identifier: es.Identifier; + identifier: TSESTree.Identifier; from: Scope; resolved: Variable | null; - writeExpr: es.Node | null; + writeExpr: TSESTree.Node | null; init: boolean; isWrite(): boolean; @@ -385,7 +387,7 @@ declare module 'eslint-scope/lib/reference' { } declare module 'eslint-scope/lib/scope-manager' { - import { es } from '@typescript-eslint/typescript-estree'; + import { TSESTree } from '@typescript-eslint/typescript-estree'; import { Scope } from 'eslint-scope/lib/scope'; import Variable from 'eslint-scope/lib/variable'; @@ -416,25 +418,28 @@ declare module 'eslint-scope/lib/scope-manager' { isStrictModeSupported(): boolean; // Returns appropriate scope for this node. - __get(node: es.Node): Scope; - getDeclaredVariables(node: es.Node): Variable[]; - acquire(node: es.Node, inner?: boolean): Scope | null; - acquireAll(node: es.Node): Scope | null; - release(node: es.Node, inner?: boolean): Scope | null; + __get(node: TSESTree.Node): Scope; + getDeclaredVariables(node: TSESTree.Node): Variable[]; + acquire(node: TSESTree.Node, inner?: boolean): Scope | null; + acquireAll(node: TSESTree.Node): Scope | null; + release(node: TSESTree.Node, inner?: boolean): Scope | null; attach(): void; detach(): void; __nestScope(scope: Scope): Scope; - __nestGlobalScope(node: es.Node): Scope; - __nestBlockScope(node: es.Node): Scope; - __nestFunctionScope(node: es.Node, isMethodDefinition: boolean): Scope; - __nestForScope(node: es.Node): Scope; - __nestCatchScope(node: es.Node): Scope; - __nestWithScope(node: es.Node): Scope; - __nestClassScope(node: es.Node): Scope; - __nestSwitchScope(node: es.Node): Scope; - __nestModuleScope(node: es.Node): Scope; - __nestFunctionExpressionNameScope(node: es.Node): Scope; + __nestGlobalScope(node: TSESTree.Node): Scope; + __nestBlockScope(node: TSESTree.Node): Scope; + __nestFunctionScope( + node: TSESTree.Node, + isMethodDefinition: boolean + ): Scope; + __nestForScope(node: TSESTree.Node): Scope; + __nestCatchScope(node: TSESTree.Node): Scope; + __nestWithScope(node: TSESTree.Node): Scope; + __nestClassScope(node: TSESTree.Node): Scope; + __nestSwitchScope(node: TSESTree.Node): Scope; + __nestModuleScope(node: TSESTree.Node): Scope; + __nestFunctionExpressionNameScope(node: TSESTree.Node): Scope; __isES6(): boolean; } diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 28d7435cec4c..84c3610dd241 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -1,10 +1,10 @@ +/// import traverser from 'eslint/lib/util/traverser'; import { AST_NODE_TYPES, parseAndGenerateServices, ParserOptions as ParserOptionsTsESTree, - ParserServices, - es + ParserServices } from '@typescript-eslint/typescript-estree'; import { analyzeScope } from './analyze-scope'; import { ParserOptions } from './parser-options'; diff --git a/packages/typescript-estree/src/parser-options.ts b/packages/typescript-estree/src/parser-options.ts index 699eb76ef92d..6ec07b902cd1 100644 --- a/packages/typescript-estree/src/parser-options.ts +++ b/packages/typescript-estree/src/parser-options.ts @@ -36,8 +36,12 @@ export interface ParserOptions { extraFileExtensions?: string[]; } +export interface ParserWeakMap { + get(key: TKey): TValue; +} + export interface ParserServices { - program?: Program; - esTreeNodeToTSNodeMap?: WeakMap; - tsNodeToESTreeNodeMap?: WeakMap; + program: Program | undefined; + esTreeNodeToTSNodeMap: ParserWeakMap | undefined; + tsNodeToESTreeNodeMap: ParserWeakMap | undefined; } diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 8605e9f8be66..500356d9f062 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -14,7 +14,7 @@ import ts from 'typescript'; import convert from './ast-converter'; import { convertError } from './convert'; import { firstDefined } from './node-utils'; -import * as es from './typedefs'; +import * as TSESTree from './typedefs'; import { Extra, ParserOptions, ParserServices } from './parser-options'; import { getFirstSemanticOrSyntacticError } from './semantic-errors'; @@ -271,10 +271,10 @@ function warnAboutTSVersion(): void { // Parser //------------------------------------------------------------------------------ -type AST = es.Program & +type AST = TSESTree.Program & (T['range'] extends true ? { range: [number, number] } : {}) & - (T['tokens'] extends true ? { tokens: es.Token[] } : {}) & - (T['comment'] extends true ? { comments: es.Comment[] } : {}); + (T['tokens'] extends true ? { tokens: TSESTree.Token[] } : {}) & + (T['comment'] extends true ? { comments: TSESTree.Comment[] } : {}); interface ParseAndGenerateServicesResult { ast: AST; @@ -416,4 +416,4 @@ export function parseAndGenerateServices< export { AST_NODE_TYPES } from './ast-node-types'; export { ParserOptions }; export { ParserServices }; -export { es }; +export { TSESTree }; From 2f6f13a8996edf6f6d8cf8aea3d77d13ba0ec75b Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 5 Feb 2019 22:56:11 +0100 Subject: [PATCH 10/13] refactor(parser): fix typo --- packages/parser/src/parser.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/parser/src/parser.ts b/packages/parser/src/parser.ts index 84c3610dd241..78d71197e9f9 100644 --- a/packages/parser/src/parser.ts +++ b/packages/parser/src/parser.ts @@ -1,4 +1,3 @@ -/// import traverser from 'eslint/lib/util/traverser'; import { AST_NODE_TYPES, From a1df95b0aeca2c9ebe4261ccc3ecbaa58007d96c Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 6 Feb 2019 02:53:54 +0100 Subject: [PATCH 11/13] refactor(*): rename as es to as TSESTree --- packages/parser/src/analyze-scope.ts | 114 +++--- .../typescript-estree/src/convert-comments.ts | 18 +- packages/typescript-estree/src/convert.ts | 366 +++++++++--------- packages/typescript-estree/src/node-utils.ts | 25 +- 4 files changed, 265 insertions(+), 258 deletions(-) diff --git a/packages/parser/src/analyze-scope.ts b/packages/parser/src/analyze-scope.ts index 918c0cb35c5f..f3a6b5f78ac1 100644 --- a/packages/parser/src/analyze-scope.ts +++ b/packages/parser/src/analyze-scope.ts @@ -11,7 +11,7 @@ import { PatternVisitorCallback, PatternVisitorOptions } from 'eslint-scope/lib/options'; -import { TSESTree as es } from '@typescript-eslint/typescript-estree'; +import { TSESTree } from '@typescript-eslint/typescript-estree'; /** * Define the override function of `Scope#__define` for global augmentation. @@ -35,7 +35,7 @@ class EnumScope extends Scope { constructor( scopeManager: ScopeManager, upperScope: Scope, - block: es.Node | null + block: TSESTree.Node | null ) { // @ts-ignore super(scopeManager, 'enum', upperScope, block, false); @@ -51,7 +51,7 @@ class PatternVisitor extends OriginalPatternVisitor { super(options, rootPattern, callback); } - Identifier(node: es.Identifier): void { + Identifier(node: TSESTree.Identifier): void { super.Identifier(node); if (node.decorators) { this.rightHandNodes.push(...node.decorators); @@ -61,7 +61,7 @@ class PatternVisitor extends OriginalPatternVisitor { } } - ArrayPattern(node: es.ArrayPattern): void { + ArrayPattern(node: TSESTree.ArrayPattern): void { node.elements.forEach(this.visit, this); if (node.decorators) { this.rightHandNodes.push(...node.decorators); @@ -71,7 +71,7 @@ class PatternVisitor extends OriginalPatternVisitor { } } - ObjectPattern(node: es.ObjectPattern): void { + ObjectPattern(node: TSESTree.ObjectPattern): void { node.properties.forEach(this.visit, this); if (node.decorators) { this.rightHandNodes.push(...node.decorators); @@ -81,7 +81,7 @@ class PatternVisitor extends OriginalPatternVisitor { } } - RestElement(node: es.RestElement): void { + RestElement(node: TSESTree.RestElement): void { super.RestElement(node); if (node.decorators) { this.rightHandNodes.push(...node.decorators); @@ -106,7 +106,7 @@ class Referencer extends OriginalReferencer { * @param [options] The flag to visit right-hand side nodes. * @param callback The callback function for left-hand side nodes. */ - visitPattern( + visitPattern( node: T, options: PatternVisitorOptions, callback: PatternVisitorCallback @@ -136,9 +136,9 @@ class Referencer extends OriginalReferencer { */ visitFunction( node: - | es.FunctionDeclaration - | es.FunctionExpression - | es.ArrowFunctionExpression + | TSESTree.FunctionDeclaration + | TSESTree.FunctionExpression + | TSESTree.ArrowFunctionExpression ): void { const { type, id, typeParameters, params, returnType, body } = node; const scopeManager = this.scopeManager; @@ -210,7 +210,7 @@ class Referencer extends OriginalReferencer { * Visit decorators. * @param node The class node to visit. */ - visitClass(node: es.ClassDeclaration | es.ClassExpression): void { + visitClass(node: TSESTree.ClassDeclaration | TSESTree.ClassExpression): void { this.visitDecorators(node.decorators); const upperTypeMode = this.typeMode; @@ -232,8 +232,8 @@ class Referencer extends OriginalReferencer { */ visitTypeParameters(node: { typeParameters?: - | es.TSTypeParameterDeclaration - | es.TSTypeParameterInstantiation; + | TSESTree.TSTypeParameterDeclaration + | TSESTree.TSTypeParameterInstantiation; }): void { if (node.typeParameters) { const upperTypeMode = this.typeMode; @@ -246,7 +246,7 @@ class Referencer extends OriginalReferencer { /** * Override. */ - JSXOpeningElement(node: es.JSXOpeningElement): void { + JSXOpeningElement(node: TSESTree.JSXOpeningElement): void { this.visit(node.name); this.visitTypeParameters(node); node.attributes.forEach(this.visit, this); @@ -257,7 +257,7 @@ class Referencer extends OriginalReferencer { * Don't create the reference object in the type mode. * @param node The Identifier node to visit. */ - Identifier(node: es.Identifier): void { + Identifier(node: TSESTree.Identifier): void { this.visitDecorators(node.decorators); if (!this.typeMode) { @@ -273,7 +273,7 @@ class Referencer extends OriginalReferencer { * @param node The MethodDefinition node to visit. */ MethodDefinition( - node: es.MethodDefinition | es.TSAbstractMethodDefinition + node: TSESTree.MethodDefinition | TSESTree.TSAbstractMethodDefinition ): void { this.visitDecorators(node.decorators); super.MethodDefinition(node); @@ -283,7 +283,9 @@ class Referencer extends OriginalReferencer { * Don't create the reference object for the key if not computed. * @param node The ClassProperty node to visit. */ - ClassProperty(node: es.ClassProperty | es.TSAbstractClassProperty): void { + ClassProperty( + node: TSESTree.ClassProperty | TSESTree.TSAbstractClassProperty + ): void { const upperTypeMode = this.typeMode; const { computed, decorators, key, typeAnnotation, value } = node; @@ -304,7 +306,7 @@ class Referencer extends OriginalReferencer { * Visit new expression. * @param node The NewExpression node to visit. */ - NewExpression(node: es.NewExpression): void { + NewExpression(node: TSESTree.NewExpression): void { this.visitTypeParameters(node); this.visit(node.callee); @@ -316,7 +318,7 @@ class Referencer extends OriginalReferencer { * Visit call expression. * @param node The CallExpression node to visit. */ - CallExpression(node: es.CallExpression): void { + CallExpression(node: TSESTree.CallExpression): void { this.visitTypeParameters(node); this.visit(node.callee); @@ -329,7 +331,7 @@ class Referencer extends OriginalReferencer { * Because to avoid confusion of `no-redeclare` rule by overloading. * @param node The TSDeclareFunction node to visit. */ - TSDeclareFunction(node: es.TSDeclareFunction): void { + TSDeclareFunction(node: TSESTree.TSDeclareFunction): void { const upperTypeMode = this.typeMode; const scope = this.currentScope(); const { id, typeParameters, params, returnType } = node; @@ -359,7 +361,7 @@ class Referencer extends OriginalReferencer { * Create reference objects for the references in parameters and return type. * @param node The TSEmptyBodyFunctionExpression node to visit. */ - TSEmptyBodyFunctionExpression(node: es.FunctionExpression): void { + TSEmptyBodyFunctionExpression(node: TSESTree.FunctionExpression): void { const upperTypeMode = this.typeMode; const { typeParameters, params, returnType } = node; @@ -375,7 +377,7 @@ class Referencer extends OriginalReferencer { * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. * @param node The TSInterfaceDeclaration node to visit. */ - TSInterfaceDeclaration(node: es.TSInterfaceDeclaration): void { + TSInterfaceDeclaration(node: TSESTree.TSInterfaceDeclaration): void { this.visitTypeNodes(node); } @@ -384,7 +386,7 @@ class Referencer extends OriginalReferencer { * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. * @param node The TSClassImplements node to visit. */ - TSClassImplements(node: es.TSClassImplements): void { + TSClassImplements(node: TSESTree.TSClassImplements): void { this.visitTypeNodes(node); } @@ -393,7 +395,7 @@ class Referencer extends OriginalReferencer { * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. * @param node The TSIndexSignature node to visit. */ - TSIndexSignature(node: es.TSIndexSignature): void { + TSIndexSignature(node: TSESTree.TSIndexSignature): void { this.visitTypeNodes(node); } @@ -401,7 +403,7 @@ class Referencer extends OriginalReferencer { * Visit type assertion. * @param node The TSTypeAssertion node to visit. */ - TSTypeAssertion(node: es.TSTypeAssertion): void { + TSTypeAssertion(node: TSESTree.TSTypeAssertion): void { if (this.typeMode) { this.visit(node.typeAnnotation); } else { @@ -417,7 +419,7 @@ class Referencer extends OriginalReferencer { * Visit as expression. * @param node The TSAsExpression node to visit. */ - TSAsExpression(node: es.TSAsExpression): void { + TSAsExpression(node: TSESTree.TSAsExpression): void { this.visit(node.expression); if (this.typeMode) { @@ -433,7 +435,7 @@ class Referencer extends OriginalReferencer { * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. * @param node The TSTypeAnnotation node to visit. */ - TSTypeAnnotation(node: es.TSTypeAnnotation): void { + TSTypeAnnotation(node: TSESTree.TSTypeAnnotation): void { this.visitTypeNodes(node); } @@ -441,7 +443,7 @@ class Referencer extends OriginalReferencer { * Switch to the type mode and visit child nodes to find `typeof x` expression in type declarations. * @param node The TSTypeParameterDeclaration node to visit. */ - TSTypeParameterDeclaration(node: es.TSTypeParameterDeclaration): void { + TSTypeParameterDeclaration(node: TSESTree.TSTypeParameterDeclaration): void { this.visitTypeNodes(node); } @@ -449,7 +451,7 @@ class Referencer extends OriginalReferencer { * Create reference objects for the references in `typeof` expression. * @param node The TSTypeQuery node to visit. */ - TSTypeQuery(node: es.TSTypeQuery): void { + TSTypeQuery(node: TSESTree.TSTypeQuery): void { if (this.typeMode) { this.typeMode = false; this.visitChildren(node); @@ -462,91 +464,91 @@ class Referencer extends OriginalReferencer { /** * @param node The TSTypeParameter node to visit. */ - TSTypeParameter(node: es.TSTypeParameter): void { + TSTypeParameter(node: TSESTree.TSTypeParameter): void { this.visitTypeNodes(node); } /** * @param node The TSInferType node to visit. */ - TSInferType(node: es.TSInferType): void { + TSInferType(node: TSESTree.TSInferType): void { this.visitTypeNodes(node); } /** * @param node The TSTypeReference node to visit. */ - TSTypeReference(node: es.TSTypeReference): void { + TSTypeReference(node: TSESTree.TSTypeReference): void { this.visitTypeNodes(node); } /** * @param node The TSTypeLiteral node to visit. */ - TSTypeLiteral(node: es.TSTypeLiteral): void { + TSTypeLiteral(node: TSESTree.TSTypeLiteral): void { this.visitTypeNodes(node); } /** * @param node The TSLiteralType node to visit. */ - TSLiteralType(node: es.TSLiteralType): void { + TSLiteralType(node: TSESTree.TSLiteralType): void { this.visitTypeNodes(node); } /** * @param node The TSIntersectionType node to visit. */ - TSIntersectionType(node: es.TSIntersectionType): void { + TSIntersectionType(node: TSESTree.TSIntersectionType): void { this.visitTypeNodes(node); } /** * @param node The TSConditionalType node to visit. */ - TSConditionalType(node: es.TSConditionalType): void { + TSConditionalType(node: TSESTree.TSConditionalType): void { this.visitTypeNodes(node); } /** * @param node The TSIndexedAccessType node to visit. */ - TSIndexedAccessType(node: es.TSIndexedAccessType): void { + TSIndexedAccessType(node: TSESTree.TSIndexedAccessType): void { this.visitTypeNodes(node); } /** * @param node The TSMappedType node to visit. */ - TSMappedType(node: es.TSMappedType): void { + TSMappedType(node: TSESTree.TSMappedType): void { this.visitTypeNodes(node); } /** * @param node The TSOptionalType node to visit. */ - TSOptionalType(node: es.TSOptionalType): void { + TSOptionalType(node: TSESTree.TSOptionalType): void { this.visitTypeNodes(node); } /** * @param node The TSParenthesizedType node to visit. */ - TSParenthesizedType(node: es.TSParenthesizedType): void { + TSParenthesizedType(node: TSESTree.TSParenthesizedType): void { this.visitTypeNodes(node); } /** * @param node The TSRestType node to visit. */ - TSRestType(node: es.TSRestType): void { + TSRestType(node: TSESTree.TSRestType): void { this.visitTypeNodes(node); } /** * @param node The TSTupleType node to visit. */ - TSTupleType(node: es.TSTupleType): void { + TSTupleType(node: TSESTree.TSTupleType): void { this.visitTypeNodes(node); } @@ -554,7 +556,7 @@ class Referencer extends OriginalReferencer { * Create reference objects for the object part. (This is `obj.prop`) * @param node The TSQualifiedName node to visit. */ - TSQualifiedName(node: es.TSQualifiedName): void { + TSQualifiedName(node: TSESTree.TSQualifiedName): void { this.visit(node.left); } @@ -562,7 +564,7 @@ class Referencer extends OriginalReferencer { * Create reference objects for the references in computed keys. * @param node The TSPropertySignature node to visit. */ - TSPropertySignature(node: es.TSPropertySignature): void { + TSPropertySignature(node: TSESTree.TSPropertySignature): void { const upperTypeMode = this.typeMode; const { computed, key, typeAnnotation, initializer } = node; @@ -584,7 +586,7 @@ class Referencer extends OriginalReferencer { * Create reference objects for the references in computed keys. * @param node The TSMethodSignature node to visit. */ - TSMethodSignature(node: es.TSMethodSignature): void { + TSMethodSignature(node: TSESTree.TSMethodSignature): void { const upperTypeMode = this.typeMode; const { computed, key, typeParameters, params, returnType } = node; @@ -620,7 +622,7 @@ class Referencer extends OriginalReferencer { * * @param node The TSEnumDeclaration node to visit. */ - TSEnumDeclaration(node: es.TSEnumDeclaration): void { + TSEnumDeclaration(node: TSESTree.TSEnumDeclaration): void { const { id, members } = node; const scopeManager = this.scopeManager; const scope = this.currentScope(); @@ -642,7 +644,7 @@ class Referencer extends OriginalReferencer { * * @param node The TSEnumMember node to visit. */ - TSEnumMember(node: es.TSEnumMember): void { + TSEnumMember(node: TSESTree.TSEnumMember): void { const { id, initializer } = node; const scope = this.currentScope(); @@ -657,7 +659,7 @@ class Referencer extends OriginalReferencer { * Create the variable object for the module name, and visit children. * @param node The TSModuleDeclaration node to visit. */ - TSModuleDeclaration(node: es.TSModuleDeclaration): void { + TSModuleDeclaration(node: TSESTree.TSModuleDeclaration): void { const scope = this.currentScope(); const { id, body } = node; @@ -675,7 +677,7 @@ class Referencer extends OriginalReferencer { this.visit(body); } - TSTypeAliasDeclaration(node: es.TSTypeAliasDeclaration): void { + TSTypeAliasDeclaration(node: TSESTree.TSTypeAliasDeclaration): void { this.typeMode = true; this.visitChildren(node); this.typeMode = false; @@ -685,16 +687,16 @@ class Referencer extends OriginalReferencer { * Process the module block. * @param node The TSModuleBlock node to visit. */ - TSModuleBlock(node: es.TSModuleBlock): void { + TSModuleBlock(node: TSESTree.TSModuleBlock): void { this.scopeManager.__nestBlockScope(node); this.visitChildren(node); this.close(node); } - TSAbstractClassProperty(node: es.TSAbstractClassProperty): void { + TSAbstractClassProperty(node: TSESTree.TSAbstractClassProperty): void { this.ClassProperty(node); } - TSAbstractMethodDefinition(node: es.TSAbstractMethodDefinition): void { + TSAbstractMethodDefinition(node: TSESTree.TSAbstractMethodDefinition): void { this.MethodDefinition(node); } @@ -702,7 +704,7 @@ class Referencer extends OriginalReferencer { * Process import equal declaration * @param node The TSImportEqualsDeclaration node to visit. */ - TSImportEqualsDeclaration(node: es.TSImportEqualsDeclaration): void { + TSImportEqualsDeclaration(node: TSESTree.TSImportEqualsDeclaration): void { const { id, moduleReference } = node; if (id && id.type === 'Identifier') { this.currentScope().__define( @@ -719,7 +721,7 @@ class Referencer extends OriginalReferencer { * 2. Configure the global scope to set `variable.eslintUsed = true` for all defined variables. This means `no-unused-vars` doesn't warn those. * @param node The TSModuleDeclaration node to visit. */ - visitGlobalAugmentation(node: es.TSModuleDeclaration): void { + visitGlobalAugmentation(node: TSESTree.TSModuleDeclaration): void { const scopeManager = this.scopeManager; const currentScope = this.currentScope(); const globalScope = scopeManager.globalScope; @@ -741,7 +743,7 @@ class Referencer extends OriginalReferencer { * Process decorators. * @param decorators The decorator nodes to visit. */ - visitDecorators(decorators?: es.Decorator[]): void { + visitDecorators(decorators?: TSESTree.Decorator[]): void { if (decorators) { decorators.forEach(this.visit, this); } @@ -751,7 +753,7 @@ class Referencer extends OriginalReferencer { * Process all child of type nodes * @param node node to be processed */ - visitTypeNodes(node: es.Node): void { + visitTypeNodes(node: TSESTree.Node): void { if (this.typeMode) { this.visitChildren(node); } else { diff --git a/packages/typescript-estree/src/convert-comments.ts b/packages/typescript-estree/src/convert-comments.ts index 59a2326122c8..3abc08bc847c 100644 --- a/packages/typescript-estree/src/convert-comments.ts +++ b/packages/typescript-estree/src/convert-comments.ts @@ -7,7 +7,7 @@ import ts from 'typescript'; import { getLocFor, getNodeContainer } from './node-utils'; -import * as es from './typedefs'; +import * as TSESTree from './typedefs'; /** * Converts a TypeScript comment to an Esprima comment. @@ -25,10 +25,10 @@ function convertTypeScriptCommentToEsprimaComment( text: string, start: number, end: number, - startLoc: es.LineAndColumnData, - endLoc: es.LineAndColumnData -): es.Comment { - const comment: es.OptionalRangeAndLoc = { + startLoc: TSESTree.LineAndColumnData, + endLoc: TSESTree.LineAndColumnData +): TSESTree.Comment { + const comment: TSESTree.OptionalRangeAndLoc = { type: block ? 'Block' : 'Line', value: text }; @@ -44,7 +44,7 @@ function convertTypeScriptCommentToEsprimaComment( }; } - return comment as es.Comment; + return comment as TSESTree.Comment; } /** @@ -59,7 +59,7 @@ function getCommentFromTriviaScanner( triviaScanner: ts.Scanner, ast: ts.SourceFile, code: string -): es.Comment { +): TSESTree.Comment { const kind = triviaScanner.getToken(); const isBlock = kind === ts.SyntaxKind.MultiLineCommentTrivia; const range = { @@ -94,8 +94,8 @@ function getCommentFromTriviaScanner( export function convertComments( ast: ts.SourceFile, code: string -): es.Comment[] { - const comments: es.Comment[] = []; +): TSESTree.Comment[] { + const comments: TSESTree.Comment[] = []; /** * Create a TypeScript Scanner, with skipTrivia set to false so that diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index eb2e69a60ece..78e66b02ddad 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -6,7 +6,7 @@ * MIT License */ import ts from 'typescript'; -import * as es from './typedefs'; +import * as TSESTree from './typedefs'; import { canContainDirective, createError, @@ -78,8 +78,8 @@ export class Converter { }; } - convertProgram(): es.Program { - return this.converter(this.ast) as es.Program; + convertProgram(): TSESTree.Program { + return this.converter(this.ast) as TSESTree.Program; } /** @@ -112,7 +112,7 @@ export class Converter { this.allowPattern = allowPattern; } - let result: es.BaseNode | null = this.convertNode( + let result: TSESTree.BaseNode | null = this.convertNode( node as TSNode, parent || node.parent ); @@ -157,9 +157,9 @@ export class Converter { return this.converter(child, parent, true, false); } - private createNode( + private createNode( node: ts.Node, - data: es.OptionalRangeAndLoc + data: TSESTree.OptionalRangeAndLoc ): T { const result = data; if (!result.range) { @@ -182,7 +182,7 @@ export class Converter { private convertTypeAnnotation( child: ts.TypeNode, parent: ts.Node - ): es.TSTypeAnnotation { + ): TSESTree.TSTypeAnnotation { // in FunctionType and ConstructorType typeAnnotation has 2 characters `=>` and in other places is just colon const offset = parent.kind === SyntaxKind.FunctionType || @@ -244,7 +244,7 @@ export class Converter { */ private convertTypeArgumentsToTypeParameters( typeArguments: ts.NodeArray - ): es.TSTypeParameterInstantiation { + ): TSESTree.TSTypeParameterInstantiation { const greaterThanToken = findNextToken(typeArguments, this.ast, this.ast)!; return { @@ -262,7 +262,7 @@ export class Converter { */ private convertTSTypeParametersToTypeParametersDeclaration( typeParameters: ts.NodeArray - ): es.TSTypeParameterDeclaration { + ): TSESTree.TSTypeParameterDeclaration { const greaterThanToken = findNextToken(typeParameters, this.ast, this.ast)!; return { @@ -282,12 +282,12 @@ export class Converter { */ private convertParameters( parameters: ts.NodeArray - ): es.Parameter[] { + ): TSESTree.Parameter[] { if (!parameters || !parameters.length) { return []; } return parameters.map(param => { - const convertedParam = this.convertChild(param) as es.Parameter; + const convertedParam = this.convertChild(param) as TSESTree.Parameter; if (param.decorators && param.decorators.length) { convertedParam.decorators = param.decorators.map(el => @@ -375,28 +375,28 @@ export class Converter { private convertJSXTagName( node: ts.JsxTagNameExpression, parent: ts.Node - ): es.JSXMemberExpression | es.JSXIdentifier { - let result: es.JSXMemberExpression | es.JSXIdentifier; + ): TSESTree.JSXMemberExpression | TSESTree.JSXIdentifier { + let result: TSESTree.JSXMemberExpression | TSESTree.JSXIdentifier; switch (node.kind) { case SyntaxKind.PropertyAccessExpression: - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.JSXMemberExpression, object: this.convertJSXTagName(node.expression, parent), property: this.convertJSXTagName( node.name, parent - ) as es.JSXIdentifier + ) as TSESTree.JSXIdentifier }); break; case SyntaxKind.ThisKeyword: - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.JSXIdentifier, name: 'this' }); break; case SyntaxKind.Identifier: default: - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.JSXIdentifier, name: node.text }); @@ -419,7 +419,7 @@ export class Converter { * @deprecated This method adds not standardized `modifiers` property in nodes */ private applyModifiersToResult( - result: es.TSEnumDeclaration | es.TSModuleDeclaration, + result: TSESTree.TSEnumDeclaration | TSESTree.TSModuleDeclaration, modifiers?: ts.ModifiersArray ): void { if (!modifiers || !modifiers.length) { @@ -474,7 +474,7 @@ export class Converter { * @param childRange The child node range used to expand location */ private fixParentLocation( - result: es.BaseNode, + result: TSESTree.BaseNode, childRange: [number, number] ): void { if (childRange[0] < result.range[0]) { @@ -495,10 +495,10 @@ export class Converter { * @param parent parentNode * @returns the converted ESTree node */ - private convertNode(node: TSNode, parent: ts.Node): es.Node | null { + private convertNode(node: TSNode, parent: ts.Node): TSESTree.Node | null { switch (node.kind) { case SyntaxKind.SourceFile: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Program, body: this.convertBodyExpressions(node.statements, node), // externalModuleIndicator is internal field in TSC @@ -510,21 +510,21 @@ export class Converter { } case SyntaxKind.Block: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.BlockStatement, body: this.convertBodyExpressions(node.statements, node) }); } case SyntaxKind.Identifier: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Identifier, name: node.text }); } case SyntaxKind.WithStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.WithStatement, object: this.convertChild(node.expression), body: this.convertChild(node.statement) @@ -533,26 +533,26 @@ export class Converter { // Control Flow case SyntaxKind.ReturnStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ReturnStatement, argument: this.convertChild(node.expression) }); case SyntaxKind.LabeledStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.LabeledStatement, label: this.convertChild(node.label), body: this.convertChild(node.statement) }); case SyntaxKind.ContinueStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ContinueStatement, label: this.convertChild(node.label) }); case SyntaxKind.BreakStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.BreakStatement, label: this.convertChild(node.label) }); @@ -560,7 +560,7 @@ export class Converter { // Choice case SyntaxKind.IfStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.IfStatement, test: this.convertChild(node.expression), consequent: this.convertChild(node.thenStatement), @@ -568,7 +568,7 @@ export class Converter { }); case SyntaxKind.SwitchStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.SwitchStatement, discriminant: this.convertChild(node.expression), cases: node.caseBlock.clauses.map(el => this.convertChild(el)) @@ -576,7 +576,7 @@ export class Converter { case SyntaxKind.CaseClause: case SyntaxKind.DefaultClause: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.SwitchCase, // expression is present in case only test: @@ -589,13 +589,13 @@ export class Converter { // Exceptions case SyntaxKind.ThrowStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ThrowStatement, argument: this.convertChild(node.expression) }); case SyntaxKind.TryStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TryStatement, block: this.convertChild(node.tryBlock), handler: this.convertChild(node.catchClause), @@ -603,7 +603,7 @@ export class Converter { }); case SyntaxKind.CatchClause: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.CatchClause, param: node.variableDeclaration ? this.convertChild(node.variableDeclaration.name) @@ -614,7 +614,7 @@ export class Converter { // Loops case SyntaxKind.WhileStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.WhileStatement, test: this.convertChild(node.expression), body: this.convertChild(node.statement) @@ -625,14 +625,14 @@ export class Converter { * a "DoStatement" */ case SyntaxKind.DoStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.DoWhileStatement, test: this.convertChild(node.expression), body: this.convertChild(node.statement) }); case SyntaxKind.ForStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ForStatement, init: this.convertChild(node.initializer), test: this.convertChild(node.condition), @@ -641,7 +641,7 @@ export class Converter { }); case SyntaxKind.ForInStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ForInStatement, left: this.convertPattern(node.initializer), right: this.convertChild(node.expression), @@ -649,7 +649,7 @@ export class Converter { }); case SyntaxKind.ForOfStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ForOfStatement, left: this.convertPattern(node.initializer), right: this.convertChild(node.expression), @@ -666,7 +666,7 @@ export class Converter { const isDeclare = hasModifier(SyntaxKind.DeclareKeyword, node); const result = this.createNode< - es.TSDeclareFunction | es.FunctionDeclaration + TSESTree.TSDeclareFunction | TSESTree.FunctionDeclaration >(node, { type: isDeclare || !node.body @@ -701,7 +701,7 @@ export class Converter { } case SyntaxKind.VariableDeclaration: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.VariableDeclarator, id: this.convertPattern(node.name), init: this.convertChild(node.initializer) @@ -722,7 +722,7 @@ export class Converter { } case SyntaxKind.VariableStatement: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.VariableDeclaration, declarations: node.declarationList.declarations.map(el => this.convertChild(el) @@ -740,7 +740,7 @@ export class Converter { // mostly for for-of, for-in case SyntaxKind.VariableDeclarationList: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.VariableDeclaration, declarations: node.declarations.map(el => this.convertChild(el)), kind: getDeclarationKind(node) @@ -749,25 +749,25 @@ export class Converter { // Expressions case SyntaxKind.ExpressionStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ExpressionStatement, expression: this.convertChild(node.expression) }); case SyntaxKind.ThisKeyword: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ThisExpression }); case SyntaxKind.ArrayLiteralExpression: { // TypeScript uses ArrayLiteralExpression in destructuring assignment, too if (this.allowPattern) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ArrayPattern, elements: node.elements.map(el => this.convertPattern(el)) }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ArrayExpression, elements: node.elements.map(el => this.convertChild(el)) }); @@ -777,12 +777,12 @@ export class Converter { case SyntaxKind.ObjectLiteralExpression: { // TypeScript uses ObjectLiteralExpression in destructuring assignment, too if (this.allowPattern) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ObjectPattern, properties: node.properties.map(el => this.convertPattern(el)) }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ObjectExpression, properties: node.properties.map(el => this.convertChild(el)) }); @@ -790,7 +790,7 @@ export class Converter { } case SyntaxKind.PropertyAssignment: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Property, key: this.convertChild(node.name), value: this.converter( @@ -807,10 +807,10 @@ export class Converter { case SyntaxKind.ShorthandPropertyAssignment: { if (node.objectAssignmentInitializer) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Property, key: this.convertChild(node.name), - value: this.createNode(node, { + value: this.createNode(node, { type: AST_NODE_TYPES.AssignmentPattern, left: this.convertPattern(node.name), right: this.convertChild(node.objectAssignmentInitializer) @@ -821,7 +821,7 @@ export class Converter { kind: 'init' }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Property, key: this.convertChild(node.name), value: this.convertChild(node.name), @@ -839,7 +839,7 @@ export class Converter { case SyntaxKind.PropertyDeclaration: { const isAbstract = hasModifier(SyntaxKind.AbstractKeyword, node); const result = this.createNode< - es.TSAbstractClassProperty | es.ClassProperty + TSESTree.TSAbstractClassProperty | TSESTree.ClassProperty >(node, { type: isAbstract ? AST_NODE_TYPES.TSAbstractClassProperty @@ -881,7 +881,7 @@ export class Converter { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.MethodDeclaration: { - const method = this.createNode(node, { + const method = this.createNode(node, { type: AST_NODE_TYPES.FunctionExpression, id: null, generator: !!node.asteriskToken, @@ -905,14 +905,14 @@ export class Converter { } let result: - | es.Property - | es.TSAbstractMethodDefinition - | es.MethodDefinition; + | TSESTree.Property + | TSESTree.TSAbstractMethodDefinition + | TSESTree.MethodDefinition; if (parent.kind === SyntaxKind.ObjectLiteralExpression) { method.params = node.parameters.map(el => this.convertChild(el)); - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.Property, key: this.convertChild(node.name), value: method, @@ -940,7 +940,7 @@ export class Converter { : AST_NODE_TYPES.MethodDefinition; result = this.createNode< - es.TSAbstractMethodDefinition | es.MethodDefinition + TSESTree.TSAbstractMethodDefinition | TSESTree.MethodDefinition >(node, { type: methodDefinitionType, key: this.convertChild(node.name), @@ -974,7 +974,7 @@ export class Converter { } else if (node.kind === SyntaxKind.SetAccessor) { result.kind = 'set'; } else if ( - !(result as es.MethodDefinition).static && + !(result as TSESTree.MethodDefinition).static && node.name.kind === SyntaxKind.StringLiteral && node.name.text === 'constructor' && result.type !== AST_NODE_TYPES.Property @@ -991,7 +991,7 @@ export class Converter { (lastModifier && findNextToken(lastModifier, node, this.ast)) || node.getFirstToken()!; - const constructor = this.createNode(node, { + const constructor = this.createNode(node, { type: AST_NODE_TYPES.FunctionExpression, id: null, params: this.convertParameters(node.parameters), @@ -1015,7 +1015,7 @@ export class Converter { constructor.returnType = this.convertTypeAnnotation(node.type, node); } - const constructorKey = this.createNode(node, { + const constructorKey = this.createNode(node, { type: AST_NODE_TYPES.Identifier, name: 'constructor', range: [constructorToken.getStart(this.ast), constructorToken.end] @@ -1023,7 +1023,7 @@ export class Converter { const isStatic = hasModifier(SyntaxKind.StaticKeyword, node); const result = this.createNode< - es.TSAbstractMethodDefinition | es.MethodDefinition + TSESTree.TSAbstractMethodDefinition | TSESTree.MethodDefinition >(node, { type: hasModifier(SyntaxKind.AbstractKeyword, node) ? AST_NODE_TYPES.TSAbstractMethodDefinition @@ -1044,7 +1044,7 @@ export class Converter { } case SyntaxKind.FunctionExpression: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.FunctionExpression, id: this.convertChild(node.name), generator: !!node.asteriskToken, @@ -1069,12 +1069,12 @@ export class Converter { } case SyntaxKind.SuperKeyword: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Super }); case SyntaxKind.ArrayBindingPattern: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ArrayPattern, elements: node.elements.map(el => this.convertPattern(el)) }); @@ -1084,7 +1084,7 @@ export class Converter { return null; case SyntaxKind.ObjectBindingPattern: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ObjectPattern, properties: node.elements.map(el => this.convertPattern(el)) }); @@ -1094,13 +1094,13 @@ export class Converter { const arrayItem = this.convertChild(node.name, parent); if (node.initializer) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.AssignmentPattern, left: arrayItem, right: this.convertChild(node.initializer) }); } else if (node.dotDotDotToken) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.RestElement, argument: arrayItem }); @@ -1108,14 +1108,14 @@ export class Converter { return arrayItem; } } else if (parent.kind === SyntaxKind.ObjectBindingPattern) { - let result: es.RestElement | es.Property; + let result: TSESTree.RestElement | TSESTree.Property; if (node.dotDotDotToken) { - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.RestElement, argument: this.convertChild(node.propertyName || node.name) }); } else { - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.Property, key: this.convertChild(node.propertyName || node.name), value: this.convertChild(node.name), @@ -1130,7 +1130,7 @@ export class Converter { } if (node.initializer) { - result.value = this.createNode(node, { + result.value = this.createNode(node, { type: AST_NODE_TYPES.AssignmentPattern, left: this.convertChild(node.name), right: this.convertChild(node.initializer), @@ -1143,7 +1143,7 @@ export class Converter { } case SyntaxKind.ArrowFunction: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.ArrowFunctionExpression, generator: false, id: null, @@ -1168,14 +1168,14 @@ export class Converter { } case SyntaxKind.YieldExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.YieldExpression, delegate: !!node.asteriskToken, argument: this.convertChild(node.expression) }); case SyntaxKind.AwaitExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.AwaitExpression, argument: this.convertChild(node.expression) }); @@ -1183,10 +1183,10 @@ export class Converter { // Template Literals case SyntaxKind.NoSubstitutionTemplateLiteral: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TemplateLiteral, quasis: [ - this.createNode(node, { + this.createNode(node, { type: AST_NODE_TYPES.TemplateElement, value: { raw: this.ast.text.slice( @@ -1202,7 +1202,7 @@ export class Converter { }); case SyntaxKind.TemplateExpression: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TemplateLiteral, quasis: [this.convertChild(node.head)], expressions: [] @@ -1216,7 +1216,7 @@ export class Converter { } case SyntaxKind.TaggedTemplateExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TaggedTemplateExpression, typeParameters: node.typeArguments ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) @@ -1229,7 +1229,7 @@ export class Converter { case SyntaxKind.TemplateMiddle: case SyntaxKind.TemplateTail: { const tail = node.kind === SyntaxKind.TemplateTail; - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TemplateElement, value: { raw: this.ast.text.slice( @@ -1247,12 +1247,12 @@ export class Converter { case SyntaxKind.SpreadAssignment: case SyntaxKind.SpreadElement: { if (this.allowPattern) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.RestElement, argument: this.convertPattern(node.expression) }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.SpreadElement, argument: this.convertChild(node.expression) }); @@ -1261,16 +1261,16 @@ export class Converter { case SyntaxKind.Parameter: { let parameter: any; - let result: es.RestElement | es.AssignmentPattern; + let result: TSESTree.RestElement | TSESTree.AssignmentPattern; if (node.dotDotDotToken) { - parameter = result = this.createNode(node, { + parameter = result = this.createNode(node, { type: AST_NODE_TYPES.RestElement, argument: this.convertChild(node.name) }); } else if (node.initializer) { parameter = this.convertChild(node.name); - result = this.createNode(node, { + result = this.createNode(node, { type: AST_NODE_TYPES.AssignmentPattern, left: parameter, right: this.convertChild(node.initializer) @@ -1305,7 +1305,7 @@ export class Converter { } if (node.modifiers) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSParameterProperty, accessibility: getTSNodeAccessibility(node) || undefined, readonly: @@ -1337,11 +1337,11 @@ export class Converter { ); const result = this.createNode< - es.ClassDeclaration | es.ClassExpression + TSESTree.ClassDeclaration | TSESTree.ClassExpression >(node, { type: classNodeType, id: this.convertChild(node.name), - body: this.createNode(node, { + body: this.createNode(node, { type: AST_NODE_TYPES.ClassBody, body: [], range: [node.members.pos - 1, node.end] @@ -1407,13 +1407,13 @@ export class Converter { // Modules case SyntaxKind.ModuleBlock: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSModuleBlock, body: this.convertBodyExpressions(node.statements, node) }); case SyntaxKind.ImportDeclaration: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.ImportDeclaration, source: this.convertChild(node.moduleSpecifier), specifiers: [] @@ -1445,20 +1445,20 @@ export class Converter { } case SyntaxKind.NamespaceImport: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ImportNamespaceSpecifier, local: this.convertChild(node.name) }); case SyntaxKind.ImportSpecifier: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ImportSpecifier, local: this.convertChild(node.name), imported: this.convertChild(node.propertyName || node.name) }); case SyntaxKind.ImportClause: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ImportDefaultSpecifier, local: this.convertChild(node.name), range: [node.getStart(this.ast), node.name!.end] @@ -1466,7 +1466,7 @@ export class Converter { case SyntaxKind.ExportDeclaration: if (node.exportClause) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ExportNamedDeclaration, source: this.convertChild(node.moduleSpecifier), specifiers: node.exportClause.elements.map(el => @@ -1475,14 +1475,14 @@ export class Converter { declaration: null }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ExportAllDeclaration, source: this.convertChild(node.moduleSpecifier) }); } case SyntaxKind.ExportSpecifier: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ExportSpecifier, local: this.convertChild(node.propertyName || node.name), exported: this.convertChild(node.name) @@ -1490,12 +1490,12 @@ export class Converter { case SyntaxKind.ExportAssignment: if (node.isExportEquals) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSExportAssignment, expression: this.convertChild(node.expression) }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ExportDefaultDeclaration, declaration: this.convertChild(node.expression) }); @@ -1510,14 +1510,14 @@ export class Converter { * ESTree uses UpdateExpression for ++/-- */ if (/^(?:\+\+|--)$/.test(operator)) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.UpdateExpression, operator, prefix: node.kind === SyntaxKind.PrefixUnaryExpression, argument: this.convertChild(node.operand) }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.UnaryExpression, operator, prefix: node.kind === SyntaxKind.PrefixUnaryExpression, @@ -1527,7 +1527,7 @@ export class Converter { } case SyntaxKind.DeleteExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.UnaryExpression, operator: 'delete', prefix: true, @@ -1535,7 +1535,7 @@ export class Converter { }); case SyntaxKind.VoidExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.UnaryExpression, operator: 'void', prefix: true, @@ -1543,7 +1543,7 @@ export class Converter { }); case SyntaxKind.TypeOfExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.UnaryExpression, operator: 'typeof', prefix: true, @@ -1551,7 +1551,7 @@ export class Converter { }); case SyntaxKind.TypeOperator: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeOperator, operator: getTextForTokenKind(node.operator) as any, typeAnnotation: this.convertChild(node.type) @@ -1562,7 +1562,7 @@ export class Converter { case SyntaxKind.BinaryExpression: { // TypeScript uses BinaryExpression for sequences as well if (isComma(node.operatorToken)) { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.SequenceExpression, expressions: [] }); @@ -1588,14 +1588,16 @@ export class Converter { this.allowPattern && type === AST_NODE_TYPES.AssignmentExpression ) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.AssignmentPattern, left: this.convertPattern(node.left, node), right: this.convertChild(node.right) }); } return this.createNode< - es.AssignmentExpression | es.LogicalExpression | es.BinaryExpression + | TSESTree.AssignmentExpression + | TSESTree.LogicalExpression + | TSESTree.BinaryExpression >(node, { type: type, operator: getTextForTokenKind(node.operatorToken.kind)!, @@ -1611,7 +1613,7 @@ export class Converter { } case SyntaxKind.PropertyAccessExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.MemberExpression, object: this.convertChild(node.expression), property: this.convertChild(node.name), @@ -1619,7 +1621,7 @@ export class Converter { }); case SyntaxKind.ElementAccessExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.MemberExpression, object: this.convertChild(node.expression), property: this.convertChild(node.argumentExpression), @@ -1627,7 +1629,7 @@ export class Converter { }); case SyntaxKind.ConditionalExpression: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.ConditionalExpression, test: this.convertChild(node.condition), consequent: this.convertChild(node.whenTrue), @@ -1635,7 +1637,7 @@ export class Converter { }); case SyntaxKind.CallExpression: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.CallExpression, callee: this.convertChild(node.expression), arguments: node.arguments.map(el => this.convertChild(el)) @@ -1649,7 +1651,7 @@ export class Converter { } case SyntaxKind.NewExpression: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.NewExpression, callee: this.convertChild(node.expression), arguments: node.arguments @@ -1665,9 +1667,9 @@ export class Converter { } case SyntaxKind.MetaProperty: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.MetaProperty, - meta: this.createNode(node.getFirstToken()!, { + meta: this.createNode(node.getFirstToken()!, { type: AST_NODE_TYPES.Identifier, name: getTextForTokenKind(node.keywordToken)! }), @@ -1676,7 +1678,7 @@ export class Converter { } case SyntaxKind.Decorator: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Decorator, expression: this.convertChild(node.expression) }); @@ -1685,7 +1687,7 @@ export class Converter { // Literals case SyntaxKind.StringLiteral: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.Literal, raw: '', value: '' @@ -1700,7 +1702,7 @@ export class Converter { } case SyntaxKind.NumericLiteral: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: Number(node.text), raw: node.getText() @@ -1708,7 +1710,7 @@ export class Converter { } case SyntaxKind.BigIntLiteral: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.BigIntLiteral, raw: '', value: '' @@ -1729,7 +1731,7 @@ export class Converter { regex = null; } - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: regex, raw: node.text, @@ -1741,14 +1743,14 @@ export class Converter { } case SyntaxKind.TrueKeyword: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: true, raw: 'true' }); case SyntaxKind.FalseKeyword: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: false, raw: 'false' @@ -1756,11 +1758,11 @@ export class Converter { case SyntaxKind.NullKeyword: { if (this.inTypeMode) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSNullKeyword }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: null, raw: 'null' @@ -1769,24 +1771,24 @@ export class Converter { } case SyntaxKind.ImportKeyword: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Import }); case SyntaxKind.EmptyStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.EmptyStatement }); case SyntaxKind.DebuggerStatement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.DebuggerStatement }); // JSX case SyntaxKind.JsxElement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXElement, openingElement: this.convertChild(node.openingElement), closingElement: this.convertChild(node.closingElement), @@ -1794,7 +1796,7 @@ export class Converter { }); case SyntaxKind.JsxFragment: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXFragment, openingFragment: this.convertChild(node.openingFragment), closingFragment: this.convertChild(node.closingFragment), @@ -1802,13 +1804,13 @@ export class Converter { }); case SyntaxKind.JsxSelfClosingElement: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXElement, /** * Convert SyntaxKind.JsxSelfClosingElement to SyntaxKind.JsxOpeningElement, * TypeScript does not seem to have the idea of openingElement when tag is self-closing */ - openingElement: this.createNode(node, { + openingElement: this.createNode(node, { type: AST_NODE_TYPES.JSXOpeningElement, typeParameters: node.typeArguments ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) @@ -1826,7 +1828,7 @@ export class Converter { } case SyntaxKind.JsxOpeningElement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXOpeningElement, typeParameters: node.typeArguments ? this.convertTypeArgumentsToTypeParameters(node.typeArguments) @@ -1839,36 +1841,36 @@ export class Converter { }); case SyntaxKind.JsxClosingElement: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXClosingElement, name: this.convertJSXTagName(node.tagName, node) }); case SyntaxKind.JsxOpeningFragment: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXOpeningFragment }); case SyntaxKind.JsxClosingFragment: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXClosingFragment }); case SyntaxKind.JsxExpression: { const expression = node.expression ? this.convertChild(node.expression) - : this.createNode(node, { + : this.createNode(node, { type: AST_NODE_TYPES.JSXEmptyExpression, range: [node.getStart(this.ast) + 1, node.getEnd() - 1] }); if (node.dotDotDotToken) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXSpreadChild, expression }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXExpressionContainer, expression }); @@ -1879,7 +1881,7 @@ export class Converter { const attributeName = this.convertChild(node.name); attributeName.type = AST_NODE_TYPES.JSXIdentifier; - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXAttribute, name: attributeName, value: this.convertChild(node.initializer) @@ -1897,14 +1899,14 @@ export class Converter { const end = node.getEnd(); if (this.options.useJSXTextNode) { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXText, value: this.ast.text.slice(start, end), raw: this.ast.text.slice(start, end), range: [start, end] }); } else { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.Literal, value: this.ast.text.slice(start, end), raw: this.ast.text.slice(start, end), @@ -1914,13 +1916,13 @@ export class Converter { } case SyntaxKind.JsxSpreadAttribute: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.JSXSpreadAttribute, argument: this.convertChild(node.expression) }); case SyntaxKind.QualifiedName: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSQualifiedName, left: this.convertChild(node.left), right: this.convertChild(node.right) @@ -1930,7 +1932,7 @@ export class Converter { // TypeScript specific case SyntaxKind.TypeReference: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeReference, typeName: this.convertType(node.typeName), typeParameters: node.typeArguments @@ -1940,7 +1942,7 @@ export class Converter { } case SyntaxKind.TypeParameter: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeParameter, name: this.convertType(node.name), constraint: node.constraint @@ -1968,28 +1970,28 @@ export class Converter { } case SyntaxKind.NonNullExpression: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSNonNullExpression, expression: this.convertChild(node.expression) }); } case SyntaxKind.TypeLiteral: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeLiteral, members: node.members.map(el => this.convertChild(el)) }); } case SyntaxKind.ArrayType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSArrayType, elementType: this.convertType(node.elementType) }); } case SyntaxKind.IndexedAccessType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSIndexedAccessType, objectType: this.convertType(node.objectType), indexType: this.convertType(node.indexType) @@ -1997,7 +1999,7 @@ export class Converter { } case SyntaxKind.ConditionalType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSConditionalType, checkType: this.convertType(node.checkType), extendsType: this.convertType(node.extendsType), @@ -2007,14 +2009,14 @@ export class Converter { } case SyntaxKind.TypeQuery: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeQuery, exprName: this.convertType(node.exprName) }); } case SyntaxKind.MappedType: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSMappedType, typeParameter: this.convertType(node.typeParameter) }); @@ -2049,7 +2051,7 @@ export class Converter { return this.convertChild(node.expression, parent); case SyntaxKind.TypeAliasDeclaration: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSTypeAliasDeclaration, id: this.convertChild(node.name), typeAnnotation: this.convertType(node.type) @@ -2071,7 +2073,7 @@ export class Converter { } case SyntaxKind.MethodSignature: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSMethodSignature, computed: isComputedProperty(node.name), key: this.convertChild(node.name), @@ -2112,7 +2114,7 @@ export class Converter { } case SyntaxKind.PropertySignature: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSPropertySignature, optional: isOptional(node) || undefined, computed: isComputedProperty(node.name), @@ -2135,7 +2137,7 @@ export class Converter { } case SyntaxKind.IndexSignature: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSIndexSignature, parameters: node.parameters.map(el => this.convertChild(el)) }); @@ -2183,10 +2185,10 @@ export class Converter { break; } const result = this.createNode< - | es.TSConstructSignatureDeclaration - | es.TSCallSignatureDeclaration - | es.TSFunctionType - | es.TSConstructorType + | TSESTree.TSConstructSignatureDeclaration + | TSESTree.TSCallSignatureDeclaration + | TSESTree.TSFunctionType + | TSESTree.TSConstructorType >(node, { type: type, params: this.convertParameters(node.parameters) @@ -2207,7 +2209,7 @@ export class Converter { case SyntaxKind.ExpressionWithTypeArguments: { const result = this.createNode< - es.TSInterfaceHeritage | es.TSClassImplements + TSESTree.TSInterfaceHeritage | TSESTree.TSClassImplements >(node, { type: parent && parent.kind === SyntaxKind.InterfaceDeclaration @@ -2226,9 +2228,9 @@ export class Converter { case SyntaxKind.InterfaceDeclaration: { const interfaceHeritageClauses = node.heritageClauses || []; - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSInterfaceDeclaration, - body: this.createNode(node, { + body: this.createNode(node, { type: AST_NODE_TYPES.TSInterfaceBody, body: node.members.map(member => this.convertChild(member)), range: [node.members.pos - 1, node.end] @@ -2286,7 +2288,7 @@ export class Converter { } case SyntaxKind.FirstTypeNode: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSTypePredicate, parameterName: this.convertChild(node.parameterName), typeAnnotation: this.convertTypeAnnotation(node.type, node) @@ -2301,7 +2303,7 @@ export class Converter { } case SyntaxKind.ImportType: - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSImportType, isTypeOf: !!node.isTypeOf, parameter: this.convertChild(node.argument), @@ -2312,7 +2314,7 @@ export class Converter { }); case SyntaxKind.EnumDeclaration: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSEnumDeclaration, id: this.convertChild(node.name), members: node.members.map(el => this.convertChild(el)) @@ -2332,7 +2334,7 @@ export class Converter { } case SyntaxKind.EnumMember: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSEnumMember, id: this.convertChild(node.name) }); @@ -2343,7 +2345,7 @@ export class Converter { } case SyntaxKind.ModuleDeclaration: { - const result = this.createNode(node, { + const result = this.createNode(node, { type: AST_NODE_TYPES.TSModuleDeclaration, id: this.convertChild(node.name) }); @@ -2361,69 +2363,69 @@ export class Converter { // TypeScript specific types case SyntaxKind.OptionalType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSOptionalType, typeAnnotation: this.convertType(node.type) }); } case SyntaxKind.ParenthesizedType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSParenthesizedType, typeAnnotation: this.convertType(node.type) }); } case SyntaxKind.TupleType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTupleType, elementTypes: node.elementTypes.map(el => this.convertType(el)) }); } case SyntaxKind.UnionType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSUnionType, types: node.types.map(el => this.convertType(el)) }); } case SyntaxKind.IntersectionType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSIntersectionType, types: node.types.map(el => this.convertType(el)) }); } case SyntaxKind.RestType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSRestType, typeAnnotation: this.convertType(node.type) }); } case SyntaxKind.AsExpression: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSAsExpression, expression: this.convertChild(node.expression), typeAnnotation: this.convertType(node.type) }); } case SyntaxKind.InferType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSInferType, typeParameter: this.convertType(node.typeParameter) }); } case SyntaxKind.LiteralType: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSLiteralType, literal: this.convertType(node.literal) }); } case SyntaxKind.TypeAssertionExpression: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSTypeAssertion, typeAnnotation: this.convertType(node.type), expression: this.convertChild(node.expression) }); } case SyntaxKind.ImportEqualsDeclaration: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSImportEqualsDeclaration, id: this.convertChild(node.name), moduleReference: this.convertChild(node.moduleReference), @@ -2431,13 +2433,13 @@ export class Converter { }); } case SyntaxKind.ExternalModuleReference: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSExternalModuleReference, expression: this.convertChild(node.expression) }); } case SyntaxKind.NamespaceExportDeclaration: { - return this.createNode(node, { + return this.createNode(node, { type: AST_NODE_TYPES.TSNamespaceExportDeclaration, id: this.convertChild(node.name) }); diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index aa5a10418c76..88503a23940c 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -6,7 +6,7 @@ */ import ts from 'typescript'; import unescape from 'lodash.unescape'; -import * as es from './typedefs'; +import * as TSESTree from './typedefs'; import { AST_NODE_TYPES } from './ast-node-types'; const SyntaxKind = ts.SyntaxKind; @@ -224,7 +224,7 @@ export function getBinaryExpressionType( export function getLineAndCharacterFor( pos: number, ast: ts.SourceFile -): es.LineAndColumnData { +): TSESTree.LineAndColumnData { const loc = ast.getLineAndCharacterOfPosition(pos); return { line: loc.line + 1, @@ -244,7 +244,7 @@ export function getLocFor( start: number, end: number, ast: ts.SourceFile -): es.SourceLocation { +): TSESTree.SourceLocation { return { start: getLineAndCharacterFor(start, ast), end: getLineAndCharacterFor(end, ast) @@ -455,11 +455,11 @@ export function isOptional(node: { * @param ast the AST * @returns the ESTreeNode with fixed exports */ -export function fixExports( +export function fixExports( node: ts.Node, result: T, ast: ts.SourceFile -): es.ExportDefaultDeclaration | es.ExportNamedDeclaration | T { +): TSESTree.ExportDefaultDeclaration | TSESTree.ExportNamedDeclaration | T { // check for exports if (node.modifiers && node.modifiers[0].kind === SyntaxKind.ExportKeyword) { const exportKeyword = node.modifiers[0]; @@ -501,7 +501,7 @@ export function fixExports( * @param token the ts.Token * @returns the token type */ -export function getTokenType(token: any): es.TokenType { +export function getTokenType(token: any): TSESTree.TokenType { // Need two checks for keywords since some are also identifiers if (token.originalKeywordKind) { switch (token.originalKeywordKind) { @@ -607,16 +607,19 @@ export function getTokenType(token: any): es.TokenType { * Extends and formats a given ts.Token, for a given AST * @param token the ts.Token * @param ast the AST object - * @returns the converted es.Token + * @returns the converted Token */ -export function convertToken(token: ts.Node, ast: ts.SourceFile): es.Token { +export function convertToken( + token: ts.Node, + ast: ts.SourceFile +): TSESTree.Token { const start = token.kind === SyntaxKind.JsxText ? token.getFullStart() : token.getStart(ast), end = token.getEnd(), value = ast.text.slice(start, end), - newToken: es.Token = { + newToken: TSESTree.Token = { type: getTokenType(token), value, range: [start, end], @@ -638,8 +641,8 @@ export function convertToken(token: ts.Node, ast: ts.SourceFile): es.Token { * @param ast the AST object * @returns the converted Tokens */ -export function convertTokens(ast: ts.SourceFile): es.Token[] { - const result: es.Token[] = []; +export function convertTokens(ast: ts.SourceFile): TSESTree.Token[] { + const result: TSESTree.Token[] = []; /** * @param node the ts.Node */ From 62b4c0a19cd52c0c10c46cb011c110c72addc89e Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 6 Feb 2019 03:23:19 +0100 Subject: [PATCH 12/13] refactor(*): add ts-estree file to improve feature refactoring --- packages/typescript-estree/src/convert-comments.ts | 2 +- packages/typescript-estree/src/convert.ts | 2 +- packages/typescript-estree/src/node-utils.ts | 2 +- packages/typescript-estree/src/parser.ts | 6 +++--- packages/typescript-estree/src/ts-estree.ts | 2 ++ 5 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 packages/typescript-estree/src/ts-estree.ts diff --git a/packages/typescript-estree/src/convert-comments.ts b/packages/typescript-estree/src/convert-comments.ts index 3abc08bc847c..1efff92648dc 100644 --- a/packages/typescript-estree/src/convert-comments.ts +++ b/packages/typescript-estree/src/convert-comments.ts @@ -7,7 +7,7 @@ import ts from 'typescript'; import { getLocFor, getNodeContainer } from './node-utils'; -import * as TSESTree from './typedefs'; +import { TSESTree } from './ts-estree'; /** * Converts a TypeScript comment to an Esprima comment. diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index 78e66b02ddad..4fbc5446b8f8 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -6,7 +6,7 @@ * MIT License */ import ts from 'typescript'; -import * as TSESTree from './typedefs'; +import { TSESTree } from './ts-estree'; import { canContainDirective, createError, diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index 88503a23940c..4ab71cf5e9a4 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -6,7 +6,7 @@ */ import ts from 'typescript'; import unescape from 'lodash.unescape'; -import * as TSESTree from './typedefs'; +import { TSESTree } from './ts-estree'; import { AST_NODE_TYPES } from './ast-node-types'; const SyntaxKind = ts.SyntaxKind; diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 40c3fc6bb504..5ca9da2c4b67 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -14,7 +14,7 @@ import ts from 'typescript'; import convert from './ast-converter'; import { convertError } from './convert'; import { firstDefined } from './node-utils'; -import * as TSESTree from './typedefs'; +import { TSESTree } from './ts-estree'; import { Extra, ParserOptions, ParserServices } from './parser-options'; import { getFirstSemanticOrSyntacticError } from './semantic-errors'; @@ -339,7 +339,7 @@ export function parse( export function parseAndGenerateServices< T extends ParserOptions = ParserOptions ->(code: string, options: T): ParseAndGenerateServicesResult { + >(code: string, options: T): ParseAndGenerateServicesResult { /** * Reset the parse configuration */ @@ -358,7 +358,7 @@ export function parseAndGenerateServices< applyParserOptionsToExtra(options); if ( typeof options.errorOnTypeScriptSyntacticAndSemanticIssues === - 'boolean' && + 'boolean' && options.errorOnTypeScriptSyntacticAndSemanticIssues ) { extra.errorOnTypeScriptSyntacticAndSemanticIssues = true; diff --git a/packages/typescript-estree/src/ts-estree.ts b/packages/typescript-estree/src/ts-estree.ts new file mode 100644 index 000000000000..846392c54430 --- /dev/null +++ b/packages/typescript-estree/src/ts-estree.ts @@ -0,0 +1,2 @@ +import * as TSESTree from './typedefs'; +export { TSESTree }; From bd5b9d72091d85db7b02029cba270f7a77223d4d Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 6 Feb 2019 03:28:06 +0100 Subject: [PATCH 13/13] refactor(*): fix formatting --- packages/typescript-estree/src/parser.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/typescript-estree/src/parser.ts b/packages/typescript-estree/src/parser.ts index 5ca9da2c4b67..bb77a186171a 100644 --- a/packages/typescript-estree/src/parser.ts +++ b/packages/typescript-estree/src/parser.ts @@ -339,7 +339,7 @@ export function parse( export function parseAndGenerateServices< T extends ParserOptions = ParserOptions - >(code: string, options: T): ParseAndGenerateServicesResult { +>(code: string, options: T): ParseAndGenerateServicesResult { /** * Reset the parse configuration */ @@ -358,7 +358,7 @@ export function parseAndGenerateServices< applyParserOptionsToExtra(options); if ( typeof options.errorOnTypeScriptSyntacticAndSemanticIssues === - 'boolean' && + 'boolean' && options.errorOnTypeScriptSyntacticAndSemanticIssues ) { extra.errorOnTypeScriptSyntacticAndSemanticIssues = true;