diff --git a/packages/ast-spec/src/base/ClassBase.ts b/packages/ast-spec/src/base/ClassBase.ts new file mode 100644 index 00000000000..4878cfc87b6 --- /dev/null +++ b/packages/ast-spec/src/base/ClassBase.ts @@ -0,0 +1,70 @@ +import type { Identifier } from '../expression/Identifier/spec'; +import type { ClassBody } from '../special/ClassBody/spec'; +import type { Decorator } from '../special/Decorator/spec'; +import type { TSClassImplements } from '../special/TSClassImplements/spec'; +import type { TSTypeParameterDeclaration } from '../special/TSTypeParameterDeclaration/spec'; +import type { TSTypeParameterInstantiation } from '../special/TSTypeParameterInstantiation/spec'; +import type { LeftHandSideExpression } from '../unions/LeftHandSideExpression'; +import type { BaseNode } from './BaseNode'; + +export interface ClassBase extends BaseNode { + /** + * Whether the class is an abstract class. + * ``` + * abstract class Foo {...} + * ``` + * This is always `undefined` for `ClassExpression`. + */ + // TODO(#5020) - make this `false` if it is not `abstract` + abstract?: boolean; + /** + * The class body. + */ + body: ClassBody; + /** + * Whether the class has been `declare`d: + * ``` + * declare class Foo {...} + * ``` + * This is always `undefined` for `ClassExpression`. + */ + // TODO(#5020) - make this `false` if it is not `declare`d + declare?: boolean; + /** + * The decorators declared for the class. + * This is `undefined` if there are no decorators. + * ``` + * @deco + * class Foo {...} + * ``` + * This is always `undefined` for `ClassExpression`. + */ + // TODO(#5020) - make this an empty array if there are none declared + decorators?: Decorator[]; + /** + * The class's name. + * - For a `ClassExpression` this may be `null` if the name is omitted. + * - For a `ClassDeclaration` this may be `null` if and only if the parent is + * an `ExportDefaultDeclaration`. + */ + id: Identifier | null; + /** + * The implemented interfaces for the class. + * This is `undefined` if there are no implemented interfaces. + */ + implements?: TSClassImplements[]; + /** + * The super class this class extends. + */ + superClass: LeftHandSideExpression | null; + /** + * The generic type parameters passed to the superClass. + * This is `undefined` if there are no generic type parameters passed. + */ + superTypeParameters?: TSTypeParameterInstantiation; + /** + * The generic type parameters declared for the class. + * This is `undefined` if there are no generic type parameters declared. + */ + typeParameters?: TSTypeParameterDeclaration; +} diff --git a/packages/ast-spec/src/base/ClassDeclarationBase.ts b/packages/ast-spec/src/base/ClassDeclarationBase.ts deleted file mode 100644 index f104b739b51..00000000000 --- a/packages/ast-spec/src/base/ClassDeclarationBase.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { Identifier } from '../expression/Identifier/spec'; -import type { ClassBody } from '../special/ClassBody/spec'; -import type { Decorator } from '../special/Decorator/spec'; -import type { TSClassImplements } from '../special/TSClassImplements/spec'; -import type { TSTypeParameterDeclaration } from '../special/TSTypeParameterDeclaration/spec'; -import type { TSTypeParameterInstantiation } from '../special/TSTypeParameterInstantiation/spec'; -import type { LeftHandSideExpression } from '../unions/LeftHandSideExpression'; -import type { BaseNode } from './BaseNode'; - -export interface ClassDeclarationBase extends BaseNode { - typeParameters?: TSTypeParameterDeclaration; - superTypeParameters?: TSTypeParameterInstantiation; - id: Identifier | null; - body: ClassBody; - superClass: LeftHandSideExpression | null; - implements?: TSClassImplements[]; - abstract?: boolean; - declare?: boolean; - decorators?: Decorator[]; -} diff --git a/packages/ast-spec/src/base/FunctionBase.ts b/packages/ast-spec/src/base/FunctionBase.ts new file mode 100644 index 00000000000..56446bc78ba --- /dev/null +++ b/packages/ast-spec/src/base/FunctionBase.ts @@ -0,0 +1,74 @@ +import type { Identifier } from '../expression/Identifier/spec'; +import type { TSTypeAnnotation } from '../special/TSTypeAnnotation/spec'; +import type { TSTypeParameterDeclaration } from '../special/TSTypeParameterDeclaration/spec'; +import type { BlockStatement } from '../statement/BlockStatement/spec'; +import type { Expression } from '../unions/Expression'; +import type { Parameter } from '../unions/Parameter'; +import type { BaseNode } from './BaseNode'; + +export interface FunctionBase extends BaseNode { + /** + * Whether the function is async: + * ``` + * async function foo(...) {...} + * const x = async function (...) {...} + * const x = async (...) => {...} + * ``` + */ + async: boolean; + /** + * The body of the function. + * - For an `ArrowFunctionExpression` this may be an `Expression` or `BlockStatement`. + * - For a `FunctionDeclaration` or `FunctionExpression` this is always a `BlockStatement. + * - For a `TSDeclareFunction` this is always `undefined`. + * - For a `TSEmptyBodyFunctionExpression` this is always `null`. + */ + body?: BlockStatement | Expression | null; + /** + * This is only `true` if and only if the node is a `TSDeclareFunction` and it has `declare`: + * ``` + * declare function foo(...) {...} + * ``` + */ + // TODO(#5020) - make this always `false` if it is not `declare`d instead of `undefined` + declare?: boolean; + /** + * This is only ever `true` if and only the node is an `ArrowFunctionExpression` and the body + * is an expression: + * ``` + * (() => 1) + * ``` + */ + expression: boolean; + /** + * Whether the function is a generator function: + * ``` + * function *foo(...) {...} + * const x = function *(...) {...} + * ``` + * This is always `false` for arrow functions as they cannot be generators. + */ + generator: boolean; + /** + * The function's name. + * - For an `ArrowFunctionExpression` this is always `null`. + * - For a `FunctionExpression` this may be `null` if the name is omitted. + * - For a `FunctionDeclaration` or `TSDeclareFunction` this may be `null` if + * and only if the parent is an `ExportDefaultDeclaration`. + */ + id: Identifier | null; + /** + * The list of parameters declared for the function. + */ + params: Parameter[]; + /** + * The return type annotation for the function. + * This is `undefined` if there is no return type declared. + */ + returnType?: TSTypeAnnotation; + /** + * The generic type parameter declaration for the function. + * This is `undefined` if there are no generic type parameters declared. + */ + typeParameters?: TSTypeParameterDeclaration; +} diff --git a/packages/ast-spec/src/base/FunctionDeclarationBase.ts b/packages/ast-spec/src/base/FunctionDeclarationBase.ts deleted file mode 100644 index 50b7aa97bf2..00000000000 --- a/packages/ast-spec/src/base/FunctionDeclarationBase.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type { Identifier } from '../expression/Identifier/spec'; -import type { TSTypeAnnotation } from '../special/TSTypeAnnotation/spec'; -import type { TSTypeParameterDeclaration } from '../special/TSTypeParameterDeclaration/spec'; -import type { BlockStatement } from '../statement/BlockStatement/spec'; -import type { Parameter } from '../unions/Parameter'; -import type { BaseNode } from './BaseNode'; - -export interface FunctionDeclarationBase extends BaseNode { - id: Identifier | null; - generator: boolean; - expression: boolean; - async: boolean; - params: Parameter[]; - body?: BlockStatement | null; - returnType?: TSTypeAnnotation; - typeParameters?: TSTypeParameterDeclaration; - declare?: boolean; -} diff --git a/packages/ast-spec/src/base/TSHeritageBase.ts b/packages/ast-spec/src/base/TSHeritageBase.ts index 5c20542e4f9..683600ec01d 100644 --- a/packages/ast-spec/src/base/TSHeritageBase.ts +++ b/packages/ast-spec/src/base/TSHeritageBase.ts @@ -3,7 +3,7 @@ import type { Expression } from '../unions/Expression'; import type { BaseNode } from './BaseNode'; export interface TSHeritageBase extends BaseNode { - // TODO(error handling) - this should be restricted to MemberExpression | Identifier + // TODO(#1852) - this should be restricted to MemberExpression | Identifier expression: Expression; typeParameters?: TSTypeParameterInstantiation; } diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-body/fixture.ts similarity index 100% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/fixture.ts rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-body/fixture.ts diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-body/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-body/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..c17328b32e8 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-body/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ missing-body TSESTree - Error 1`] = `[TSError: '{' expected.]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-body/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-body/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..4f8ef959d9b --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-body/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ missing-body Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:9)]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-body/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-body/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..18e4442401e --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-body/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ missing-body Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/fixture.ts new file mode 100644 index 00000000000..83ffb99a72b --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/fixture.ts @@ -0,0 +1 @@ +class C extends D<> {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..4f99d71eb95 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ missing-extends-type-param TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..f8435732131 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ missing-extends-type-param Babel - Error 1`] = `[SyntaxError: Type argument list cannot be empty. (1:17)]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..35683b84121 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ missing-extends-type-param Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/fixture.ts new file mode 100644 index 00000000000..4f3d75967f9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/fixture.ts @@ -0,0 +1 @@ +class C<> {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..9682f9c4373 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ missing-type-param TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..a14c3c54cac --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ missing-type-param Babel - Error 1`] = `[SyntaxError: Type parameter list cannot be empty. (1:7)]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..49567ea7a7b --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ missing-type-param Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/1-TSESTree-Error.shot deleted file mode 100644 index 30525843580..00000000000 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/1-TSESTree-Error.shot +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ClassDeclaration _error_ no-body TSESTree - Error 1`] = `[TSError: '{' expected.]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/2-Babel-Error.shot deleted file mode 100644 index e72c371e842..00000000000 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/2-Babel-Error.shot +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ClassDeclaration _error_ no-body Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:9)]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/3-Alignment-Error.shot deleted file mode 100644 index b6946023222..00000000000 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/no-body/snapshots/3-Alignment-Error.shot +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ClassDeclaration _error_ no-body Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/fixture.ts new file mode 100644 index 00000000000..383479818e6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/fixture.ts @@ -0,0 +1 @@ +class C<1> {} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..0be64ad3473 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ non-identifier-type-param TSESTree - Error 1`] = `[TSError: Type parameter declaration expected.]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..6ef9a4c481a --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ non-identifier-type-param Babel - Error 1`] = `[SyntaxError: Unexpected token (1:8)]`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..98c58289073 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration _error_ non-identifier-type-param Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/fixture.ts similarity index 100% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/fixture.ts rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/fixture.ts diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/1-TSESTree-AST.shot similarity index 95% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/1-TSESTree-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/1-TSESTree-AST.shot index ab7726fcd52..7f37d13c488 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/1-TSESTree-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorMany TSESTree - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration decorator-many TSESTree - AST 1`] = ` Program { type: "Program", body: Array [ diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/2-TSESTree-Tokens.shot similarity index 94% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/2-TSESTree-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/2-TSESTree-Tokens.shot index f406c812335..5f64c50c3bd 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/2-TSESTree-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorMany TSESTree - Tokens 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration decorator-many TSESTree - Tokens 1`] = ` Array [ Punctuator { type: "Punctuator", diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/3-Babel-AST.shot similarity index 95% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/3-Babel-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/3-Babel-AST.shot index 60af58e326d..3c94fd556d0 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/3-Babel-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorMany Babel - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration decorator-many Babel - AST 1`] = ` Program { type: "Program", body: Array [ diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/4-Babel-Tokens.shot similarity index 94% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/4-Babel-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/4-Babel-Tokens.shot index 888d2f213d3..e7d7dba3776 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/4-Babel-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorMany Babel - Tokens 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration decorator-many Babel - Tokens 1`] = ` Array [ Punctuator { type: "Punctuator", diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..751a6cc951f --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decorator-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..338a8838194 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration decorator-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/fixture.ts similarity index 100% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/fixture.ts rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/fixture.ts diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/1-TSESTree-AST.shot similarity index 93% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/1-TSESTree-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/1-TSESTree-AST.shot index f0550dcabbe..aba5fc9308d 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/1-TSESTree-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorOne TSESTree - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration decorator-one TSESTree - AST 1`] = ` Program { type: "Program", body: Array [ diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/2-TSESTree-Tokens.shot similarity index 92% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/2-TSESTree-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/2-TSESTree-Tokens.shot index 7354a4e9bfe..7d75dd27790 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/2-TSESTree-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorOne TSESTree - Tokens 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration decorator-one TSESTree - Tokens 1`] = ` Array [ Punctuator { type: "Punctuator", diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/3-Babel-AST.shot similarity index 94% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/3-Babel-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/3-Babel-AST.shot index f2e4581ba58..9f91cb39e80 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/3-Babel-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorOne Babel - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration decorator-one Babel - AST 1`] = ` Program { type: "Program", body: Array [ diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/4-Babel-Tokens.shot similarity index 92% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/4-Babel-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/4-Babel-Tokens.shot index eb1816cba73..3b6aa60b33d 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/4-Babel-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorOne Babel - Tokens 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration decorator-one Babel - Tokens 1`] = ` Array [ Punctuator { type: "Punctuator", diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/5-AST-Alignment-AST.shot similarity index 68% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/5-AST-Alignment-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/5-AST-Alignment-AST.shot index 97881c1404c..503bd4f5ad8 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/5-AST-Alignment-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorMany AST Alignment - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration decorator-one AST Alignment - AST 1`] = ` "Snapshot Diff: Compared values have no visual difference." `; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/6-AST-Alignment-Tokens.shot similarity index 68% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/6-AST-Alignment-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/6-AST-Alignment-Tokens.shot index e57e9fa7313..1ab8923d733 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorMany/snapshots/6-AST-Alignment-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decorator-one/snapshots/6-AST-Alignment-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorMany AST Alignment - Token 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration decorator-one AST Alignment - Token 1`] = ` "Snapshot Diff: Compared values have no visual difference." `; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/fixture.ts similarity index 100% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/fixture.ts rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/fixture.ts diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/1-TSESTree-AST.shot similarity index 97% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/1-TSESTree-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/1-TSESTree-AST.shot index da9fc3ba5ca..43fbb02d6c0 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/1-TSESTree-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters TSESTree - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration extends-type-param TSESTree - AST 1`] = ` Program { type: "Program", body: Array [ diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/2-TSESTree-Tokens.shot similarity index 97% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/2-TSESTree-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/2-TSESTree-Tokens.shot index 3eb2b515a24..c0ea9a80846 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/2-TSESTree-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters TSESTree - Tokens 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration extends-type-param TSESTree - Tokens 1`] = ` Array [ Keyword { type: "Keyword", diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/3-Babel-AST.shot similarity index 98% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/3-Babel-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/3-Babel-AST.shot index 8f9634b6629..2071afa4c8e 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/3-Babel-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters Babel - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration extends-type-param Babel - AST 1`] = ` Program { type: "Program", body: Array [ diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/4-Babel-Tokens.shot similarity index 98% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/4-Babel-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/4-Babel-Tokens.shot index db93259e13a..a19207090a5 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/4-Babel-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters Babel - Tokens 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration extends-type-param Babel - Tokens 1`] = ` Array [ Keyword { type: "Keyword", diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/5-AST-Alignment-AST.shot similarity index 81% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/5-AST-Alignment-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/5-AST-Alignment-AST.shot index 17f60ddc36a..d7a16a19520 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/5-AST-Alignment-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters AST Alignment - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration extends-type-param AST Alignment - AST 1`] = ` "Snapshot Diff: Compared values have no visual difference." `; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/6-AST-Alignment-Tokens.shot similarity index 80% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/6-AST-Alignment-Tokens.shot index 8c6277e35df..e231ba6210a 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/extends-type-param/snapshots/6-AST-Alignment-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration extends-type-parameters AST Alignment - Token 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration extends-type-param AST Alignment - Token 1`] = ` "Snapshot Diff: Compared values have no visual difference." `; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/fixture.ts similarity index 100% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/fixture.ts rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/fixture.ts diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/1-TSESTree-AST.shot similarity index 94% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/1-TSESTree-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/1-TSESTree-AST.shot index 09fb61990bf..13f2fe48ba0 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/1-TSESTree-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration type-parameters TSESTree - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration type-param TSESTree - AST 1`] = ` Program { type: "Program", body: Array [ diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/2-TSESTree-Tokens.shot similarity index 93% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/2-TSESTree-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/2-TSESTree-Tokens.shot index 7afa2b8839b..4b814b82829 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/2-TSESTree-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration type-parameters TSESTree - Tokens 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration type-param TSESTree - Tokens 1`] = ` Array [ Keyword { type: "Keyword", diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/3-Babel-AST.shot similarity index 94% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/3-Babel-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/3-Babel-AST.shot index de9ab22cc6b..288661b1311 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/3-Babel-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration type-parameters Babel - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration type-param Babel - AST 1`] = ` Program { type: "Program", body: Array [ diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/4-Babel-Tokens.shot similarity index 93% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/4-Babel-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/4-Babel-Tokens.shot index 89bca663a6d..27db70bb89e 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/4-Babel-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration type-parameters Babel - Tokens 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration type-param Babel - Tokens 1`] = ` Array [ Keyword { type: "Keyword", diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/5-AST-Alignment-AST.shot similarity index 95% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/5-AST-Alignment-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/5-AST-Alignment-AST.shot index 2dd40abc556..0ee9dbba035 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/5-AST-Alignment-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration type-parameters AST Alignment - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration type-param AST Alignment - AST 1`] = ` "Snapshot Diff: - TSESTree + Babel diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..581d856705d --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-param/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration type-param AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/fixture.ts similarity index 100% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/fixture.ts rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/fixture.ts diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/1-TSESTree-AST.shot similarity index 98% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/1-TSESTree-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/1-TSESTree-AST.shot index c3bf9660d6d..aac248040d8 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/1-TSESTree-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters TSESTree - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-param TSESTree - AST 1`] = ` Program { type: "Program", body: Array [ diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/2-TSESTree-Tokens.shot similarity index 97% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/2-TSESTree-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/2-TSESTree-Tokens.shot index f73a167dba3..f697768aad0 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/2-TSESTree-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters TSESTree - Tokens 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-param TSESTree - Tokens 1`] = ` Array [ Keyword { type: "Keyword", diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/3-Babel-AST.shot similarity index 98% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/3-Babel-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/3-Babel-AST.shot index 7c5a5149bbe..e5856d26fbc 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/3-Babel-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters Babel - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-param Babel - AST 1`] = ` Program { type: "Program", body: Array [ diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/4-Babel-Tokens.shot similarity index 97% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/4-Babel-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/4-Babel-Tokens.shot index 17ca652dc4a..97d16c68e18 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/4-Babel-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters Babel - Tokens 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-param Babel - Tokens 1`] = ` Array [ Keyword { type: "Keyword", diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/5-AST-Alignment-AST.shot similarity index 98% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/5-AST-Alignment-AST.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/5-AST-Alignment-AST.shot index 25dcb54dbeb..f6d5a3c73b3 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/5-AST-Alignment-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters AST Alignment - AST 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-param AST Alignment - AST 1`] = ` "Snapshot Diff: - TSESTree + Babel diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/6-AST-Alignment-Tokens.shot similarity index 76% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/6-AST-Alignment-Tokens.shot rename to packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/6-AST-Alignment-Tokens.shot index a99d685df3d..01862c4c751 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters/snapshots/6-AST-Alignment-Tokens.shot +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/snapshots/6-AST-Alignment-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration type-parameters AST Alignment - Token 1`] = ` +exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-param AST Alignment - Token 1`] = ` "Snapshot Diff: Compared values have no visual difference." `; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot deleted file mode 100644 index 4e5329e739f..00000000000 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/snapshots/6-AST-Alignment-Tokens.shot +++ /dev/null @@ -1,6 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ClassDeclaration type-parameters-extends-type-parameters AST Alignment - Token 1`] = ` -"Snapshot Diff: -Compared values have no visual difference." -`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/fixture.ts b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/fixture.ts new file mode 100644 index 00000000000..b790f0b57f6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/fixture.ts @@ -0,0 +1,3 @@ +class Foo { + prop; +} diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..bdbfa5822bb --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration with-member-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + PropertyDefinition { + type: "PropertyDefinition", + computed: false, + declare: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [14, 18], + loc: { + start: { column: 2, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, + override: false, + static: false, + value: null, + + range: [14, 19], + loc: { + start: { column: 2, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + ], + + range: [10, 21], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..1184bd1ae08 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration with-member-one TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [14, 18], + loc: { + start: { column: 2, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [18, 19], + loc: { + start: { column: 6, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [20, 21], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..df5b728f558 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration with-member-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ClassDeclaration { + type: "ClassDeclaration", + body: ClassBody { + type: "ClassBody", + body: Array [ + PropertyDefinition { + type: "PropertyDefinition", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [14, 18], + loc: { + start: { column: 2, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, + static: false, + value: null, + + range: [14, 19], + loc: { + start: { column: 2, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + ], + + range: [10, 21], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..3fe5916a116 --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration with-member-one Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "class", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [14, 18], + loc: { + start: { column: 2, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [18, 19], + loc: { + start: { column: 6, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [20, 21], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..121e647439e --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,75 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration with-member-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + ClassDeclaration { + type: 'ClassDeclaration', + body: ClassBody { + type: 'ClassBody', + body: Array [ + PropertyDefinition { + type: 'PropertyDefinition', + computed: false, +- declare: false, + key: Identifier { + type: 'Identifier', + name: 'prop', + + range: [14, 18], + loc: { + start: { column: 2, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, +- override: false, + static: false, + value: null, + + range: [14, 19], + loc: { + start: { column: 2, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + ], + + range: [10, 21], + loc: { + start: { column: 10, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'Foo', + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + superClass: null, + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..89d6bb8a18e --- /dev/null +++ b/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/with-member-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ClassDeclaration with-member-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/spec.ts b/packages/ast-spec/src/declaration/ClassDeclaration/spec.ts index 2154b8863a0..50112b70b5e 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ClassDeclaration/spec.ts @@ -1,6 +1,19 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; -import type { ClassDeclarationBase } from '../../base/ClassDeclarationBase'; +import type { ClassBase } from '../../base/ClassBase'; +import type { Identifier } from '../../expression/Identifier/spec'; -export interface ClassDeclaration extends ClassDeclarationBase { +interface ClassDeclarationBase extends ClassBase { type: AST_NODE_TYPES.ClassDeclaration; } + +export interface ClassDeclarationWithName extends ClassDeclarationBase { + id: Identifier; +} + +export interface ClassDeclarationWithOptionalName extends ClassDeclarationBase { + id: Identifier | null; +} + +export type ClassDeclaration = + | ClassDeclarationWithName + | ClassDeclarationWithOptionalName; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/fixture.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/fixture.ts new file mode 100644 index 00000000000..0a8ce4f553c --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/fixture.ts @@ -0,0 +1 @@ +export type * as x from 'a'; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..4e1ab2405d4 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,48 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration kind-type TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ExportAllDeclaration { + type: "ExportAllDeclaration", + assertions: Array [], + exported: Identifier { + type: "Identifier", + name: "x", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + exportKind: "type", + source: Literal { + type: "Literal", + raw: "'a'", + value: "a", + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..a28f9c4f903 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ kind-type TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..18b68176cbe --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ kind-type Babel - Error 1`] = `[SyntaxError: Unexpected token (1:12)]`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..f5bfa8f5615 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration kind-type TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [7, 11], + loc: { + start: { column: 7, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [14, 16], + loc: { + start: { column: 14, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [19, 23], + loc: { + start: { column: 19, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + String { + type: "String", + value: "'a'", + + range: [24, 27], + loc: { + start: { column: 24, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..f9e05e0f6ea --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/kind-type/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ kind-type Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/fixture.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/missing-source/fixture.ts similarity index 100% rename from packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/fixture.ts rename to packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/missing-source/fixture.ts diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/missing-source/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/missing-source/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..d3c411c7ec3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/missing-source/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ missing-source TSESTree - Error 1`] = `[TSError: Expression expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/missing-source/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/missing-source/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..b45b0c8fc85 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/missing-source/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ missing-source Babel - Error 1`] = `[SyntaxError: Unexpected token (1:13)]`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/missing-source/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/missing-source/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..89889f0ae31 --- /dev/null +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/missing-source/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ExportAllDeclaration _error_ missing-source Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/1-TSESTree-Error.shot deleted file mode 100644 index acdaf4c735f..00000000000 --- a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/1-TSESTree-Error.shot +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ExportAllDeclaration _error_ no-source TSESTree - Error 1`] = `[TSError: Expression expected.]`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/2-Babel-Error.shot deleted file mode 100644 index 8bd09ace8dc..00000000000 --- a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/2-Babel-Error.shot +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ExportAllDeclaration _error_ no-source Babel - Error 1`] = `[SyntaxError: Unexpected token (1:13)]`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/3-Alignment-Error.shot deleted file mode 100644 index c2ac962baac..00000000000 --- a/packages/ast-spec/src/declaration/ExportAllDeclaration/fixtures/_error_/no-source/snapshots/3-Alignment-Error.shot +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`AST Fixtures declaration ExportAllDeclaration _error_ no-source Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts index 5cf3301a50d..168f7b40b61 100644 --- a/packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ExportAllDeclaration/spec.ts @@ -7,8 +7,24 @@ import type { ExportKind } from '../ExportAndImportKind'; export interface ExportAllDeclaration extends BaseNode { type: AST_NODE_TYPES.ExportAllDeclaration; - source: StringLiteral | null; - exportKind: ExportKind; - exported: Identifier | null; + /** + * The assertions declared for the export. + * ``` + * export * from 'mod' assert { type: 'json' }; + * ``` + */ assertions: ImportAttribute[]; + /** + * The name for the exported items. `null` if no name is assigned. + */ + exported: Identifier | null; + /** + * The kind of the export. + */ + // TODO(#1852) - breaking change remove this because it is a semantic error to have it + exportKind: ExportKind; + /** + * The source module being exported from. + */ + source: StringLiteral; } diff --git a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts index 2cfe1cce5b3..51b1248854a 100644 --- a/packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ExportDefaultDeclaration/spec.ts @@ -1,15 +1,16 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; import type { BaseNode } from '../../base/BaseNode'; -import type { ExportDeclaration } from '../../unions/ExportDeclaration'; -import type { Expression } from '../../unions/Expression'; +import type { DefaultExportDeclarations } from '../../unions/ExportDeclaration'; import type { ExportKind } from '../ExportAndImportKind'; export interface ExportDefaultDeclaration extends BaseNode { type: AST_NODE_TYPES.ExportDefaultDeclaration; - declaration: - | // TODO(error handling) - the following are disallowed syntactically, but allowed by TS error recovery: - // TSEnumDeclaration, TSModuleDeclaration, TSTypeAliasDeclaration, VariableDeclaration - ExportDeclaration - | Expression; + /** + * The declaration being exported. + */ + declaration: DefaultExportDeclarations; + /** + * The kind of the export. + */ exportKind: ExportKind; } diff --git a/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts index 3e2989b7499..061c53f4b46 100644 --- a/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ExportNamedDeclaration/spec.ts @@ -3,15 +3,73 @@ import type { BaseNode } from '../../base/BaseNode'; import type { StringLiteral } from '../../expression/literal/StringLiteral/spec'; import type { ExportSpecifier } from '../../special/ExportSpecifier/spec'; import type { ImportAttribute } from '../../special/ImportAttribute/spec'; -import type { ExportDeclaration } from '../../unions/ExportDeclaration'; +import type { NamedExportDeclarations } from '../../unions/ExportDeclaration'; import type { ExportKind } from '../ExportAndImportKind'; -export interface ExportNamedDeclaration extends BaseNode { +interface ExportNamedDeclarationBase extends BaseNode { type: AST_NODE_TYPES.ExportNamedDeclaration; - // TODO(error handling) - ClassExpression is not valid here - declaration: ExportDeclaration | null; - specifiers: ExportSpecifier[]; - source: StringLiteral | null; + /** + * The assertions declared for the export. + * ``` + * export { foo } from 'mod' assert { type: 'json' }; + * ``` + * This will be an empty array if `source` is `null` + */ + assertions: ImportAttribute[]; + /** + * The exported declaration. + * ``` + * export const x = 1; + * ``` + * This will be `null` if `source` is not `null`, or if there are `specifiers` + */ + declaration: NamedExportDeclarations | null; + /** + * The kind of the export. + */ exportKind: ExportKind; + /** + * The source module being exported from. + */ + source: StringLiteral | null; + /** + * The specifiers being exported. + * ``` + * export { a, b }; + * ``` + * This will be an empty array if `declaration` is not `null` + */ + specifiers: ExportSpecifier[]; +} + +export interface ExportNamedDeclarationWithoutSourceWithMultiple + extends ExportNamedDeclarationBase { + // this will always be empty array assertions: ImportAttribute[]; + declaration: NamedExportDeclarations; + source: null; + specifiers: ExportSpecifier[]; } + +export interface ExportNamedDeclarationWithoutSourceWithSingle + extends ExportNamedDeclarationBase { + // this will always be empty array + assertions: ImportAttribute[]; + declaration: null; + source: null; + // this will always be empty array + specifiers: ExportSpecifier[]; +} + +export interface ExportNamedDeclarationWithSource + extends ExportNamedDeclarationBase { + assertions: ImportAttribute[]; + declaration: null; + source: StringLiteral; + specifiers: ExportSpecifier[]; +} + +export type ExportNamedDeclaration = + | ExportNamedDeclarationWithoutSourceWithMultiple + | ExportNamedDeclarationWithoutSourceWithSingle + | ExportNamedDeclarationWithSource; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/fixture.ts new file mode 100644 index 00000000000..6c532730c0b --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/fixture.ts @@ -0,0 +1 @@ +function () {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..e8630b3f99c --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ missing-id-and-not-exported TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..d0110ccac63 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ missing-id-and-not-exported Babel - Error 1`] = `[SyntaxError: Unexpected token (1:9)]`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..adae3f26337 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-id-and-not-exported/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ missing-id-and-not-exported Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/fixture.ts new file mode 100644 index 00000000000..0988137a7e7 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/fixture.ts @@ -0,0 +1 @@ +function foo<>() {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..2ffb9878bc9 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ missing-type-param TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..83a2a868f15 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ missing-type-param Babel - Error 1`] = `[SyntaxError: Type parameter list cannot be empty. (1:12)]`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..04a70d3af29 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ missing-type-param Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/fixture.ts new file mode 100644 index 00000000000..4e06a77dc7f --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/fixture.ts @@ -0,0 +1 @@ +function 1() {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..156bebb725c --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ non-identifier-name TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..d23f3eff955 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ non-identifier-name Babel - Error 1`] = `[SyntaxError: Unexpected token (1:9)]`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..f34f77cd1b8 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ non-identifier-name Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/fixture.ts new file mode 100644 index 00000000000..99644e47f36 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/fixture.ts @@ -0,0 +1 @@ +function foo<1>() {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..8c643863afb --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ non-identifier-type-param TSESTree - Error 1`] = `[TSError: Type parameter declaration expected.]`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..8be1b8d27a3 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ non-identifier-type-param Babel - Error 1`] = `[SyntaxError: Unexpected token (1:13)]`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..f2b863d8647 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration _error_ non-identifier-type-param Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/fixture.ts new file mode 100644 index 00000000000..f9df9686dd6 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/fixture.ts @@ -0,0 +1 @@ +async function foo() {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..7a7cd7ea28a --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration async TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: true, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + params: Array [], + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..3ca43d1e9fa --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration async TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "async", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [6, 14], + loc: { + start: { column: 6, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..c24f3da9207 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/3-Babel-AST.shot @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration async Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: true, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + params: Array [], + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..22c009c000f --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration async Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "async", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [6, 14], + loc: { + start: { column: 6, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..fe3cf227fba --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration async AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..b7e2ed7bd9a --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/async/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration async AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/fixture.ts new file mode 100644 index 00000000000..b0400ee9b26 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/fixture.ts @@ -0,0 +1 @@ +function foo() {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..e21b80de90e --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration empty TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [15, 17], + loc: { + start: { column: 15, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..d53355506df --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration empty TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..e339b4afda4 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration empty Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [15, 17], + loc: { + start: { column: 15, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..0b7e51f4235 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration empty Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..b08265806b5 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration empty AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..de6b3f7e116 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration empty AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/fixture.ts new file mode 100644 index 00000000000..f60d20a34b7 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/fixture.ts @@ -0,0 +1 @@ +function* foo() {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..7ad2d7a2dce --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration generator TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [16, 18], + loc: { + start: { column: 16, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + expression: false, + generator: true, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [10, 13], + loc: { + start: { column: 10, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + params: Array [], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..d6d22923684 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration generator TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [10, 13], + loc: { + start: { column: 10, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..46d3edd3250 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/3-Babel-AST.shot @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration generator Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [16, 18], + loc: { + start: { column: 16, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + expression: false, + generator: true, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [10, 13], + loc: { + start: { column: 10, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + params: Array [], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..3fb7fa84513 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration generator Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [10, 13], + loc: { + start: { column: 10, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/5-AST-Alignment-AST.shot similarity index 67% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/5-AST-Alignment-AST.shot rename to packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/5-AST-Alignment-AST.shot index 19b8f62ee26..e94e87d038a 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/5-AST-Alignment-AST.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorOne AST Alignment - AST 1`] = ` +exports[`AST Fixtures declaration FunctionDeclaration generator AST Alignment - AST 1`] = ` "Snapshot Diff: Compared values have no visual difference." `; diff --git a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/6-AST-Alignment-Tokens.shot similarity index 68% rename from packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/6-AST-Alignment-Tokens.shot rename to packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/6-AST-Alignment-Tokens.shot index 915fd1d51f9..033a7496b3c 100644 --- a/packages/ast-spec/src/declaration/ClassDeclaration/fixtures/decoratorOne/snapshots/6-AST-Alignment-Tokens.shot +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/generator/snapshots/6-AST-Alignment-Tokens.shot @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AST Fixtures declaration ClassDeclaration decoratorOne AST Alignment - Token 1`] = ` +exports[`AST Fixtures declaration FunctionDeclaration generator AST Alignment - Token 1`] = ` "Snapshot Diff: Compared values have no visual difference." `; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/fixture.ts new file mode 100644 index 00000000000..8dca93172ea --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/fixture.ts @@ -0,0 +1 @@ +function foo(a, b, c) {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..9a6db3d1c4c --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [22, 24], + loc: { + start: { column: 22, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [ + Identifier { + type: "Identifier", + name: "a", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + name: "b", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + name: "c", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..08de97f6423 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-many TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "c", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..c04ed824284 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,80 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [22, 24], + loc: { + start: { column: 22, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [ + Identifier { + type: "Identifier", + name: "a", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + name: "b", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + name: "c", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..a0aa4487994 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-many Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "c", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..f8b80c46b1e --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..70640eb186a --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/fixture.ts new file mode 100644 index 00000000000..ef1dd099d3f --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/fixture.ts @@ -0,0 +1 @@ +function foo(a) {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..99d9cdc9e98 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,60 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [16, 18], + loc: { + start: { column: 16, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [ + Identifier { + type: "Identifier", + name: "a", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..81f8b5dc751 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-one TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..6e503e760fb --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,60 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [16, 18], + loc: { + start: { column: 16, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [ + Identifier { + type: "Identifier", + name: "a", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..802761abb0e --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-one Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..5c75a74de72 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..f6f408e32c2 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/param-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration param-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/fixture.ts new file mode 100644 index 00000000000..4fa04cdbc0b --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/fixture.ts @@ -0,0 +1 @@ +function foo(): void {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..d9d3eccf8d7 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration returnType TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + returnType: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSVoidKeyword { + type: "TSVoidKeyword", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [14, 20], + loc: { + start: { column: 14, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..d3930ccf8dc --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration returnType TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "void", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..8f9c235c429 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/3-Babel-AST.shot @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration returnType Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + returnType: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSVoidKeyword { + type: "TSVoidKeyword", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [14, 20], + loc: { + start: { column: 14, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..0c94d7108ae --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration returnType Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "void", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..d0df21058e9 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration returnType AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..0a4b02ae424 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/returnType/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration returnType AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/fixture.ts new file mode 100644 index 00000000000..36ddc225d14 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/fixture.ts @@ -0,0 +1 @@ +function foo() {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..24eae0d3290 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,123 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [24, 26], + loc: { + start: { column: 24, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + out: false, + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "U", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + out: false, + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "V", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + out: false, + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + + range: [12, 21], + loc: { + start: { column: 12, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..99504b18340 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-many TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "U", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "V", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..690e6d4036b --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [24, 26], + loc: { + start: { column: 24, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + name: "U", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + name: "V", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + + range: [12, 21], + loc: { + start: { column: 12, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..b7e57a6f404 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-many Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "U", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "V", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..98ace90820f --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,130 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + FunctionDeclaration { + type: 'FunctionDeclaration', + async: false, + body: BlockStatement { + type: 'BlockStatement', + body: Array [], + + range: [24, 26], + loc: { + start: { column: 24, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: 'Identifier', + name: 'foo', + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: 'TSTypeParameterDeclaration', + params: Array [ + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'T', +- +- range: [13, 14], +- loc: { +- start: { column: 13, line: 1 }, +- end: { column: 14, line: 1 }, +- }, +- }, +- out: false, ++ name: 'T', + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'U', +- +- range: [16, 17], +- loc: { +- start: { column: 16, line: 1 }, +- end: { column: 17, line: 1 }, +- }, +- }, +- out: false, ++ name: 'U', + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'V', +- +- range: [19, 20], +- loc: { +- start: { column: 19, line: 1 }, +- end: { column: 20, line: 1 }, +- }, +- }, +- out: false, ++ name: 'V', + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + + range: [12, 21], + loc: { + start: { column: 12, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..af00d0fb852 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/fixture.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/fixture.ts new file mode 100644 index 00000000000..7994e752aa8 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/fixture.ts @@ -0,0 +1 @@ +function foo() {} diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..b2caab0f05b --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,81 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [18, 20], + loc: { + start: { column: 18, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + out: false, + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..9227520d153 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-one TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..5083d4d25cb --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,70 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + FunctionDeclaration { + type: "FunctionDeclaration", + async: false, + body: BlockStatement { + type: "BlockStatement", + body: Array [], + + range: [18, 20], + loc: { + start: { column: 18, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..72cd1481fd3 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-one Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..b997a40aca3 --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + FunctionDeclaration { + type: 'FunctionDeclaration', + async: false, + body: BlockStatement { + type: 'BlockStatement', + body: Array [], + + range: [18, 20], + loc: { + start: { column: 18, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + expression: false, + generator: false, + id: Identifier { + type: 'Identifier', + name: 'foo', + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: 'TSTypeParameterDeclaration', + params: Array [ + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'T', +- +- range: [13, 14], +- loc: { +- start: { column: 13, line: 1 }, +- end: { column: 14, line: 1 }, +- }, +- }, +- out: false, ++ name: 'T', + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + + range: [12, 15], + loc: { + start: { column: 12, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..bf84a177ecc --- /dev/null +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration FunctionDeclaration type-param-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/FunctionDeclaration/spec.ts b/packages/ast-spec/src/declaration/FunctionDeclaration/spec.ts index 59d7c4ffe39..4fe3d2dc693 100644 --- a/packages/ast-spec/src/declaration/FunctionDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/FunctionDeclaration/spec.ts @@ -1,8 +1,25 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; -import type { FunctionDeclarationBase } from '../../base/FunctionDeclarationBase'; +import type { FunctionBase } from '../../base/FunctionBase'; +import type { Identifier } from '../../expression/Identifier/spec'; import type { BlockStatement } from '../../statement/BlockStatement/spec'; -export interface FunctionDeclaration extends FunctionDeclarationBase { +interface FunctionDeclarationBase extends FunctionBase { type: AST_NODE_TYPES.FunctionDeclaration; body: BlockStatement; + // TODO(#5020) - make this always `false` if it is not `declare`d instead of `undefined` + declare?: false; + expression: false; } + +export interface FunctionDeclarationWithName extends FunctionDeclarationBase { + id: Identifier; +} + +export interface FunctionDeclarationWithOptionalName + extends FunctionDeclarationBase { + id: Identifier | null; +} + +export type FunctionDeclaration = + | FunctionDeclarationWithName + | FunctionDeclarationWithOptionalName; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/fixture.ts new file mode 100644 index 00000000000..965d8a69653 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/fixture.ts @@ -0,0 +1 @@ +import 1 from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..233c225dd50 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ default-non-identifier TSESTree - Error 1`] = `[TSError: Declaration or statement expected.]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..438c9cdf750 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ default-non-identifier Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:7)]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..2e0bcbec5a5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/default-non-identifier/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ default-non-identifier Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/fixture.ts new file mode 100644 index 00000000000..f3cb6e658e2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/fixture.ts @@ -0,0 +1 @@ +import { b }, * as a from 'a'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..d94d399517f --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ named-and-namespace TSESTree - Error 1`] = `[TSError: 'from' expected.]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..9cf4c4b719a --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ named-and-namespace Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "from" (1:12)]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..89fae3fa27c --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-and-namespace/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ named-and-namespace Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/fixture.ts new file mode 100644 index 00000000000..6a7fb92600d --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/fixture.ts @@ -0,0 +1 @@ +import { 1 } from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..2ca1651099b --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ named-non-identifier TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..970528e3253 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ named-non-identifier Babel - Error 1`] = `[SyntaxError: Unexpected token (1:9)]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..fefbeef9c52 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/named-non-identifier/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ named-non-identifier Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/fixture.ts new file mode 100644 index 00000000000..9f7ee22b7dd --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/fixture.ts @@ -0,0 +1 @@ +import * as b, a from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..9d2be22fe16 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-and-default TSESTree - Error 1`] = `[TSError: 'from' expected.]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..294d069aacc --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-and-default Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "from" (1:13)]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..6e491db0e63 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-default/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-and-default Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/fixture.ts new file mode 100644 index 00000000000..52bcac2fdbf --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/fixture.ts @@ -0,0 +1 @@ +import * as a, { b } from 'a'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..a2271606e4b --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-and-named TSESTree - Error 1`] = `[TSError: 'from' expected.]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..605940a8433 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-and-named Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "from" (1:13)]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..f1e891dbeca --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-named/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-and-named Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/fixture.ts new file mode 100644 index 00000000000..6d678fc5983 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/fixture.ts @@ -0,0 +1 @@ +import * as a, * as b from 'a'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..0a5d4ab3922 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-and-namespace TSESTree - Error 1`] = `[TSError: 'from' expected.]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..8efbfcaf519 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-and-namespace Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "from" (1:13)]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..e3c8c7a6288 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-and-namespace/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-and-namespace Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/fixture.ts new file mode 100644 index 00000000000..539e09df8d0 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/fixture.ts @@ -0,0 +1 @@ +import * as 1 from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..fa9ec459a92 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-non-identifier TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..a511cc6c94d --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-non-identifier Babel - Error 1`] = `[SyntaxError: Unexpected token (1:12)]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..f0d97ae32bc --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/namespace-non-identifier/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ namespace-non-identifier Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/fixture.ts new file mode 100644 index 00000000000..a4a63604c81 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/fixture.ts @@ -0,0 +1 @@ +import * as x from module; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..4cfff84fd98 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ non-string-source TSESTree - Error 1`] = `[TSError: Module specifier must be a string literal.]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..49abb836662 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ non-string-source Babel - Error 1`] = `[SyntaxError: Unexpected token (1:19)]`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..0d5964ffc24 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/_error_/non-string-source/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration _error_ non-string-source Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/fixture.ts new file mode 100644 index 00000000000..3bd366a8d05 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/fixture.ts @@ -0,0 +1 @@ +import * as a from 'mod' assert { type: 'json' }; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..877884e2c9a --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration assertion TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [ + ImportAttribute { + type: "ImportAttribute", + key: Identifier { + type: "Identifier", + name: "type", + + range: [34, 38], + loc: { + start: { column: 34, line: 1 }, + end: { column: 38, line: 1 }, + }, + }, + value: Literal { + type: "Literal", + raw: "'json'", + value: "json", + + range: [40, 46], + loc: { + start: { column: 40, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + + range: [34, 46], + loc: { + start: { column: 34, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + ], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [19, 24], + loc: { + start: { column: 19, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + specifiers: Array [ + ImportNamespaceSpecifier { + type: "ImportNamespaceSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [7, 13], + loc: { + start: { column: 7, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 50], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..3b0706c7d31 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration assertion TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [9, 11], + loc: { + start: { column: 9, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [14, 18], + loc: { + start: { column: 14, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [19, 24], + loc: { + start: { column: 19, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "assert", + + range: [25, 31], + loc: { + start: { column: 25, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [32, 33], + loc: { + start: { column: 32, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [34, 38], + loc: { + start: { column: 34, line: 1 }, + end: { column: 38, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [38, 39], + loc: { + start: { column: 38, line: 1 }, + end: { column: 39, line: 1 }, + }, + }, + String { + type: "String", + value: "'json'", + + range: [40, 46], + loc: { + start: { column: 40, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [48, 49], + loc: { + start: { column: 48, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..54c2381228b --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/3-Babel-AST.shot @@ -0,0 +1,90 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration assertion Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [ + ImportAttribute { + type: "ImportAttribute", + key: Identifier { + type: "Identifier", + name: "type", + + range: [34, 38], + loc: { + start: { column: 34, line: 1 }, + end: { column: 38, line: 1 }, + }, + }, + value: Literal { + type: "Literal", + raw: "'json'", + value: "json", + + range: [40, 46], + loc: { + start: { column: 40, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + + range: [34, 46], + loc: { + start: { column: 34, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + ], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [19, 24], + loc: { + start: { column: 19, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + specifiers: Array [ + ImportNamespaceSpecifier { + type: "ImportNamespaceSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [7, 13], + loc: { + start: { column: 7, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + + range: [0, 49], + loc: { + start: { column: 0, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 50], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..30c2bd49245 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration assertion Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [9, 11], + loc: { + start: { column: 9, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [14, 18], + loc: { + start: { column: 14, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [19, 24], + loc: { + start: { column: 19, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "assert", + + range: [25, 31], + loc: { + start: { column: 25, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [32, 33], + loc: { + start: { column: 32, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [34, 38], + loc: { + start: { column: 34, line: 1 }, + end: { column: 38, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [38, 39], + loc: { + start: { column: 38, line: 1 }, + end: { column: 39, line: 1 }, + }, + }, + String { + type: "String", + value: "'json'", + + range: [40, 46], + loc: { + start: { column: 40, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [47, 48], + loc: { + start: { column: 47, line: 1 }, + end: { column: 48, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [48, 49], + loc: { + start: { column: 48, line: 1 }, + end: { column: 49, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..c7b85e439da --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration assertion AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..3189b2704ef --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/assertion/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration assertion AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/fixture.ts new file mode 100644 index 00000000000..ac5f18056a3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/fixture.ts @@ -0,0 +1 @@ +import a, { b, c, d } from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..3b5e6f5d956 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,149 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [27, 32], + loc: { + start: { column: 27, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + specifiers: Array [ + ImportDefaultSpecifier { + type: "ImportDefaultSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "d", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "d", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..1d4c57f89eb --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-many TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "d", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [22, 26], + loc: { + start: { column: 22, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [27, 32], + loc: { + start: { column: 27, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [32, 33], + loc: { + start: { column: 32, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..d1207f8c6cc --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,149 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [27, 32], + loc: { + start: { column: 27, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + specifiers: Array [ + ImportDefaultSpecifier { + type: "ImportDefaultSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "d", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "d", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 34], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..3cfb21679c8 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-many Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "d", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [22, 26], + loc: { + start: { column: 22, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [27, 32], + loc: { + start: { column: 27, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [32, 33], + loc: { + start: { column: 32, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..5a7d0eb9f83 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..00895e19374 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/fixture.ts new file mode 100644 index 00000000000..d808a750ce8 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/fixture.ts @@ -0,0 +1,2 @@ +// prettier-ignore +import a, {} from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..0e94a0b6bb9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-none TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [37, 42], + loc: { + start: { column: 18, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + specifiers: Array [ + ImportDefaultSpecifier { + type: "ImportDefaultSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [26, 27], + loc: { + start: { column: 7, line: 2 }, + end: { column: 8, line: 2 }, + }, + }, + + range: [26, 27], + loc: { + start: { column: 7, line: 2 }, + end: { column: 8, line: 2 }, + }, + }, + ], + + range: [19, 43], + loc: { + start: { column: 0, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + ], + sourceType: "module", + + range: [19, 44], + loc: { + start: { column: 0, line: 2 }, + end: { column: 0, line: 3 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..99bb6d113e5 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-none TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [19, 25], + loc: { + start: { column: 0, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [26, 27], + loc: { + start: { column: 7, line: 2 }, + end: { column: 8, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [27, 28], + loc: { + start: { column: 8, line: 2 }, + end: { column: 9, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [29, 30], + loc: { + start: { column: 10, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [30, 31], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [32, 36], + loc: { + start: { column: 13, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [37, 42], + loc: { + start: { column: 18, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [42, 43], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..ee34379e43e --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/3-Babel-AST.shot @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-none Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [37, 42], + loc: { + start: { column: 18, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + specifiers: Array [ + ImportDefaultSpecifier { + type: "ImportDefaultSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [26, 27], + loc: { + start: { column: 7, line: 2 }, + end: { column: 8, line: 2 }, + }, + }, + + range: [26, 27], + loc: { + start: { column: 7, line: 2 }, + end: { column: 8, line: 2 }, + }, + }, + ], + + range: [19, 43], + loc: { + start: { column: 0, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, + ], + sourceType: "module", + + range: [19, 44], + loc: { + start: { column: 0, line: 2 }, + end: { column: 0, line: 3 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..56ab10c4f1c --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-none Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [19, 25], + loc: { + start: { column: 0, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [26, 27], + loc: { + start: { column: 7, line: 2 }, + end: { column: 8, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [27, 28], + loc: { + start: { column: 8, line: 2 }, + end: { column: 9, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [29, 30], + loc: { + start: { column: 10, line: 2 }, + end: { column: 11, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [30, 31], + loc: { + start: { column: 11, line: 2 }, + end: { column: 12, line: 2 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [32, 36], + loc: { + start: { column: 13, line: 2 }, + end: { column: 17, line: 2 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [37, 42], + loc: { + start: { column: 18, line: 2 }, + end: { column: 23, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [42, 43], + loc: { + start: { column: 23, line: 2 }, + end: { column: 24, line: 2 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..77b9d9ec72b --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-none AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..db5dec353c2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-none/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-none AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/fixture.ts new file mode 100644 index 00000000000..5e938031ed6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/fixture.ts @@ -0,0 +1 @@ +import a, { b } from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..362d429e027 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,89 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [21, 26], + loc: { + start: { column: 21, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + specifiers: Array [ + ImportDefaultSpecifier { + type: "ImportDefaultSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..99806f28e2f --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-one TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [21, 26], + loc: { + start: { column: 21, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..45b6d3ec61e --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,89 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [21, 26], + loc: { + start: { column: 21, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + specifiers: Array [ + ImportDefaultSpecifier { + type: "ImportDefaultSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..e11fa0be693 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-one Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [21, 26], + loc: { + start: { column: 21, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..8661b6d43b2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..8f0c817495a --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-named-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-named-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/fixture.ts new file mode 100644 index 00000000000..e18354616a7 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/fixture.ts @@ -0,0 +1 @@ +import a, * as b from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..88c4eac8c15 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,78 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-namespace TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [22, 27], + loc: { + start: { column: 22, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + specifiers: Array [ + ImportDefaultSpecifier { + type: "ImportDefaultSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + ImportNamespaceSpecifier { + type: "ImportNamespaceSpecifier", + local: Identifier { + type: "Identifier", + name: "b", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [10, 16], + loc: { + start: { column: 10, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + ], + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..f78a2e96178 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-namespace TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [12, 14], + loc: { + start: { column: 12, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [17, 21], + loc: { + start: { column: 17, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [22, 27], + loc: { + start: { column: 22, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..25d8c6db0a3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/3-Babel-AST.shot @@ -0,0 +1,78 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-namespace Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [22, 27], + loc: { + start: { column: 22, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + specifiers: Array [ + ImportDefaultSpecifier { + type: "ImportDefaultSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + ImportNamespaceSpecifier { + type: "ImportNamespaceSpecifier", + local: Identifier { + type: "Identifier", + name: "b", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [10, 16], + loc: { + start: { column: 10, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + ], + + range: [0, 28], + loc: { + start: { column: 0, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..b6bc0f06e1d --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-namespace Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [12, 14], + loc: { + start: { column: 12, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [17, 21], + loc: { + start: { column: 17, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [22, 27], + loc: { + start: { column: 22, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..c975ae69118 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-namespace AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..2ea3772b5fc --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default-and-namespace/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default-and-namespace AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/fixture.ts new file mode 100644 index 00000000000..b4fa44ea435 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/fixture.ts @@ -0,0 +1 @@ +import a from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..8575ecc99e2 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [14, 19], + loc: { + start: { column: 14, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + specifiers: Array [ + ImportDefaultSpecifier { + type: "ImportDefaultSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + ], + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..b2ac2cf753d --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [9, 13], + loc: { + start: { column: 9, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [14, 19], + loc: { + start: { column: 14, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..bfb44b15fa6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/3-Babel-AST.shot @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [14, 19], + loc: { + start: { column: 14, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + specifiers: Array [ + ImportDefaultSpecifier { + type: "ImportDefaultSpecifier", + local: Identifier { + type: "Identifier", + name: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + ], + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..e5c09dd423e --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [9, 13], + loc: { + start: { column: 9, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [14, 19], + loc: { + start: { column: 14, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..2524045a807 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..75669766d63 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/default/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration default AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/fixture.ts new file mode 100644 index 00000000000..4c8852af562 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/fixture.ts @@ -0,0 +1 @@ +import { a, b, c } from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..a90f8ca955a --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,130 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [24, 29], + loc: { + start: { column: 24, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + specifiers: Array [ + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + ], + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..8eba9974a71 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-many TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [19, 23], + loc: { + start: { column: 19, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [24, 29], + loc: { + start: { column: 24, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..89d89d705a6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,130 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [24, 29], + loc: { + start: { column: 24, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + specifiers: Array [ + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + ], + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..123471f1513 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-many Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "c", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [19, 23], + loc: { + start: { column: 19, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [24, 29], + loc: { + start: { column: 24, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..3f4b4b678e7 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..254949c9452 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/fixture.ts new file mode 100644 index 00000000000..421d8a81af3 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/fixture.ts @@ -0,0 +1 @@ +import {} from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..12f54a5140e --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-none TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [15, 20], + loc: { + start: { column: 15, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + specifiers: Array [], + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..04c72987e07 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-none TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [10, 14], + loc: { + start: { column: 10, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [15, 20], + loc: { + start: { column: 15, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..cf425c46b79 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/3-Babel-AST.shot @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-none Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [15, 20], + loc: { + start: { column: 15, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + specifiers: Array [], + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..ec45fb03592 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-none Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [10, 14], + loc: { + start: { column: 10, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [15, 20], + loc: { + start: { column: 15, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..aa52a0d98d1 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-none AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..4f0ab4858e6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-none/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-none AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/fixture.ts new file mode 100644 index 00000000000..7f1f6a4aa22 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/fixture.ts @@ -0,0 +1 @@ +import { a } from 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..9030519529e --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,70 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [18, 23], + loc: { + start: { column: 18, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + specifiers: Array [ + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..b437ec118b9 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-one TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [13, 17], + loc: { + start: { column: 13, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [18, 23], + loc: { + start: { column: 18, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..6bc6fe7a38b --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,70 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [18, 23], + loc: { + start: { column: 18, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + specifiers: Array [ + ImportSpecifier { + type: "ImportSpecifier", + imported: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + importKind: "value", + local: Identifier { + type: "Identifier", + name: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..fddf4bb21ef --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-one Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "from", + + range: [13, 17], + loc: { + start: { column: 13, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [18, 23], + loc: { + start: { column: 18, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..a502907e8f6 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..f1aacd2d411 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/named-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration named-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/fixture.ts b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/fixture.ts new file mode 100644 index 00000000000..381cd70b72f --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/fixture.ts @@ -0,0 +1 @@ +import 'mod'; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..62da72509bd --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration side-effect TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [7, 12], + loc: { + start: { column: 7, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + specifiers: Array [], + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..dd471c34db4 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration side-effect TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [7, 12], + loc: { + start: { column: 7, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..ab134ebecf8 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/3-Babel-AST.shot @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration side-effect Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + ImportDeclaration { + type: "ImportDeclaration", + assertions: Array [], + importKind: "value", + source: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [7, 12], + loc: { + start: { column: 7, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + specifiers: Array [], + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..d8e354e5b03 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration side-effect Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [7, 12], + loc: { + start: { column: 7, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..2fa96b2dc1c --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration side-effect AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..1d074a39903 --- /dev/null +++ b/packages/ast-spec/src/declaration/ImportDeclaration/fixtures/side-effect/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration ImportDeclaration side-effect AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/ImportDeclaration/spec.ts b/packages/ast-spec/src/declaration/ImportDeclaration/spec.ts index b9689fe2c09..389af77f87a 100644 --- a/packages/ast-spec/src/declaration/ImportDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/ImportDeclaration/spec.ts @@ -7,8 +7,31 @@ import type { ImportKind } from '../ExportAndImportKind'; export interface ImportDeclaration extends BaseNode { type: AST_NODE_TYPES.ImportDeclaration; + /** + * The assertions declared for the export. + * ``` + * import * from 'mod' assert { type: 'json' }; + * ``` + */ + assertions: ImportAttribute[]; + /** + * The kind of the import. + */ + importKind: ImportKind; + /** + * The source module being imported from. + */ source: StringLiteral; + /** + * The specifiers being imported. + * If this is an empty array then either there are no specifiers: + * ``` + * import {} from 'mod'; + * ``` + * Or it is a side-effect import: + * ``` + * import 'mod'; + * ``` + */ specifiers: ImportClause[]; - importKind: ImportKind; - assertions: ImportAttribute[]; } diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/fixture.ts new file mode 100644 index 00000000000..204adf1135a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/fixture.ts @@ -0,0 +1 @@ +declare async function foo(); diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..d01382249a1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction async TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: true, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [23, 26], + loc: { + start: { column: 23, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + params: Array [], + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..79f1c74928b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ async TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..01db37879fb --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ async Babel - Error 1`] = `[SyntaxError: Missing semicolon. (1:7)]`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..57b56f38b08 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction async TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "async", + + range: [8, 13], + loc: { + start: { column: 8, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [14, 22], + loc: { + start: { column: 14, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [23, 26], + loc: { + start: { column: 23, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..1f36cb0955f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/async/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ async Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/fixture.ts new file mode 100644 index 00000000000..d99be022e46 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/fixture.ts @@ -0,0 +1 @@ +declare function foo(): void {}; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..ca0dba2a0c3 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ declare-with-body TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..e56bbb59892 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ declare-with-body Babel - Error 1`] = `[SyntaxError: An implementation cannot be declared in ambient contexts. (1:0)]`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..22b125b5643 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ declare-with-body Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/fixture.ts new file mode 100644 index 00000000000..9b557f21605 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/fixture.ts @@ -0,0 +1 @@ +declare function (); diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..53a142d37be --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ missing-id-and-not-exported TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..bb9716addfb --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ missing-id-and-not-exported Babel - Error 1`] = `[SyntaxError: Unexpected token (1:17)]`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..7bd554c552a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-id-and-not-exported/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ missing-id-and-not-exported Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/fixture.ts new file mode 100644 index 00000000000..a209e2670b2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/fixture.ts @@ -0,0 +1 @@ +declare function foo<>(): void; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..217a78df58b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ missing-type-param TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..be819649c55 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ missing-type-param Babel - Error 1`] = `[SyntaxError: Type parameter list cannot be empty. (1:20)]`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..83fabb4dfc7 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ missing-type-param Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/fixture.ts new file mode 100644 index 00000000000..15adf45390c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/fixture.ts @@ -0,0 +1 @@ +declare function 1(); diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..86f0f5e5e10 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ non-identifier-name TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..12fadb8985a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ non-identifier-name Babel - Error 1`] = `[SyntaxError: Unexpected token (1:17)]`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..0587657ad4e --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ non-identifier-name Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/fixture.ts new file mode 100644 index 00000000000..0143e128d1f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/fixture.ts @@ -0,0 +1 @@ +declare function f<1>(): void; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..4b033027f13 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ non-identifier-type-param TSESTree - Error 1`] = `[TSError: Type parameter declaration expected.]`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..82c36588558 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ non-identifier-type-param Babel - Error 1`] = `[SyntaxError: Unexpected token (1:19)]`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..0d57d7e26a4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction _error_ non-identifier-type-param Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/fixture.ts new file mode 100644 index 00000000000..a55ca703c8e --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/fixture.ts @@ -0,0 +1 @@ +declare function foo(); diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..59ea1f2fa4c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction empty TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [], + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..68ee13556c4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction empty TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..43be5f098ab --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/3-Babel-AST.shot @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction empty Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [], + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..ec3fc4b9093 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction empty Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..89f8ab5e347 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction empty AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..e5a96e857c6 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction empty AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/fixture.ts new file mode 100644 index 00000000000..55243eab2f5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/fixture.ts @@ -0,0 +1 @@ +declare function* foo(); diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..ed8b5305792 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction generator TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: true, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + params: Array [], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..a0152865940 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction generator TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..3da973bf9f5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/3-Babel-AST.shot @@ -0,0 +1,40 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction generator Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: true, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + params: Array [], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..58082427903 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction generator Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "*", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [18, 21], + loc: { + start: { column: 18, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..e5478271a49 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction generator AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..0c5870a8a61 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/generator/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction generator AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/fixture.ts new file mode 100644 index 00000000000..3f5ccd7a7bf --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/fixture.ts @@ -0,0 +1 @@ +declare function foo(a, b, c); diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..a7f8479f43a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [ + Identifier { + type: "Identifier", + name: "a", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + name: "b", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + name: "c", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..f6aa7066f1a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-many TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "c", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..d1e098a0e89 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [ + Identifier { + type: "Identifier", + name: "a", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + name: "b", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + name: "c", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..c27b9fa0a5e --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-many Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "b", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "c", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..cfed52f085e --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..d41363d11c2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/fixture.ts new file mode 100644 index 00000000000..1e929f63edd --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/fixture.ts @@ -0,0 +1 @@ +declare function foo(a); diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..1f21a6f71f8 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,51 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [ + Identifier { + type: "Identifier", + name: "a", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..d8412c94212 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-one TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..abf7337612c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,51 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [ + Identifier { + type: "Identifier", + name: "a", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..9dba1e7717c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-one Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..81f8c45d656 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..ab3a33eb7f9 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/param-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction param-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/fixture.ts new file mode 100644 index 00000000000..7ab5bf14937 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/fixture.ts @@ -0,0 +1 @@ +declare function foo(): void; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..45e65dbe80a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction returnType TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [], + returnType: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSVoidKeyword { + type: "TSVoidKeyword", + + range: [24, 28], + loc: { + start: { column: 24, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + + range: [22, 28], + loc: { + start: { column: 22, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..f06fda6f01e --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction returnType TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "void", + + range: [24, 28], + loc: { + start: { column: 24, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..1ccc35aaadb --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/3-Babel-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction returnType Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [], + returnType: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSVoidKeyword { + type: "TSVoidKeyword", + + range: [24, 28], + loc: { + start: { column: 24, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + + range: [22, 28], + loc: { + start: { column: 22, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + + range: [0, 29], + loc: { + start: { column: 0, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..703e02000f5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction returnType Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "void", + + range: [24, 28], + loc: { + start: { column: 24, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..bddda38b36f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction returnType AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..994903ee609 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/returnType/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction returnType AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/fixture.ts new file mode 100644 index 00000000000..4ab67258323 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/fixture.ts @@ -0,0 +1 @@ +declare function foo(); diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..aefd6e905e2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,114 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "T", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + out: false, + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "U", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + out: false, + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "V", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + out: false, + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + + range: [20, 29], + loc: { + start: { column: 20, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..92b21a76dcf --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-many TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "U", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "V", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..76dc2ebf1f5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,81 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: "T", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + name: "U", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + name: "V", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + + range: [20, 29], + loc: { + start: { column: 20, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..6aaaa58051c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-many Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "U", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "V", + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [30, 31], + loc: { + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [31, 32], + loc: { + start: { column: 31, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..5c07aedab59 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,121 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSDeclareFunction { + type: 'TSDeclareFunction', + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: 'Identifier', + name: 'foo', + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: 'TSTypeParameterDeclaration', + params: Array [ + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'T', +- +- range: [21, 22], +- loc: { +- start: { column: 21, line: 1 }, +- end: { column: 22, line: 1 }, +- }, +- }, +- out: false, ++ name: 'T', + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'U', +- +- range: [24, 25], +- loc: { +- start: { column: 24, line: 1 }, +- end: { column: 25, line: 1 }, +- }, +- }, +- out: false, ++ name: 'U', + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'V', +- +- range: [27, 28], +- loc: { +- start: { column: 27, line: 1 }, +- end: { column: 28, line: 1 }, +- }, +- }, +- out: false, ++ name: 'V', + + range: [27, 28], + loc: { + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, + }, + }, + ], + + range: [20, 29], + loc: { + start: { column: 20, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + + range: [0, 32], + loc: { + start: { column: 0, line: 1 }, + end: { column: 32, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 33], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..cae8ddcdbee --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/fixture.ts new file mode 100644 index 00000000000..3f66cd9c460 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/fixture.ts @@ -0,0 +1 @@ +declare function foo(); diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..4767a93811c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,72 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "T", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + out: false, + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + + range: [20, 23], + loc: { + start: { column: 20, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..cf3ce53768e --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-one TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..745e9cba393 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: "T", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + + range: [20, 23], + loc: { + start: { column: 20, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..8f4c003543d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-one Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "function", + + range: [8, 16], + loc: { + start: { column: 8, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..6763966b08f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,77 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSDeclareFunction { + type: 'TSDeclareFunction', + async: false, + declare: true, + expression: false, + generator: false, + id: Identifier { + type: 'Identifier', + name: 'foo', + + range: [17, 20], + loc: { + start: { column: 17, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + params: Array [], + typeParameters: TSTypeParameterDeclaration { + type: 'TSTypeParameterDeclaration', + params: Array [ + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'T', +- +- range: [21, 22], +- loc: { +- start: { column: 21, line: 1 }, +- end: { column: 22, line: 1 }, +- }, +- }, +- out: false, ++ name: 'T', + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + + range: [20, 23], + loc: { + start: { column: 20, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..669ef13533f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction type-param-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/fixture.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/fixture.ts new file mode 100644 index 00000000000..242942bf817 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/fixture.ts @@ -0,0 +1 @@ +function foo(): void; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..5c46a6508af --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,57 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction without-declare TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + returnType: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSVoidKeyword { + type: "TSVoidKeyword", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [14, 20], + loc: { + start: { column: 14, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..67a00cfbc1a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction without-declare TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "void", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..2e49a416b76 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/3-Babel-AST.shot @@ -0,0 +1,57 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction without-declare Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSDeclareFunction { + type: "TSDeclareFunction", + async: false, + expression: false, + generator: false, + id: Identifier { + type: "Identifier", + name: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + params: Array [], + returnType: TSTypeAnnotation { + type: "TSTypeAnnotation", + typeAnnotation: TSVoidKeyword { + type: "TSVoidKeyword", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [14, 20], + loc: { + start: { column: 14, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..0c6751d92ce --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction without-declare Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "function", + + range: [0, 8], + loc: { + start: { column: 0, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "foo", + + range: [9, 12], + loc: { + start: { column: 9, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ":", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "void", + + range: [16, 20], + loc: { + start: { column: 16, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..7f5b5b1b141 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction without-declare AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..9995b1b0eb9 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/fixtures/without-declare/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSDeclareFunction without-declare AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts b/packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts index 88bd4aff2f2..ea37a1e874f 100644 --- a/packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts +++ b/packages/ast-spec/src/declaration/TSDeclareFunction/spec.ts @@ -1,6 +1,13 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; -import type { FunctionDeclarationBase } from '../../base/FunctionDeclarationBase'; +import type { FunctionBase } from '../../base/FunctionBase'; +import type { BlockStatement } from '../../statement/BlockStatement/spec'; -export interface TSDeclareFunction extends FunctionDeclarationBase { +// TODO(#1852) - async + declare are semantically invalid together +export interface TSDeclareFunction extends FunctionBase { type: AST_NODE_TYPES.TSDeclareFunction; + // TODO(#1852) - breaking change enforce this is always `null` like `TSEmptyBodyFunctionExpression` + body?: BlockStatement; + // TODO(#5020) - make this always `false` if it is not `declare`d instead of `undefined` + declare?: boolean; + expression: false; } diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/fixture.ts b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/fixture.ts new file mode 100644 index 00000000000..eeaa8c95655 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/fixture.ts @@ -0,0 +1 @@ +enum Foo; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..89896499476 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration _error_ missing-body TSESTree - Error 1`] = `[TSError: '{' expected.]`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..69fc4aef147 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration _error_ missing-body Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:8)]`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..4d1d30b58b6 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-body/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration _error_ missing-body Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/fixture.ts b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/fixture.ts new file mode 100644 index 00000000000..14404051ead --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/fixture.ts @@ -0,0 +1 @@ +enum {} diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..0653a9025ef --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration _error_ missing-id TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..676c0503e37 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration _error_ missing-id Babel - Error 1`] = `[SyntaxError: Unexpected token (1:5)]`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..5fb97329274 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration _error_ missing-id Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/fixture.ts b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/fixture.ts new file mode 100644 index 00000000000..9089db7067d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/fixture.ts @@ -0,0 +1 @@ +enum 1 {} diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..15a27efccaf --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration _error_ non-identifier-name TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..1cf8f0ab899 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration _error_ non-identifier-name Babel - Error 1`] = `[SyntaxError: Unexpected token (1:5)]`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..dd5c6175008 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration _error_ non-identifier-name Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/fixture.ts b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/fixture.ts new file mode 100644 index 00000000000..97b096b8754 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/fixture.ts @@ -0,0 +1 @@ +const enum Foo {} diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..1d59f828b67 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration const TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSEnumDeclaration { + type: "TSEnumDeclaration", + const: true, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [11, 14], + loc: { + start: { column: 11, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + members: Array [], + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..a25cddd52f6 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration const TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "const", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "enum", + + range: [6, 10], + loc: { + start: { column: 6, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [11, 14], + loc: { + start: { column: 11, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..5ee7fea32e6 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/3-Babel-AST.shot @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration const Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSEnumDeclaration { + type: "TSEnumDeclaration", + const: true, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [11, 14], + loc: { + start: { column: 11, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + members: Array [], + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..4a4ccaf3ecc --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration const Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "const", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "enum", + + range: [6, 10], + loc: { + start: { column: 6, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [11, 14], + loc: { + start: { column: 11, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..95d4c8f6b4a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration const AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..2e994fa6ae9 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/const/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration const AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Keyword { + type: 'Keyword', + value: 'const', + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'enum', + + range: [6, 10], + loc: { + start: { column: 6, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [11, 14], + loc: { + start: { column: 11, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/fixture.ts b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/fixture.ts new file mode 100644 index 00000000000..6ec0c1cbf6a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/fixture.ts @@ -0,0 +1 @@ +declare enum Foo {} diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..8b742184ed9 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration declare TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSEnumDeclaration { + type: "TSEnumDeclaration", + declare: true, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [13, 16], + loc: { + start: { column: 13, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + members: Array [], + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..b045362a4c5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration declare TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "enum", + + range: [8, 12], + loc: { + start: { column: 8, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [13, 16], + loc: { + start: { column: 13, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..21a3e86cd15 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration declare Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSEnumDeclaration { + type: "TSEnumDeclaration", + declare: true, + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [13, 16], + loc: { + start: { column: 13, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + members: Array [], + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..ccf2a20885e --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration declare Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "enum", + + range: [8, 12], + loc: { + start: { column: 8, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [13, 16], + loc: { + start: { column: 13, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..5085b6b4609 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration declare AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..11a6693745f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration declare AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Identifier { + type: 'Identifier', + value: 'declare', + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'enum', + + range: [8, 12], + loc: { + start: { column: 8, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [13, 16], + loc: { + start: { column: 13, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/fixture.ts b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/fixture.ts new file mode 100644 index 00000000000..f418fb66f4f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/fixture.ts @@ -0,0 +1 @@ +enum Foo {} diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..85e4f093eb2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration empty TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSEnumDeclaration { + type: "TSEnumDeclaration", + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + members: Array [], + + range: [0, 11], + loc: { + start: { column: 0, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..c419adb8309 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration empty TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "enum", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..79ad82443c7 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration empty Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSEnumDeclaration { + type: "TSEnumDeclaration", + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + members: Array [], + + range: [0, 11], + loc: { + start: { column: 0, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..688f75fe0f2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration empty Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "enum", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..2ce5c714db1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration empty AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..5c9479e0ff8 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,52 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration empty AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'enum', + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/fixture.ts b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/fixture.ts new file mode 100644 index 00000000000..a639ff46e1b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/fixture.ts @@ -0,0 +1,3 @@ +enum Foo { + A, +} diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..dc9b0027eed --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration with-member-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSEnumDeclaration { + type: "TSEnumDeclaration", + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + members: Array [ + TSEnumMember { + type: "TSEnumMember", + id: Identifier { + type: "Identifier", + name: "A", + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + ], + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..e0ddd7d58be --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration with-member-one TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "enum", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..47761319694 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration with-member-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSEnumDeclaration { + type: "TSEnumDeclaration", + id: Identifier { + type: "Identifier", + name: "Foo", + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + members: Array [ + TSEnumMember { + type: "TSEnumMember", + id: Identifier { + type: "Identifier", + name: "A", + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + ], + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..08d14feb8c4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration with-member-one Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "enum", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "Foo", + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..b707fc5d46b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration with-member-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..cf146a98eac --- /dev/null +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/fixtures/with-member-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,72 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSEnumDeclaration with-member-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'enum', + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'Foo', + + range: [5, 8], + loc: { + start: { column: 5, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'A', + + range: [13, 14], + loc: { + start: { column: 2, line: 2 }, + end: { column: 3, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ',', + + range: [14, 15], + loc: { + start: { column: 3, line: 2 }, + end: { column: 4, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [16, 17], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts index 1c1530d501f..9a0df845c5d 100644 --- a/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/TSEnumDeclaration/spec.ts @@ -6,9 +6,30 @@ import type { Modifier } from '../../unions/Modifier'; export interface TSEnumDeclaration extends BaseNode { type: AST_NODE_TYPES.TSEnumDeclaration; - id: Identifier; - members: TSEnumMember[]; + /** + * Whether this is a `const` enum. + * ``` + * const enum Foo {...} + * ``` + */ + // TODO(#5020) - make this `false` if it is not `const` const?: boolean; + /** + * Whether this is a `declare`d enum. + * ``` + * declare enum Foo {...} + * ``` + */ + // TODO(#5020) - make this `false` if it is not `declare`d declare?: boolean; + /** + * The enum name. + */ + id: Identifier; + /** + * The enum members. + */ + members: TSEnumMember[]; + // TODO(#4759) - breaking change remove this modifiers?: Modifier[]; } diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/fixture.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/fixture.ts new file mode 100644 index 00000000000..7fe439305a4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/fixture.ts @@ -0,0 +1 @@ +import F = 1; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..3593291fdb2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ entity-name-invalid TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..d5cc0b77735 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ entity-name-invalid Babel - Error 1`] = `[SyntaxError: Unexpected token (1:11)]`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..463142c713f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/entity-name-invalid/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ entity-name-invalid Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/fixture.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/fixture.ts new file mode 100644 index 00000000000..b67ea934e8c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/fixture.ts @@ -0,0 +1 @@ +import F = require(1); diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..51aedf5fa31 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..b19940abe31 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string Babel - Error 1`] = `[SyntaxError: Unexpected token (1:19)]`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..cda96c9ac3d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ external-module-ref-non-string Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/fixture.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/fixture.ts new file mode 100644 index 00000000000..769999c5f68 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/fixture.ts @@ -0,0 +1,2 @@ +type T = 1; +import type F = T; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..387be14ced2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ import-kind TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..b8f9e5be4e4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ import-kind Babel - Error 1`] = `[SyntaxError: An import alias can not use 'import type'. (2:16)]`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..d9472dcc7b6 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ import-kind Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/fixture.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/fixture.ts new file mode 100644 index 00000000000..2b0ead218dd --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/fixture.ts @@ -0,0 +1 @@ +import = A.B; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..b5dc03a804c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ missing-id TSESTree - Error 1`] = `[TSError: Declaration or statement expected.]`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..3c24250cf63 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ missing-id Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:7)]`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..3f9e697fc06 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ missing-id Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/fixture.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/fixture.ts new file mode 100644 index 00000000000..3ce78a91241 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/fixture.ts @@ -0,0 +1 @@ +import F; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..cb33fd8279b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ missing-reference TSESTree - Error 1`] = `[TSError: '=' expected.]`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..6dcc0a59954 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ missing-reference Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "from" (1:8)]`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..7a3b4167a3b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/_error_/missing-reference/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration _error_ missing-reference Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/fixture.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/fixture.ts new file mode 100644 index 00000000000..fdcbe7ffe41 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/fixture.ts @@ -0,0 +1 @@ +import F = A.B.C; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..6d438a8c596 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,85 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSImportEqualsDeclaration { + type: "TSImportEqualsDeclaration", + id: Identifier { + type: "Identifier", + name: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + importKind: "value", + isExport: false, + moduleReference: TSQualifiedName { + type: "TSQualifiedName", + left: TSQualifiedName { + type: "TSQualifiedName", + left: Identifier { + type: "Identifier", + name: "A", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + right: Identifier { + type: "Identifier", + name: "B", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + + range: [11, 14], + loc: { + start: { column: 11, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + right: Identifier { + type: "Identifier", + name: "C", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [11, 16], + loc: { + start: { column: 11, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..7d0291e8b8b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-many TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "B", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "C", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..e4d68bb9f75 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,85 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSImportEqualsDeclaration { + type: "TSImportEqualsDeclaration", + id: Identifier { + type: "Identifier", + name: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + importKind: "value", + isExport: false, + moduleReference: TSQualifiedName { + type: "TSQualifiedName", + left: TSQualifiedName { + type: "TSQualifiedName", + left: Identifier { + type: "Identifier", + name: "A", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + right: Identifier { + type: "Identifier", + name: "B", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + + range: [11, 14], + loc: { + start: { column: 11, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + right: Identifier { + type: "Identifier", + name: "C", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [11, 16], + loc: { + start: { column: 11, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..08ed3e892d5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-many Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "B", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "C", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..88ec007b237 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..b006c4e07d2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/fixture.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/fixture.ts new file mode 100644 index 00000000000..ac623ee9e28 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/fixture.ts @@ -0,0 +1 @@ +import F = A; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..aa18656723b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSImportEqualsDeclaration { + type: "TSImportEqualsDeclaration", + id: Identifier { + type: "Identifier", + name: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + importKind: "value", + isExport: false, + moduleReference: Identifier { + type: "Identifier", + name: "A", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..1e7f3ae9a45 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-one TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..d6e2ea9ed20 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSImportEqualsDeclaration { + type: "TSImportEqualsDeclaration", + id: Identifier { + type: "Identifier", + name: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + importKind: "value", + isExport: false, + moduleReference: Identifier { + type: "Identifier", + name: "A", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..85b199a73a4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-one Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..0cb17969d4f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..28d07eeb473 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/entity-name-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration entity-name-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/fixture.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/fixture.ts new file mode 100644 index 00000000000..2c8ef7abf25 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/fixture.ts @@ -0,0 +1 @@ +import F = require('mod'); diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..aca9d9ab5f3 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,57 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration external-module-ref-string TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSImportEqualsDeclaration { + type: "TSImportEqualsDeclaration", + id: Identifier { + type: "Identifier", + name: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + importKind: "value", + isExport: false, + moduleReference: TSExternalModuleReference { + type: "TSExternalModuleReference", + expression: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [19, 24], + loc: { + start: { column: 19, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [11, 25], + loc: { + start: { column: 11, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + sourceType: "module", + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..023028ef7d9 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration external-module-ref-string TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "require", + + range: [11, 18], + loc: { + start: { column: 11, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [19, 24], + loc: { + start: { column: 19, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..f904ff1dbcf --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/3-Babel-AST.shot @@ -0,0 +1,57 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration external-module-ref-string Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSImportEqualsDeclaration { + type: "TSImportEqualsDeclaration", + id: Identifier { + type: "Identifier", + name: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + importKind: "value", + isExport: false, + moduleReference: TSExternalModuleReference { + type: "TSExternalModuleReference", + expression: Literal { + type: "Literal", + raw: "'mod'", + value: "mod", + + range: [19, 24], + loc: { + start: { column: 19, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [11, 25], + loc: { + start: { column: 11, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..91b65568fbe --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration external-module-ref-string Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "import", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "require", + + range: [11, 18], + loc: { + start: { column: 11, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "(", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + String { + type: "String", + value: "'mod'", + + range: [19, 24], + loc: { + start: { column: 19, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [25, 26], + loc: { + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..a0b231ec7a1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration external-module-ref-string AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSImportEqualsDeclaration { + type: 'TSImportEqualsDeclaration', + id: Identifier { + type: 'Identifier', + name: 'F', + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + importKind: 'value', + isExport: false, + moduleReference: TSExternalModuleReference { + type: 'TSExternalModuleReference', + expression: Literal { + type: 'Literal', + raw: '\\\\'mod\\\\'', + value: 'mod', + + range: [19, 24], + loc: { + start: { column: 19, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [11, 25], + loc: { + start: { column: 11, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + + range: [0, 26], + loc: { + start: { column: 0, line: 1 }, + end: { column: 26, line: 1 }, + }, + }, + ], +- sourceType: 'module', ++ sourceType: 'script', + + range: [0, 27], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..ce5e5680101 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSImportEqualsDeclaration external-module-ref-string AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/spec.ts index 5ccd9b6fc4f..d4db9a64168 100644 --- a/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/TSImportEqualsDeclaration/spec.ts @@ -7,8 +7,27 @@ import type { ImportKind } from '../ExportAndImportKind'; export interface TSImportEqualsDeclaration extends BaseNode { type: AST_NODE_TYPES.TSImportEqualsDeclaration; + /** + * The locally imported name + */ id: Identifier; + /** + * The value being aliased. + * ``` + * import F1 = A; + * import F2 = A.B.C; + * import F3 = require('mod'); + * ``` + */ moduleReference: EntityName | TSExternalModuleReference; + // TODO(#1852) - breaking change remove this as it is invalid importKind: ImportKind; + /** + * Whether this is immediately exported + * ``` + * export import F = A; + * ``` + */ + // TODO(#4130) - this should be represented in the AST isExport: boolean; } diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/fixture.ts new file mode 100644 index 00000000000..b3123630664 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/fixture.ts @@ -0,0 +1 @@ +interface F; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..128274dff58 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-body TSESTree - Error 1`] = `[TSError: '{' expected.]`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..12baf6e0738 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-body Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:11)]`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..6caba1ae72c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-body/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-body Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/fixture.ts new file mode 100644 index 00000000000..74fde08aea1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/fixture.ts @@ -0,0 +1 @@ +interface F extends {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..a33eb58a06d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-extends TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..add92930a37 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-extends Babel - Error 1`] = `[SyntaxError: 'extends' list cannot be empty. (1:20)]`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..6eb1bf9104f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-extends Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/fixture.ts new file mode 100644 index 00000000000..6b562c272fc --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/fixture.ts @@ -0,0 +1 @@ +interface {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..d640ad78d53 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-id TSESTree - Error 1`] = `[TSError: Interface must be given a name.]`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..e06bfcc1a1c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-id Babel - Error 1`] = `[SyntaxError: 'interface' declarations must be followed by an identifier. (1:10)]`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..bbce8c51c4d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-id Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/fixture.ts new file mode 100644 index 00000000000..f03a31c78c2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/fixture.ts @@ -0,0 +1 @@ +interface F<> {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..9d0be0712d4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-type-param TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..936edbec8c8 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-type-param Babel - Error 1`] = `[SyntaxError: Type parameter list cannot be empty. (1:11)]`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..5846179dd56 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ missing-type-param Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/fixture.ts new file mode 100644 index 00000000000..c649bd49662 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/fixture.ts @@ -0,0 +1 @@ +interface F extends 1 {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..e8e8c0e5fdb --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ non-identifier-extends TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..e7b584a9cd2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ non-identifier-extends Babel - Error 1`] = `[SyntaxError: Unexpected token (1:20)]`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..c429168c288 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ non-identifier-extends Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/fixture.ts new file mode 100644 index 00000000000..7b8c5e961ee --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/fixture.ts @@ -0,0 +1 @@ +interface 1 {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..7b6a2f0a666 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ non-identifier-name TSESTree - Error 1`] = `[TSError: Interface name cannot be '1'.]`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..64f544addb3 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ non-identifier-name Babel - Error 1`] = `[SyntaxError: 'interface' declarations must be followed by an identifier. (1:10)]`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..5470a1ec04e --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ non-identifier-name Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/fixture.ts new file mode 100644 index 00000000000..2809a08b8cf --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/fixture.ts @@ -0,0 +1 @@ +interface F<1> {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..e48629574cf --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ non-identifier-type-param TSESTree - Error 1`] = `[TSError: Type parameter declaration expected.]`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..69166a9fa11 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ non-identifier-type-param Babel - Error 1`] = `[SyntaxError: Unexpected token (1:12)]`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..5f1be010c62 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-type-param/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration _error_ non-identifier-type-param Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/fixture.ts new file mode 100644 index 00000000000..0e8aa5a3479 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/fixture.ts @@ -0,0 +1 @@ +declare interface F {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..501d609a46c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration declare TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [20, 22], + loc: { + start: { column: 20, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + declare: true, + id: Identifier { + type: "Identifier", + name: "F", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..8899a66c8a3 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration declare TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "interface", + + range: [8, 17], + loc: { + start: { column: 8, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..4642a30ee6d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration declare Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [20, 22], + loc: { + start: { column: 20, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + declare: true, + id: Identifier { + type: "Identifier", + name: "F", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..b75639c632d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration declare Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "interface", + + range: [8, 17], + loc: { + start: { column: 8, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..c5bfaba693b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration declare AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..057cff33527 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration declare AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Identifier { + type: 'Identifier', + value: 'declare', + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'interface', + + range: [8, 17], + loc: { + start: { column: 8, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'F', + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/fixture.ts new file mode 100644 index 00000000000..296dc32043f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/fixture.ts @@ -0,0 +1 @@ +interface F {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..aa7db317692 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,45 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration empty TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [12, 14], + loc: { + start: { column: 12, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..b46401c8187 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration empty TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..e6048d6bde4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/3-Babel-AST.shot @@ -0,0 +1,45 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration empty Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [12, 14], + loc: { + start: { column: 12, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..01311e4df0c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration empty Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..42bc3c4eb68 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration empty AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..68a5be8dd4f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/empty/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,52 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration empty AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'interface', + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'F', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/fixture.ts new file mode 100644 index 00000000000..a0c396132b5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/fixture.ts @@ -0,0 +1 @@ +interface F extends A, B, C {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..2e08532845c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,104 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [28, 30], + loc: { + start: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + extends: Array [ + TSInterfaceHeritage { + type: "TSInterfaceHeritage", + expression: Identifier { + type: "Identifier", + name: "A", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + TSInterfaceHeritage { + type: "TSInterfaceHeritage", + expression: Identifier { + type: "Identifier", + name: "B", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + TSInterfaceHeritage { + type: "TSInterfaceHeritage", + expression: Identifier { + type: "Identifier", + name: "C", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..b5418859abc --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-many TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [12, 19], + loc: { + start: { column: 12, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "B", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "C", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..18e1c620074 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,104 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [28, 30], + loc: { + start: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + extends: Array [ + TSExpressionWithTypeArguments { + type: "TSExpressionWithTypeArguments", + expression: Identifier { + type: "Identifier", + name: "A", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + TSExpressionWithTypeArguments { + type: "TSExpressionWithTypeArguments", + expression: Identifier { + type: "Identifier", + name: "B", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + TSExpressionWithTypeArguments { + type: "TSExpressionWithTypeArguments", + expression: Identifier { + type: "Identifier", + name: "C", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..c6f5129d13f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,106 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-many Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [12, 19], + loc: { + start: { column: 12, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "B", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "C", + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..793c00b7e98 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,114 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSInterfaceDeclaration { + type: 'TSInterfaceDeclaration', + body: TSInterfaceBody { + type: 'TSInterfaceBody', + body: Array [], + + range: [28, 30], + loc: { + start: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + extends: Array [ +- TSInterfaceHeritage { +- type: 'TSInterfaceHeritage', ++ TSExpressionWithTypeArguments { ++ type: 'TSExpressionWithTypeArguments', + expression: Identifier { + type: 'Identifier', + name: 'A', + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, +- TSInterfaceHeritage { +- type: 'TSInterfaceHeritage', ++ TSExpressionWithTypeArguments { ++ type: 'TSExpressionWithTypeArguments', + expression: Identifier { + type: 'Identifier', + name: 'B', + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +- TSInterfaceHeritage { +- type: 'TSInterfaceHeritage', ++ TSExpressionWithTypeArguments { ++ type: 'TSExpressionWithTypeArguments', + expression: Identifier { + type: 'Identifier', + name: 'C', + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + ], + id: Identifier { + type: 'Identifier', + name: 'F', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 30], + loc: { + start: { column: 0, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 31], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..c6ea1aca49b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,112 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'interface', + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'F', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'extends', + + range: [12, 19], + loc: { + start: { column: 12, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'A', + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ',', + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'B', + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ',', + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'C', + + range: [26, 27], + loc: { + start: { column: 26, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [28, 29], + loc: { + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [29, 30], + loc: { + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/fixture.ts new file mode 100644 index 00000000000..cd5394400b5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/fixture.ts @@ -0,0 +1 @@ +interface F extends A {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..795dc661bbe --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [22, 24], + loc: { + start: { column: 22, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + extends: Array [ + TSInterfaceHeritage { + type: "TSInterfaceHeritage", + expression: Identifier { + type: "Identifier", + name: "A", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + ], + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..b9e3f8a240d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-one TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [12, 19], + loc: { + start: { column: 12, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..87260af0dd5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [22, 24], + loc: { + start: { column: 22, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + extends: Array [ + TSExpressionWithTypeArguments { + type: "TSExpressionWithTypeArguments", + expression: Identifier { + type: "Identifier", + name: "A", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + ], + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..26da7a11f7c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-one Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "extends", + + range: [12, 19], + loc: { + start: { column: 12, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..fe6cf12f1a5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,72 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSInterfaceDeclaration { + type: 'TSInterfaceDeclaration', + body: TSInterfaceBody { + type: 'TSInterfaceBody', + body: Array [], + + range: [22, 24], + loc: { + start: { column: 22, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + extends: Array [ +- TSInterfaceHeritage { +- type: 'TSInterfaceHeritage', ++ TSExpressionWithTypeArguments { ++ type: 'TSExpressionWithTypeArguments', + expression: Identifier { + type: 'Identifier', + name: 'A', + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + ], + id: Identifier { + type: 'Identifier', + name: 'F', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 25], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..f12bb69db9b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/extends-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,72 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration extends-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'interface', + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'F', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Keyword { + type: 'Keyword', + value: 'extends', + + range: [12, 19], + loc: { + start: { column: 12, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'A', + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [23, 24], + loc: { + start: { column: 23, line: 1 }, + end: { column: 24, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/fixture.ts new file mode 100644 index 00000000000..82042ece0e3 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/fixture.ts @@ -0,0 +1 @@ +interface F {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..6aea3322462 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,119 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "T", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + out: false, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "U", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + out: false, + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "V", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + out: false, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + + range: [11, 20], + loc: { + start: { column: 11, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..d96cb3d9489 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-many TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "U", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "V", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..579e9191d10 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: "T", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + name: "U", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + name: "V", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + + range: [11, 20], + loc: { + start: { column: 11, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..174304a412f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,116 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-many Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "U", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "V", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..56e43bd6632 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,126 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSInterfaceDeclaration { + type: 'TSInterfaceDeclaration', + body: TSInterfaceBody { + type: 'TSInterfaceBody', + body: Array [], + + range: [21, 23], + loc: { + start: { column: 21, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'F', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: 'TSTypeParameterDeclaration', + params: Array [ + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'T', +- +- range: [12, 13], +- loc: { +- start: { column: 12, line: 1 }, +- end: { column: 13, line: 1 }, +- }, +- }, +- out: false, ++ name: 'T', + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'U', +- +- range: [15, 16], +- loc: { +- start: { column: 15, line: 1 }, +- end: { column: 16, line: 1 }, +- }, +- }, +- out: false, ++ name: 'U', + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'V', +- +- range: [18, 19], +- loc: { +- start: { column: 18, line: 1 }, +- end: { column: 19, line: 1 }, +- }, +- }, +- out: false, ++ name: 'V', + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + + range: [11, 20], + loc: { + start: { column: 11, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..889b7b8eba0 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,122 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'interface', + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'F', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '<', + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'T', + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ',', + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'U', + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ',', + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'V', + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '>', + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [22, 23], + loc: { + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/fixture.ts new file mode 100644 index 00000000000..abd3720f1a6 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/fixture.ts @@ -0,0 +1 @@ +interface F {} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..15f67448566 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,77 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [15, 17], + loc: { + start: { column: 15, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "T", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + out: false, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + + range: [11, 14], + loc: { + start: { column: 11, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..d88a78ec400 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-one TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..dc81d623ecc --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [], + + range: [15, 17], + loc: { + start: { column: 15, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: "T", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + + range: [11, 14], + loc: { + start: { column: 11, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..a41373677b1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-one Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..d6859d52b51 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSInterfaceDeclaration { + type: 'TSInterfaceDeclaration', + body: TSInterfaceBody { + type: 'TSInterfaceBody', + body: Array [], + + range: [15, 17], + loc: { + start: { column: 15, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + id: Identifier { + type: 'Identifier', + name: 'F', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: 'TSTypeParameterDeclaration', + params: Array [ + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'T', +- +- range: [12, 13], +- loc: { +- start: { column: 12, line: 1 }, +- end: { column: 13, line: 1 }, +- }, +- }, +- out: false, ++ name: 'T', + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + + range: [11, 14], + loc: { + start: { column: 11, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..fc20247a46e --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration type-param-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'interface', + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'F', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '<', + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'T', + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '>', + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/fixture.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/fixture.ts new file mode 100644 index 00000000000..2f47465c4e0 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/fixture.ts @@ -0,0 +1,3 @@ +interface F { + prop; +} diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..424cf585b19 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration with-member-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [ + TSPropertySignature { + type: "TSPropertySignature", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [16, 20], + loc: { + start: { column: 2, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, + + range: [16, 21], + loc: { + start: { column: 2, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + ], + + range: [12, 23], + loc: { + start: { column: 12, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..c57ff756e66 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration with-member-one TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [16, 20], + loc: { + start: { column: 2, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [20, 21], + loc: { + start: { column: 6, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..94437c371ec --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration with-member-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSInterfaceDeclaration { + type: "TSInterfaceDeclaration", + body: TSInterfaceBody { + type: "TSInterfaceBody", + body: Array [ + TSPropertySignature { + type: "TSPropertySignature", + computed: false, + key: Identifier { + type: "Identifier", + name: "prop", + + range: [16, 20], + loc: { + start: { column: 2, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, + + range: [16, 21], + loc: { + start: { column: 2, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + ], + + range: [12, 23], + loc: { + start: { column: 12, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 1, line: 3 }, + }, + }, + ], + sourceType: "script", + + range: [0, 24], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 4 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..af379bd7026 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration with-member-one Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "interface", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "prop", + + range: [16, 20], + loc: { + start: { column: 2, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [20, 21], + loc: { + start: { column: 6, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [22, 23], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..8e0b58b2efe --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration with-member-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..32b0173342d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/fixtures/with-member-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,72 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSInterfaceDeclaration with-member-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'interface', + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'F', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '{', + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'prop', + + range: [16, 20], + loc: { + start: { column: 2, line: 2 }, + end: { column: 6, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [20, 21], + loc: { + start: { column: 6, line: 2 }, + end: { column: 7, line: 2 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '}', + + range: [22, 23], + loc: { + start: { column: 0, line: 3 }, + end: { column: 1, line: 3 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts index 1e95380c3cb..a75c769daf9 100644 --- a/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/TSInterfaceDeclaration/spec.ts @@ -7,11 +7,30 @@ import type { TSTypeParameterDeclaration } from '../../special/TSTypeParameterDe export interface TSInterfaceDeclaration extends BaseNode { type: AST_NODE_TYPES.TSInterfaceDeclaration; + // TODO(#4759) - breaking change remove this + abstract?: boolean; + /** + * The body of the interface + */ body: TSInterfaceBody; - id: Identifier; - typeParameters?: TSTypeParameterDeclaration; + /** + * Whether the interface was `declare`d, `undefined` otherwise + */ + // TODO(#5020) - make this `false` if it is not `declare`d + declare?: boolean; + /** + * The types this interface `extends` + */ extends?: TSInterfaceHeritage[]; + /** + * The name of this interface + */ + id: Identifier; + // TODO(#4759) - breaking change remove this implements?: TSInterfaceHeritage[]; - abstract?: boolean; - declare?: boolean; + /** + * The generic type parameters declared for the interface. + * This is `undefined` if there are no generic type parameters declared. + */ + typeParameters?: TSTypeParameterDeclaration; } diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/fixture.ts new file mode 100644 index 00000000000..95cad257504 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/fixture.ts @@ -0,0 +1 @@ +module 1 {} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..082a7d854c2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ module-invalid-id TSESTree - Error 1`] = `[TSError: Namespace name cannot be '1'.]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..9848b6e55cd --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ module-invalid-id Babel - Error 1`] = `[SyntaxError: Missing semicolon. (1:6)]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..1ed7cf1aba5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-invalid-id/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ module-invalid-id Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/fixture.ts new file mode 100644 index 00000000000..7d0dcd8add3 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/fixture.ts @@ -0,0 +1 @@ +module F; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..0a8a833a27a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ module-missing-body TSESTree - Error 1`] = `[TSError: '{' expected.]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..c7c0b7ca1d4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ module-missing-body Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:8)]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..f8381f6dde3 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/module-missing-body/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ module-missing-body Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/fixture.ts new file mode 100644 index 00000000000..fe124427907 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/fixture.ts @@ -0,0 +1 @@ +declare namespace F; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..6a1c0b8eebf --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-declare-no-body TSESTree - Error 1`] = `[TSError: '{' expected.]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..0cc4df30bc5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-declare-no-body Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:19)]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..62ff96dfe97 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-declare-no-body/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-declare-no-body Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/fixture.ts new file mode 100644 index 00000000000..173024ac6a3 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/fixture.ts @@ -0,0 +1 @@ +namespace 'a' {} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..bdb99cfb914 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-id-literal TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..3dc7480d32a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-id-literal Babel - Error 1`] = `[SyntaxError: Missing semicolon. (1:9)]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..354b7482759 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-id-literal/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-id-literal Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/fixture.ts new file mode 100644 index 00000000000..32cdae5da4b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/fixture.ts @@ -0,0 +1 @@ +namespace 1 {} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..3fbcf961cfa --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-invalid-id TSESTree - Error 1`] = `[TSError: Namespace name cannot be '1'.]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..be52f2461a2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-invalid-id Babel - Error 1`] = `[SyntaxError: Missing semicolon. (1:9)]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..1a3abc42ed7 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-invalid-id/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-invalid-id Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/fixture.ts new file mode 100644 index 00000000000..d0caf4acec4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/fixture.ts @@ -0,0 +1 @@ +namespace F; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..33a26d312ca --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-no-body TSESTree - Error 1`] = `[TSError: '{' expected.]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..4e9e941de86 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-no-body Babel - Error 1`] = `[SyntaxError: Unexpected token, expected "{" (1:11)]`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..2c9165727c1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/_error_/namespace-no-body/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration _error_ namespace-no-body Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/fixture.ts new file mode 100644 index 00000000000..3f1ee73dee1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/fixture.ts @@ -0,0 +1 @@ +declare global {} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..424909a0e10 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration global TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [15, 17], + loc: { + start: { column: 15, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + declare: true, + global: true, + id: Identifier { + type: "Identifier", + name: "global", + + range: [8, 14], + loc: { + start: { column: 8, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..910131ba7b8 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration global TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "global", + + range: [8, 14], + loc: { + start: { column: 8, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..4e1a238040b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/3-Babel-AST.shot @@ -0,0 +1,47 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration global Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [15, 17], + loc: { + start: { column: 15, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + declare: true, + global: true, + id: Identifier { + type: "Identifier", + name: "global", + + range: [8, 14], + loc: { + start: { column: 8, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + + range: [0, 17], + loc: { + start: { column: 0, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..393012dfc4b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration global Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "global", + + range: [8, 14], + loc: { + start: { column: 8, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..bdf25926153 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration global AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..b92eb152c95 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/global/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration global AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/fixture.ts new file mode 100644 index 00000000000..2758941f3c3 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/fixture.ts @@ -0,0 +1 @@ +declare module 'a'; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..a0ad297f73c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare-no-body TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + declare: true, + id: Literal { + type: "Literal", + raw: "'a'", + value: "a", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..0c2959419e2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare-no-body TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "module", + + range: [8, 14], + loc: { + start: { column: 8, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + String { + type: "String", + value: "'a'", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..d90a0fdea6a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/3-Babel-AST.shot @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare-no-body Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + declare: true, + id: Literal { + type: "Literal", + raw: "'a'", + value: "a", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..d6f2b8430a1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare-no-body Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "module", + + range: [8, 14], + loc: { + start: { column: 8, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + String { + type: "String", + value: "'a'", + + range: [15, 18], + loc: { + start: { column: 15, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..29dc0c7a776 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare-no-body AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..6341815959d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare-no-body/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare-no-body AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/fixture.ts new file mode 100644 index 00000000000..2cbec48309b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/fixture.ts @@ -0,0 +1 @@ +declare module F {} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..74a329eeb58 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [17, 19], + loc: { + start: { column: 17, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + declare: true, + id: Identifier { + type: "Identifier", + name: "F", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..487f26037f8 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "module", + + range: [8, 14], + loc: { + start: { column: 8, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..dd00b5173a1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/3-Babel-AST.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [17, 19], + loc: { + start: { column: 17, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + declare: true, + id: Identifier { + type: "Identifier", + name: "F", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..e2dfc2330dc --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "module", + + range: [8, 14], + loc: { + start: { column: 8, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..d70930f793c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..bae19f0bd14 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-declare/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-declare AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/fixture.ts new file mode 100644 index 00000000000..499f1194467 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/fixture.ts @@ -0,0 +1 @@ +module F {} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..3559c1ce1a1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,45 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-identifier TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [9, 11], + loc: { + start: { column: 9, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [0, 11], + loc: { + start: { column: 0, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..e8658090b43 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-identifier TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "module", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..7acb1bcd871 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/3-Babel-AST.shot @@ -0,0 +1,45 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-identifier Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [9, 11], + loc: { + start: { column: 9, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [0, 11], + loc: { + start: { column: 0, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..f8093f686fb --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-identifier Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "module", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..829de93e3df --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-identifier AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..2d09487a662 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-identifier/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-identifier AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/fixture.ts new file mode 100644 index 00000000000..6e2ddacd253 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/fixture.ts @@ -0,0 +1 @@ +module 'a' {} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..da4f7cdc9af --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-literal TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [11, 13], + loc: { + start: { column: 11, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + id: Literal { + type: "Literal", + raw: "'a'", + value: "a", + + range: [7, 10], + loc: { + start: { column: 7, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..35a1efd6dc9 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-literal TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "module", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + String { + type: "String", + value: "'a'", + + range: [7, 10], + loc: { + start: { column: 7, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..fafc835ec47 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/3-Babel-AST.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-literal Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [11, 13], + loc: { + start: { column: 11, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + id: Literal { + type: "Literal", + raw: "'a'", + value: "a", + + range: [7, 10], + loc: { + start: { column: 7, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..a463f80b9e5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-literal Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "module", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + String { + type: "String", + value: "'a'", + + range: [7, 10], + loc: { + start: { column: 7, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..f13f22dfe7d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-literal AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..1e1bc9d73c3 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-literal/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-literal AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/fixture.ts new file mode 100644 index 00000000000..56162d5e58b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/fixture.ts @@ -0,0 +1 @@ +module A.B.C {} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..3dfc069dda7 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-qualified-name TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [13, 15], + loc: { + start: { column: 13, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "C", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [11, 15], + loc: { + start: { column: 11, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "B", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 15], + loc: { + start: { column: 9, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "A", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 16], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..70d7cd911e1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-qualified-name TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "module", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "B", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "C", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..c6af56a9883 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/3-Babel-AST.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-qualified-name Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [13, 15], + loc: { + start: { column: 13, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "C", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + + range: [11, 15], + loc: { + start: { column: 11, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "B", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 15], + loc: { + start: { column: 9, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "A", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 16], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..b03c2f7b5a8 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-qualified-name Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "module", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "B", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "C", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..d442f261db2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-qualified-name AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..68241771f7c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/module-id-qualified-name/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration module-id-qualified-name AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/fixture.ts new file mode 100644 index 00000000000..ebc35823e75 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/fixture.ts @@ -0,0 +1 @@ +declare namespace F {} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..c373a655222 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-declare TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [20, 22], + loc: { + start: { column: 20, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + declare: true, + id: Identifier { + type: "Identifier", + name: "F", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..18d298125dd --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-declare TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "namespace", + + range: [8, 17], + loc: { + start: { column: 8, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..26936650860 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/3-Babel-AST.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-declare Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [20, 22], + loc: { + start: { column: 20, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + declare: true, + id: Identifier { + type: "Identifier", + name: "F", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..374070330ed --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-declare Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "namespace", + + range: [8, 17], + loc: { + start: { column: 8, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..614b9695a3c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-declare AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..1e9fda98a78 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-declare/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-declare AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/fixture.ts new file mode 100644 index 00000000000..fb1741b05b2 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/fixture.ts @@ -0,0 +1 @@ +namespace F {} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..e6303e2d3ed --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,45 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-identifier TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [12, 14], + loc: { + start: { column: 12, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..15cd21e3ad5 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-identifier TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "namespace", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..2e47480e044 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/3-Babel-AST.shot @@ -0,0 +1,45 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-identifier Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [12, 14], + loc: { + start: { column: 12, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..1fb07e00228 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-identifier Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "namespace", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "F", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..a0aa056256b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-identifier AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..112e01d377c --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-identifier/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-identifier AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/fixture.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/fixture.ts new file mode 100644 index 00000000000..c7c1b751f8d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/fixture.ts @@ -0,0 +1 @@ +namespace A.B.C {} diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..98cd5bbe817 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-qualified-name TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [16, 18], + loc: { + start: { column: 16, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "C", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + + range: [14, 18], + loc: { + start: { column: 14, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "B", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 18], + loc: { + start: { column: 12, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "A", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..fcd5df00be8 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-qualified-name TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "namespace", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "B", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "C", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..569b49fb327 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/3-Babel-AST.shot @@ -0,0 +1,83 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-qualified-name Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleDeclaration { + type: "TSModuleDeclaration", + body: TSModuleBlock { + type: "TSModuleBlock", + body: Array [], + + range: [16, 18], + loc: { + start: { column: 16, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "C", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + + range: [14, 18], + loc: { + start: { column: 14, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "B", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 18], + loc: { + start: { column: 12, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + id: Identifier { + type: "Identifier", + name: "A", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [0, 18], + loc: { + start: { column: 0, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..8f3b974a3ab --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-qualified-name Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "namespace", + + range: [0, 9], + loc: { + start: { column: 0, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "A", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "B", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ".", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "C", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "{", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "}", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..a7a16eee58a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-qualified-name AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..1e60c8843aa --- /dev/null +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/fixtures/namespace-id-qualified-name/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSModuleDeclaration namespace-id-qualified-name AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts index ac63e52a593..e077d1648e1 100644 --- a/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/TSModuleDeclaration/spec.ts @@ -7,11 +7,24 @@ import type { Modifier } from '../../unions/Modifier'; export interface TSModuleDeclaration extends BaseNode { type: AST_NODE_TYPES.TSModuleDeclaration; + /** + * The name of the module + * ``` + * namespace A {} + * namespace A.B.C {} + * module 'a' {} + * ``` + */ id: Identifier | Literal; + /** + * The body of the module. + * This can only be `undefined` for the code `declare module 'mod';` + * This will be a `TSModuleDeclaration` if the name is "nested" (`Foo.Bar`). + */ body?: | TSModuleBlock /* - TODO - we currently emit this due to bad parser handling of nested modules + TODO(#4966) - we currently emit this due to bad parser handling of nested modules namespace Foo.Bar {} ^^^^^^^^^^^^^^^^^^^^ TSModuleDeclaration ^^^^^^ TSModuleDeclaration @@ -20,7 +33,22 @@ export interface TSModuleDeclaration extends BaseNode { This should instead emit a TSQualifiedName for the `id` and not emit an inner TSModuleDeclaration */ | TSModuleDeclaration; + /** + * Whether this is a global declaration + * ``` + * declare global {} + * ``` + */ + // TODO(#5020) - make this `false` if not `global` global?: boolean; + /** + * Whether the module is `declare`d + * ``` + * declare namespace F {} + * ``` + */ + // TODO(#5020) - make this `false` if it is not `declare`d declare?: boolean; + // TODO(#4759) - breaking change remove this modifiers?: Modifier[]; } diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/fixture.ts b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/fixture.ts new file mode 100644 index 00000000000..bbcfe5795de --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/fixture.ts @@ -0,0 +1 @@ +export as namespace; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..e47c9aa7c25 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration _error_ missing-id TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..300850581d6 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration _error_ missing-id Babel - Error 1`] = `[SyntaxError: Unexpected token (1:19)]`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..0b5d774603f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/missing-id/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration _error_ missing-id Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/fixture.ts b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/fixture.ts new file mode 100644 index 00000000000..a8878e61afe --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/fixture.ts @@ -0,0 +1 @@ +export as namespace 1; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..3e11b470029 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration _error_ non-identifier-name TSESTree - Error 1`] = `[TSError: Identifier expected.]`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..f2641cc64de --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration _error_ non-identifier-name Babel - Error 1`] = `[SyntaxError: Unexpected token (1:20)]`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..defe8a17bba --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration _error_ non-identifier-name Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/fixture.ts b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/fixture.ts new file mode 100644 index 00000000000..ff8bbadf397 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/fixture.ts @@ -0,0 +1 @@ +export as namespace a; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..914df1fad85 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,35 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration valid TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSNamespaceExportDeclaration { + type: "TSNamespaceExportDeclaration", + id: Identifier { + type: "Identifier", + name: "a", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..8399bbd3d1d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration valid TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [7, 9], + loc: { + start: { column: 7, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "namespace", + + range: [10, 19], + loc: { + start: { column: 10, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..c3861bcab7b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/3-Babel-AST.shot @@ -0,0 +1,35 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration valid Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSNamespaceExportDeclaration { + type: "TSNamespaceExportDeclaration", + id: Identifier { + type: "Identifier", + name: "a", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + + range: [0, 22], + loc: { + start: { column: 0, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 23], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..dfe3eae2d2a --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration valid Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "export", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "as", + + range: [7, 9], + loc: { + start: { column: 7, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "namespace", + + range: [10, 19], + loc: { + start: { column: 10, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "a", + + range: [20, 21], + loc: { + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [21, 22], + loc: { + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..6cd11e1f4b3 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration valid AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..c7d4f1d7315 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/fixtures/valid/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSNamespaceExportDeclaration valid AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/spec.ts index 6853d4a2854..da63cca2ac6 100644 --- a/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/TSNamespaceExportDeclaration/spec.ts @@ -4,5 +4,8 @@ import type { Identifier } from '../../expression/Identifier/spec'; export interface TSNamespaceExportDeclaration extends BaseNode { type: AST_NODE_TYPES.TSNamespaceExportDeclaration; + /** + * The name the global variable being exported to + */ id: Identifier; } diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/fixture.ts b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/fixture.ts new file mode 100644 index 00000000000..3bd6bc6c605 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/fixture.ts @@ -0,0 +1 @@ +type T<> = 1; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..9902528eb41 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration _error_ missing-type-parameter TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..b18ec532458 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration _error_ missing-type-parameter Babel - Error 1`] = `[SyntaxError: Type parameter list cannot be empty. (1:6)]`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..99587163b89 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration _error_ missing-type-parameter Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/fixture.ts b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/fixture.ts new file mode 100644 index 00000000000..533f0b183cf --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/fixture.ts @@ -0,0 +1 @@ +type 1 = 2; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..7eaf3f0bba4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration _error_ non-identifier-name TSESTree - Error 1`] = `[TSError: Type alias name cannot be '1'.]`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..f7c419205f7 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration _error_ non-identifier-name Babel - Error 1`] = `[SyntaxError: Missing semicolon. (1:4)]`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..7ccef6da61f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-name/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration _error_ non-identifier-name Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/fixture.ts b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/fixture.ts new file mode 100644 index 00000000000..059c8eaf43d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/fixture.ts @@ -0,0 +1 @@ +type T<1> = 2; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..b11bc95c96d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration _error_ non-identifier-type-parameter TSESTree - Error 1`] = `[TSError: Type parameter declaration expected.]`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..bb7b44f3afe --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration _error_ non-identifier-type-parameter Babel - Error 1`] = `[SyntaxError: Unexpected token (1:7)]`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..ad412071cc1 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/_error_/non-identifier-type-parameter/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration _error_ non-identifier-type-parameter Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/fixture.ts b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/fixture.ts new file mode 100644 index 00000000000..87882321e28 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/fixture.ts @@ -0,0 +1 @@ +declare type T = 1; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..63becdaa218 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration declare TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: true, + id: Identifier { + type: "Identifier", + name: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..8599ab30609 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration declare TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [8, 12], + loc: { + start: { column: 8, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..36939724fc4 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration declare Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + declare: true, + id: Identifier { + type: "Identifier", + name: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + + range: [0, 19], + loc: { + start: { column: 0, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..48da9f1cfb8 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,66 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration declare Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "type", + + range: [8, 12], + loc: { + start: { column: 8, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [15, 16], + loc: { + start: { column: 15, line: 1 }, + end: { column: 16, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [17, 18], + loc: { + start: { column: 17, line: 1 }, + end: { column: 18, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..890509a8dcb --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration declare AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..6d9b60683b6 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration declare AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/fixture.ts b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/fixture.ts new file mode 100644 index 00000000000..98fb2f852da --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/fixture.ts @@ -0,0 +1 @@ +type T = 1; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..af8a41ed478 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,87 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-many TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "U", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + out: false, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + ], + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..a84e1cc058d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-many TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "U", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..db6209388e7 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/3-Babel-AST.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-many Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: "U", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + ], + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..92442f10c0d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,86 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-many Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "U", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..a80b5aa0a11 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,92 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-many AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', + id: Identifier { + type: 'Identifier', + name: 'T', + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: 'TSLiteralType', + literal: Literal { + type: 'Literal', + raw: '1', + value: 1, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: 'TSTypeParameterDeclaration', + params: Array [ + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'U', +- +- range: [7, 8], +- loc: { +- start: { column: 7, line: 1 }, +- end: { column: 8, line: 1 }, +- }, +- }, +- out: false, ++ name: 'U', + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + ], + + range: [6, 9], + loc: { + start: { column: 6, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..b693d3c055d --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-many/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-many AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/fixture.ts b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/fixture.ts new file mode 100644 index 00000000000..8ca0a977313 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/fixture.ts @@ -0,0 +1 @@ +type T = 1; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..6bf2120e61b --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,129 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-one TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "U", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + out: false, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "V", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + out: false, + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + in: false, + name: Identifier { + type: "Identifier", + name: "W", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + out: false, + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + + range: [6, 15], + loc: { + start: { column: 6, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..c23889fa8fd --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,126 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-one TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "U", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "V", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "W", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..60c8977e60f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/3-Babel-AST.shot @@ -0,0 +1,96 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-one Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: "TSTypeParameterDeclaration", + params: Array [ + TSTypeParameter { + type: "TSTypeParameter", + name: "U", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + name: "V", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + TSTypeParameter { + type: "TSTypeParameter", + name: "W", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + + range: [6, 15], + loc: { + start: { column: 6, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..f6e56c2aa5f --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,126 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-one Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "<", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "U", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "V", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "W", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ">", + + range: [14, 15], + loc: { + start: { column: 14, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [16, 17], + loc: { + start: { column: 16, line: 1 }, + end: { column: 17, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [19, 20], + loc: { + start: { column: 19, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..d754f2bf397 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-one AST Alignment - AST 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Program { + type: 'Program', + body: Array [ + TSTypeAliasDeclaration { + type: 'TSTypeAliasDeclaration', + id: Identifier { + type: 'Identifier', + name: 'T', + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: 'TSLiteralType', + literal: Literal { + type: 'Literal', + raw: '1', + value: 1, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + + range: [18, 19], + loc: { + start: { column: 18, line: 1 }, + end: { column: 19, line: 1 }, + }, + }, + typeParameters: TSTypeParameterDeclaration { + type: 'TSTypeParameterDeclaration', + params: Array [ + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'U', +- +- range: [7, 8], +- loc: { +- start: { column: 7, line: 1 }, +- end: { column: 8, line: 1 }, +- }, +- }, +- out: false, ++ name: 'U', + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'V', +- +- range: [10, 11], +- loc: { +- start: { column: 10, line: 1 }, +- end: { column: 11, line: 1 }, +- }, +- }, +- out: false, ++ name: 'V', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + TSTypeParameter { + type: 'TSTypeParameter', +- in: false, +- name: Identifier { +- type: 'Identifier', +- name: 'W', +- +- range: [13, 14], +- loc: { +- start: { column: 13, line: 1 }, +- end: { column: 14, line: 1 }, +- }, +- }, +- out: false, ++ name: 'W', + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + + range: [6, 15], + loc: { + start: { column: 6, line: 1 }, + end: { column: 15, line: 1 }, + }, + }, + + range: [0, 20], + loc: { + start: { column: 0, line: 1 }, + end: { column: 20, line: 1 }, + }, + }, + ], + sourceType: 'script', + + range: [0, 21], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, + }" +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..bc7fa2d6aac --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/type-param-one/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration type-param-one AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/fixture.ts b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/fixture.ts new file mode 100644 index 00000000000..0d6d62642cc --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/fixture.ts @@ -0,0 +1 @@ +type T = 1; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..424ed29eb52 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,55 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration valid TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [0, 11], + loc: { + start: { column: 0, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..e3b35e444aa --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration valid TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..7fad93c1cab --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/3-Babel-AST.shot @@ -0,0 +1,55 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration valid Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + TSTypeAliasDeclaration { + type: "TSTypeAliasDeclaration", + id: Identifier { + type: "Identifier", + name: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + typeAnnotation: TSLiteralType { + type: "TSLiteralType", + literal: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + + range: [0, 11], + loc: { + start: { column: 0, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..12901c93f94 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration valid Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "type", + + range: [0, 4], + loc: { + start: { column: 0, line: 1 }, + end: { column: 4, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "T", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..9cc16a451ec --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration valid AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..4de04778d63 --- /dev/null +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/fixtures/valid/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration TSTypeAliasDeclaration valid AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/spec.ts b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/spec.ts index 61ce986c2a2..15ab0a40c13 100644 --- a/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/TSTypeAliasDeclaration/spec.ts @@ -6,8 +6,25 @@ import type { TypeNode } from '../../unions/TypeNode'; export interface TSTypeAliasDeclaration extends BaseNode { type: AST_NODE_TYPES.TSTypeAliasDeclaration; + /** + * Whether the type was `declare`d. + * ``` + * declare type T = 1; + * ``` + */ + // TODO(#5020) - make this `false` if it is not `declare`d + declare?: boolean; + /** + * The name of the type. + */ id: Identifier; + /** + * The "value" (type) of the declaration + */ typeAnnotation: TypeNode; - declare?: boolean; + /** + * The generic type parameters declared for the type. + * This is `undefined` if there are no generic type parameters declared. + */ typeParameters?: TSTypeParameterDeclaration; } diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/fixture.ts b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/fixture.ts new file mode 100644 index 00000000000..21a6e1beba9 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/fixture.ts @@ -0,0 +1 @@ +const = 1; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..3f61a7ec4bd --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration _error_ missing-id-with-value TSESTree - Error 1`] = `[TSError: Variable declaration expected.]`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..5e6f7bc3288 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration _error_ missing-id-with-value Babel - Error 1`] = `[SyntaxError: Unexpected token (1:6)]`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..830f2f4e93c --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-with-value/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration _error_ missing-id-with-value Error Alignment 1`] = `"Both errored"`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/fixture.ts b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/fixture.ts new file mode 100644 index 00000000000..c53e6c27952 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/fixture.ts @@ -0,0 +1 @@ +const; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/snapshots/1-TSESTree-Error.shot new file mode 100644 index 00000000000..6537d529262 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration _error_ missing-id-without-value TSESTree - Error 1`] = `"NO ERROR"`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/snapshots/2-Babel-Error.shot new file mode 100644 index 00000000000..7a42d0e079b --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/snapshots/2-Babel-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration _error_ missing-id-without-value Babel - Error 1`] = `[SyntaxError: Unexpected token (1:5)]`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/snapshots/3-Alignment-Error.shot new file mode 100644 index 00000000000..cd2401b6862 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/snapshots/3-Alignment-Error.shot @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration _error_ missing-id-without-value Error Alignment 1`] = `"Babel errored but TSESTree didn't"`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/fixture.ts b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/fixture.ts new file mode 100644 index 00000000000..943c458c79e --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/fixture.ts @@ -0,0 +1 @@ +const x = 1; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..d7290bd926d --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-with-value TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + init: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [6, 11], + loc: { + start: { column: 6, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + kind: "const", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..df6fc4d3998 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-with-value TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "const", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..2cd36dbb467 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/3-Babel-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-with-value Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + init: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [6, 11], + loc: { + start: { column: 6, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + kind: "const", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..5a5ce6855a2 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-with-value Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "const", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..65c9ece0d43 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-with-value AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..abc02d7344b --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-with-value/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-with-value AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/fixture.ts b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/fixture.ts new file mode 100644 index 00000000000..943c458c79e --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/fixture.ts @@ -0,0 +1 @@ +const x = 1; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..ac4cd6b70d8 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-without-value TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + init: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [6, 11], + loc: { + start: { column: 6, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + kind: "const", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..ee275ed63d9 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-without-value TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "const", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..c41b8219393 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/3-Babel-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-without-value Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + init: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + + range: [6, 11], + loc: { + start: { column: 6, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + kind: "const", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..62b0896e9fd --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-without-value Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "const", + + range: [0, 5], + loc: { + start: { column: 0, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..56007597c38 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-without-value AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..cc37accf3c5 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/const-without-value/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration const-without-value AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/fixture.ts b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/fixture.ts new file mode 100644 index 00000000000..3dc63502e9c --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/fixture.ts @@ -0,0 +1 @@ +declare let x; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..19c59fcc338 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration declare TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + init: null, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + declare: true, + kind: "let", + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..5e3638b00d8 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration declare TSESTree - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Keyword { + type: "Keyword", + value: "let", + + range: [8, 11], + loc: { + start: { column: 8, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..9cd49f740e4 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/3-Babel-AST.shot @@ -0,0 +1,49 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration declare Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + init: null, + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + ], + declare: true, + kind: "let", + + range: [0, 14], + loc: { + start: { column: 0, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 15], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..5b7e380551c --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration declare Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "declare", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "let", + + range: [8, 11], + loc: { + start: { column: 8, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..005dc078e1d --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration declare AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..6d4eee5276a --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/declare/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,52 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration declare AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ + Identifier { + type: 'Identifier', + value: 'declare', + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'let', + + range: [8, 11], + loc: { + start: { column: 8, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'x', + + range: [12, 13], + loc: { + start: { column: 12, line: 1 }, + end: { column: 13, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [13, 14], + loc: { + start: { column: 13, line: 1 }, + end: { column: 14, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/fixture.ts b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/fixture.ts new file mode 100644 index 00000000000..db913399448 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/fixture.ts @@ -0,0 +1 @@ +let x = 1; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..a1c7625b457 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-with-value TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + init: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + + range: [4, 9], + loc: { + start: { column: 4, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + ], + kind: "let", + + range: [0, 10], + loc: { + start: { column: 0, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 11], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..fa835fcdd32 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-with-value TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "let", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..5c5236d0482 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/3-Babel-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-with-value Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + init: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + + range: [4, 9], + loc: { + start: { column: 4, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + ], + kind: "let", + + range: [0, 10], + loc: { + start: { column: 0, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 11], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..6f4bc74a6bd --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-with-value Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "let", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..2697799a415 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-with-value AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..e8e2c1727b2 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-with-value/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,62 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-with-value AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'let', + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'x', + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: '=', + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Numeric { + type: 'Numeric', + value: '1', + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/fixture.ts b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/fixture.ts new file mode 100644 index 00000000000..2756c24c457 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/fixture.ts @@ -0,0 +1 @@ +let x; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..86d5e5fb9d1 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,48 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-without-value TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + init: null, + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + ], + kind: "let", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..66e4c76e567 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-without-value TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "let", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..78ac80c4cf4 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/3-Babel-AST.shot @@ -0,0 +1,48 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-without-value Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + init: null, + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + ], + kind: "let", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..78f58826ca6 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-without-value Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "let", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..8082a31f808 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-without-value AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..949c66669c7 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/let-without-value/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,42 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration let-without-value AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'let', + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'x', + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/fixture.ts b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/fixture.ts new file mode 100644 index 00000000000..6736426d70f --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/fixture.ts @@ -0,0 +1 @@ +let x, y, z; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..f34767c5d50 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration multiple-declarations TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + init: null, + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "y", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + init: null, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "z", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + init: null, + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + kind: "let", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..b47b272ca68 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration multiple-declarations TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "let", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "y", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "z", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..b52ef758247 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/3-Babel-AST.shot @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration multiple-declarations Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + init: null, + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "y", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + init: null, + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "z", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + init: null, + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + ], + kind: "let", + + range: [0, 12], + loc: { + start: { column: 0, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 13], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..2e324512abe --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,76 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration multiple-declarations Babel - Tokens 1`] = ` +Array [ + Identifier { + type: "Identifier", + value: "let", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "y", + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ",", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "z", + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..10b9167907c --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration multiple-declarations AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..d1e4b8c9a7b --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/multiple-declarations/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration multiple-declarations AST Alignment - Token 1`] = ` +"Snapshot Diff: +- TSESTree ++ Babel + + Array [ +- Keyword { +- type: 'Keyword', ++ Identifier { ++ type: 'Identifier', + value: 'let', + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'x', + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ',', + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'y', + + range: [7, 8], + loc: { + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ',', + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Identifier { + type: 'Identifier', + value: 'z', + + range: [10, 11], + loc: { + start: { column: 10, line: 1 }, + end: { column: 11, line: 1 }, + }, + }, + Punctuator { + type: 'Punctuator', + value: ';', + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, + ]" +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/fixture.ts b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/fixture.ts new file mode 100644 index 00000000000..b506100a909 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/fixture.ts @@ -0,0 +1 @@ +var x = 1; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..d0b455dc1a2 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-with-value TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + init: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + + range: [4, 9], + loc: { + start: { column: 4, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + ], + kind: "var", + + range: [0, 10], + loc: { + start: { column: 0, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 11], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..2f9b9d78704 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-with-value TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "var", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..1420d42a8ca --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/3-Babel-AST.shot @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-with-value Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + init: Literal { + type: "Literal", + raw: "1", + value: 1, + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + + range: [4, 9], + loc: { + start: { column: 4, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + ], + kind: "var", + + range: [0, 10], + loc: { + start: { column: 0, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 11], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..bbab28532c6 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,56 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-with-value Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "var", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: "=", + + range: [6, 7], + loc: { + start: { column: 6, line: 1 }, + end: { column: 7, line: 1 }, + }, + }, + Numeric { + type: "Numeric", + value: "1", + + range: [8, 9], + loc: { + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..b107c9499d4 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-with-value AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..1eb3bcd0b98 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-with-value/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-with-value AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/fixture.ts b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/fixture.ts new file mode 100644 index 00000000000..96f6d3a3f15 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/fixture.ts @@ -0,0 +1 @@ +var x; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/1-TSESTree-AST.shot new file mode 100644 index 00000000000..9af840c2c53 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/1-TSESTree-AST.shot @@ -0,0 +1,48 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-without-value TSESTree - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + init: null, + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + ], + kind: "var", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/2-TSESTree-Tokens.shot new file mode 100644 index 00000000000..ba7245b545e --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/2-TSESTree-Tokens.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-without-value TSESTree - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "var", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/3-Babel-AST.shot new file mode 100644 index 00000000000..a3bb2551bf2 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/3-Babel-AST.shot @@ -0,0 +1,48 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-without-value Babel - AST 1`] = ` +Program { + type: "Program", + body: Array [ + VariableDeclaration { + type: "VariableDeclaration", + declarations: Array [ + VariableDeclarator { + type: "VariableDeclarator", + id: Identifier { + type: "Identifier", + name: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + init: null, + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + ], + kind: "var", + + range: [0, 6], + loc: { + start: { column: 0, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, + ], + sourceType: "script", + + range: [0, 7], + loc: { + start: { column: 0, line: 1 }, + end: { column: 0, line: 2 }, + }, +} +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/4-Babel-Tokens.shot new file mode 100644 index 00000000000..289daee1ace --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/4-Babel-Tokens.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-without-value Babel - Tokens 1`] = ` +Array [ + Keyword { + type: "Keyword", + value: "var", + + range: [0, 3], + loc: { + start: { column: 0, line: 1 }, + end: { column: 3, line: 1 }, + }, + }, + Identifier { + type: "Identifier", + value: "x", + + range: [4, 5], + loc: { + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [5, 6], + loc: { + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, + }, + }, +] +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/5-AST-Alignment-AST.shot new file mode 100644 index 00000000000..b8594239a06 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/5-AST-Alignment-AST.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-without-value AST Alignment - AST 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/6-AST-Alignment-Tokens.shot b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/6-AST-Alignment-Tokens.shot new file mode 100644 index 00000000000..3d401ca8c69 --- /dev/null +++ b/packages/ast-spec/src/declaration/VariableDeclaration/fixtures/var-without-value/snapshots/6-AST-Alignment-Tokens.shot @@ -0,0 +1,6 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AST Fixtures declaration VariableDeclaration var-without-value AST Alignment - Token 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; diff --git a/packages/ast-spec/src/declaration/VariableDeclaration/spec.ts b/packages/ast-spec/src/declaration/VariableDeclaration/spec.ts index 418a51eb735..4bc9b0f4854 100644 --- a/packages/ast-spec/src/declaration/VariableDeclaration/spec.ts +++ b/packages/ast-spec/src/declaration/VariableDeclaration/spec.ts @@ -4,8 +4,31 @@ import type { VariableDeclarator } from '../../special/VariableDeclarator/spec'; export interface VariableDeclaration extends BaseNode { type: AST_NODE_TYPES.VariableDeclaration; - // NOTE - this is not guaranteed to have any elements in it. i.e. `const;` + /** + * The variables declared by this declaration. + * Note that there may be 0 declarations (i.e. `const;`). + * ``` + * let x; + * let y, z; + * ``` + */ + // TODO(#1852) - this should be guaranteed to have at least 1 element in it. declarations: VariableDeclarator[]; - kind: 'const' | 'let' | 'var'; + /** + * Whether the declaration is `declare`d + * ``` + * declare const x = 1; + * ``` + */ + // TODO(#5020) - make this `false` if it is not `declare`d declare?: boolean; + /** + * The keyword used to declare the variable(s) + * ``` + * const x = 1; + * let y = 2; + * var z = 3; + * ``` + */ + kind: 'const' | 'let' | 'var'; } diff --git a/packages/ast-spec/src/expression/ClassExpression/spec.ts b/packages/ast-spec/src/expression/ClassExpression/spec.ts index 15215c31f1b..dfe6c0d1b41 100644 --- a/packages/ast-spec/src/expression/ClassExpression/spec.ts +++ b/packages/ast-spec/src/expression/ClassExpression/spec.ts @@ -1,6 +1,9 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; -import type { ClassDeclarationBase } from '../../base/ClassDeclarationBase'; +import type { ClassBase } from '../../base/ClassBase'; -export interface ClassExpression extends ClassDeclarationBase { +export interface ClassExpression extends ClassBase { type: AST_NODE_TYPES.ClassExpression; + abstract?: undefined; + declare?: undefined; + decorators?: undefined; } diff --git a/packages/ast-spec/src/expression/FunctionExpression/spec.ts b/packages/ast-spec/src/expression/FunctionExpression/spec.ts index 111be168b02..41f592a972f 100644 --- a/packages/ast-spec/src/expression/FunctionExpression/spec.ts +++ b/packages/ast-spec/src/expression/FunctionExpression/spec.ts @@ -1,8 +1,9 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; -import type { FunctionDeclarationBase } from '../../base/FunctionDeclarationBase'; +import type { FunctionBase } from '../../base/FunctionBase'; import type { BlockStatement } from '../../statement/BlockStatement/spec'; -export interface FunctionExpression extends FunctionDeclarationBase { +export interface FunctionExpression extends FunctionBase { type: AST_NODE_TYPES.FunctionExpression; body: BlockStatement; + expression: false; } diff --git a/packages/ast-spec/src/expression/TSEmptyBodyFunctionExpression/spec.ts b/packages/ast-spec/src/expression/TSEmptyBodyFunctionExpression/spec.ts index 2cc413c0109..77c8779c7d1 100644 --- a/packages/ast-spec/src/expression/TSEmptyBodyFunctionExpression/spec.ts +++ b/packages/ast-spec/src/expression/TSEmptyBodyFunctionExpression/spec.ts @@ -1,7 +1,8 @@ import type { AST_NODE_TYPES } from '../../ast-node-types'; -import type { FunctionDeclarationBase } from '../../base/FunctionDeclarationBase'; +import type { FunctionBase } from '../../base/FunctionBase'; -export interface TSEmptyBodyFunctionExpression extends FunctionDeclarationBase { +export interface TSEmptyBodyFunctionExpression extends FunctionBase { type: AST_NODE_TYPES.TSEmptyBodyFunctionExpression; body: null; + id: null; } diff --git a/packages/ast-spec/src/special/TSExternalModuleReference/spec.ts b/packages/ast-spec/src/special/TSExternalModuleReference/spec.ts index e634d4d0d6e..1efd283fd8c 100644 --- a/packages/ast-spec/src/special/TSExternalModuleReference/spec.ts +++ b/packages/ast-spec/src/special/TSExternalModuleReference/spec.ts @@ -4,5 +4,6 @@ import type { Expression } from '../../unions/Expression'; export interface TSExternalModuleReference extends BaseNode { type: AST_NODE_TYPES.TSExternalModuleReference; + // TODO(#1852) - this must be a string expression: Expression; } diff --git a/packages/ast-spec/src/unions/ExportDeclaration.ts b/packages/ast-spec/src/unions/ExportDeclaration.ts index 1ae9d9ddb9f..b78996d1405 100644 --- a/packages/ast-spec/src/unions/ExportDeclaration.ts +++ b/packages/ast-spec/src/unions/ExportDeclaration.ts @@ -1,20 +1,48 @@ -import type { ClassDeclaration } from '../declaration/ClassDeclaration/spec'; -import type { FunctionDeclaration } from '../declaration/FunctionDeclaration/spec'; +import type { + ClassDeclarationWithName, + ClassDeclarationWithOptionalName, +} from '../declaration/ClassDeclaration/spec'; +import type { + FunctionDeclarationWithName, + FunctionDeclarationWithOptionalName, +} from '../declaration/FunctionDeclaration/spec'; import type { TSDeclareFunction } from '../declaration/TSDeclareFunction/spec'; import type { TSEnumDeclaration } from '../declaration/TSEnumDeclaration/spec'; import type { TSInterfaceDeclaration } from '../declaration/TSInterfaceDeclaration/spec'; import type { TSModuleDeclaration } from '../declaration/TSModuleDeclaration/spec'; import type { TSTypeAliasDeclaration } from '../declaration/TSTypeAliasDeclaration/spec'; import type { VariableDeclaration } from '../declaration/VariableDeclaration/spec'; -import type { ClassExpression } from '../expression/ClassExpression/spec'; +import type { Expression } from './Expression'; -export type ExportDeclaration = - | ClassDeclaration - | ClassExpression - | FunctionDeclaration +// TODO(#1852) - the following are disallowed syntactically, but allowed by TS error recovery: +// TSEnumDeclaration, TSModuleDeclaration, TSTypeAliasDeclaration, VariableDeclaration +export type DefaultExportDeclarations = + | ClassDeclarationWithOptionalName + | Expression + | FunctionDeclarationWithName + | FunctionDeclarationWithOptionalName + | TSDeclareFunction + | TSEnumDeclaration + | TSInterfaceDeclaration + | TSModuleDeclaration + | TSTypeAliasDeclaration + | VariableDeclaration; + +// TODO(#1852) - the following are disallowed syntactically, but allowed by TS error recovery: +// ClassDeclarationWithOptionalName, FunctionDeclarationWithOptionalName +export type NamedExportDeclarations = + | ClassDeclarationWithName + | ClassDeclarationWithOptionalName + | FunctionDeclarationWithName + | FunctionDeclarationWithOptionalName | TSDeclareFunction | TSEnumDeclaration | TSInterfaceDeclaration | TSModuleDeclaration | TSTypeAliasDeclaration | VariableDeclaration; + +// TODO - breaking change remove this in the next major +export type ExportDeclaration = + | DefaultExportDeclarations + | NamedExportDeclarations; diff --git a/packages/ast-spec/src/unions/Statement.ts b/packages/ast-spec/src/unions/Statement.ts index e1af96b7fe5..56a4cfaf1ae 100644 --- a/packages/ast-spec/src/unions/Statement.ts +++ b/packages/ast-spec/src/unions/Statement.ts @@ -1,8 +1,8 @@ -import type { ClassDeclaration } from '../declaration/ClassDeclaration/spec'; +import type { ClassDeclarationWithName } from '../declaration/ClassDeclaration/spec'; import type { ExportAllDeclaration } from '../declaration/ExportAllDeclaration/spec'; import type { ExportDefaultDeclaration } from '../declaration/ExportDefaultDeclaration/spec'; import type { ExportNamedDeclaration } from '../declaration/ExportNamedDeclaration/spec'; -import type { FunctionDeclaration } from '../declaration/FunctionDeclaration/spec'; +import type { FunctionDeclarationWithName } from '../declaration/FunctionDeclaration/spec'; import type { ImportDeclaration } from '../declaration/ImportDeclaration/spec'; import type { TSDeclareFunction } from '../declaration/TSDeclareFunction/spec'; import type { TSEnumDeclaration } from '../declaration/TSEnumDeclaration/spec'; @@ -34,7 +34,7 @@ import type { WithStatement } from '../statement/WithStatement/spec'; export type Statement = | BlockStatement | BreakStatement - | ClassDeclaration + | ClassDeclarationWithName | ContinueStatement | DebuggerStatement | DoWhileStatement @@ -45,7 +45,7 @@ export type Statement = | ForInStatement | ForOfStatement | ForStatement - | FunctionDeclaration + | FunctionDeclarationWithName | IfStatement | ImportDeclaration | LabeledStatement @@ -75,4 +75,4 @@ export type ProgramStatement = | TSImportEqualsDeclaration | TSNamespaceExportDeclaration; -// TODO - once we have syntax errors, the types in ProgramStatement should not be in Statement +// TODO(#1852) - the types in ProgramStatement should not be in Statement diff --git a/packages/ast-spec/tests/fixtures-with-differences-ast.shot b/packages/ast-spec/tests/fixtures-with-differences-ast.shot index 2a37d6b6582..9d3e5d88ccc 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-ast.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-ast.shot @@ -4,13 +4,25 @@ exports[`AST Fixtures List fixtures with AST differences 1`] = ` Set { "declaration/ClassDeclaration/fixtures/implements-many/fixture.ts", "declaration/ClassDeclaration/fixtures/implements-one/fixture.ts", - "declaration/ClassDeclaration/fixtures/type-parameters-extends-type-parameters/fixture.ts", - "declaration/ClassDeclaration/fixtures/type-parameters/fixture.ts", + "declaration/ClassDeclaration/fixtures/type-param/fixture.ts", + "declaration/ClassDeclaration/fixtures/type-parameters-extends-type-param/fixture.ts", + "declaration/ClassDeclaration/fixtures/with-member-one/fixture.ts", "declaration/ExportNamedDeclaration/fixtures/aliased/fixture.ts", "declaration/ExportNamedDeclaration/fixtures/declare-function/fixture.ts", "declaration/ExportNamedDeclaration/fixtures/identifier-braced/fixture.ts", "declaration/ExportNamedDeclaration/fixtures/identifier-many/fixture.ts", "declaration/ExportNamedDeclaration/fixtures/interface/fixture.ts", "declaration/ExportNamedDeclaration/fixtures/type-alias/fixture.ts", + "declaration/FunctionDeclaration/fixtures/type-param-many/fixture.ts", + "declaration/FunctionDeclaration/fixtures/type-param-one/fixture.ts", + "declaration/TSDeclareFunction/fixtures/type-param-many/fixture.ts", + "declaration/TSDeclareFunction/fixtures/type-param-one/fixture.ts", + "declaration/TSImportEqualsDeclaration/fixtures/external-module-ref-string/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/extends-many/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/extends-one/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/type-param-many/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/type-param-one/fixture.ts", + "declaration/TSTypeAliasDeclaration/fixtures/type-param-many/fixture.ts", + "declaration/TSTypeAliasDeclaration/fixtures/type-param-one/fixture.ts", } `; diff --git a/packages/ast-spec/tests/fixtures-with-differences-errors.shot b/packages/ast-spec/tests/fixtures-with-differences-errors.shot index 59b5c479a75..f9c7ef6147d 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-errors.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-errors.shot @@ -4,8 +4,22 @@ exports[`AST Fixtures List fixtures with Error differences 1`] = ` Object { "Babel errored but TSESTree didn't": Set { "declaration/ClassDeclaration/fixtures/_error_/implements-non-identifier/fixture.ts", + "declaration/ClassDeclaration/fixtures/_error_/missing-extends-type-param/fixture.ts", + "declaration/ClassDeclaration/fixtures/_error_/missing-type-param/fixture.ts", + "declaration/ExportAllDeclaration/fixtures/_error_/kind-type/fixture.ts", "declaration/ExportAllDeclaration/fixtures/_error_/type-kind/fixture.ts", "declaration/ExportNamedDeclaration/fixtures/_error_/anonymous-class/fixture.ts", + "declaration/FunctionDeclaration/fixtures/_error_/missing-type-param/fixture.ts", + "declaration/TSDeclareFunction/fixtures/_error_/async/fixture.ts", + "declaration/TSDeclareFunction/fixtures/_error_/declare-with-body/fixture.ts", + "declaration/TSDeclareFunction/fixtures/_error_/missing-type-param/fixture.ts", + "declaration/TSImportEqualsDeclaration/fixtures/_error_/external-module-ref-non-string/fixture.ts", + "declaration/TSImportEqualsDeclaration/fixtures/_error_/import-kind/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/_error_/missing-extends/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/_error_/missing-type-param/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/_error_/non-identifier-extends/fixture.ts", + "declaration/TSTypeAliasDeclaration/fixtures/_error_/missing-type-parameter/fixture.ts", + "declaration/VariableDeclaration/fixtures/_error_/missing-id-without-value/fixture.ts", }, "TSESTree errored but Babel didn't": Set { "declaration/ExportAllDeclaration/fixtures/_error_/named-non-identifier/fixture.ts", diff --git a/packages/ast-spec/tests/fixtures-with-differences-tokens.shot b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot index 6c8d721a41a..ee92fc9b050 100644 --- a/packages/ast-spec/tests/fixtures-with-differences-tokens.shot +++ b/packages/ast-spec/tests/fixtures-with-differences-tokens.shot @@ -7,5 +7,20 @@ Set { "declaration/ExportDefaultDeclaration/fixtures/interface/fixture.ts", "declaration/ExportNamedDeclaration/fixtures/enum/fixture.ts", "declaration/ExportNamedDeclaration/fixtures/interface/fixture.ts", + "declaration/TSEnumDeclaration/fixtures/const/fixture.ts", + "declaration/TSEnumDeclaration/fixtures/declare/fixture.ts", + "declaration/TSEnumDeclaration/fixtures/empty/fixture.ts", + "declaration/TSEnumDeclaration/fixtures/with-member-one/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/declare/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/empty/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/extends-many/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/extends-one/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/type-param-many/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/type-param-one/fixture.ts", + "declaration/TSInterfaceDeclaration/fixtures/with-member-one/fixture.ts", + "declaration/VariableDeclaration/fixtures/declare/fixture.ts", + "declaration/VariableDeclaration/fixtures/let-with-value/fixture.ts", + "declaration/VariableDeclaration/fixtures/let-without-value/fixture.ts", + "declaration/VariableDeclaration/fixtures/multiple-declarations/fixture.ts", } `; diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index af75c6ce428..9e576429690 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -142,7 +142,11 @@ export class Converter { * @param result result * @returns the ESTreeNode with fixed exports */ - private fixExports( + private fixExports< + T extends + | TSESTree.DefaultExportDeclarations + | TSESTree.NamedExportDeclarations, + >( node: | ts.FunctionDeclaration | ts.VariableStatement @@ -184,9 +188,10 @@ export class Converter { const isType = result.type === AST_NODE_TYPES.TSInterfaceDeclaration || result.type === AST_NODE_TYPES.TSTypeAliasDeclaration; - const isDeclare = result.declare === true; + const isDeclare = 'declare' in result && result.declare === true; return this.createNode(node, { type: AST_NODE_TYPES.ExportNamedDeclaration, + // @ts-expect-error - TODO, narrow the types here declaration: result, specifiers: [], source: null, @@ -745,10 +750,19 @@ export class Converter { private assertModuleSpecifier( node: ts.ExportDeclaration | ts.ImportDeclaration, + allowNull: boolean, ): void { + if (!allowNull && node.moduleSpecifier == null) { + throw createError( + this.ast, + node.pos, + 'Module specifier must be a string literal.', + ); + } + if ( node.moduleSpecifier && - node.moduleSpecifier.kind !== SyntaxKind.StringLiteral + node.moduleSpecifier?.kind !== SyntaxKind.StringLiteral ) { throw createError( this.ast, @@ -964,10 +978,6 @@ export class Converter { result.returnType = this.convertTypeAnnotation(node.type, node); } - if (isDeclare) { - result.declare = true; - } - // Process typeParameters if (node.typeParameters) { result.typeParameters = @@ -976,6 +986,10 @@ export class Converter { ); } + if (isDeclare) { + result.declare = true; + } + // check for exports return this.fixExports(node, result); } @@ -1737,7 +1751,7 @@ export class Converter { }); case SyntaxKind.ImportDeclaration: { - this.assertModuleSpecifier(node); + this.assertModuleSpecifier(node, false); const result = this.createNode(node, { type: AST_NODE_TYPES.ImportDeclaration, @@ -1804,8 +1818,8 @@ export class Converter { } case SyntaxKind.ExportDeclaration: { - this.assertModuleSpecifier(node); if (node.exportClause?.kind === SyntaxKind.NamedExports) { + this.assertModuleSpecifier(node, true); return this.createNode(node, { type: AST_NODE_TYPES.ExportNamedDeclaration, source: this.convertChild(node.moduleSpecifier), @@ -1817,6 +1831,7 @@ export class Converter { assertions: this.convertAssertClasue(node.assertClause), }); } else { + this.assertModuleSpecifier(node, false); return this.createNode(node, { type: AST_NODE_TYPES.ExportAllDeclaration, source: this.convertChild(node.moduleSpecifier),