From 0a800e3f1d930721dc6e31b76e6048eae8e9de2e Mon Sep 17 00:00:00 2001 From: Armano Date: Fri, 21 Dec 2018 23:19:25 +0100 Subject: [PATCH 01/24] fix: add proper support for unsupported types --- src/ast-node-types.ts | 20 +- src/convert.ts | 37 + src/ts-nodes.ts | 2 + tests/ast-alignment/fixtures-to-test.ts | 4 + .../typescript/types/array-type.src.ts | 1 + .../typescript/types/intersection-type.src.ts | 1 + .../typescript/types/nested-types.src.ts | 1 + .../types/parenthesized-type-src.ts | 1 + .../typescript/types/tuple-type.src.ts | 1 + .../typescript/types/union-type.src.ts | 1 + tests/lib/__snapshots__/typescript.ts.snap | 2290 +++++++++++++++++ 11 files changed, 2351 insertions(+), 8 deletions(-) create mode 100644 tests/fixtures/typescript/types/array-type.src.ts create mode 100644 tests/fixtures/typescript/types/intersection-type.src.ts create mode 100644 tests/fixtures/typescript/types/nested-types.src.ts create mode 100644 tests/fixtures/typescript/types/parenthesized-type-src.ts create mode 100644 tests/fixtures/typescript/types/tuple-type.src.ts create mode 100644 tests/fixtures/typescript/types/union-type.src.ts diff --git a/src/ast-node-types.ts b/src/ast-node-types.ts index 58f6eea..dce3e51 100644 --- a/src/ast-node-types.ts +++ b/src/ast-node-types.ts @@ -86,6 +86,13 @@ export const AST_NODE_TYPES: { [key: string]: string } = { ThisExpression: 'ThisExpression', ThrowStatement: 'ThrowStatement', TryStatement: 'TryStatement', + UnaryExpression: 'UnaryExpression', + UpdateExpression: 'UpdateExpression', + VariableDeclaration: 'VariableDeclaration', + VariableDeclarator: 'VariableDeclarator', + WhileStatement: 'WhileStatement', + WithStatement: 'WithStatement', + YieldExpression: 'YieldExpression', /** * TS-prefixed nodes */ @@ -140,15 +147,12 @@ export const AST_NODE_TYPES: { [key: string]: string } = { TSTypeParameterInstantiation: 'TSTypeParameterInstantiation', TSTypePredicate: 'TSTypePredicate', TSTypeReference: 'TSTypeReference', + TSIntersectionType: 'TSIntersectionType', + TSTupleType: 'TSTupleType', + TSOptionalType: 'TSOptionalType', + TSParenthesizedType: 'TSParenthesizedType', TSUnionType: 'TSUnionType', TSUndefinedKeyword: 'TSUndefinedKeyword', TSUnknownKeyword: 'TSUnknownKeyword', - TSVoidKeyword: 'TSVoidKeyword', - UnaryExpression: 'UnaryExpression', - UpdateExpression: 'UpdateExpression', - VariableDeclaration: 'VariableDeclaration', - VariableDeclarator: 'VariableDeclarator', - WhileStatement: 'WhileStatement', - WithStatement: 'WithStatement', - YieldExpression: 'YieldExpression' + TSVoidKeyword: 'TSVoidKeyword' }; diff --git a/src/convert.ts b/src/convert.ts index 22a4ec6..d93f3d3 100644 --- a/src/convert.ts +++ b/src/convert.ts @@ -2513,6 +2513,43 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { break; } + // TypeScript specific types + case SyntaxKind.OptionalType: { + Object.assign(result, { + type: AST_NODE_TYPES.TSOptionalType, + typeAnnotation: convertChild(node.type) + }); + break; + } + case SyntaxKind.ParenthesizedType: { + Object.assign(result, { + type: AST_NODE_TYPES.TSParenthesizedType, + typeAnnotation: convertChild(node.type) + }); + break; + } + case SyntaxKind.TupleType: { + Object.assign(result, { + type: AST_NODE_TYPES.TSTupleType, + elementTypes: node.elementTypes.map(convertChild) + }); + break; + } + case SyntaxKind.UnionType: { + Object.assign(result, { + type: AST_NODE_TYPES.TSUnionType, + types: node.types.map(convertChild) + }); + break; + } + case SyntaxKind.IntersectionType: { + Object.assign(result, { + type: AST_NODE_TYPES.TSIntersectionType, + types: node.types.map(convertChild) + }); + break; + } + default: deeplyCopy(); } diff --git a/src/ts-nodes.ts b/src/ts-nodes.ts index 93d692f..69682cb 100644 --- a/src/ts-nodes.ts +++ b/src/ts-nodes.ts @@ -50,6 +50,8 @@ export type TSNode = ts.Node & | ts.ParenthesizedTypeNode | ts.TypeOperatorNode | ts.IndexedAccessTypeNode + | ts.FunctionTypeNode + | ts.ConstructorTypeNode | ts.MappedTypeNode | ts.LiteralTypeNode | ts.StringLiteral diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index ce914e1..a77c268 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -528,6 +528,10 @@ let fixturePatternConfigsToTest = [ */ 'declare-namespace-with-exported-function' ] + }), + + createFixturePatternConfigFor('typescript/types', { + fileType: 'ts' }) ]; diff --git a/tests/fixtures/typescript/types/array-type.src.ts b/tests/fixtures/typescript/types/array-type.src.ts new file mode 100644 index 0000000..5d038fc --- /dev/null +++ b/tests/fixtures/typescript/types/array-type.src.ts @@ -0,0 +1 @@ +type Foo = string[] diff --git a/tests/fixtures/typescript/types/intersection-type.src.ts b/tests/fixtures/typescript/types/intersection-type.src.ts new file mode 100644 index 0000000..93da940 --- /dev/null +++ b/tests/fixtures/typescript/types/intersection-type.src.ts @@ -0,0 +1 @@ +type LinkedList = T & { next: LinkedList }; diff --git a/tests/fixtures/typescript/types/nested-types.src.ts b/tests/fixtures/typescript/types/nested-types.src.ts new file mode 100644 index 0000000..adaf9a3 --- /dev/null +++ b/tests/fixtures/typescript/types/nested-types.src.ts @@ -0,0 +1 @@ +type Foo = [number, string?, boolean?] | [{}, [number?] | null & boolean[]] & {} diff --git a/tests/fixtures/typescript/types/parenthesized-type-src.ts b/tests/fixtures/typescript/types/parenthesized-type-src.ts new file mode 100644 index 0000000..5a03e27 --- /dev/null +++ b/tests/fixtures/typescript/types/parenthesized-type-src.ts @@ -0,0 +1 @@ +type Foo = (string | number) diff --git a/tests/fixtures/typescript/types/tuple-type.src.ts b/tests/fixtures/typescript/types/tuple-type.src.ts new file mode 100644 index 0000000..75a6d8e --- /dev/null +++ b/tests/fixtures/typescript/types/tuple-type.src.ts @@ -0,0 +1 @@ +type Foo = [string, string?] diff --git a/tests/fixtures/typescript/types/union-type.src.ts b/tests/fixtures/typescript/types/union-type.src.ts new file mode 100644 index 0000000..a2cfaf9 --- /dev/null +++ b/tests/fixtures/typescript/types/union-type.src.ts @@ -0,0 +1 @@ +type Foo = string & number diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index edcf3d4..70e33b8 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -70986,3 +70986,2293 @@ Object { "type": "Program", } `; + +exports[`typescript fixtures/types/array-type.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "elementType": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSStringKeyword", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 19, + ], + "type": "TSArrayType", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 20, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "]", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/intersection-type.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "LinkedList", + "range": Array [ + 5, + 15, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 49, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 49, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 48, + ], + "type": "TSIntersectionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 21, + 22, + ], + "type": "Identifier", + }, + }, + Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "members": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "name": "next", + "range": Array [ + 27, + 31, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 46, + ], + "type": "TSPropertySignature", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 46, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 46, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "name": "LinkedList", + "range": Array [ + 33, + 43, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 44, + "line": 1, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 44, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 44, + 45, + ], + "type": "Identifier", + }, + }, + ], + "range": Array [ + 43, + 46, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + }, + }, + ], + "range": Array [ + 25, + 48, + ], + "type": "TSTypeLiteral", + }, + ], + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 16, + 17, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 15, + 18, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 50, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 15, + ], + "type": "Identifier", + "value": "LinkedList", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": "&", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 31, + ], + "type": "Identifier", + "value": "next", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 43, + ], + "type": "Identifier", + "value": "LinkedList", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 44, + "line": 1, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 45, + "line": 1, + }, + }, + "range": Array [ + 45, + 46, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 49, + "line": 1, + }, + "start": Object { + "column": 48, + "line": 1, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/nested-types.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 80, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 80, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 80, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 80, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "elementTypes": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "TSNumberKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 27, + ], + "type": "TSOptionalType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 26, + ], + "type": "TSStringKeyword", + }, + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 37, + ], + "type": "TSOptionalType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 36, + ], + "type": "TSBooleanKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 38, + ], + "type": "TSTupleType", + }, + Object { + "loc": Object { + "end": Object { + "column": 80, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 80, + ], + "type": "TSIntersectionType", + "types": Array [ + Object { + "elementTypes": Array [ + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "members": Array [], + "range": Array [ + 42, + 44, + ], + "type": "TSTypeLiteral", + }, + Object { + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 74, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "elementTypes": Array [ + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 54, + ], + "type": "TSOptionalType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 53, + ], + "type": "TSNumberKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 55, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 55, + ], + "type": "TSTupleType", + }, + Object { + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 58, + "line": 1, + }, + }, + "range": Array [ + 58, + 74, + ], + "type": "TSIntersectionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 62, + "line": 1, + }, + "start": Object { + "column": 58, + "line": 1, + }, + }, + "range": Array [ + 58, + 62, + ], + "type": "TSNullKeyword", + }, + Object { + "elementType": Object { + "loc": Object { + "end": Object { + "column": 72, + "line": 1, + }, + "start": Object { + "column": 65, + "line": 1, + }, + }, + "range": Array [ + 65, + 72, + ], + "type": "TSBooleanKeyword", + }, + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 65, + "line": 1, + }, + }, + "range": Array [ + 65, + 74, + ], + "type": "TSArrayType", + }, + ], + }, + ], + }, + ], + "loc": Object { + "end": Object { + "column": 75, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 75, + ], + "type": "TSTupleType", + }, + Object { + "loc": Object { + "end": Object { + "column": 80, + "line": 1, + }, + "start": Object { + "column": 78, + "line": 1, + }, + }, + "members": Array [], + "range": Array [ + 78, + 80, + ], + "type": "TSTypeLiteral", + }, + ], + }, + ], + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 81, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 26, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 36, + ], + "type": "Identifier", + "value": "boolean", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 37, + "line": 1, + }, + }, + "range": Array [ + 37, + 38, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "range": Array [ + 42, + 43, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 44, + "line": 1, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 53, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 1, + }, + "start": Object { + "column": 53, + "line": 1, + }, + }, + "range": Array [ + 53, + 54, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 55, + "line": 1, + }, + "start": Object { + "column": 54, + "line": 1, + }, + }, + "range": Array [ + 54, + 55, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 57, + "line": 1, + }, + "start": Object { + "column": 56, + "line": 1, + }, + }, + "range": Array [ + 56, + 57, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 62, + "line": 1, + }, + "start": Object { + "column": 58, + "line": 1, + }, + }, + "range": Array [ + 58, + 62, + ], + "type": "Keyword", + "value": "null", + }, + Object { + "loc": Object { + "end": Object { + "column": 64, + "line": 1, + }, + "start": Object { + "column": 63, + "line": 1, + }, + }, + "range": Array [ + 63, + 64, + ], + "type": "Punctuator", + "value": "&", + }, + Object { + "loc": Object { + "end": Object { + "column": 72, + "line": 1, + }, + "start": Object { + "column": 65, + "line": 1, + }, + }, + "range": Array [ + 65, + 72, + ], + "type": "Identifier", + "value": "boolean", + }, + Object { + "loc": Object { + "end": Object { + "column": 73, + "line": 1, + }, + "start": Object { + "column": 72, + "line": 1, + }, + }, + "range": Array [ + 72, + 73, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 73, + "line": 1, + }, + }, + "range": Array [ + 73, + 74, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 75, + "line": 1, + }, + "start": Object { + "column": 74, + "line": 1, + }, + }, + "range": Array [ + 74, + 75, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 77, + "line": 1, + }, + "start": Object { + "column": 76, + "line": 1, + }, + }, + "range": Array [ + 76, + 77, + ], + "type": "Punctuator", + "value": "&", + }, + Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 1, + }, + "start": Object { + "column": 78, + "line": 1, + }, + }, + "range": Array [ + 78, + 79, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 80, + "line": 1, + }, + "start": Object { + "column": 79, + "line": 1, + }, + }, + "range": Array [ + 79, + 80, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/tuple-type.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "elementTypes": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 27, + ], + "type": "TSOptionalType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 26, + ], + "type": "TSStringKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 28, + ], + "type": "TSTupleType", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 29, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 26, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": "]", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/union-type.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 26, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 26, + ], + "type": "TSIntersectionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 26, + ], + "type": "TSNumberKeyword", + }, + ], + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 27, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "&", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 26, + ], + "type": "Identifier", + "value": "number", + }, + ], + "type": "Program", +} +`; From 5e3498bba5281d2259a534468b0eca395eb1fb62 Mon Sep 17 00:00:00 2001 From: Armano Date: Fri, 21 Dec 2018 23:22:07 +0100 Subject: [PATCH 02/24] fix: add missing TSAbstractClassDeclaration in ast-node-types --- src/ast-node-types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ast-node-types.ts b/src/ast-node-types.ts index dce3e51..15f1319 100644 --- a/src/ast-node-types.ts +++ b/src/ast-node-types.ts @@ -96,6 +96,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = { /** * TS-prefixed nodes */ + TSAbstractClassDeclaration: 'TSAbstractClassDeclaration', TSAbstractClassProperty: 'TSAbstractClassProperty', TSAbstractKeyword: 'TSAbstractKeyword', TSAbstractMethodDefinition: 'TSAbstractMethodDefinition', From 052c0730d36a5c2cd0aab0f4a08ca348cad68b2a Mon Sep 17 00:00:00 2001 From: Armano Date: Fri, 21 Dec 2018 23:29:29 +0100 Subject: [PATCH 03/24] test: correct test for TSParenthesizedType --- ...-type-src.ts => parenthesized-type.src.ts} | 0 tests/lib/__snapshots__/typescript.ts.snap | 274 ++++++++++++++++++ 2 files changed, 274 insertions(+) rename tests/fixtures/typescript/types/{parenthesized-type-src.ts => parenthesized-type.src.ts} (100%) diff --git a/tests/fixtures/typescript/types/parenthesized-type-src.ts b/tests/fixtures/typescript/types/parenthesized-type.src.ts similarity index 100% rename from tests/fixtures/typescript/types/parenthesized-type-src.ts rename to tests/fixtures/typescript/types/parenthesized-type.src.ts diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index 70e33b8..fec4780 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -72764,6 +72764,280 @@ Object { } `; +exports[`typescript fixtures/types/parenthesized-type.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 28, + ], + "type": "TSParenthesizedType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 27, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 27, + ], + "type": "TSNumberKeyword", + }, + ], + }, + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 29, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 27, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ")", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/types/tuple-type.src 1`] = ` Object { "body": Array [ From 51e15b5712033d96dc4db3aafc9dc68d8a2dda9e Mon Sep 17 00:00:00 2001 From: Armano Date: Fri, 21 Dec 2018 23:53:32 +0100 Subject: [PATCH 04/24] fix: add missing TSBigIntKeyword to ast-node-types --- src/ast-node-types.ts | 1 + tests/ast-alignment/fixtures-to-test.ts | 8 +- .../basics/typed-keyword-bigint.src.ts | 1 + .../basics/typed-keyword-boolean.src.ts | 1 + .../basics/typed-keyword-number.src.ts | 1 + .../basics/typed-keyword-string.src.ts | 1 + tests/lib/__snapshots__/typescript.ts.snap | 596 ++++++++++++++++++ 7 files changed, 608 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/typescript/basics/typed-keyword-bigint.src.ts create mode 100644 tests/fixtures/typescript/basics/typed-keyword-boolean.src.ts create mode 100644 tests/fixtures/typescript/basics/typed-keyword-number.src.ts create mode 100644 tests/fixtures/typescript/basics/typed-keyword-string.src.ts diff --git a/src/ast-node-types.ts b/src/ast-node-types.ts index 15f1319..9dbbc2f 100644 --- a/src/ast-node-types.ts +++ b/src/ast-node-types.ts @@ -104,6 +104,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = { TSArrayType: 'TSArrayType', TSAsyncKeyword: 'TSAsyncKeyword', TSBooleanKeyword: 'TSBooleanKeyword', + TSBigIntKeyword: 'TSBigIntKeyword', TSConstructorType: 'TSConstructorType', TSConstructSignature: 'TSConstructSignature', TSDeclareKeyword: 'TSDeclareKeyword', diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index a77c268..fc157ea 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -438,7 +438,13 @@ let fixturePatternConfigsToTest = [ * Not yet supported in Babylon https://github.com/babel/babel/issues/7749 */ 'import-type', - 'import-type-with-type-parameters-in-type-reference' + 'import-type-with-type-parameters-in-type-reference', + /** + * babel is not supporting it yet + * Babel: TSTypeReference -> Identifier + * tsep: TSBigIntKeyword + */ + 'typed-keyword-bigint' ], parseWithSourceTypeModule: [ 'export-named-enum', diff --git a/tests/fixtures/typescript/basics/typed-keyword-bigint.src.ts b/tests/fixtures/typescript/basics/typed-keyword-bigint.src.ts new file mode 100644 index 0000000..c02b862 --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-bigint.src.ts @@ -0,0 +1 @@ +type Foo = bigint diff --git a/tests/fixtures/typescript/basics/typed-keyword-boolean.src.ts b/tests/fixtures/typescript/basics/typed-keyword-boolean.src.ts new file mode 100644 index 0000000..3d441e3 --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-boolean.src.ts @@ -0,0 +1 @@ +type Foo = boolean diff --git a/tests/fixtures/typescript/basics/typed-keyword-number.src.ts b/tests/fixtures/typescript/basics/typed-keyword-number.src.ts new file mode 100644 index 0000000..9133270 --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-number.src.ts @@ -0,0 +1 @@ +type Foo = number diff --git a/tests/fixtures/typescript/basics/typed-keyword-string.src.ts b/tests/fixtures/typescript/basics/typed-keyword-string.src.ts new file mode 100644 index 0000000..d508231 --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-string.src.ts @@ -0,0 +1 @@ +type Foo = string diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index fec4780..9bd650f 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -43651,6 +43651,602 @@ Object { } `; +exports[`typescript fixtures/basics/typed-keyword-bigint.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSBigIntKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "Identifier", + "value": "bigint", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/typed-keyword-boolean.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 18, + ], + "type": "TSBooleanKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 18, + ], + "type": "Identifier", + "value": "boolean", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/typed-keyword-number.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSNumberKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "Identifier", + "value": "number", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/typed-keyword-string.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSStringKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "Identifier", + "value": "string", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/typed-this.src 1`] = ` Object { "body": Array [ From d3704b1e1f309b01d63284d3f6f6055d20cb0e3e Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 22 Dec 2018 01:27:00 +0100 Subject: [PATCH 05/24] test: add test cases for true/false typed keywords --- tests/ast-alignment/fixtures-to-test.ts | 14 +- .../basics/typed-keyword-false.src.ts | 1 + .../basics/typed-keyword-true.src.ts | 1 + tests/lib/__snapshots__/typescript.ts.snap | 336 ++++++++++++++++++ 4 files changed, 351 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/typescript/basics/typed-keyword-false.src.ts create mode 100644 tests/fixtures/typescript/basics/typed-keyword-true.src.ts diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index fc157ea..bbd495f 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -444,7 +444,19 @@ let fixturePatternConfigsToTest = [ * Babel: TSTypeReference -> Identifier * tsep: TSBigIntKeyword */ - 'typed-keyword-bigint' + 'typed-keyword-bigint', + /** + * https://github.com/babel/babel/issues/9228 + * Babel: BooleanLiteral + * tsep: Literal + */ + 'typed-keyword-true', + /** + * https://github.com/babel/babel/issues/9228 + * Babel: BooleanLiteral + * tsep: Literal + */ + 'typed-keyword-false' ], parseWithSourceTypeModule: [ 'export-named-enum', diff --git a/tests/fixtures/typescript/basics/typed-keyword-false.src.ts b/tests/fixtures/typescript/basics/typed-keyword-false.src.ts new file mode 100644 index 0000000..b9c6360 --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-false.src.ts @@ -0,0 +1 @@ +type Foo = false diff --git a/tests/fixtures/typescript/basics/typed-keyword-true.src.ts b/tests/fixtures/typescript/basics/typed-keyword-true.src.ts new file mode 100644 index 0000000..6906160 --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-true.src.ts @@ -0,0 +1 @@ +type Foo = true diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index 9bd650f..065c42e 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -43949,6 +43949,174 @@ Object { } `; +exports[`typescript fixtures/basics/typed-keyword-false.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 16, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "literal": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 16, + ], + "raw": "false", + "type": "Literal", + "value": false, + }, + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 16, + ], + "type": "TSLiteralType", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 16, + ], + "type": "Boolean", + "value": "false", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/typed-keyword-number.src 1`] = ` Object { "body": Array [ @@ -44247,6 +44415,174 @@ Object { } `; +exports[`typescript fixtures/basics/typed-keyword-true.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 15, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "literal": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 15, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 15, + ], + "type": "TSLiteralType", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 16, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 15, + ], + "type": "Boolean", + "value": "true", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/typed-this.src 1`] = ` Object { "body": Array [ From 410386dbe03dc96f11049e4f7c9339664dff46c3 Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 22 Dec 2018 01:57:35 +0100 Subject: [PATCH 06/24] test: add keyword: never, null, object, symbol, undefined, unknown, void --- .../basics/typed-keyword-never.src.ts | 1 + .../basics/typed-keyword-null.src.ts | 1 + .../basics/typed-keyword-object.src.ts | 1 + .../basics/typed-keyword-symbol.src.ts | 1 + .../basics/typed-keyword-undefined.src.ts | 1 + .../basics/typed-keyword-unknown.src.ts | 1 + .../basics/typed-keyword-void.src.ts | 1 + tests/lib/__snapshots__/typescript.ts.snap | 1127 ++++++++++++++++- 8 files changed, 1092 insertions(+), 42 deletions(-) create mode 100644 tests/fixtures/typescript/basics/typed-keyword-never.src.ts create mode 100644 tests/fixtures/typescript/basics/typed-keyword-null.src.ts create mode 100644 tests/fixtures/typescript/basics/typed-keyword-object.src.ts create mode 100644 tests/fixtures/typescript/basics/typed-keyword-symbol.src.ts create mode 100644 tests/fixtures/typescript/basics/typed-keyword-undefined.src.ts create mode 100644 tests/fixtures/typescript/basics/typed-keyword-unknown.src.ts create mode 100644 tests/fixtures/typescript/basics/typed-keyword-void.src.ts diff --git a/tests/fixtures/typescript/basics/typed-keyword-never.src.ts b/tests/fixtures/typescript/basics/typed-keyword-never.src.ts new file mode 100644 index 0000000..1f2b390 --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-never.src.ts @@ -0,0 +1 @@ +type Foo = never diff --git a/tests/fixtures/typescript/basics/typed-keyword-null.src.ts b/tests/fixtures/typescript/basics/typed-keyword-null.src.ts new file mode 100644 index 0000000..da97119 --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-null.src.ts @@ -0,0 +1 @@ +type Foo = null diff --git a/tests/fixtures/typescript/basics/typed-keyword-object.src.ts b/tests/fixtures/typescript/basics/typed-keyword-object.src.ts new file mode 100644 index 0000000..0a689a9 --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-object.src.ts @@ -0,0 +1 @@ +type Foo = object diff --git a/tests/fixtures/typescript/basics/typed-keyword-symbol.src.ts b/tests/fixtures/typescript/basics/typed-keyword-symbol.src.ts new file mode 100644 index 0000000..a5d3de1 --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-symbol.src.ts @@ -0,0 +1 @@ +type Foo = symbol diff --git a/tests/fixtures/typescript/basics/typed-keyword-undefined.src.ts b/tests/fixtures/typescript/basics/typed-keyword-undefined.src.ts new file mode 100644 index 0000000..588094c --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-undefined.src.ts @@ -0,0 +1 @@ +type Foo = undefined diff --git a/tests/fixtures/typescript/basics/typed-keyword-unknown.src.ts b/tests/fixtures/typescript/basics/typed-keyword-unknown.src.ts new file mode 100644 index 0000000..cbdeb16 --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-unknown.src.ts @@ -0,0 +1 @@ +type Foo = unknown diff --git a/tests/fixtures/typescript/basics/typed-keyword-void.src.ts b/tests/fixtures/typescript/basics/typed-keyword-void.src.ts new file mode 100644 index 0000000..d62ee2c --- /dev/null +++ b/tests/fixtures/typescript/basics/typed-keyword-void.src.ts @@ -0,0 +1 @@ +type Foo = void diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index 065c42e..53e600f 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -44117,6 +44117,304 @@ Object { } `; +exports[`typescript fixtures/basics/typed-keyword-never.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 16, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 16, + ], + "type": "TSNeverKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 16, + ], + "type": "Identifier", + "value": "never", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/typed-keyword-null.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 15, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 15, + ], + "type": "TSNullKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 16, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 15, + ], + "type": "Keyword", + "value": "null", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/typed-keyword-number.src 1`] = ` Object { "body": Array [ @@ -44141,7 +44439,603 @@ Object { }, "loc": Object { "end": Object { - "column": 17, + "column": 17, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSNumberKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "Identifier", + "value": "number", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/typed-keyword-object.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSObjectKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "Identifier", + "value": "object", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/typed-keyword-string.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSStringKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "Identifier", + "value": "string", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/typed-keyword-symbol.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSSymbolKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "Identifier", + "value": "symbol", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/typed-keyword-true.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 15, "line": 1, }, "start": Object { @@ -44151,13 +45045,32 @@ Object { }, "range": Array [ 0, - 17, + 15, ], "type": "TSTypeAliasDeclaration", "typeAnnotation": Object { + "literal": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 15, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, "loc": Object { "end": Object { - "column": 17, + "column": 15, "line": 1, }, "start": Object { @@ -44167,9 +45080,9 @@ Object { }, "range": Array [ 11, - 17, + 15, ], - "type": "TSNumberKeyword", + "type": "TSLiteralType", }, }, ], @@ -44185,7 +45098,7 @@ Object { }, "range": Array [ 0, - 18, + 16, ], "sourceType": "script", "tokens": Array [ @@ -44246,7 +45159,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 17, + "column": 15, "line": 1, }, "start": Object { @@ -44256,17 +45169,166 @@ Object { }, "range": Array [ 11, - 17, + 15, + ], + "type": "Boolean", + "value": "true", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/typed-keyword-undefined.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 20, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 20, + ], + "type": "TSUndefinedKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 21, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, ], "type": "Identifier", - "value": "number", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 20, + ], + "type": "Identifier", + "value": "undefined", }, ], "type": "Program", } `; -exports[`typescript fixtures/basics/typed-keyword-string.src 1`] = ` +exports[`typescript fixtures/basics/typed-keyword-unknown.src 1`] = ` Object { "body": Array [ Object { @@ -44290,7 +45352,7 @@ Object { }, "loc": Object { "end": Object { - "column": 17, + "column": 18, "line": 1, }, "start": Object { @@ -44300,13 +45362,13 @@ Object { }, "range": Array [ 0, - 17, + 18, ], "type": "TSTypeAliasDeclaration", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 17, + "column": 18, "line": 1, }, "start": Object { @@ -44316,9 +45378,9 @@ Object { }, "range": Array [ 11, - 17, + 18, ], - "type": "TSStringKeyword", + "type": "TSUnknownKeyword", }, }, ], @@ -44334,7 +45396,7 @@ Object { }, "range": Array [ 0, - 18, + 19, ], "sourceType": "script", "tokens": Array [ @@ -44395,7 +45457,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 17, + "column": 18, "line": 1, }, "start": Object { @@ -44405,17 +45467,17 @@ Object { }, "range": Array [ 11, - 17, + 18, ], "type": "Identifier", - "value": "string", + "value": "unknown", }, ], "type": "Program", } `; -exports[`typescript fixtures/basics/typed-keyword-true.src 1`] = ` +exports[`typescript fixtures/basics/typed-keyword-void.src 1`] = ` Object { "body": Array [ Object { @@ -44453,25 +45515,6 @@ Object { ], "type": "TSTypeAliasDeclaration", "typeAnnotation": Object { - "literal": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 15, - ], - "raw": "true", - "type": "Literal", - "value": true, - }, "loc": Object { "end": Object { "column": 15, @@ -44486,7 +45529,7 @@ Object { 11, 15, ], - "type": "TSLiteralType", + "type": "TSVoidKeyword", }, }, ], @@ -44575,8 +45618,8 @@ Object { 11, 15, ], - "type": "Boolean", - "value": "true", + "type": "Keyword", + "value": "void", }, ], "type": "Program", From 672f0f8ea8dcaea3ba36574f587cc5f96c2cfb29 Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 22 Dec 2018 05:54:28 +0100 Subject: [PATCH 07/24] chore: add links to issues --- tests/ast-alignment/fixtures-to-test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index bbd495f..2fef0a8 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -440,19 +440,19 @@ let fixturePatternConfigsToTest = [ 'import-type', 'import-type-with-type-parameters-in-type-reference', /** - * babel is not supporting it yet + * babel is not supporting it yet https://github.com/babel/babel/pull/9230 * Babel: TSTypeReference -> Identifier * tsep: TSBigIntKeyword */ 'typed-keyword-bigint', /** - * https://github.com/babel/babel/issues/9228 + * Awaiting feedback on Babel issue https://github.com/babel/babel/issues/9228 * Babel: BooleanLiteral * tsep: Literal */ 'typed-keyword-true', /** - * https://github.com/babel/babel/issues/9228 + * Not yet supported in Babel https://github.com/babel/babel/issues/9228 * Babel: BooleanLiteral * tsep: Literal */ From 010f0cb63e04aefe6f0b2f956a14a7dc3180f471 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 23 Dec 2018 02:27:18 +0100 Subject: [PATCH 08/24] fix: add missing BigIntKeyword to isTypeKeyword --- src/node-utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node-utils.ts b/src/node-utils.ts index bc35214..3a7b7d6 100644 --- a/src/node-utils.ts +++ b/src/node-utils.ts @@ -337,6 +337,7 @@ function isTypeKeyword(kind: number): boolean { switch (kind) { case SyntaxKind.AnyKeyword: case SyntaxKind.BooleanKeyword: + case SyntaxKind.BigIntKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.NumberKeyword: case SyntaxKind.ObjectKeyword: From aa048d8beba855ea602b9975d601d0428aae5808 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 23 Dec 2018 03:43:02 +0100 Subject: [PATCH 09/24] fix: correct detection of destructing assigment --- src/convert.ts | 34 +- tests/ast-alignment/fixtures-to-test.ts | 16 +- .../defaults-object-assign.src.js | 1 + .../destructuring-assignment-nested.src.ts | 1 + .../destructuring-assignment-object.src.ts | 1 + .../destructuring-assignment-property.src.ts | 3 + tests/lib/__snapshots__/javascript.ts.snap | 535 +++ tests/lib/__snapshots__/typescript.ts.snap | 3095 ++++++++++++++++- 8 files changed, 3660 insertions(+), 26 deletions(-) create mode 100644 tests/fixtures/javascript/destructuring/defaults-object-assign.src.js create mode 100644 tests/fixtures/typescript/basics/destructuring-assignment-nested.src.ts create mode 100644 tests/fixtures/typescript/basics/destructuring-assignment-object.src.ts create mode 100644 tests/fixtures/typescript/basics/destructuring-assignment-property.src.ts diff --git a/src/convert.ts b/src/convert.ts index d93f3d3..00c36f3 100644 --- a/src/convert.ts +++ b/src/convert.ts @@ -799,7 +799,9 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { let arrayIsInAssignment; if (arrayAssignNode) { - if (node.parent.kind === SyntaxKind.CallExpression) { + if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { + arrayIsInAssignment = false; + } else if (node.parent.kind === SyntaxKind.CallExpression) { arrayIsInAssignment = false; } else if ( nodeUtils.getBinaryExpressionType( @@ -849,7 +851,9 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { let objectIsInAssignment = false; if (objectAssignNode) { - if ((objectAssignNode as any).left === node) { + if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { + objectIsInAssignment = false; + } else if ((objectAssignNode as any).left === node) { objectIsInAssignment = true; } else if (node.parent.kind === SyntaxKind.CallExpression) { objectIsInAssignment = false; @@ -1576,7 +1580,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { const openBrace = nodeUtils.findNextToken(lastClassToken, ast, ast)!; const superClass = heritageClauses.find( - (clause: any) => clause.token === SyntaxKind.ExtendsKeyword + clause => clause.token === SyntaxKind.ExtendsKeyword ); if (superClass) { @@ -1596,7 +1600,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { } const implementsClause = heritageClauses.find( - (clause: any) => clause.token === SyntaxKind.ImplementsKeyword + clause => clause.token === SyntaxKind.ImplementsKeyword ); Object.assign(result, { @@ -1849,16 +1853,18 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { // if the binary expression is in a destructured array, switch it if (result.type === AST_NODE_TYPES.AssignmentExpression) { - const upperArrayNode = nodeUtils.findAncestorOfKind( - node, - SyntaxKind.ArrayLiteralExpression - ), - upperArrayAssignNode = - upperArrayNode && - nodeUtils.findAncestorOfKind( - upperArrayNode, - SyntaxKind.BinaryExpression - ); + const upperArrayNode = nodeUtils.findFirstMatchingAncestor( + node, + parent => + parent.kind === SyntaxKind.ArrayLiteralExpression || + parent.kind === SyntaxKind.ObjectLiteralExpression + ); + const upperArrayAssignNode = + upperArrayNode && + nodeUtils.findAncestorOfKind( + upperArrayNode, + SyntaxKind.BinaryExpression + ); let upperArrayIsInAssignment; diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index 2fef0a8..6e674bc 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -200,6 +200,8 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('javascript/experimentalDynamicImport'), createFixturePatternConfigFor('javascript/exponentiationOperators'), + createFixturePatternConfigFor('javascript/experimentalOptionalCatchBinding'), + createFixturePatternConfigFor('javascript/forOf', { ignore: [ /** @@ -295,6 +297,8 @@ let fixturePatternConfigsToTest = [ ] }), + createFixturePatternConfigFor('javascript/objectLiteral'), + createFixturePatternConfigFor('javascript/objectLiteralComputedProperties'), createFixturePatternConfigFor('javascript/objectLiteralDuplicateProperties', { @@ -345,11 +349,7 @@ let fixturePatternConfigsToTest = [ /** * AST difference */ - 'react-typed-props', - /** - * currently babylon not supported - */ - 'generic-jsx-element' + 'react-typed-props' ] }), @@ -415,12 +415,6 @@ let fixturePatternConfigsToTest = [ 'export-type-function-declaration', 'abstract-interface', 'keyof-operator', - /** - * tsep bug - Program.body[0].expression.left.properties[0].value.right is currently showing up - * as `ArrayPattern`, babylon, acorn and espree say it should be `ArrayExpression` - * TODO: Fix this - */ - 'destructuring-assignment', /** * Babylon bug for optional or abstract methods? */ diff --git a/tests/fixtures/javascript/destructuring/defaults-object-assign.src.js b/tests/fixtures/javascript/destructuring/defaults-object-assign.src.js new file mode 100644 index 0000000..4f84af4 --- /dev/null +++ b/tests/fixtures/javascript/destructuring/defaults-object-assign.src.js @@ -0,0 +1 @@ +({ Object=0, String=0 } = {}) diff --git a/tests/fixtures/typescript/basics/destructuring-assignment-nested.src.ts b/tests/fixtures/typescript/basics/destructuring-assignment-nested.src.ts new file mode 100644 index 0000000..0c7c1bf --- /dev/null +++ b/tests/fixtures/typescript/basics/destructuring-assignment-nested.src.ts @@ -0,0 +1 @@ +({ foo: { bar: { baz: [a, { foo: [x] = [3] } = { foo: [2]}] = [] } = {} } = { } } = { foo: { bar: { baz: [2, { foo: [3] }] } }}); diff --git a/tests/fixtures/typescript/basics/destructuring-assignment-object.src.ts b/tests/fixtures/typescript/basics/destructuring-assignment-object.src.ts new file mode 100644 index 0000000..29aaf2c --- /dev/null +++ b/tests/fixtures/typescript/basics/destructuring-assignment-object.src.ts @@ -0,0 +1 @@ +({ foo = {} } = bar); diff --git a/tests/fixtures/typescript/basics/destructuring-assignment-property.src.ts b/tests/fixtures/typescript/basics/destructuring-assignment-property.src.ts new file mode 100644 index 0000000..2958638 --- /dev/null +++ b/tests/fixtures/typescript/basics/destructuring-assignment-property.src.ts @@ -0,0 +1,3 @@ +function Foo({ foo = [] } = bar) { + +} diff --git a/tests/lib/__snapshots__/javascript.ts.snap b/tests/lib/__snapshots__/javascript.ts.snap index eaad453..0e7dfb2 100644 --- a/tests/lib/__snapshots__/javascript.ts.snap +++ b/tests/lib/__snapshots__/javascript.ts.snap @@ -38903,6 +38903,541 @@ Object { } `; +exports[`javascript fixtures/destructuring/defaults-object-assign.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "name": "Object", + "range": Array [ + 3, + 9, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 3, + 11, + ], + "shorthand": true, + "type": "Property", + "value": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "name": "Object", + "range": Array [ + 3, + 9, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 11, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "raw": "0", + "type": "Literal", + "value": 0, + }, + "type": "AssignmentPattern", + }, + }, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "String", + "range": Array [ + 13, + 19, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 13, + 21, + ], + "shorthand": true, + "type": "Property", + "value": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "String", + "range": Array [ + 13, + 19, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 21, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "raw": "0", + "type": "Literal", + "value": 0, + }, + "type": "AssignmentPattern", + }, + }, + ], + "range": Array [ + 1, + 23, + ], + "type": "ObjectPattern", + }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "operator": "=", + "range": Array [ + 1, + 28, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "properties": Array [], + "range": Array [ + 26, + 28, + ], + "type": "ObjectExpression", + }, + "type": "AssignmentExpression", + }, + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 29, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 30, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 1, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 2, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 9, + ], + "type": "Identifier", + "value": "Object", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Numeric", + "value": "0", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 19, + ], + "type": "Identifier", + "value": "String", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Numeric", + "value": "0", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 29, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 29, + ], + "type": "Punctuator", + "value": ")", + }, + ], + "type": "Program", +} +`; + exports[`javascript fixtures/destructuring/defaults-object-longform.src 1`] = ` Object { "body": Array [ diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index 53e600f..39cf13a 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -21030,7 +21030,7 @@ Object { 9, 11, ], - "type": "ArrayPattern", + "type": "ArrayExpression", }, "type": "AssignmentPattern", }, @@ -21313,6 +21313,3099 @@ Object { } `; +exports[`typescript fixtures/basics/destructuring-assignment-nested.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 81, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 3, + 6, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 79, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 3, + 79, + ], + "shorthand": false, + "type": "Property", + "value": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 73, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": "bar", + "range": Array [ + 10, + 13, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 71, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 10, + 71, + ], + "shorthand": false, + "type": "Property", + "value": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 66, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "name": "baz", + "range": Array [ + 17, + 20, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 64, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 17, + 64, + ], + "shorthand": false, + "type": "Property", + "value": Object { + "left": Object { + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 23, + 24, + ], + "type": "Identifier", + }, + Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 28, + 31, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 28, + 42, + ], + "shorthand": false, + "type": "Property", + "value": Object { + "left": Object { + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 34, + 35, + ], + "type": "Identifier", + }, + ], + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 36, + ], + "type": "ArrayPattern", + }, + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 42, + ], + "right": Object { + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 1, + }, + "start": Object { + "column": 40, + "line": 1, + }, + }, + "range": Array [ + 40, + 41, + ], + "raw": "3", + "type": "Literal", + "value": 3, + }, + ], + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 42, + ], + "type": "ArrayExpression", + }, + "type": "AssignmentPattern", + }, + }, + ], + "range": Array [ + 26, + 44, + ], + "type": "ObjectPattern", + }, + "loc": Object { + "end": Object { + "column": 58, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 58, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 58, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 52, + "line": 1, + }, + "start": Object { + "column": 49, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 49, + 52, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 57, + "line": 1, + }, + "start": Object { + "column": 49, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 49, + 57, + ], + "shorthand": false, + "type": "Property", + "value": Object { + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 1, + }, + "start": Object { + "column": 55, + "line": 1, + }, + }, + "range": Array [ + 55, + 56, + ], + "raw": "2", + "type": "Literal", + "value": 2, + }, + ], + "loc": Object { + "end": Object { + "column": 57, + "line": 1, + }, + "start": Object { + "column": 54, + "line": 1, + }, + }, + "range": Array [ + 54, + 57, + ], + "type": "ArrayExpression", + }, + }, + ], + "range": Array [ + 47, + 58, + ], + "type": "ObjectExpression", + }, + "type": "AssignmentPattern", + }, + ], + "loc": Object { + "end": Object { + "column": 59, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 59, + ], + "type": "ArrayPattern", + }, + "loc": Object { + "end": Object { + "column": 64, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 64, + ], + "right": Object { + "elements": Array [], + "loc": Object { + "end": Object { + "column": 64, + "line": 1, + }, + "start": Object { + "column": 62, + "line": 1, + }, + }, + "range": Array [ + 62, + 64, + ], + "type": "ArrayExpression", + }, + "type": "AssignmentPattern", + }, + }, + ], + "range": Array [ + 15, + 66, + ], + "type": "ObjectPattern", + }, + "loc": Object { + "end": Object { + "column": 71, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 71, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 71, + "line": 1, + }, + "start": Object { + "column": 69, + "line": 1, + }, + }, + "properties": Array [], + "range": Array [ + 69, + 71, + ], + "type": "ObjectExpression", + }, + "type": "AssignmentPattern", + }, + }, + ], + "range": Array [ + 8, + 73, + ], + "type": "ObjectPattern", + }, + "loc": Object { + "end": Object { + "column": 79, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 79, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 1, + }, + "start": Object { + "column": 76, + "line": 1, + }, + }, + "properties": Array [], + "range": Array [ + 76, + 79, + ], + "type": "ObjectExpression", + }, + "type": "AssignmentPattern", + }, + }, + ], + "range": Array [ + 1, + 81, + ], + "type": "ObjectPattern", + }, + "loc": Object { + "end": Object { + "column": 127, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "operator": "=", + "range": Array [ + 1, + 127, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 127, + "line": 1, + }, + "start": Object { + "column": 84, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 89, + "line": 1, + }, + "start": Object { + "column": 86, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 86, + 89, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 126, + "line": 1, + }, + "start": Object { + "column": 86, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 86, + 126, + ], + "shorthand": false, + "type": "Property", + "value": Object { + "loc": Object { + "end": Object { + "column": 126, + "line": 1, + }, + "start": Object { + "column": 91, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 96, + "line": 1, + }, + "start": Object { + "column": 93, + "line": 1, + }, + }, + "name": "bar", + "range": Array [ + 93, + 96, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 124, + "line": 1, + }, + "start": Object { + "column": 93, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 93, + 124, + ], + "shorthand": false, + "type": "Property", + "value": Object { + "loc": Object { + "end": Object { + "column": 124, + "line": 1, + }, + "start": Object { + "column": 98, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 103, + "line": 1, + }, + "start": Object { + "column": 100, + "line": 1, + }, + }, + "name": "baz", + "range": Array [ + 100, + 103, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 122, + "line": 1, + }, + "start": Object { + "column": 100, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 100, + 122, + ], + "shorthand": false, + "type": "Property", + "value": Object { + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 107, + "line": 1, + }, + "start": Object { + "column": 106, + "line": 1, + }, + }, + "range": Array [ + 106, + 107, + ], + "raw": "2", + "type": "Literal", + "value": 2, + }, + Object { + "loc": Object { + "end": Object { + "column": 121, + "line": 1, + }, + "start": Object { + "column": 109, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 114, + "line": 1, + }, + "start": Object { + "column": 111, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 111, + 114, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 119, + "line": 1, + }, + "start": Object { + "column": 111, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 111, + 119, + ], + "shorthand": false, + "type": "Property", + "value": Object { + "elements": Array [ + Object { + "loc": Object { + "end": Object { + "column": 118, + "line": 1, + }, + "start": Object { + "column": 117, + "line": 1, + }, + }, + "range": Array [ + 117, + 118, + ], + "raw": "3", + "type": "Literal", + "value": 3, + }, + ], + "loc": Object { + "end": Object { + "column": 119, + "line": 1, + }, + "start": Object { + "column": 116, + "line": 1, + }, + }, + "range": Array [ + 116, + 119, + ], + "type": "ArrayExpression", + }, + }, + ], + "range": Array [ + 109, + 121, + ], + "type": "ObjectExpression", + }, + ], + "loc": Object { + "end": Object { + "column": 122, + "line": 1, + }, + "start": Object { + "column": 105, + "line": 1, + }, + }, + "range": Array [ + 105, + 122, + ], + "type": "ArrayExpression", + }, + }, + ], + "range": Array [ + 98, + 124, + ], + "type": "ObjectExpression", + }, + }, + ], + "range": Array [ + 91, + 126, + ], + "type": "ObjectExpression", + }, + }, + ], + "range": Array [ + 84, + 127, + ], + "type": "ObjectExpression", + }, + "type": "AssignmentExpression", + }, + "loc": Object { + "end": Object { + "column": 129, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 129, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 130, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 1, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 2, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 6, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 13, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 20, + ], + "type": "Identifier", + "value": "baz", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 31, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 37, + "line": 1, + }, + }, + "range": Array [ + 37, + 38, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 1, + }, + "start": Object { + "column": 40, + "line": 1, + }, + }, + "range": Array [ + 40, + 41, + ], + "type": "Numeric", + "value": "3", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 45, + "line": 1, + }, + }, + "range": Array [ + 45, + 46, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 52, + "line": 1, + }, + "start": Object { + "column": 49, + "line": 1, + }, + }, + "range": Array [ + 49, + 52, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 1, + }, + "start": Object { + "column": 52, + "line": 1, + }, + }, + "range": Array [ + 52, + 53, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 55, + "line": 1, + }, + "start": Object { + "column": 54, + "line": 1, + }, + }, + "range": Array [ + 54, + 55, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 56, + "line": 1, + }, + "start": Object { + "column": 55, + "line": 1, + }, + }, + "range": Array [ + 55, + 56, + ], + "type": "Numeric", + "value": "2", + }, + Object { + "loc": Object { + "end": Object { + "column": 57, + "line": 1, + }, + "start": Object { + "column": 56, + "line": 1, + }, + }, + "range": Array [ + 56, + 57, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 58, + "line": 1, + }, + "start": Object { + "column": 57, + "line": 1, + }, + }, + "range": Array [ + 57, + 58, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 59, + "line": 1, + }, + "start": Object { + "column": 58, + "line": 1, + }, + }, + "range": Array [ + 58, + 59, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 61, + "line": 1, + }, + "start": Object { + "column": 60, + "line": 1, + }, + }, + "range": Array [ + 60, + 61, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 63, + "line": 1, + }, + "start": Object { + "column": 62, + "line": 1, + }, + }, + "range": Array [ + 62, + 63, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 64, + "line": 1, + }, + "start": Object { + "column": 63, + "line": 1, + }, + }, + "range": Array [ + 63, + 64, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 66, + "line": 1, + }, + "start": Object { + "column": 65, + "line": 1, + }, + }, + "range": Array [ + 65, + 66, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 68, + "line": 1, + }, + "start": Object { + "column": 67, + "line": 1, + }, + }, + "range": Array [ + 67, + 68, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 70, + "line": 1, + }, + "start": Object { + "column": 69, + "line": 1, + }, + }, + "range": Array [ + 69, + 70, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 71, + "line": 1, + }, + "start": Object { + "column": 70, + "line": 1, + }, + }, + "range": Array [ + 70, + 71, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 73, + "line": 1, + }, + "start": Object { + "column": 72, + "line": 1, + }, + }, + "range": Array [ + 72, + 73, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 75, + "line": 1, + }, + "start": Object { + "column": 74, + "line": 1, + }, + }, + "range": Array [ + 74, + 75, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 77, + "line": 1, + }, + "start": Object { + "column": 76, + "line": 1, + }, + }, + "range": Array [ + 76, + 77, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 1, + }, + "start": Object { + "column": 78, + "line": 1, + }, + }, + "range": Array [ + 78, + 79, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 81, + "line": 1, + }, + "start": Object { + "column": 80, + "line": 1, + }, + }, + "range": Array [ + 80, + 81, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 83, + "line": 1, + }, + "start": Object { + "column": 82, + "line": 1, + }, + }, + "range": Array [ + 82, + 83, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 85, + "line": 1, + }, + "start": Object { + "column": 84, + "line": 1, + }, + }, + "range": Array [ + 84, + 85, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 89, + "line": 1, + }, + "start": Object { + "column": 86, + "line": 1, + }, + }, + "range": Array [ + 86, + 89, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 90, + "line": 1, + }, + "start": Object { + "column": 89, + "line": 1, + }, + }, + "range": Array [ + 89, + 90, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 92, + "line": 1, + }, + "start": Object { + "column": 91, + "line": 1, + }, + }, + "range": Array [ + 91, + 92, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 96, + "line": 1, + }, + "start": Object { + "column": 93, + "line": 1, + }, + }, + "range": Array [ + 93, + 96, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 97, + "line": 1, + }, + "start": Object { + "column": 96, + "line": 1, + }, + }, + "range": Array [ + 96, + 97, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 99, + "line": 1, + }, + "start": Object { + "column": 98, + "line": 1, + }, + }, + "range": Array [ + 98, + 99, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 103, + "line": 1, + }, + "start": Object { + "column": 100, + "line": 1, + }, + }, + "range": Array [ + 100, + 103, + ], + "type": "Identifier", + "value": "baz", + }, + Object { + "loc": Object { + "end": Object { + "column": 104, + "line": 1, + }, + "start": Object { + "column": 103, + "line": 1, + }, + }, + "range": Array [ + 103, + 104, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 106, + "line": 1, + }, + "start": Object { + "column": 105, + "line": 1, + }, + }, + "range": Array [ + 105, + 106, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 107, + "line": 1, + }, + "start": Object { + "column": 106, + "line": 1, + }, + }, + "range": Array [ + 106, + 107, + ], + "type": "Numeric", + "value": "2", + }, + Object { + "loc": Object { + "end": Object { + "column": 108, + "line": 1, + }, + "start": Object { + "column": 107, + "line": 1, + }, + }, + "range": Array [ + 107, + 108, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 110, + "line": 1, + }, + "start": Object { + "column": 109, + "line": 1, + }, + }, + "range": Array [ + 109, + 110, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 114, + "line": 1, + }, + "start": Object { + "column": 111, + "line": 1, + }, + }, + "range": Array [ + 111, + 114, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 115, + "line": 1, + }, + "start": Object { + "column": 114, + "line": 1, + }, + }, + "range": Array [ + 114, + 115, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 117, + "line": 1, + }, + "start": Object { + "column": 116, + "line": 1, + }, + }, + "range": Array [ + 116, + 117, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 118, + "line": 1, + }, + "start": Object { + "column": 117, + "line": 1, + }, + }, + "range": Array [ + 117, + 118, + ], + "type": "Numeric", + "value": "3", + }, + Object { + "loc": Object { + "end": Object { + "column": 119, + "line": 1, + }, + "start": Object { + "column": 118, + "line": 1, + }, + }, + "range": Array [ + 118, + 119, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 121, + "line": 1, + }, + "start": Object { + "column": 120, + "line": 1, + }, + }, + "range": Array [ + 120, + 121, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 122, + "line": 1, + }, + "start": Object { + "column": 121, + "line": 1, + }, + }, + "range": Array [ + 121, + 122, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 124, + "line": 1, + }, + "start": Object { + "column": 123, + "line": 1, + }, + }, + "range": Array [ + 123, + 124, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 126, + "line": 1, + }, + "start": Object { + "column": 125, + "line": 1, + }, + }, + "range": Array [ + 125, + 126, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 127, + "line": 1, + }, + "start": Object { + "column": 126, + "line": 1, + }, + }, + "range": Array [ + 126, + 127, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 128, + "line": 1, + }, + "start": Object { + "column": 127, + "line": 1, + }, + }, + "range": Array [ + 127, + 128, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 129, + "line": 1, + }, + "start": Object { + "column": 128, + "line": 1, + }, + }, + "range": Array [ + 128, + 129, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/destructuring-assignment-object.src 1`] = ` +Object { + "body": Array [ + Object { + "expression": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 3, + 6, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 3, + 11, + ], + "shorthand": true, + "type": "Property", + "value": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 3, + 6, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 11, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "properties": Array [], + "range": Array [ + 9, + 11, + ], + "type": "ObjectExpression", + }, + "type": "AssignmentPattern", + }, + }, + ], + "range": Array [ + 1, + 13, + ], + "type": "ObjectPattern", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "operator": "=", + "range": Array [ + 1, + 19, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "name": "bar", + "range": Array [ + 16, + 19, + ], + "type": "Identifier", + }, + "type": "AssignmentExpression", + }, + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 21, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 22, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 1, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 1, + "line": 1, + }, + }, + "range": Array [ + 1, + 2, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 6, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 19, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/destructuring-assignment-property.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 37, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "properties": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 15, + 18, + ], + "type": "Identifier", + }, + "kind": "init", + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "method": false, + "range": Array [ + 15, + 23, + ], + "shorthand": true, + "type": "Property", + "value": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 15, + 18, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 23, + ], + "right": Object { + "elements": Array [], + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 23, + ], + "type": "ArrayExpression", + }, + "type": "AssignmentPattern", + }, + }, + ], + "range": Array [ + 13, + 25, + ], + "type": "ObjectPattern", + }, + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 31, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "name": "bar", + "range": Array [ + 28, + 31, + ], + "type": "Identifier", + }, + "type": "AssignmentPattern", + }, + ], + "range": Array [ + 0, + 37, + ], + "type": "FunctionDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 38, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 18, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 28, + "line": 1, + }, + }, + "range": Array [ + 28, + 31, + ], + "type": "Identifier", + "value": "bar", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/export-assignment.src 1`] = ` Object { "body": Array [ From 4061041d09630f3706d5da62cffbc912216d397a Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 23 Dec 2018 15:35:17 +0100 Subject: [PATCH 10/24] test: enable tests --- tests/ast-alignment/fixtures-to-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index 6e674bc..cb92d47 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -105,7 +105,7 @@ function createFixturePatternConfigFor( * An array of FixturePatternConfigs */ let fixturePatternConfigsToTest = [ - createFixturePatternConfigFor('basics'), + createFixturePatternConfigFor('javascript/basics'), createFixturePatternConfigFor('comments', { ignore: [ From 9e3a7b43a6ac7f05a0aaf18af3160b0cdbd232dc Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 23 Dec 2018 18:26:44 +0100 Subject: [PATCH 11/24] test: change babel sourceType to unambiguous --- package.json | 2 +- tests/ast-alignment/fixtures-to-test.ts | 237 ++----- tests/ast-alignment/parse.ts | 6 +- tests/ast-alignment/spec.ts | 34 +- tests/ast-alignment/utils.ts | 9 +- yarn.lock | 820 ++++++++++++------------ 6 files changed, 514 insertions(+), 594 deletions(-) diff --git a/package.json b/package.json index 2199885..49b519e 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "BSD-2-Clause", "devDependencies": { "@babel/code-frame": "7.0.0", - "@babel/parser": "7.1.6", + "@babel/parser": "7.2.3", "@commitlint/cli": "^7.1.2", "@commitlint/config-conventional": "^7.1.2", "@commitlint/travis-cli": "^7.1.2", diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index cb92d47..5b01c20 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -1,29 +1,23 @@ import glob from 'glob'; +import fs from 'fs'; import path from 'path'; + import jsxKnownIssues from '../jsx-known-issues'; -import { ParserOptions as BabelParserOptions } from '@babel/parser'; -import { ParserOptions } from '../../src/temp-types-based-on-js-source'; interface Fixture { filename: string; - config?: { - babelParserOptions?: BabelParserOptions; - typeScriptESTreeOptions?: ParserOptions; - }; + ignoreSourceType: boolean; } interface FixturePatternConfig { pattern: string; - config?: { - babelParserOptions?: BabelParserOptions; - typeScriptESTreeOptions?: ParserOptions; - }; + ignoreSourceType: boolean; } interface CreateFixturePatternConfig { ignore?: string[]; fileType?: string; - parseWithSourceTypeModule?: string[]; + ignoreSourceType?: string[]; } /** @@ -66,7 +60,7 @@ function createFixturePatternConfigFor( config = config || ({} as CreateFixturePatternConfig); config.ignore = config.ignore || []; config.fileType = config.fileType || 'js'; - config.parseWithSourceTypeModule = config.parseWithSourceTypeModule || []; + config.ignoreSourceType = config.ignoreSourceType || []; /** * The TypeScript compiler gives us the "externalModuleIndicator" to allow typescript-estree do dynamically detect the "sourceType". * Babylon does not have an equivalent feature (although perhaps it might come in the future https://github.com/babel/babylon/issues/440), @@ -77,27 +71,24 @@ function createFixturePatternConfigFor( * First merge the fixtures which need to be parsed with sourceType: "module" into the * ignore list, and then add their full config into the global array. */ - if (config.parseWithSourceTypeModule.length) { + if (config.ignoreSourceType.length) { config.ignore = ([] as string[]).concat( config.ignore, - config.parseWithSourceTypeModule + config.ignoreSourceType ); - for (const fixture of config.parseWithSourceTypeModule) { + for (const fixture of config.ignoreSourceType) { fixturesRequiringSourceTypeModule.push({ // It needs to be the full path from within fixtures/ for the pattern pattern: `${fixturesSubPath}/${fixture}.src.${config.fileType}`, - config: { - babelParserOptions: { - sourceType: 'module' - } - } + ignoreSourceType: true }); } } return { pattern: `${fixturesSubPath}/!(${config.ignore.join('|')}).src.${ config.fileType - }` + }`, + ignoreSourceType: false }; } @@ -109,10 +100,9 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('comments', { ignore: [ - 'export-default-anonymous-class', // needs to be parsed with `sourceType: "module"` /** * Template strings seem to also be affected by the difference in opinion between different parsers in: - * https://github.com/babel/babylon/issues/673 + * https://github.com/babel/babel/issues/6681 */ 'no-comment-template', // Purely AST diffs 'template-string-block' // Purely AST diffs @@ -126,7 +116,7 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('javascript/experimentalObjectRestSpread', { ignore: [ /** - * Trailing comma is not permitted after a "RestElement" in Babylon + * Trailing comma is not permitted after a "RestElement" in Babel */ 'invalid-rest-trailing-comma' ] @@ -139,11 +129,10 @@ let fixturePatternConfigsToTest = [ * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ - 'error-dup-params', // babylon parse errors - 'error-dup-params', // babylon parse errors - 'error-strict-dup-params', // babylon parse errors - 'error-strict-octal', // babylon parse errors - 'error-two-lines' // babylon parse errors + 'error-dup-params', // babel parse errors + 'error-strict-dup-params', // babel parse errors + 'error-strict-octal', // babel parse errors + 'error-two-lines' // babel parse errors ] }), @@ -156,14 +145,14 @@ let fixturePatternConfigsToTest = [ /** * super() is being used outside of constructor. Other parsers (e.g. espree, acorn) do not error on this. */ - 'class-one-method-super', // babylon parse errors + 'class-one-method-super', // babel parse errors /** * Expected babylon parse errors - all of these files below produce parse errors in espree * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ - 'invalid-class-declaration', // babylon parse errors - 'invalid-class-setter-declaration' // babylon parse errors + 'invalid-class-declaration', // babel parse errors + 'invalid-class-setter-declaration' // babel parse errors ] }), @@ -176,7 +165,7 @@ let fixturePatternConfigsToTest = [ * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ - 'invalid-defaults-object-assign' // babylon parse errors + 'invalid-defaults-object-assign' // babel parse errors ] }), @@ -192,14 +181,13 @@ let fixturePatternConfigsToTest = [ * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ - 'error-complex-destructured-spread-first' // babylon parse errors + 'error-complex-destructured-spread-first' // babel parse errors ] }), createFixturePatternConfigFor('javascript/experimentalAsyncIteration'), createFixturePatternConfigFor('javascript/experimentalDynamicImport'), createFixturePatternConfigFor('javascript/exponentiationOperators'), - createFixturePatternConfigFor('javascript/experimentalOptionalCatchBinding'), createFixturePatternConfigFor('javascript/forOf', { @@ -207,7 +195,7 @@ let fixturePatternConfigsToTest = [ /** * TypeScript, espree and acorn parse this fine - esprima, flow and babylon do not... */ - 'for-of-with-function-initializer' // babylon parse errors + 'for-of-with-function-initializer' // babel parse errors ] }), @@ -216,73 +204,16 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('javascript/modules', { ignore: [ - /** - * TypeScript, flow and babylon parse this fine - esprima, espree and acorn do not... - */ - 'invalid-export-default', // typescript-estree parse errors /** * Expected babylon parse errors - all of these files below produce parse errors in espree * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ - 'invalid-export-named-default', // babylon parse errors - 'invalid-import-default-module-specifier', // babylon parse errors - 'invalid-import-module-specifier', // babylon parse errors - /** - * Deleting local variable in strict mode - */ - 'error-delete', // babylon parse errors - /** - * 'with' in strict mode - */ - 'error-strict' // babylon parse errors + 'invalid-export-named-default', // babel parse errors + 'invalid-import-default-module-specifier', // babel parse errors + 'invalid-import-module-specifier' // babel parse errors ], - parseWithSourceTypeModule: [ - 'export-default-array', - 'export-default-class', - 'export-default-expression', - 'export-default-function', - 'export-default-named-class', - 'export-default-named-function', - 'export-default-number', - 'export-default-object', - 'export-default-value', - 'export-from-batch', - 'export-from-default', - 'export-from-named-as-default', - 'export-from-named-as-specifier', - 'export-from-named-as-specifiers', - 'export-from-specifier', - 'export-from-specifiers', - 'export-function', - 'export-named-as-default', - 'export-named-as-specifier', - 'export-named-as-specifiers', - 'export-named-class', - 'export-named-empty', - 'export-named-specifier', - 'export-named-specifiers-comma', - 'export-named-specifiers', - 'export-var-anonymous-function', - 'export-var-number', - 'export-var', - 'import-default-and-named-specifiers', - 'import-default-and-namespace-specifiers', - 'import-default-as', - 'import-default', - 'import-jquery', - 'import-module', - 'import-named-as-specifier', - 'import-named-as-specifiers', - 'import-named-empty', - 'import-named-specifier', - 'import-named-specifiers-comma', - 'import-named-specifiers', - 'import-namespace-specifier', - 'import-null-as-nil', - 'invalid-await', - 'invalid-class' - ] + ignoreSourceType: ['error-function', 'error-strict', 'error-delete'] }), createFixturePatternConfigFor('javascript/newTarget', { @@ -292,13 +223,12 @@ let fixturePatternConfigsToTest = [ * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ - 'invalid-new-target', // babylon parse errors - 'invalid-unknown-property' // babylon parse errors + 'invalid-new-target', // babel parse errors + 'invalid-unknown-property' // babel parse errors ] }), createFixturePatternConfigFor('javascript/objectLiteral'), - createFixturePatternConfigFor('javascript/objectLiteralComputedProperties'), createFixturePatternConfigFor('javascript/objectLiteralDuplicateProperties', { @@ -308,8 +238,8 @@ let fixturePatternConfigsToTest = [ * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ - 'error-proto-property', // babylon parse errors - 'error-proto-string-property' // babylon parse errors + 'error-proto-property', // babel parse errors + 'error-proto-string-property' // babel parse errors ] }), @@ -327,14 +257,19 @@ let fixturePatternConfigsToTest = [ * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ - 'error-no-default', // babylon parse errors - 'error-not-last' // babylon parse errors + 'error-no-default', // babel parse errors + 'error-not-last' // babel parse errors ] }), createFixturePatternConfigFor('javascript/spread'), createFixturePatternConfigFor('javascript/unicodeCodePointEscapes'), - createFixturePatternConfigFor('jsx', { ignore: jsxFilesWithKnownIssues }), + + /* ================================================== */ + + createFixturePatternConfigFor('jsx', { + ignore: jsxFilesWithKnownIssues + }), createFixturePatternConfigFor('jsx-useJSXTextNode'), /* ================================================== */ @@ -344,13 +279,7 @@ let fixturePatternConfigsToTest = [ */ createFixturePatternConfigFor('tsx', { - fileType: 'tsx', - ignore: [ - /** - * AST difference - */ - 'react-typed-props' - ] + fileType: 'tsx' }), /* ================================================== */ @@ -369,13 +298,13 @@ let fixturePatternConfigsToTest = [ /** * Other babylon parse errors relating to invalid syntax. */ - 'abstract-class-with-abstract-constructor', // babylon parse errors - 'class-with-export-parameter-properties', // babylon parse errors - 'class-with-optional-methods', // babylon parse errors - 'class-with-static-parameter-properties', // babylon parse errors - 'interface-with-all-property-types', // babylon parse errors - 'interface-with-construct-signature-with-parameter-accessibility', // babylon parse errors - 'class-with-implements-and-extends', // babylon parse errors + 'abstract-class-with-abstract-constructor', // babel parse errors + 'class-with-export-parameter-properties', // babel parse errors + 'class-with-implements-and-extends', // babel parse errors + 'class-with-optional-methods', // babel parse errors + 'class-with-static-parameter-properties', // babel parse errors + 'interface-with-all-property-types', // babel parse errors + 'interface-with-construct-signature-with-parameter-accessibility', // babel parse errors /** * typescript-estree erroring, but babylon not. */ @@ -418,11 +347,11 @@ let fixturePatternConfigsToTest = [ /** * Babylon bug for optional or abstract methods? */ - 'abstract-class-with-abstract-method', // babylon parse errors - 'abstract-class-with-optional-method', // babylon parse errors - 'declare-class-with-optional-method', // babylon parse errors + 'abstract-class-with-abstract-method', // babel parse errors + 'abstract-class-with-optional-method', // babel parse errors + 'declare-class-with-optional-method', // babel parse errors /** - * Awaiting feedback on Babylon issue https://github.com/babel/babylon/issues/700 + * Awaiting feedback on Babylon issue https://github.com/babel/babel/issues/6679 */ 'class-with-private-parameter-properties', 'class-with-protected-parameter-properties', @@ -432,35 +361,11 @@ let fixturePatternConfigsToTest = [ * Not yet supported in Babylon https://github.com/babel/babel/issues/7749 */ 'import-type', - 'import-type-with-type-parameters-in-type-reference', - /** - * babel is not supporting it yet https://github.com/babel/babel/pull/9230 - * Babel: TSTypeReference -> Identifier - * tsep: TSBigIntKeyword - */ - 'typed-keyword-bigint', - /** - * Awaiting feedback on Babel issue https://github.com/babel/babel/issues/9228 - * Babel: BooleanLiteral - * tsep: Literal - */ - 'typed-keyword-true', - /** - * Not yet supported in Babel https://github.com/babel/babel/issues/9228 - * Babel: BooleanLiteral - * tsep: Literal - */ - 'typed-keyword-false' + 'import-type-with-type-parameters-in-type-reference' ], - parseWithSourceTypeModule: [ - 'export-named-enum', - 'export-assignment', - 'export-type-alias-declaration', - 'export-type-class-declaration', - 'export-default-class-with-generic', - 'export-default-class-with-multiple-generics', - 'export-named-class-with-generic', - 'export-named-class-with-multiple-generics' + ignoreSourceType: [ + // https://github.com/babel/babel/issues/9213 + 'export-assignment' ] }), @@ -500,12 +405,12 @@ let fixturePatternConfigsToTest = [ /** * TypeScript-specific tests taken from "errorRecovery". Babylon is not being as forgiving as the TypeScript compiler here. */ - 'class-empty-extends-implements', // babylon parse errors - 'class-empty-extends', // babylon parse errors - 'decorator-on-enum-declaration', // babylon parse errors - 'decorator-on-interface-declaration', // babylon parse errors - 'interface-property-modifiers', // babylon parse errors - 'enum-with-keywords' // babylon parse errors + 'class-empty-extends-implements', // babel parse errors + 'class-empty-extends', // babel parse errors + 'decorator-on-enum-declaration', // babel parse errors + 'decorator-on-interface-declaration', // babel parse errors + 'interface-property-modifiers', // babel parse errors + 'enum-with-keywords' // babel parse errors ] }), @@ -514,14 +419,14 @@ let fixturePatternConfigsToTest = [ ignore: [ /** * AST difference - * tsep: TSAbstractClassDeclaration - * babel: ClassDeclaration[abstract=true] + * tsep: heritage = [] + * babel: heritage = undefined */ 'interface', /** * AST difference - * tsep: heritage = [] - * babel: heritage = undefined + * tsep: TSAbstractClassDeclaration + * babel: ClassDeclaration[abstract=true] */ 'abstract-class' ] @@ -539,11 +444,11 @@ let fixturePatternConfigsToTest = [ * tsep: TSNamespaceFunctionDeclaration */ 'declare-namespace-with-exported-function' + ], + ignoreSourceType: [ + 'module-with-default-exports', + 'ambient-module-declaration-with-import' ] - }), - - createFixturePatternConfigFor('typescript/types', { - fileType: 'ts' }) ]; @@ -572,7 +477,7 @@ fixturePatternConfigsToTest.forEach(fixturePatternConfig => { matchingFixtures.forEach(filename => { fixturesToTest.push({ filename, - config: fixturePatternConfig.config + ignoreSourceType: fixturePatternConfig.ignoreSourceType }); }); }); diff --git a/tests/ast-alignment/parse.ts b/tests/ast-alignment/parse.ts index 85e53bd..c5df123 100644 --- a/tests/ast-alignment/parse.ts +++ b/tests/ast-alignment/parse.ts @@ -19,12 +19,12 @@ function parseWithBabelParser( parserOptions?: BabelParserOptions ) { parserOptions = parserOptions || {}; - const babylon = require('@babel/parser'); - return babylon.parse( + const babel = require('@babel/parser'); + return babel.parse( text, Object.assign( { - sourceType: 'script', + sourceType: 'unambiguous', allowImportExportEverywhere: true, allowReturnOutsideFunction: true, ranges: true, diff --git a/tests/ast-alignment/spec.ts b/tests/ast-alignment/spec.ts index 7ab17c7..31814b9 100644 --- a/tests/ast-alignment/spec.ts +++ b/tests/ast-alignment/spec.ts @@ -7,35 +7,29 @@ fixturesToTest.forEach(fixture => { const filename = fixture.filename; const source = fs.readFileSync(filename, 'utf8').replace(/\r\n/g, '\n'); - const config = fixture.config || {}; - config.typeScriptESTreeOptions = config.typeScriptESTreeOptions || {}; - config.babelParserOptions = config.babelParserOptions || {}; - /** * Parse with typescript-estree */ const typeScriptESTreeResult = parse(source, { - parser: 'typescript-estree', - typeScriptESTreeOptions: config.typeScriptESTreeOptions + parser: 'typescript-estree' }); /** - * Parse the source with babylon typescript-plugin + * Parse the source with @babel/parser typescript-plugin */ const babelParserResult = parse(source, { - parser: '@babel/parser', - babelParserOptions: config.babelParserOptions + parser: '@babel/parser' }); /** - * If babylon fails to parse the source, ensure that typescript-estree has the same fundamental issue + * If babel fails to parse the source, ensure that typescript-estree has the same fundamental issue */ if (babelParserResult.parseError) { /** - * FAIL: babylon errored but typescript-estree did not + * FAIL: babel errored but typescript-estree did not */ if (!typeScriptESTreeResult.parseError) { - it(`TEST FAIL [BABYLON ERRORED, BUT TSEP DID NOT] - ${filename}`, () => { + it(`TEST FAIL [BABEL ERRORED, BUT TSEP DID NOT] - ${filename}`, () => { expect(typeScriptESTreeResult.parseError).toEqual( babelParserResult.parseError ); @@ -54,10 +48,10 @@ fixturesToTest.forEach(fixture => { } /** - * FAIL: typescript-estree errored but babylon did not + * FAIL: typescript-estree errored but babel did not */ if (typeScriptESTreeResult.parseError) { - it(`TEST FAIL [TSEP ERRORED, BUT BABYLON DID NOT] - ${filename}`, () => { + it(`TEST FAIL [TSEP ERRORED, BUT BABEL DID NOT] - ${filename}`, () => { expect(babelParserResult.parseError).toEqual( typeScriptESTreeResult.parseError ); @@ -72,14 +66,18 @@ fixturesToTest.forEach(fixture => { expect(babelParserResult.ast).toBeTruthy(); expect(typeScriptESTreeResult.ast).toBeTruthy(); /** - * Perform some extra formatting steps on the babylon AST before comparing + * Perform some extra formatting steps on the babel AST before comparing */ expect( - parseUtils.removeLocationDataFromProgramNode( - parseUtils.preprocessBabylonAST(babelParserResult.ast) + parseUtils.removeLocationDataAndSourceTypeFromProgramNode( + parseUtils.preprocessBabylonAST(babelParserResult.ast), + fixture.ignoreSourceType ) ).toEqual( - parseUtils.removeLocationDataFromProgramNode(typeScriptESTreeResult.ast) + parseUtils.removeLocationDataAndSourceTypeFromProgramNode( + typeScriptESTreeResult.ast, + fixture.ignoreSourceType + ) ); }); }); diff --git a/tests/ast-alignment/utils.ts b/tests/ast-alignment/utils.ts index 95fb1f9..f09ea70 100644 --- a/tests/ast-alignment/utils.ts +++ b/tests/ast-alignment/utils.ts @@ -142,10 +142,17 @@ export function preprocessBabylonAST(ast: any): any { * See: https://github.com/babel/babylon/issues/673 * * @param {Object} ast the raw AST with a Program node at its top level + * @param {boolean} ignoreSourceType fix for issues with unambiguous type detection * @returns {Object} the ast with the location data removed from the Program node */ -export function removeLocationDataFromProgramNode(ast: any) { +export function removeLocationDataAndSourceTypeFromProgramNode( + ast: any, + ignoreSourceType: boolean +) { delete ast.loc; delete ast.range; + if (ignoreSourceType) { + delete ast.sourceType; + } return ast; } diff --git a/yarn.lock b/yarn.lock index 25ccc12..9333764 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10,17 +10,17 @@ "@babel/highlight" "^7.0.0" "@babel/core@^7.0.0": - version "7.1.6" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.1.6.tgz#3733cbee4317429bc87c62b29cf8587dba7baeb3" - integrity sha512-Hz6PJT6e44iUNpAn8AoyAs6B3bl60g7MJQaI0rZEar6ECzh6+srYO1xlIdssio34mPaUtAb1y+XlkkSJzok3yw== + version "7.2.2" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.2.2.tgz#07adba6dde27bb5ad8d8672f15fde3e08184a687" + integrity sha512-59vB0RWt09cAct5EIe58+NzGP4TFSD3Bz//2/ELy3ZeTeKF6VTD1AXlH8BGGbCX0PuobZBsIzO7IAI9PH67eKw== dependencies: "@babel/code-frame" "^7.0.0" - "@babel/generator" "^7.1.6" - "@babel/helpers" "^7.1.5" - "@babel/parser" "^7.1.6" - "@babel/template" "^7.1.2" - "@babel/traverse" "^7.1.6" - "@babel/types" "^7.1.6" + "@babel/generator" "^7.2.2" + "@babel/helpers" "^7.2.0" + "@babel/parser" "^7.2.2" + "@babel/template" "^7.2.2" + "@babel/traverse" "^7.2.2" + "@babel/types" "^7.2.2" convert-source-map "^1.1.0" debug "^4.1.0" json5 "^2.1.0" @@ -29,12 +29,12 @@ semver "^5.4.1" source-map "^0.5.0" -"@babel/generator@^7.1.6": - version "7.1.6" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.1.6.tgz#001303cf87a5b9d093494a4bf251d7b5d03d3999" - integrity sha512-brwPBtVvdYdGxtenbQgfCdDPmtkmUBZPjUoK5SXJEBuHaA5BCubh9ly65fzXz7R6o5rA76Rs22ES8Z+HCc0YIQ== +"@babel/generator@^7.2.2": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.2.2.tgz#18c816c70962640eab42fe8cae5f3947a5c65ccc" + integrity sha512-I4o675J/iS8k+P38dvJ3IBGqObLXyQLTxtrR4u9cSUJOURvafeEWb/pFMOTwtNrmq73mJzyF6ueTbO1BtN0Zeg== dependencies: - "@babel/types" "^7.1.6" + "@babel/types" "^7.2.2" jsesc "^2.5.1" lodash "^4.17.10" source-map "^0.5.0" @@ -119,15 +119,15 @@ "@babel/types" "^7.0.0" "@babel/helper-module-transforms@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.1.0.tgz#470d4f9676d9fad50b324cdcce5fbabbc3da5787" - integrity sha512-0JZRd2yhawo79Rcm4w0LwSMILFmFXjugG3yqf+P/UsKsRS1mJCmMwwlHDlMg7Avr9LrvSpp4ZSULO9r8jpCzcw== + version "7.2.2" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.2.2.tgz#ab2f8e8d231409f8370c883d20c335190284b963" + integrity sha512-YRD7I6Wsv+IHuTPkAmAS4HhY0dkPobgLftHp0cRGZSdrRvmZY8rFvae/GVu3bD00qscuvK3WPHB3YdNpBXUqrA== dependencies: "@babel/helper-module-imports" "^7.0.0" "@babel/helper-simple-access" "^7.1.0" "@babel/helper-split-export-declaration" "^7.0.0" - "@babel/template" "^7.1.0" - "@babel/types" "^7.0.0" + "@babel/template" "^7.2.2" + "@babel/types" "^7.2.2" lodash "^4.17.10" "@babel/helper-optimise-call-expression@^7.0.0": @@ -161,13 +161,13 @@ "@babel/types" "^7.0.0" "@babel/helper-replace-supers@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.1.0.tgz#5fc31de522ec0ef0899dc9b3e7cf6a5dd655f362" - integrity sha512-BvcDWYZRWVuDeXTYZWxekQNO5D4kO55aArwZOTFXw6rlLQA8ZaDicJR1sO47h+HrnCiDFiww0fSPV0d713KBGQ== + version "7.2.3" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.2.3.tgz#19970020cf22677d62b3a689561dbd9644d8c5e5" + integrity sha512-GyieIznGUfPXPWu0yLS6U55Mz67AZD9cUk0BfirOWlPrXlBcan9Gz+vHGz+cPfuoweZSnPzPIm67VtQM0OWZbA== dependencies: "@babel/helper-member-expression-to-functions" "^7.0.0" "@babel/helper-optimise-call-expression" "^7.0.0" - "@babel/traverse" "^7.1.0" + "@babel/traverse" "^7.2.3" "@babel/types" "^7.0.0" "@babel/helper-simple-access@^7.1.0": @@ -186,23 +186,23 @@ "@babel/types" "^7.0.0" "@babel/helper-wrap-function@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.1.0.tgz#8cf54e9190706067f016af8f75cb3df829cc8c66" - integrity sha512-R6HU3dete+rwsdAfrOzTlE9Mcpk4RjU3aX3gi9grtmugQY0u79X7eogUvfXA5sI81Mfq1cn6AgxihfN33STjJA== + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.2.0.tgz#c4e0012445769e2815b55296ead43a958549f6fa" + integrity sha512-o9fP1BZLLSrYlxYEYyl2aS+Flun5gtjTIG8iln+XuEzQTs0PLagAGSXUcqruJwD5fM48jzIEggCKpIfWTcR7pQ== dependencies: "@babel/helper-function-name" "^7.1.0" "@babel/template" "^7.1.0" "@babel/traverse" "^7.1.0" - "@babel/types" "^7.0.0" + "@babel/types" "^7.2.0" -"@babel/helpers@^7.1.5": - version "7.1.5" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.1.5.tgz#68bfc1895d685f2b8f1995e788dbfe1f6ccb1996" - integrity sha512-2jkcdL02ywNBry1YNFAH/fViq4fXG0vdckHqeJk+75fpQ2OH+Az6076tX/M0835zA45E0Cqa6pV5Kiv9YOqjEg== +"@babel/helpers@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.2.0.tgz#8335f3140f3144270dc63c4732a4f8b0a50b7a21" + integrity sha512-Fr07N+ea0dMcMN8nFpuK6dUIT7/ivt9yKQdEEnjVS83tG2pHwPi03gYmk/tyuwONnZ+sY+GFFPlWGgCtW1hF9A== dependencies: "@babel/template" "^7.1.2" "@babel/traverse" "^7.1.5" - "@babel/types" "^7.1.5" + "@babel/types" "^7.2.0" "@babel/highlight@^7.0.0": version "7.0.0" @@ -213,116 +213,116 @@ esutils "^2.0.2" js-tokens "^4.0.0" -"@babel/parser@7.1.6", "@babel/parser@^7.1.2", "@babel/parser@^7.1.6": - version "7.1.6" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.1.6.tgz#16e97aca1ec1062324a01c5a6a7d0df8dd189854" - integrity sha512-dWP6LJm9nKT6ALaa+bnL247GHHMWir3vSlZ2+IHgHgktZQx0L3Uvq2uAWcuzIe+fujRsYWBW2q622C5UvGK9iQ== +"@babel/parser@7.2.3", "@babel/parser@^7.2.2", "@babel/parser@^7.2.3": + version "7.2.3" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.2.3.tgz#32f5df65744b70888d17872ec106b02434ba1489" + integrity sha512-0LyEcVlfCoFmci8mXx8A5oIkpkOgyo8dRHtxBnK9RRBwxO2+JZPNsqtVEZQ7mJFPxnXF9lfmU24mHOPI0qnlkA== -"@babel/plugin-proposal-async-generator-functions@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.1.0.tgz#41c1a702e10081456e23a7b74d891922dd1bb6ce" - integrity sha512-Fq803F3Jcxo20MXUSDdmZZXrPe6BWyGcWBPPNB/M7WaUYESKDeKMOGIxEzQOjGSmW/NWb6UaPZrtTB2ekhB/ew== +"@babel/plugin-proposal-async-generator-functions@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.2.0.tgz#b289b306669dce4ad20b0252889a15768c9d417e" + integrity sha512-+Dfo/SCQqrwx48ptLVGLdE39YtWRuKc/Y9I5Fy0P1DDBB9lsAHpjcEJQt+4IifuSOSTLBKJObJqMvaO1pIE8LQ== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-remap-async-to-generator" "^7.1.0" - "@babel/plugin-syntax-async-generators" "^7.0.0" + "@babel/plugin-syntax-async-generators" "^7.2.0" -"@babel/plugin-proposal-json-strings@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.0.0.tgz#3b4d7b5cf51e1f2e70f52351d28d44fc2970d01e" - integrity sha512-kfVdUkIAGJIVmHmtS/40i/fg/AGnw/rsZBCaapY5yjeO5RA9m165Xbw9KMOu2nqXP5dTFjEjHdfNdoVcHv133Q== +"@babel/plugin-proposal-json-strings@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.2.0.tgz#568ecc446c6148ae6b267f02551130891e29f317" + integrity sha512-MAFV1CA/YVmYwZG0fBQyXhmj0BHCB5egZHCKWIFVv/XCxAeVGIHfos3SwDck4LvCllENIAg7xMKOG5kH0dzyUg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-syntax-json-strings" "^7.0.0" + "@babel/plugin-syntax-json-strings" "^7.2.0" -"@babel/plugin-proposal-object-rest-spread@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.0.0.tgz#9a17b547f64d0676b6c9cecd4edf74a82ab85e7e" - integrity sha512-14fhfoPcNu7itSen7Py1iGN0gEm87hX/B+8nZPqkdmANyyYWYMY2pjA3r8WXbWVKMzfnSNS0xY8GVS0IjXi/iw== +"@babel/plugin-proposal-object-rest-spread@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.2.0.tgz#88f5fec3e7ad019014c97f7ee3c992f0adbf7fb8" + integrity sha512-1L5mWLSvR76XYUQJXkd/EEQgjq8HHRP6lQuZTTg0VA4tTGPpGemmCdAfQIz1rzEuWAm+ecP8PyyEm30jC1eQCg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-syntax-object-rest-spread" "^7.0.0" + "@babel/plugin-syntax-object-rest-spread" "^7.2.0" -"@babel/plugin-proposal-optional-catch-binding@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.0.0.tgz#b610d928fe551ff7117d42c8bb410eec312a6425" - integrity sha512-JPqAvLG1s13B/AuoBjdBYvn38RqW6n1TzrQO839/sIpqLpbnXKacsAgpZHzLD83Sm8SDXMkkrAvEnJ25+0yIpw== +"@babel/plugin-proposal-optional-catch-binding@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.2.0.tgz#135d81edb68a081e55e56ec48541ece8065c38f5" + integrity sha512-mgYj3jCcxug6KUcX4OBoOJz3CMrwRfQELPQ5560F70YQUBZB7uac9fqaWamKR1iWUzGiK2t0ygzjTScZnVz75g== dependencies: "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-syntax-optional-catch-binding" "^7.0.0" + "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" -"@babel/plugin-proposal-unicode-property-regex@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.0.0.tgz#498b39cd72536cd7c4b26177d030226eba08cd33" - integrity sha512-tM3icA6GhC3ch2SkmSxv7J/hCWKISzwycub6eGsDrFDgukD4dZ/I+x81XgW0YslS6mzNuQ1Cbzh5osjIMgepPQ== +"@babel/plugin-proposal-unicode-property-regex@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.2.0.tgz#abe7281fe46c95ddc143a65e5358647792039520" + integrity sha512-LvRVYb7kikuOtIoUeWTkOxQEV1kYvL5B6U3iWEGCzPNRus1MzJweFqORTj+0jkxozkTSYNJozPOddxmqdqsRpw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-regex" "^7.0.0" regexpu-core "^4.2.0" -"@babel/plugin-syntax-async-generators@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.0.0.tgz#bf0891dcdbf59558359d0c626fdc9490e20bc13c" - integrity sha512-im7ged00ddGKAjcZgewXmp1vxSZQQywuQXe2B1A7kajjZmDeY/ekMPmWr9zJgveSaQH0k7BcGrojQhcK06l0zA== +"@babel/plugin-syntax-async-generators@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.2.0.tgz#69e1f0db34c6f5a0cf7e2b3323bf159a76c8cb7f" + integrity sha512-1ZrIRBv2t0GSlcwVoQ6VgSLpLgiN/FVQUzt9znxo7v2Ov4jJrs8RY8tv0wvDmFN3qIdMKWrmMMW6yZ0G19MfGg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-syntax-json-strings@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.0.0.tgz#0d259a68090e15b383ce3710e01d5b23f3770cbd" - integrity sha512-UlSfNydC+XLj4bw7ijpldc1uZ/HB84vw+U6BTuqMdIEmz/LDe63w/GHtpQMdXWdqQZFeAI9PjnHe/vDhwirhKA== +"@babel/plugin-syntax-json-strings@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.2.0.tgz#72bd13f6ffe1d25938129d2a186b11fd62951470" + integrity sha512-5UGYnMSLRE1dqqZwug+1LISpA403HzlSfsg6P9VXU6TBjcSHeNlw4DxDx7LgpF+iKZoOG/+uzqoRHTdcUpiZNg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-syntax-object-rest-spread@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.0.0.tgz#37d8fbcaf216bd658ea1aebbeb8b75e88ebc549b" - integrity sha512-5A0n4p6bIiVe5OvQPxBnesezsgFJdHhSs3uFSvaPdMqtsovajLZ+G2vZyvNe10EzJBWWo3AcHGKhAFUxqwp2dw== +"@babel/plugin-syntax-object-rest-spread@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.2.0.tgz#3b7a3e733510c57e820b9142a6579ac8b0dfad2e" + integrity sha512-t0JKGgqk2We+9may3t0xDdmneaXmyxq0xieYcKHxIsrJO64n1OiMWNUtc5gQK1PA0NpdCRrtZp4z+IUaKugrSA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-syntax-optional-catch-binding@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.0.0.tgz#886f72008b3a8b185977f7cb70713b45e51ee475" - integrity sha512-Wc+HVvwjcq5qBg1w5RG9o9RVzmCaAg/Vp0erHCKpAYV8La6I94o4GQAmFYNmkzoMO6gzoOSulpKeSSz6mPEoZw== +"@babel/plugin-syntax-optional-catch-binding@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.2.0.tgz#a94013d6eda8908dfe6a477e7f9eda85656ecf5c" + integrity sha512-bDe4xKNhb0LI7IvZHiA13kff0KEfaGX/Hv4lMA9+7TEc63hMNvfKo6ZFpXhKuEp+II/q35Gc4NoMeDZyaUbj9w== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-arrow-functions@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.0.0.tgz#a6c14875848c68a3b4b3163a486535ef25c7e749" - integrity sha512-2EZDBl1WIO/q4DIkIp4s86sdp4ZifL51MoIviLY/gG/mLSuOIEg7J8o6mhbxOTvUJkaN50n+8u41FVsr5KLy/w== +"@babel/plugin-transform-arrow-functions@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.2.0.tgz#9aeafbe4d6ffc6563bf8f8372091628f00779550" + integrity sha512-ER77Cax1+8/8jCB9fo4Ud161OZzWN5qawi4GusDuRLcDbDG+bIGYY20zb2dfAFdTRGzrfq2xZPvF0R64EHnimg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-async-to-generator@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.1.0.tgz#109e036496c51dd65857e16acab3bafdf3c57811" - integrity sha512-rNmcmoQ78IrvNCIt/R9U+cixUHeYAzgusTFgIAv+wQb9HJU4szhpDD6e5GCACmj/JP5KxuCwM96bX3L9v4ZN/g== +"@babel/plugin-transform-async-to-generator@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.2.0.tgz#68b8a438663e88519e65b776f8938f3445b1a2ff" + integrity sha512-CEHzg4g5UraReozI9D4fblBYABs7IM6UerAVG7EJVrTLC5keh00aEuLUT+O40+mJCEzaXkYfTCUKIyeDfMOFFQ== dependencies: "@babel/helper-module-imports" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-remap-async-to-generator" "^7.1.0" -"@babel/plugin-transform-block-scoped-functions@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.0.0.tgz#482b3f75103927e37288b3b67b65f848e2aa0d07" - integrity sha512-AOBiyUp7vYTqz2Jibe1UaAWL0Hl9JUXEgjFvvvcSc9MVDItv46ViXFw2F7SVt1B5k+KWjl44eeXOAk3UDEaJjQ== +"@babel/plugin-transform-block-scoped-functions@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.2.0.tgz#5d3cc11e8d5ddd752aa64c9148d0db6cb79fd190" + integrity sha512-ntQPR6q1/NKuphly49+QiQiTN0O63uOwjdD6dhIjSWBI5xlrbUFh720TIpzBhpnrLfv2tNH/BXvLIab1+BAI0w== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-block-scoping@^7.1.5": - version "7.1.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.1.5.tgz#3e8e0bc9a5104519923302a24f748f72f2f61f37" - integrity sha512-jlYcDrz+5ayWC7mxgpn1Wj8zj0mmjCT2w0mPIMSwO926eXBRxpEgoN/uQVRBfjtr8ayjcmS+xk2G1jaP8JjMJQ== +"@babel/plugin-transform-block-scoping@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.2.0.tgz#f17c49d91eedbcdf5dd50597d16f5f2f770132d4" + integrity sha512-vDTgf19ZEV6mx35yiPJe4fS02mPQUUcBNwWQSZFXSzTSbsJFQvHt7DqyS3LK8oOWALFOsJ+8bbqBgkirZteD5Q== dependencies: "@babel/helper-plugin-utils" "^7.0.0" lodash "^4.17.10" -"@babel/plugin-transform-classes@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.1.0.tgz#ab3f8a564361800cbc8ab1ca6f21108038432249" - integrity sha512-rNaqoD+4OCBZjM7VaskladgqnZ1LO6o2UxuWSDzljzW21pN1KXkB7BstAVweZdxQkHAujps5QMNOTWesBciKFg== +"@babel/plugin-transform-classes@^7.2.0": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.2.2.tgz#6c90542f210ee975aa2aa8c8b5af7fa73a126953" + integrity sha512-gEZvgTy1VtcDOaQty1l10T3jQmJKlNVxLDCs+3rCVPr6nMkODLELxViq5X9l+rfxbie3XrfrMCYYY6eX3aOcOQ== dependencies: "@babel/helper-annotate-as-pure" "^7.0.0" "@babel/helper-define-map" "^7.1.0" @@ -333,95 +333,95 @@ "@babel/helper-split-export-declaration" "^7.0.0" globals "^11.1.0" -"@babel/plugin-transform-computed-properties@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.0.0.tgz#2fbb8900cd3e8258f2a2ede909b90e7556185e31" - integrity sha512-ubouZdChNAv4AAWAgU7QKbB93NU5sHwInEWfp+/OzJKA02E6Woh9RVoX4sZrbRwtybky/d7baTUqwFx+HgbvMA== +"@babel/plugin-transform-computed-properties@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.2.0.tgz#83a7df6a658865b1c8f641d510c6f3af220216da" + integrity sha512-kP/drqTxY6Xt3NNpKiMomfgkNn4o7+vKxK2DDKcBG9sHj51vHqMBGy8wbDS/J4lMxnqs153/T3+DmCEAkC5cpA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-destructuring@^7.0.0": - version "7.1.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.1.3.tgz#e69ff50ca01fac6cb72863c544e516c2b193012f" - integrity sha512-Mb9M4DGIOspH1ExHOUnn2UUXFOyVTiX84fXCd+6B5iWrQg/QMeeRmSwpZ9lnjYLSXtZwiw80ytVMr3zue0ucYw== +"@babel/plugin-transform-destructuring@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.2.0.tgz#e75269b4b7889ec3a332cd0d0c8cff8fed0dc6f3" + integrity sha512-coVO2Ayv7g0qdDbrNiadE4bU7lvCd9H539m2gMknyVjjMdwF/iCOM7R+E8PkntoqLkltO0rk+3axhpp/0v68VQ== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-dotall-regex@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.0.0.tgz#73a24da69bc3c370251f43a3d048198546115e58" - integrity sha512-00THs8eJxOJUFVx1w8i1MBF4XH4PsAjKjQ1eqN/uCH3YKwP21GCKfrn6YZFZswbOk9+0cw1zGQPHVc1KBlSxig== +"@babel/plugin-transform-dotall-regex@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.2.0.tgz#f0aabb93d120a8ac61e925ea0ba440812dbe0e49" + integrity sha512-sKxnyHfizweTgKZf7XsXu/CNupKhzijptfTM+bozonIuyVrLWVUvYjE2bhuSBML8VQeMxq4Mm63Q9qvcvUcciQ== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-regex" "^7.0.0" regexpu-core "^4.1.3" -"@babel/plugin-transform-duplicate-keys@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.0.0.tgz#a0601e580991e7cace080e4cf919cfd58da74e86" - integrity sha512-w2vfPkMqRkdxx+C71ATLJG30PpwtTpW7DDdLqYt2acXU7YjztzeWW2Jk1T6hKqCLYCcEA5UQM/+xTAm+QCSnuQ== +"@babel/plugin-transform-duplicate-keys@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.2.0.tgz#d952c4930f312a4dbfff18f0b2914e60c35530b3" + integrity sha512-q+yuxW4DsTjNceUiTzK0L+AfQ0zD9rWaTLiUqHA8p0gxx7lu1EylenfzjeIWNkPy6e/0VG/Wjw9uf9LueQwLOw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-exponentiation-operator@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.1.0.tgz#9c34c2ee7fd77e02779cfa37e403a2e1003ccc73" - integrity sha512-uZt9kD1Pp/JubkukOGQml9tqAeI8NkE98oZnHZ2qHRElmeKCodbTZgOEUtujSCSLhHSBWbzNiFSDIMC4/RBTLQ== +"@babel/plugin-transform-exponentiation-operator@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.2.0.tgz#a63868289e5b4007f7054d46491af51435766008" + integrity sha512-umh4hR6N7mu4Elq9GG8TOu9M0bakvlsREEC+ialrQN6ABS4oDQ69qJv1VtR3uxlKMCQMCvzk7vr17RHKcjx68A== dependencies: "@babel/helper-builder-binary-assignment-operator-visitor" "^7.1.0" "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-for-of@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.0.0.tgz#f2ba4eadb83bd17dc3c7e9b30f4707365e1c3e39" - integrity sha512-TlxKecN20X2tt2UEr2LNE6aqA0oPeMT1Y3cgz8k4Dn1j5ObT8M3nl9aA37LLklx0PBZKETC9ZAf9n/6SujTuXA== +"@babel/plugin-transform-for-of@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.2.0.tgz#ab7468befa80f764bb03d3cb5eef8cc998e1cad9" + integrity sha512-Kz7Mt0SsV2tQk6jG5bBv5phVbkd0gd27SgYD4hH1aLMJRchM0dzHaXvrWhVZ+WxAlDoAKZ7Uy3jVTW2mKXQ1WQ== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-function-name@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.1.0.tgz#29c5550d5c46208e7f730516d41eeddd4affadbb" - integrity sha512-VxOa1TMlFMtqPW2IDYZQaHsFrq/dDoIjgN098NowhexhZcz3UGlvPgZXuE1jEvNygyWyxRacqDpCZt+par1FNg== +"@babel/plugin-transform-function-name@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.2.0.tgz#f7930362829ff99a3174c39f0afcc024ef59731a" + integrity sha512-kWgksow9lHdvBC2Z4mxTsvc7YdY7w/V6B2vy9cTIPtLEE9NhwoWivaxdNM/S37elu5bqlLP/qOY906LukO9lkQ== dependencies: "@babel/helper-function-name" "^7.1.0" "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-literals@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.0.0.tgz#2aec1d29cdd24c407359c930cdd89e914ee8ff86" - integrity sha512-1NTDBWkeNXgpUcyoVFxbr9hS57EpZYXpje92zv0SUzjdu3enaRwF/l3cmyRnXLtIdyJASyiS6PtybK+CgKf7jA== +"@babel/plugin-transform-literals@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.2.0.tgz#690353e81f9267dad4fd8cfd77eafa86aba53ea1" + integrity sha512-2ThDhm4lI4oV7fVQ6pNNK+sx+c/GM5/SaML0w/r4ZB7sAneD/piDJtwdKlNckXeyGK7wlwg2E2w33C/Hh+VFCg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-modules-amd@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.1.0.tgz#f9e0a7072c12e296079b5a59f408ff5b97bf86a8" - integrity sha512-wt8P+xQ85rrnGNr2x1iV3DW32W8zrB6ctuBkYBbf5/ZzJY99Ob4MFgsZDFgczNU76iy9PWsy4EuxOliDjdKw6A== +"@babel/plugin-transform-modules-amd@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.2.0.tgz#82a9bce45b95441f617a24011dc89d12da7f4ee6" + integrity sha512-mK2A8ucqz1qhrdqjS9VMIDfIvvT2thrEsIQzbaTdc5QFzhDjQv2CkJJ5f6BXIkgbmaoax3zBr2RyvV/8zeoUZw== dependencies: "@babel/helper-module-transforms" "^7.1.0" "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-modules-commonjs@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.1.0.tgz#0a9d86451cbbfb29bd15186306897c67f6f9a05c" - integrity sha512-wtNwtMjn1XGwM0AXPspQgvmE6msSJP15CX2RVfpTSTNPLhKhaOjaIfBaVfj4iUZ/VrFSodcFedwtPg/NxwQlPA== +"@babel/plugin-transform-modules-commonjs@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.2.0.tgz#c4f1933f5991d5145e9cfad1dfd848ea1727f404" + integrity sha512-V6y0uaUQrQPXUrmj+hgnks8va2L0zcZymeU7TtWEgdRLNkceafKXEduv7QzgQAE4lT+suwooG9dC7LFhdRAbVQ== dependencies: "@babel/helper-module-transforms" "^7.1.0" "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-simple-access" "^7.1.0" -"@babel/plugin-transform-modules-systemjs@^7.0.0": - version "7.1.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.1.3.tgz#2119a3e3db612fd74a19d88652efbfe9613a5db0" - integrity sha512-PvTxgjxQAq4pvVUZF3mD5gEtVDuId8NtWkJsZLEJZMZAW3TvgQl1pmydLLN1bM8huHFVVU43lf0uvjQj9FRkKw== +"@babel/plugin-transform-modules-systemjs@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.2.0.tgz#912bfe9e5ff982924c81d0937c92d24994bb9068" + integrity sha512-aYJwpAhoK9a+1+O625WIjvMY11wkB/ok0WClVwmeo3mCjcNRjt+/8gHWrB5i+00mUju0gWsBkQnPpdvQ7PImmQ== dependencies: "@babel/helper-hoist-variables" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-modules-umd@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.1.0.tgz#a29a7d85d6f28c3561c33964442257cc6a21f2a8" - integrity sha512-enrRtn5TfRhMmbRwm7F8qOj0qEYByqUvTttPEGimcBH4CJHphjyK1Vg7sdU7JjeEmgSpM890IT/efS2nMHwYig== +"@babel/plugin-transform-modules-umd@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.2.0.tgz#7678ce75169f0877b8eb2235538c074268dd01ae" + integrity sha512-BV3bw6MyUH1iIsGhXlOK6sXhmSarZjtJ/vMiD9dNmpY8QXFFQTj+6v92pcfy1iqa8DeAfJFwoxcrS/TUZda6sw== dependencies: "@babel/helper-module-transforms" "^7.1.0" "@babel/helper-plugin-utils" "^7.0.0" @@ -433,18 +433,18 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-object-super@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.1.0.tgz#b1ae194a054b826d8d4ba7ca91486d4ada0f91bb" - integrity sha512-/O02Je1CRTSk2SSJaq0xjwQ8hG4zhZGNjE8psTsSNPXyLRCODv7/PBozqT5AmQMzp7MI3ndvMhGdqp9c96tTEw== +"@babel/plugin-transform-object-super@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.2.0.tgz#b35d4c10f56bab5d650047dad0f1d8e8814b6598" + integrity sha512-VMyhPYZISFZAqAPVkiYb7dUe2AsVi2/wCT5+wZdsNO31FojQJa9ns40hzZ6U9f50Jlq4w6qwzdBB2uwqZ00ebg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-replace-supers" "^7.1.0" -"@babel/plugin-transform-parameters@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.1.0.tgz#44f492f9d618c9124026e62301c296bf606a7aed" - integrity sha512-vHV7oxkEJ8IHxTfRr3hNGzV446GAb+0hgbA7o/0Jd76s+YzccdWuTU296FOCOl/xweU4t/Ya4g41yWz80RFCRw== +"@babel/plugin-transform-parameters@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.2.0.tgz#0d5ad15dc805e2ea866df4dd6682bfe76d1408c2" + integrity sha512-kB9+hhUidIgUoBQ0MsxMewhzr8i60nMa2KgeJKQWYrqQpqcBYtnpR+JgkadZVZoaEZ/eKu9mclFaVwhRpLNSzA== dependencies: "@babel/helper-call-delegate" "^7.1.0" "@babel/helper-get-function-arity" "^7.0.0" @@ -457,103 +457,103 @@ dependencies: regenerator-transform "^0.13.3" -"@babel/plugin-transform-shorthand-properties@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.0.0.tgz#85f8af592dcc07647541a0350e8c95c7bf419d15" - integrity sha512-g/99LI4vm5iOf5r1Gdxq5Xmu91zvjhEG5+yZDJW268AZELAu4J1EiFLnkSG3yuUsZyOipVOVUKoGPYwfsTymhw== +"@babel/plugin-transform-shorthand-properties@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.2.0.tgz#6333aee2f8d6ee7e28615457298934a3b46198f0" + integrity sha512-QP4eUM83ha9zmYtpbnyjTLAGKQritA5XW/iG9cjtuOI8s1RuL/3V6a3DeSHfKutJQ+ayUfeZJPcnCYEQzaPQqg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-spread@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.0.0.tgz#93583ce48dd8c85e53f3a46056c856e4af30b49b" - integrity sha512-L702YFy2EvirrR4shTj0g2xQp7aNwZoWNCkNu2mcoU0uyzMl0XRwDSwzB/xp6DSUFiBmEXuyAyEN16LsgVqGGQ== +"@babel/plugin-transform-spread@^7.2.0": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.2.2.tgz#3103a9abe22f742b6d406ecd3cd49b774919b406" + integrity sha512-KWfky/58vubwtS0hLqEnrWJjsMGaOeSBn90Ezn5Jeg9Z8KKHmELbP1yGylMlm5N6TPKeY9A2+UaSYLdxahg01w== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-sticky-regex@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.0.0.tgz#30a9d64ac2ab46eec087b8530535becd90e73366" - integrity sha512-LFUToxiyS/WD+XEWpkx/XJBrUXKewSZpzX68s+yEOtIbdnsRjpryDw9U06gYc6klYEij/+KQVRnD3nz3AoKmjw== +"@babel/plugin-transform-sticky-regex@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.2.0.tgz#a1e454b5995560a9c1e0d537dfc15061fd2687e1" + integrity sha512-KKYCoGaRAf+ckH8gEL3JHUaFVyNHKe3ASNsZ+AlktgHevvxGigoIttrEJb8iKN03Q7Eazlv1s6cx2B2cQ3Jabw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-regex" "^7.0.0" -"@babel/plugin-transform-template-literals@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.0.0.tgz#084f1952efe5b153ddae69eb8945f882c7a97c65" - integrity sha512-vA6rkTCabRZu7Nbl9DfLZE1imj4tzdWcg5vtdQGvj+OH9itNNB6hxuRMHuIY8SGnEt1T9g5foqs9LnrHzsqEFg== +"@babel/plugin-transform-template-literals@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.2.0.tgz#d87ed01b8eaac7a92473f608c97c089de2ba1e5b" + integrity sha512-FkPix00J9A/XWXv4VoKJBMeSkyY9x/TqIh76wzcdfl57RJJcf8CehQ08uwfhCDNtRQYtHQKBTwKZDEyjE13Lwg== dependencies: "@babel/helper-annotate-as-pure" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-typeof-symbol@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.0.0.tgz#4dcf1e52e943e5267b7313bff347fdbe0f81cec9" - integrity sha512-1r1X5DO78WnaAIvs5uC48t41LLckxsYklJrZjNKcevyz83sF2l4RHbw29qrCPr/6ksFsdfRpT/ZgxNWHXRnffg== +"@babel/plugin-transform-typeof-symbol@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.2.0.tgz#117d2bcec2fbf64b4b59d1f9819894682d29f2b2" + integrity sha512-2LNhETWYxiYysBtrBTqL8+La0jIoQQnIScUJc74OYvUGRmkskNY4EzLCnjHBzdmb38wqtTaixpo1NctEcvMDZw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-unicode-regex@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.0.0.tgz#c6780e5b1863a76fe792d90eded9fcd5b51d68fc" - integrity sha512-uJBrJhBOEa3D033P95nPHu3nbFwFE9ZgXsfEitzoIXIwqAZWk7uXcg06yFKXz9FSxBH5ucgU/cYdX0IV8ldHKw== +"@babel/plugin-transform-unicode-regex@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.2.0.tgz#4eb8db16f972f8abb5062c161b8b115546ade08b" + integrity sha512-m48Y0lMhrbXEJnVUaYly29jRXbQ3ksxPrS1Tg8t+MHqzXhtBYAvI51euOBaoAlZLPHsieY9XPVMf80a5x0cPcA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-regex" "^7.0.0" regexpu-core "^4.1.3" "@babel/polyfill@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.0.0.tgz#c8ff65c9ec3be6a1ba10113ebd40e8750fb90bff" - integrity sha512-dnrMRkyyr74CRelJwvgnnSUDh2ge2NCTyHVwpOdvRMHtJUyxLtMAfhBN3s64pY41zdw0kgiLPh6S20eb1NcX6Q== + version "7.2.5" + resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.2.5.tgz#6c54b964f71ad27edddc567d065e57e87ed7fa7d" + integrity sha512-8Y/t3MWThtMLYr0YNC/Q76tqN1w30+b0uQMeFUYauG2UGTR19zyUtFrAzT23zNtBxPp+LbE5E/nwV/q/r3y6ug== dependencies: core-js "^2.5.7" - regenerator-runtime "^0.11.1" + regenerator-runtime "^0.12.0" "@babel/preset-env@^7.0.0": - version "7.1.6" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.1.6.tgz#a0bf4b96b6bfcf6e000afc5b72b4abe7cc13ae97" - integrity sha512-YIBfpJNQMBkb6MCkjz/A9J76SNCSuGVamOVBgoUkLzpJD/z8ghHi9I42LQ4pulVX68N/MmImz6ZTixt7Azgexw== + version "7.2.3" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.2.3.tgz#948c8df4d4609c99c7e0130169f052ea6a7a8933" + integrity sha512-AuHzW7a9rbv5WXmvGaPX7wADxFkZIqKlbBh1dmZUQp4iwiPpkE/Qnrji6SC4UQCQzvWY/cpHET29eUhXS9cLPw== dependencies: "@babel/helper-module-imports" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-proposal-async-generator-functions" "^7.1.0" - "@babel/plugin-proposal-json-strings" "^7.0.0" - "@babel/plugin-proposal-object-rest-spread" "^7.0.0" - "@babel/plugin-proposal-optional-catch-binding" "^7.0.0" - "@babel/plugin-proposal-unicode-property-regex" "^7.0.0" - "@babel/plugin-syntax-async-generators" "^7.0.0" - "@babel/plugin-syntax-object-rest-spread" "^7.0.0" - "@babel/plugin-syntax-optional-catch-binding" "^7.0.0" - "@babel/plugin-transform-arrow-functions" "^7.0.0" - "@babel/plugin-transform-async-to-generator" "^7.1.0" - "@babel/plugin-transform-block-scoped-functions" "^7.0.0" - "@babel/plugin-transform-block-scoping" "^7.1.5" - "@babel/plugin-transform-classes" "^7.1.0" - "@babel/plugin-transform-computed-properties" "^7.0.0" - "@babel/plugin-transform-destructuring" "^7.0.0" - "@babel/plugin-transform-dotall-regex" "^7.0.0" - "@babel/plugin-transform-duplicate-keys" "^7.0.0" - "@babel/plugin-transform-exponentiation-operator" "^7.1.0" - "@babel/plugin-transform-for-of" "^7.0.0" - "@babel/plugin-transform-function-name" "^7.1.0" - "@babel/plugin-transform-literals" "^7.0.0" - "@babel/plugin-transform-modules-amd" "^7.1.0" - "@babel/plugin-transform-modules-commonjs" "^7.1.0" - "@babel/plugin-transform-modules-systemjs" "^7.0.0" - "@babel/plugin-transform-modules-umd" "^7.1.0" + "@babel/plugin-proposal-async-generator-functions" "^7.2.0" + "@babel/plugin-proposal-json-strings" "^7.2.0" + "@babel/plugin-proposal-object-rest-spread" "^7.2.0" + "@babel/plugin-proposal-optional-catch-binding" "^7.2.0" + "@babel/plugin-proposal-unicode-property-regex" "^7.2.0" + "@babel/plugin-syntax-async-generators" "^7.2.0" + "@babel/plugin-syntax-object-rest-spread" "^7.2.0" + "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" + "@babel/plugin-transform-arrow-functions" "^7.2.0" + "@babel/plugin-transform-async-to-generator" "^7.2.0" + "@babel/plugin-transform-block-scoped-functions" "^7.2.0" + "@babel/plugin-transform-block-scoping" "^7.2.0" + "@babel/plugin-transform-classes" "^7.2.0" + "@babel/plugin-transform-computed-properties" "^7.2.0" + "@babel/plugin-transform-destructuring" "^7.2.0" + "@babel/plugin-transform-dotall-regex" "^7.2.0" + "@babel/plugin-transform-duplicate-keys" "^7.2.0" + "@babel/plugin-transform-exponentiation-operator" "^7.2.0" + "@babel/plugin-transform-for-of" "^7.2.0" + "@babel/plugin-transform-function-name" "^7.2.0" + "@babel/plugin-transform-literals" "^7.2.0" + "@babel/plugin-transform-modules-amd" "^7.2.0" + "@babel/plugin-transform-modules-commonjs" "^7.2.0" + "@babel/plugin-transform-modules-systemjs" "^7.2.0" + "@babel/plugin-transform-modules-umd" "^7.2.0" "@babel/plugin-transform-new-target" "^7.0.0" - "@babel/plugin-transform-object-super" "^7.1.0" - "@babel/plugin-transform-parameters" "^7.1.0" + "@babel/plugin-transform-object-super" "^7.2.0" + "@babel/plugin-transform-parameters" "^7.2.0" "@babel/plugin-transform-regenerator" "^7.0.0" - "@babel/plugin-transform-shorthand-properties" "^7.0.0" - "@babel/plugin-transform-spread" "^7.0.0" - "@babel/plugin-transform-sticky-regex" "^7.0.0" - "@babel/plugin-transform-template-literals" "^7.0.0" - "@babel/plugin-transform-typeof-symbol" "^7.0.0" - "@babel/plugin-transform-unicode-regex" "^7.0.0" - browserslist "^4.1.0" + "@babel/plugin-transform-shorthand-properties" "^7.2.0" + "@babel/plugin-transform-spread" "^7.2.0" + "@babel/plugin-transform-sticky-regex" "^7.2.0" + "@babel/plugin-transform-template-literals" "^7.2.0" + "@babel/plugin-transform-typeof-symbol" "^7.2.0" + "@babel/plugin-transform-unicode-regex" "^7.2.0" + browserslist "^4.3.4" invariant "^2.2.2" js-levenshtein "^1.1.3" semver "^5.3.0" @@ -571,34 +571,34 @@ pirates "^4.0.0" source-map-support "^0.5.9" -"@babel/template@^7.1.0", "@babel/template@^7.1.2": - version "7.1.2" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.1.2.tgz#090484a574fef5a2d2d7726a674eceda5c5b5644" - integrity sha512-SY1MmplssORfFiLDcOETrW7fCLl+PavlwMh92rrGcikQaRq4iWPVH0MpwPpY3etVMx6RnDjXtr6VZYr/IbP/Ag== +"@babel/template@^7.1.0", "@babel/template@^7.1.2", "@babel/template@^7.2.2": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.2.2.tgz#005b3fdf0ed96e88041330379e0da9a708eb2907" + integrity sha512-zRL0IMM02AUDwghf5LMSSDEz7sBCO2YnNmpg3uWTZj/v1rcG2BmQUvaGU8GhU8BvfMh1k2KIAYZ7Ji9KXPUg7g== dependencies: "@babel/code-frame" "^7.0.0" - "@babel/parser" "^7.1.2" - "@babel/types" "^7.1.2" + "@babel/parser" "^7.2.2" + "@babel/types" "^7.2.2" -"@babel/traverse@^7.1.0", "@babel/traverse@^7.1.5", "@babel/traverse@^7.1.6": - version "7.1.6" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.1.6.tgz#c8db9963ab4ce5b894222435482bd8ea854b7b5c" - integrity sha512-CXedit6GpISz3sC2k2FsGCUpOhUqKdyL0lqNrImQojagnUMXf8hex4AxYFRuMkNGcvJX5QAFGzB5WJQmSv8SiQ== +"@babel/traverse@^7.1.0", "@babel/traverse@^7.1.5", "@babel/traverse@^7.2.2", "@babel/traverse@^7.2.3": + version "7.2.3" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.2.3.tgz#7ff50cefa9c7c0bd2d81231fdac122f3957748d8" + integrity sha512-Z31oUD/fJvEWVR0lNZtfgvVt512ForCTNKYcJBGbPb1QZfve4WGH8Wsy7+Mev33/45fhP/hwQtvgusNdcCMgSw== dependencies: "@babel/code-frame" "^7.0.0" - "@babel/generator" "^7.1.6" + "@babel/generator" "^7.2.2" "@babel/helper-function-name" "^7.1.0" "@babel/helper-split-export-declaration" "^7.0.0" - "@babel/parser" "^7.1.6" - "@babel/types" "^7.1.6" + "@babel/parser" "^7.2.3" + "@babel/types" "^7.2.2" debug "^4.1.0" globals "^11.1.0" lodash "^4.17.10" -"@babel/types@^7.0.0", "@babel/types@^7.1.2", "@babel/types@^7.1.5", "@babel/types@^7.1.6": - version "7.1.6" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.1.6.tgz#0adb330c3a281348a190263aceb540e10f04bcce" - integrity sha512-DMiUzlY9DSjVsOylJssxLHSgj6tWM9PRFJOGW/RaOglVOK9nzTxoOMfTfRQXGUCUQ/HmlG2efwC+XqUEJ5ay4w== +"@babel/types@^7.0.0", "@babel/types@^7.2.0", "@babel/types@^7.2.2": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.2.2.tgz#44e10fc24e33af524488b716cdaee5360ea8ed1e" + integrity sha512-fKCuD6UFUMkR541eDWL+2ih/xFZBXPOg/7EQFeTluMDebfqR4jrpaCjLhkWlQS4hT6nRa2PMEgXKbRB5/H2fpg== dependencies: esutils "^2.0.2" lodash "^4.17.10" @@ -775,11 +775,11 @@ integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== "@octokit/endpoint@^3.0.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-3.1.0.tgz#ec60152d018d75d4eed5d8a5fd68c9a1e99f3b50" - integrity sha512-ANAOhyEY40qzOjQPEYXqg3GDGLYTjLDjqQqcG1wgqRoE7qFLnvx5a0upzxpes83UK/YHUu6qTymZl/yTu4GvKg== + version "3.1.1" + resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-3.1.1.tgz#ede9afefaa4d6b7584169e12346425c6fbb45cc3" + integrity sha512-KPkoTvKwCTetu/UqonLs1pfwFO5HAqTv/Ksp9y4NAg//ZgUCpvJsT4Hrst85uEzJvkB8+LxKyR4Bfv2X8O4cmQ== dependencies: - deepmerge "2.2.1" + deepmerge "3.0.0" is-plain-object "^2.0.4" universal-user-agent "^2.0.1" url-template "^2.0.8" @@ -795,9 +795,9 @@ universal-user-agent "^2.0.1" "@octokit/rest@^16.0.1": - version "16.1.0" - resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.1.0.tgz#43bee0f58821b6c6a4c9d63e14919a1fb67a71b5" - integrity sha512-/D1XokSycOE+prxxI2r9cxssiLMqcr+BsEUjdruC67puEEjNJjJoRIkuA1b20jOkX5Ue3Rz99Mu9rTnNmjetUA== + version "16.3.0" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.3.0.tgz#98a24a3334312a87fff8a2a54c1dca4d0900d54d" + integrity sha512-u0HkROLB0nOSfJhkF5FKMg6I12m6cN5S3S73Lwtfgrs9u4LhgUCZN2hC2KDyIaT7nhvNe9Kx0PgxhhD6li6QsA== dependencies: "@octokit/request" "2.2.0" before-after-hook "^1.2.0" @@ -835,9 +835,9 @@ integrity sha512-9Tj/qn+y2j+sjCI3Jd+qseGtHjOAeg7dU2/lVcqIQ9TV3QDaDXDYXcoOHU+7o2Hwh8L8ymL4gfuO7KxDs3q2zg== "@semantic-release/github@^5.1.0": - version "5.2.5" - resolved "https://registry.yarnpkg.com/@semantic-release/github/-/github-5.2.5.tgz#14e53d99f1e84c76b5674b7506f235a7a4cae302" - integrity sha512-myO00q84CyfyzaEZ4OdA7GOMCQKd+juZd5g2Cloh4jV6CyiMyWflZ629RH99wjAVUiwMKnvX2SQ5XPFvO1+FCw== + version "5.2.7" + resolved "https://registry.yarnpkg.com/@semantic-release/github/-/github-5.2.7.tgz#d9eb8bcc9332a02b85458ddb0988a17023e2b460" + integrity sha512-cWQhM9bdBv8KAwClmwM64Mo3vsOHVM2aJAGI6K3qbJfJ3GsLJLh1hTi+rMd5EkZ2DA8zUUHCiAJZ3ujMvUB0yg== dependencies: "@octokit/rest" "^16.0.1" "@semantic-release/error" "^2.2.0" @@ -853,14 +853,14 @@ lodash "^4.17.4" mime "^2.0.3" p-filter "^1.0.0" - p-retry "^2.0.0" + p-retry "^3.0.0" parse-github-url "^1.0.1" url-join "^4.0.0" "@semantic-release/npm@^5.0.5": - version "5.1.1" - resolved "https://registry.yarnpkg.com/@semantic-release/npm/-/npm-5.1.1.tgz#f05d50ad174b7b90d71367799780e6dedb7797d8" - integrity sha512-5OnV0od1HKp2QjToXxQufvHNG8n+IQlp7h3FjqmZYH7DAHzAGx4NCf/R4p3RhyX5YJEfQl4ZflX9219JVNsuJg== + version "5.1.2" + resolved "https://registry.yarnpkg.com/@semantic-release/npm/-/npm-5.1.2.tgz#96dda235677c628059abb35f5e8f447f1c5c4d64" + integrity sha512-hAt8Q86jjp0AiykihhZ7vuCFKYz0j8v3W6Jae8b+RCLi8IUofrPF1ZImx3oY0rRu8ZZSb4aU9uxtFmeOYZebjg== dependencies: "@semantic-release/error" "^2.2.0" aggregate-error "^1.0.0" @@ -889,12 +889,10 @@ into-stream "^4.0.0" lodash "^4.17.4" -"@sindresorhus/is@^0.12.0": - version "0.12.0" - resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.12.0.tgz#55c37409c809e802efea25911a579731adfc6e07" - integrity sha512-9ve22cGrAKlSRvi8Vb2JIjzcaaQg79531yQHnF+hi/kOpsSj3Om8AyR1wcHrgl0u7U3vYQ7gmF5erZzOp4+51Q== - dependencies: - symbol-observable "^1.2.0" +"@sindresorhus/is@^0.14.0": + version "0.14.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" + integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== "@szmarczak/http-timer@^1.1.0": version "1.1.1" @@ -942,9 +940,9 @@ "@types/lodash" "*" "@types/lodash@*": - version "4.14.118" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.118.tgz#247bab39bfcc6d910d4927c6e06cbc70ec376f27" - integrity sha512-iiJbKLZbhSa6FYRip/9ZDX6HXhayXLDGY2Fqws9cOkEQ6XeKfaxB0sC541mowZJueYyMnVUmmG+al5/4fCDrgw== + version "4.14.119" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.119.tgz#be847e5f4bc3e35e46d041c394ead8b603ad8b39" + integrity sha512-Z3TNyBL8Vd/M9D9Ms2S3LmFq2sSMzahodD6rCS9V2N44HUMINb75jNkSuwAx7eo2ufqTdfOdtGQpNbieUjPQmw== "@types/minimatch@*": version "3.0.3" @@ -952,9 +950,9 @@ integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== "@types/node@*", "@types/node@^10.12.2": - version "10.12.11" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.11.tgz#715c476c99a5f6898a1ae61caf9825e43c03912e" - integrity sha512-3iIOhNiPGTdcUNVCv9e5G7GotfvJJe2pc9w2UgDXlUwnxSZ3RgcUocIU+xYm+rTU54jIKih998QE4dMOyMN1NQ== + version "10.12.18" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67" + integrity sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ== "@types/semver@^5.5.0": version "5.5.0" @@ -962,9 +960,9 @@ integrity sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ== "@types/shelljs@^0.8.0": - version "0.8.0" - resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.8.0.tgz#0caa56b68baae4f68f44e0dd666ab30b098e3632" - integrity sha512-vs1hCC8RxLHRu2bwumNyYRNrU3o8BtZhLysH5A4I98iYmA2APl6R3uNQb5ihl+WiwH0xdC9LLO+vRrXLs/Kyxg== + version "0.8.1" + resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.8.1.tgz#133e874b5fb816a2e1c8647839c82d76760b1191" + integrity sha512-1lQw+48BuVgp6c1+z8EMipp18IdnV2dLh6KQGwOm+kJy9nPjEkaqRKmwbDNEYf//EKBvKcwOC6V2cDrNxVoQeQ== dependencies: "@types/glob" "*" "@types/node" "*" @@ -1033,9 +1031,9 @@ aggregate-error@^1.0.0: indent-string "^3.0.0" ajv@^6.5.5: - version "6.6.1" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.6.1.tgz#6360f5ed0d80f232cc2b294c362d5dc2e538dd61" - integrity sha512-ZoJjft5B+EJBjUyu9C9Hc0OZyPZSSlOF+plzouTrg6UlA8f+e/n8NIgBFG/9tppJtpPWfthHakK7juJdNDODww== + version "6.6.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.6.2.tgz#caceccf474bf3fc3ce3b147443711a24063cc30d" + integrity sha512-FBHEW6Jf5TB9MGBgUUA9XHkTbjXYfAUjY43ACMfmdMRHniyoMHjHjzD50OK8LGDWQwp4rWEsIq5kEqq7rvIM1g== dependencies: fast-deep-equal "^2.0.1" fast-json-stable-stringify "^2.0.0" @@ -1487,15 +1485,15 @@ block-stream@*: dependencies: inherits "~2.0.0" -bluebird@^3.5.0, bluebird@^3.5.1, bluebird@~3.5.1: +bluebird@^3.5.0, bluebird@^3.5.1, bluebird@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7" integrity sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw== bottleneck@^2.0.1: - version "2.13.0" - resolved "https://registry.yarnpkg.com/bottleneck/-/bottleneck-2.13.0.tgz#875df17df9e62c76bea42b62af3a45c73a995c4f" - integrity sha512-9YmZ0aiKta2OAxTujKCS/INjGWCIGWK4Ff1nQpgHnR4CTjlk9jcnpaHOjPnMZPtqRXkqwKdtxZgvJ9udsXylaw== + version "2.14.1" + resolved "https://registry.yarnpkg.com/bottleneck/-/bottleneck-2.14.1.tgz#3134b3dabbdafa19abbb0531c03529858d029190" + integrity sha512-FAZr9OekUbx/lCGY/Sok2QOFOy3exRWRcjVJfmHrh3J9UoIaLHT0E+TwhXTIPmKS8JHuX6i/eH/kmhhHBEx7DQ== boxen@^1.2.1: version "1.3.0" @@ -1555,14 +1553,14 @@ browser-resolve@^1.11.3: dependencies: resolve "1.1.7" -browserslist@^4.1.0: - version "4.3.4" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.3.4.tgz#4477b737db6a1b07077275b24791e680d4300425" - integrity sha512-u5iz+ijIMUlmV8blX82VGFrB9ecnUg5qEt55CMZ/YJEhha+d8qpBfOFuutJ6F/VKRXjZoD33b6uvarpPxcl3RA== +browserslist@^4.3.4: + version "4.3.6" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.3.6.tgz#0f9d9081afc66b36f477c6bdf3813f784f42396a" + integrity sha512-kMGKs4BTzRWviZ8yru18xBpx+CyHG9eqgRbj9XbE3IMgtczf4aiA0Y1YCpVdvUieKGZ03kolSPXqTcscBCb9qw== dependencies: - caniuse-lite "^1.0.30000899" - electron-to-chromium "^1.3.82" - node-releases "^1.0.1" + caniuse-lite "^1.0.30000921" + electron-to-chromium "^1.3.92" + node-releases "^1.1.1" bs-logger@0.x: version "0.2.6" @@ -1628,23 +1626,23 @@ cacache@^10.0.4: y18n "^4.0.0" cacache@^11.0.1, cacache@^11.0.2, cacache@^11.2.0: - version "11.3.1" - resolved "https://registry.yarnpkg.com/cacache/-/cacache-11.3.1.tgz#d09d25f6c4aca7a6d305d141ae332613aa1d515f" - integrity sha512-2PEw4cRRDu+iQvBTTuttQifacYjLPhET+SYO/gEFMy8uhi+jlJREDAjSF5FWSdV/Aw5h18caHA7vMTw2c+wDzA== + version "11.3.2" + resolved "https://registry.yarnpkg.com/cacache/-/cacache-11.3.2.tgz#2d81e308e3d258ca38125b676b98b2ac9ce69bfa" + integrity sha512-E0zP4EPGDOaT2chM08Als91eYnf8Z+eH1awwwVsngUmgppfM5jjJ8l3z5vO5p5w/I3LsiXawb1sW0VY65pQABg== dependencies: - bluebird "^3.5.1" - chownr "^1.0.1" - figgy-pudding "^3.1.0" - glob "^7.1.2" - graceful-fs "^4.1.11" - lru-cache "^4.1.3" + bluebird "^3.5.3" + chownr "^1.1.1" + figgy-pudding "^3.5.1" + glob "^7.1.3" + graceful-fs "^4.1.15" + lru-cache "^5.1.1" mississippi "^3.0.0" mkdirp "^0.5.1" move-concurrently "^1.0.1" promise-inflight "^1.0.1" rimraf "^2.6.2" - ssri "^6.0.0" - unique-filename "^1.1.0" + ssri "^6.0.1" + unique-filename "^1.1.1" y18n "^4.0.0" cache-base@^1.0.1: @@ -1663,9 +1661,9 @@ cache-base@^1.0.1: unset-value "^1.0.0" cacheable-request@^5.1.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-5.2.0.tgz#00c87097835af4caf92a97390660ecadce51187d" - integrity sha512-h1n0vjpFaByTvU6PiyTKk2kx4OnuV1aVUynCUd/FiKl4icpPSceowk3rHczwFEBuZvz+E1EU4KExR0MCPeQfaQ== + version "5.2.1" + resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-5.2.1.tgz#41814b0460b68b9baf74f57f5a6046224d55d71e" + integrity sha512-+dLut9zvvuIM/MrtdHBVSh/QYJ9+uCKYoqww9cOYrndQH4O4rD/qH0IAwFhD5WJKfmWE6WgCOrLQPd/H5YJRVQ== dependencies: clone-response "^1.0.2" get-stream "^4.0.0" @@ -1735,10 +1733,10 @@ camelcase@^5.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42" integrity sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA== -caniuse-lite@^1.0.30000899: - version "1.0.30000912" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000912.tgz#08e650d4090a9c0ab06bfd2b46b7d3ad6dcaea28" - integrity sha512-M3zAtV36U+xw5mMROlTXpAHClmPAor6GPKAMD5Yi7glCB5sbMPFtnQ3rGpk4XqPdUrrTIaVYSJZxREZWNy8QJg== +caniuse-lite@^1.0.30000921: + version "1.0.30000923" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000923.tgz#148f9bda508024b5ce957b463ae2e8302b451bb2" + integrity sha512-j5ur7eeluOFjjPUkydtXP4KFAsmH3XaQNch5tvWSO+dLHYt5PE+VgJZLWtbVOodfWij6m6zas28T4gB/cLYq1w== capture-exit@^1.2.0: version "1.2.0" @@ -1804,7 +1802,7 @@ chownr@~1.0.1: resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.0.1.tgz#e2a75042a9551908bebd25b8523d5f9769d79181" integrity sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE= -ci-info@^1.4.0, ci-info@^1.5.0: +ci-info@^1.5.0, ci-info@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.6.0.tgz#2ca20dbb9ceb32d4524a683303313f0304b1e497" integrity sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A== @@ -1941,9 +1939,9 @@ colors@1.0.3: integrity sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs= colors@^1.1.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.2.tgz#2df8ff573dfbf255af562f8ce7181d6b971a359b" - integrity sha512-rhP0JSBGYvpcNQj4s5AdShMeE5ahMop96cTeDl/v9qQQm2fYClE2QXZRi8wLzc+GmXSxdIqqbOIAhyObEXDbfQ== + version "1.3.3" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.3.tgz#39e005d546afe01e01f9c4ca8fa50f686a01205d" + integrity sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg== columnify@~1.5.4: version "1.5.4" @@ -2003,7 +2001,7 @@ concat-stream@^1.5.0, concat-stream@^1.5.2: readable-stream "^2.2.2" typedarray "^0.0.6" -config-chain@~1.1.11: +config-chain@^1.1.12: version "1.1.12" resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa" integrity sha512-a1eOIcu8+7lUInge4Rpf/n4Krkf3Dd9lqhljRzII1/Zno/kRtUWnznPO3jOKBmTEktkt3fkxisUcivoj0ebzoA== @@ -2124,9 +2122,9 @@ copy-descriptor@^0.1.0: integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= core-js@^2.4.0, core-js@^2.5.0, core-js@^2.5.7: - version "2.5.7" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" - integrity sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw== + version "2.6.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.1.tgz#87416ae817de957a3f249b3b5ca475d4aaed6042" + integrity sha512-L72mmmEayPJBejKIWe2pYtGis5r0tQ5NaJekdhyXgeMQTpJoBsH0NL4ElY2LfSoV15xeQWKQ+XTTOZdyero5Xg== core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" @@ -2244,9 +2242,9 @@ data-urls@^1.0.0: whatwg-url "^7.0.0" date-fns@^1.27.2: - version "1.29.0" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.29.0.tgz#12e609cdcb935127311d04d33334e2960a2a54e6" - integrity sha512-lbTXWZ6M20cWH8N9S6afb0SBm6tMk+uUg6z3MqHPKE9atmsY3kJkTm8vKe93izJ2B2+q5MV990sM2CHgtAZaOw== + version "1.30.1" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c" + integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw== dateformat@^3.0.0: version "3.0.3" @@ -2275,9 +2273,9 @@ debug@^3.1.0: ms "^2.1.1" debug@^4.0.0, debug@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.0.tgz#373687bffa678b38b1cd91f861b63850035ddc87" - integrity sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg== + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== dependencies: ms "^2.1.1" @@ -2326,10 +2324,10 @@ deep-is@~0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= -deepmerge@2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-2.2.1.tgz#5d3ff22a01c00f645405a2fbc17d0778a1801170" - integrity sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA== +deepmerge@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-3.0.0.tgz#ca7903b34bfa1f8c2eab6779280775a411bfc6ba" + integrity sha512-a8z8bkgHsAML+uHLqmMS83HHlpy3PvZOOuiTQqaa3wu8ZVg3h0hqHk6aCsGdOnZV2XMM/FRimNGjUh0KCcmHBw== default-require-extensions@^1.0.0: version "1.0.0" @@ -2493,10 +2491,10 @@ editor@~1.0.0: resolved "https://registry.yarnpkg.com/editor/-/editor-1.0.0.tgz#60c7f87bd62bcc6a894fa8ccd6afb7823a24f742" integrity sha1-YMf4e9YrzGqJT6jM1q+3gjok90I= -electron-to-chromium@^1.3.82: - version "1.3.86" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.86.tgz#a45ea01da5b26500d12bca5e0f194ebb3e1fd14e" - integrity sha512-BcmXOu37FCPxrrh0wyKgKi5dAjIu2ohxN5ptapkLPKRC3IBK2NeIwh9n1x/8HzSRQiEKamJkDce1ZgOGgEX9iw== +electron-to-chromium@^1.3.92: + version "1.3.96" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.96.tgz#25770ec99b8b07706dedf3a5f43fa50cb54c4f9a" + integrity sha512-ZUXBUyGLeoJxp4Nt6G/GjBRLnyz8IKQGexZ2ndWaoegThgMGFO1tdDYID5gBV32/1S83osjJHyfzvanE/8HY4Q== elegant-spinner@^1.0.1: version "1.0.1" @@ -2518,9 +2516,9 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0: once "^1.4.0" env-ci@^3.0.0: - version "3.1.2" - resolved "https://registry.yarnpkg.com/env-ci/-/env-ci-3.1.2.tgz#ee3c78cd24f61ee12aca8b69ecdf0a97ca3ceb5b" - integrity sha512-qJ+ug5OEHEK6HyjhEB0z2tPJCmdvemQE3WUUYEe7qj7teZIJGjZK9elWB4kxE8qRdVHWl4aBvyVmX0Y5xlMbBw== + version "3.1.3" + resolved "https://registry.yarnpkg.com/env-ci/-/env-ci-3.1.3.tgz#17626015676d35bfb64d6f2945a178d559c0d23d" + integrity sha512-4NudFu3oUCNprsGkt/LmvqAwJlzX9QT8289AavXiDH1pBJuEd4n0ty98yUOWN3uFtjOhOGrmt1/FDKFxCewejw== dependencies: execa "^1.0.0" java-properties "^0.2.9" @@ -3159,7 +3157,7 @@ glob@7.1.2: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@~7.1.2: +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3: version "7.1.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== @@ -3219,11 +3217,11 @@ got@^6.7.1: url-parse-lax "^1.0.0" got@^9.1.0: - version "9.3.2" - resolved "https://registry.yarnpkg.com/got/-/got-9.3.2.tgz#f6e3bd063aa8f461ccd924afa2ba2b61deab3989" - integrity sha512-OyKOUg71IKvwb8Uj0KP6EN3+qVVvXmYsFznU1fnwUnKtDbZnwSlAi7muNlu4HhBfN9dImtlgg9e7H0g5qVdaeQ== + version "9.5.0" + resolved "https://registry.yarnpkg.com/got/-/got-9.5.0.tgz#6fd0312c6b694c0a11d9119d95fd7daed174eb49" + integrity sha512-N+4kb6i9t1lauJ4NwLVVoFVLxZNa6i+iivtNzCSVw7+bVbTXoq0qXctdd8i9rj3lrI0zDk5NGzcO4bfpEP6Uuw== dependencies: - "@sindresorhus/is" "^0.12.0" + "@sindresorhus/is" "^0.14.0" "@szmarczak/http-timer" "^1.1.0" cacheable-request "^5.1.0" decompress-response "^3.3.0" @@ -3235,7 +3233,7 @@ got@^9.1.0: to-readable-stream "^1.0.0" url-parse-lax "^3.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6, graceful-fs@~4.1.11: +graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6: version "4.1.15" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== @@ -4940,6 +4938,13 @@ lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@^4.1.2, lru-cache@^4.1.3: pseudomap "^1.0.2" yallist "^2.1.2" +lru-cache@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" + integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== + dependencies: + yallist "^3.0.2" + macos-release@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.0.0.tgz#7dddf4caf79001a851eb4fba7fb6034f251276ab" @@ -5220,9 +5225,9 @@ minipass@^2.2.1, minipass@^2.3.3, minipass@^2.3.4: yallist "^3.0.0" minizlib@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.1.1.tgz#6734acc045a46e61d596a43bb9d9cd326e19cc42" - integrity sha512-TrfjCjk4jLhcJyGMYymBH6oTXcWjYbUAXTHDbtnWHjZC25h0cdajHuPE1zxb4DVmu8crfh+HwH/WMuyLG0nHBg== + version "1.2.1" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.2.1.tgz#dd27ea6136243c7c880684e8672bb3a45fd9b614" + integrity sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA== dependencies: minipass "^2.2.1" @@ -5306,9 +5311,9 @@ mute-stream@~0.0.4: integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s= nan@^2.9.2: - version "2.11.1" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.1.tgz#90e22bccb8ca57ea4cd37cc83d3819b52eea6766" - integrity sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA== + version "2.12.1" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552" + integrity sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw== nanomatch@^1.2.9: version "1.2.13" @@ -5426,10 +5431,10 @@ node-pre-gyp@^0.10.0: semver "^5.3.0" tar "^4" -node-releases@^1.0.1: - version "1.0.5" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.0.5.tgz#a641adcc968b039a27345d92ef10b093e5cbd41d" - integrity sha512-Ky7q0BO1BBkG/rQz6PkEZ59rwo+aSfhczHP1wwq8IowoVdN/FpiP7qp0XW0P2+BVCWe5fQUBozdbVd54q1RbCQ== +node-releases@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.2.tgz#93c17fba5eec8650ad908de5433fa8763baebe4d" + integrity sha512-j1gEV/zX821yxdWp/1vBMN0pSUjuH9oGUdLCb4PfUko6ZW7KdRs3Z+QGGwDUhYtSpQvdVVyLd2V0YvLsmdg5jQ== dependencies: semver "^5.3.0" @@ -5476,14 +5481,14 @@ normalize-url@^3.1.0: integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg== normalize-url@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.0.0.tgz#6c2214dde2fc8ea88509ec79774ccbd1d426c1ea" - integrity sha512-OrtNzJOeI9+UaF8KfvPoqh8ZVjLiun+fggtLzrpPsmdOU01eIp3vYXDfeFv4KwqJxcmmrW/ubNCN+9iIQRVtfw== + version "4.1.0" + resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.1.0.tgz#307e74c87473efa81969ad1b4bb91f1990178904" + integrity sha512-X781mkWeK6PDMAZJfGn/wnwil4dV6pIdF9euiNqtA89uJvZuNDJO2YyJxiwpPhTQcF5pYUU1v+kcOxzYV6rZlA== npm-audit-report@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/npm-audit-report/-/npm-audit-report-1.3.1.tgz#e79ea1fcb5ffaf3031102b389d5222c2b0459632" - integrity sha512-SjTF8ZP4rOu3JiFrTMi4M1CmVo2tni2sP4TzhyCMHwnMGf6XkdGLZKt9cdZ12esKf0mbQqFyU9LtY0SoeahL7g== + version "1.3.2" + resolved "https://registry.yarnpkg.com/npm-audit-report/-/npm-audit-report-1.3.2.tgz#303bc78cd9e4c226415076a4f7e528c89fc77018" + integrity sha512-abeqS5ONyXNaZJPGAf6TOUMNdSe1Y6cpc9MLBRn+CuUoYbfdca6AxOyXVlfIv9OgKX+cacblbG5w7A6ccwoTPw== dependencies: cli-table3 "^0.5.0" console-control-strings "^1.1.0" @@ -5534,7 +5539,7 @@ npm-logical-tree@^1.2.1: semver "^5.5.0" validate-npm-package-name "^3.0.0" -npm-packlist@^1.1.10, npm-packlist@^1.1.11, npm-packlist@^1.1.6: +npm-packlist@^1.1.10, npm-packlist@^1.1.12, npm-packlist@^1.1.6: version "1.1.12" resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.1.12.tgz#22bde2ebc12e72ca482abd67afc51eb49377243a" integrity sha512-WJKFOVMeAlsU/pjXuqVdzU0WfgtIBCupkEVwn+1Y0ERAbUfWw8R4GjgVbaKnUjRoD2FoQbHOCbOyT5Mbs9Lw4g== @@ -5631,9 +5636,9 @@ npm-which@^3.0.1: which "^1.2.10" npm@^6.3.0: - version "6.4.1" - resolved "https://registry.yarnpkg.com/npm/-/npm-6.4.1.tgz#4f39f9337b557a28faed4a771d5c8802d6b4288b" - integrity sha512-mXJL1NTVU136PtuopXCUQaNWuHlXCTp4McwlSW8S9/Aj8OEPAlSBgo8og7kJ01MjCDrkmqFQTvN5tTEhBMhXQg== + version "6.5.0" + resolved "https://registry.yarnpkg.com/npm/-/npm-6.5.0.tgz#30ed48d4cd4d17d68ee04a5fcf9fa2ca9167d819" + integrity sha512-SPq8zG2Kto+Xrq55E97O14Jla13PmQT5kSnvwBj88BmJZ5Nvw++OmlWfhjkB67pcgP5UEXljEtnGFKZtOgt6MQ== dependencies: JSONStream "^1.3.4" abbrev "~1.1.1" @@ -5642,28 +5647,28 @@ npm@^6.3.0: aproba "~1.2.0" archy "~1.0.0" bin-links "^1.1.2" - bluebird "~3.5.1" + bluebird "^3.5.3" byte-size "^4.0.3" cacache "^11.2.0" call-limit "~1.1.0" chownr "~1.0.1" - ci-info "^1.4.0" + ci-info "^1.6.0" cli-columns "^3.1.2" cli-table3 "^0.5.0" cmd-shim "~2.0.2" columnify "~1.5.4" - config-chain "~1.1.11" + config-chain "^1.1.12" detect-indent "~5.0.0" detect-newline "^2.1.0" dezalgo "~1.0.3" editor "~1.0.0" - figgy-pudding "^3.4.1" + figgy-pudding "^3.5.1" find-npm-prefix "^1.0.2" fs-vacuum "~1.2.10" fs-write-stream-atomic "~1.0.10" gentle-fs "^2.0.1" - glob "~7.1.2" - graceful-fs "~4.1.11" + glob "^7.1.3" + graceful-fs "^4.1.15" has-unicode "~2.0.1" hosted-git-info "^2.7.1" iferr "^1.0.2" @@ -5697,7 +5702,7 @@ npm@^6.3.0: npm-install-checks "~3.0.0" npm-lifecycle "^2.1.0" npm-package-arg "^6.1.0" - npm-packlist "^1.1.11" + npm-packlist "^1.1.12" npm-pick-manifest "^2.1.0" npm-profile "^3.0.2" npm-registry-client "^8.6.0" @@ -5705,7 +5710,7 @@ npm@^6.3.0: npm-user-validate "~1.0.0" npmlog "~4.1.2" once "~1.4.0" - opener "^1.5.0" + opener "^1.5.1" osenv "^0.1.5" pacote "^8.1.6" path-is-inside "~1.0.2" @@ -5723,14 +5728,14 @@ npm@^6.3.0: retry "^0.12.0" rimraf "~2.6.2" safe-buffer "^5.1.2" - semver "^5.5.0" + semver "^5.5.1" sha "~2.0.1" slide "~1.1.6" sorted-object "~2.0.1" sorted-union-stream "~2.1.3" - ssri "^6.0.0" + ssri "^6.0.1" stringify-package "^1.0.0" - tar "^4.4.6" + tar "^4.4.8" text-table "~0.2.0" tiny-relative-date "^1.3.0" uid-number "0.0.6" @@ -5838,7 +5843,7 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" -opener@^1.5.0: +opener@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.1.tgz#6d2f0e77f1a0af0032aca716c2c1fbb8e7e8abed" integrity sha512-goYSy5c2UXE4Ra1xixabeVh1guIX/ZV/YokJksb6q2lubWu6UbvPQ20p542/sFIll1nl8JnCyK9oBaOcCWXwvA== @@ -5982,10 +5987,10 @@ p-reduce@^1.0.0: resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa" integrity sha1-GMKw3ZNqRpClKfgjH1ig/bakffo= -p-retry@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/p-retry/-/p-retry-2.0.0.tgz#b97f1f4d6d81a3c065b2b40107b811e995c1bfba" - integrity sha512-ZbCuzAmiwJ45q4evp/IG9D+5MUllGSUeCWwPt3j/tdYSi1KPkSD+46uqmAA1LhccDhOXv8kYZKNb8x78VflzfA== +p-retry@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-retry/-/p-retry-3.0.0.tgz#f1a09233417dd40b42a7a4a3ed0f4780f23b90d8" + integrity sha512-fAB7bebxaj8nylNAsxPNkwPZ/48bXFdFnWrz0v2sV+H5BsGfVL7Ap7KgONqy7rOK4ZI1I+SU+lmettO3hM+2HQ== dependencies: retry "^0.12.0" @@ -6121,7 +6126,7 @@ path-key@^2.0.0, path-key@^2.0.1: resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= -path-parse@^1.0.5: +path-parse@^1.0.5, path-parse@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== @@ -6302,9 +6307,9 @@ pseudomap@^1.0.2: integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= psl@^1.1.24, psl@^1.1.28: - version "1.1.29" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.29.tgz#60f580d360170bb722a797cc704411e6da850c67" - integrity sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ== + version "1.1.31" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.31.tgz#e9aa86d0101b5b105cbe93ac6b784cd547276184" + integrity sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw== pump@^2.0.0, pump@^2.0.1: version "2.0.1" @@ -6574,11 +6579,16 @@ regenerator-runtime@^0.10.5: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" integrity sha1-M2w+/BIgrc7dosn6tntaeVWjNlg= -regenerator-runtime@^0.11.0, regenerator-runtime@^0.11.1: +regenerator-runtime@^0.11.0: version "0.11.1" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== +regenerator-runtime@^0.12.0: + version "0.12.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de" + integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg== + regenerator-transform@^0.13.3: version "0.13.3" resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.13.3.tgz#264bd9ff38a8ce24b06e0636496b2c856b57bcbb" @@ -6602,14 +6612,14 @@ regex-not@^1.0.0, regex-not@^1.0.2: safe-regex "^1.1.0" regexpu-core@^4.1.3, regexpu-core@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.2.0.tgz#a3744fa03806cffe146dea4421a3e73bdcc47b1d" - integrity sha512-Z835VSnJJ46CNBttalHD/dB+Sj2ezmY6Xp38npwU87peK6mqOzOpV8eYktdkLTEkzzD+JsTcxd84ozd8I14+rw== + version "4.4.0" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.4.0.tgz#8d43e0d1266883969720345e70c275ee0aec0d32" + integrity sha512-eDDWElbwwI3K0Lo6CqbQbA6FwgtCz4kYTarrri1okfkRLZAqstU+B3voZBCjg8Fl6iq0gXrJG6MvRgLthfvgOA== dependencies: regenerate "^1.4.0" regenerate-unicode-properties "^7.0.0" - regjsgen "^0.4.0" - regjsparser "^0.3.0" + regjsgen "^0.5.0" + regjsparser "^0.6.0" unicode-match-property-ecmascript "^1.0.4" unicode-match-property-value-ecmascript "^1.0.2" @@ -6628,15 +6638,15 @@ registry-url@^3.0.3: dependencies: rc "^1.0.1" -regjsgen@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.4.0.tgz#c1eb4c89a209263f8717c782591523913ede2561" - integrity sha512-X51Lte1gCYUdlwhF28+2YMO0U6WeN0GLpgpA7LK7mbdDnkQYiwvEpmpe0F/cv5L14EbxgrdayAG3JETBv0dbXA== +regjsgen@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.5.0.tgz#a7634dc08f89209c2049adda3525711fb97265dd" + integrity sha512-RnIrLhrXCX5ow/E5/Mh2O4e/oa1/jW0eaBKTSy3LaCj+M3Bqvm97GWDp2yUtzIs4LEn65zR2yiYGFqb2ApnzDA== -regjsparser@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.3.0.tgz#3c326da7fcfd69fa0d332575a41c8c0cdf588c96" - integrity sha512-zza72oZBBHzt64G7DxdqrOo/30bhHkwMUoT0WqfGu98XLd7N+1tsy5MJ96Bk4MD0y74n629RhmrGW6XlnLLwCA== +regjsparser@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.6.0.tgz#f1e6ae8b7da2bae96c99399b868cd6c933a2ba9c" + integrity sha512-RQ7YyokLiQBomUJuUG8iGVvkgOLxwyZM8k6d3q5SAXpg4r5TZJZigKFvC6PpD+qQ98bCDC5YelPeA3EucDoNeQ== dependencies: jsesc "~0.5.0" @@ -6767,11 +6777,11 @@ resolve@1.1.7: integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs= resolve@1.x, resolve@^1.1.6, resolve@^1.3.2: - version "1.8.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26" - integrity sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA== + version "1.9.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.9.0.tgz#a14c6fdfa8f92a7df1d996cb7105fa744658ea06" + integrity sha512-TZNye00tI67lwYvzxCxHGjwTNlUV70io54/Ed4j6PscB8xVfuBJpRenI/o6dVk0cY0PYTY27AgCoGGxRnYuItQ== dependencies: - path-parse "^1.0.5" + path-parse "^1.0.6" responselike@^1.0.2: version "1.0.2" @@ -6873,9 +6883,9 @@ sax@^1.2.4: integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== semantic-release@^15.9.16: - version "15.12.3" - resolved "https://registry.yarnpkg.com/semantic-release/-/semantic-release-15.12.3.tgz#9f7c5a8ac55624a6418e0bf95bf53c2030487c12" - integrity sha512-3HCKD2ORxi6jItIoP9WeYJjjHsZqozSf6WUGcLClnRH553OVNKf4mLdOwo9UHJe6dVNSk5z7oDfGWKGwVy63BA== + version "15.13.1" + resolved "https://registry.yarnpkg.com/semantic-release/-/semantic-release-15.13.1.tgz#18541032504aa0b443d011083685c9b42eb38c9f" + integrity sha512-bkrfQ10BhbJRMeq/Ih9DZ9FO4ffDwFYsRR134JP9JvQSf8GVX4sg3SnFFd7Q10C6pKwjKqMZ4+ZNB5uQYMLPEg== dependencies: "@semantic-release/commit-analyzer" "^6.1.0" "@semantic-release/error" "^2.2.0" @@ -6921,7 +6931,7 @@ semver-regex@^2.0.0: resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-2.0.0.tgz#a93c2c5844539a770233379107b38c7b4ac9d338" integrity sha512-mUdIBBvdn0PLOeP3TEkMH7HHeUP3GjsXCwKarjv/kGmUFOYg1VqEemKhoQpWMu6X2I8kHeuVdGibLGkVK+/5Qw== -"semver@2 >=2.2.1 || 3.x || 4 || 5", "semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@5.6.0, "semver@^2.3.0 || 3.x || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5, semver@^5.5.0: +"semver@2 >=2.2.1 || 3.x || 4 || 5", "semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@5.6.0, "semver@^2.3.0 || 3.x || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5, semver@^5.5.0, semver@^5.5.1: version "5.6.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== @@ -7161,9 +7171,9 @@ spawn-error-forwarder@~1.0.0: integrity sha1-Gv2Uc46ZmwNG17n8NzvlXgdXcCk= spdx-correct@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.0.2.tgz#19bb409e91b47b1ad54159243f7312a858db3c2e" - integrity sha512-q9hedtzyXHr5S0A1vEPoK/7l8NpfkFYTq6iCY+Pno2ZbdZR6WexZFtqeVGkGxW3TEJMN914Z55EnAGMmenlIQQ== + version "3.1.0" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4" + integrity sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q== dependencies: spdx-expression-parse "^3.0.0" spdx-license-ids "^3.0.0" @@ -7182,9 +7192,9 @@ spdx-expression-parse@^3.0.0: spdx-license-ids "^3.0.0" spdx-license-ids@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.2.tgz#a59efc09784c2a5bada13cfeaf5c75dd214044d2" - integrity sha512-qky9CVt0lVIECkEsYbNILVnPvycuEBkXoMFLRWsREkomQLevYhtRKC+R91a5TOAQ3bCMjikRwhyaRqj1VYatYg== + version "3.0.3" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.3.tgz#81c0ce8f21474756148bbb5f3bfc0f36bf15d76e" + integrity sha512-uBIcIl3Ih6Phe3XHK1NqboJLdGfwr1UN3k6wSD1dZpmPsIkb8AGNbZYJ1fOBk834+Gxy8rpfDxrS6XLEMZMY2g== split-string@^3.0.1, split-string@^3.0.2: version "3.1.0" @@ -7220,9 +7230,9 @@ sprintf-js@~1.0.2: integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= sshpk@^1.7.0: - version "1.15.2" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.15.2.tgz#c946d6bd9b1a39d0e8635763f5242d6ed6dcb629" - integrity sha512-Ra/OXQtuh0/enyl4ETZAfTaeksa6BXks5ZcjpSUNrjBr0DvrJKX+1fsKDPpT9TBXgHAFsa4510aNVgI8g/+SzA== + version "1.16.0" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.0.tgz#1d4963a2fbffe58050aa9084ca20be81741c07de" + integrity sha512-Zhev35/y7hRMcID/upReIvRse+I9SVhyVre/KTJSJQWMz3C3+G+HpO7m1wK/yckEtujKZ7dS4hkVxAnmHaIGVQ== dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -7241,7 +7251,7 @@ ssri@^5.2.4: dependencies: safe-buffer "^5.1.1" -ssri@^6.0.0: +ssri@^6.0.0, ssri@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8" integrity sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA== @@ -7421,7 +7431,7 @@ supports-color@^5.2.0, supports-color@^5.3.0: dependencies: has-flag "^3.0.0" -symbol-observable@^1.1.0, symbol-observable@^1.2.0: +symbol-observable@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ== @@ -7440,7 +7450,7 @@ tar@^2.0.0: fstream "^1.0.2" inherits "2" -tar@^4, tar@^4.4.3, tar@^4.4.6: +tar@^4, tar@^4.4.3, tar@^4.4.8: version "4.4.8" resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.8.tgz#b19eec3fde2a96e64666df9fdb40c5ca1bc3747d" integrity sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ== @@ -7583,9 +7593,9 @@ traverse@~0.6.6: integrity sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc= travis-deploy-once@^5.0.8: - version "5.0.9" - resolved "https://registry.yarnpkg.com/travis-deploy-once/-/travis-deploy-once-5.0.9.tgz#c5a2f639e17d8fd542f66d25ade126179d5e8acf" - integrity sha512-cyHFErzq0HTEGY29RAq1clqFdt/IkCrlcOmyM1cGoGnEyukrrFi1fpy6JH3Mlf+88XsFwvluqKVWzj2bdz3k8A== + version "5.0.11" + resolved "https://registry.yarnpkg.com/travis-deploy-once/-/travis-deploy-once-5.0.11.tgz#32665480f82ee43b7936f19371f839cdc9b30202" + integrity sha512-iyctEtFvgXxin3Ur6jqqM9QdUqUKU8DShdVlRMDFwhLZ8+IGt3PnYPNZDSW45iDKCiUNJ0tGVidNpVDBG2ioKQ== dependencies: "@babel/core" "^7.0.0" "@babel/polyfill" "^7.0.0" @@ -7594,7 +7604,7 @@ travis-deploy-once@^5.0.8: chalk "^2.1.0" execa "^1.0.0" got "^9.1.0" - p-retry "^2.0.0" + p-retry "^3.0.0" semver "^5.4.1" update-notifier "^2.3.0" url-join "^4.0.0" @@ -7715,7 +7725,7 @@ union-value@^1.0.0: is-extendable "^0.1.1" set-value "^0.4.3" -unique-filename@^1.1.0, unique-filename@~1.1.0: +unique-filename@^1.1.0, unique-filename@^1.1.1, unique-filename@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-1.1.1.tgz#1d69769369ada0583103a1e6ae87681b56573230" integrity sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ== From 1624c13db531f356d0fb9f0d5c3698ad9563dccc Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 25 Dec 2018 00:27:24 +0100 Subject: [PATCH 12/24] chore: update message --- tests/ast-alignment/fixtures-to-test.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index 5b01c20..7275a5a 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -63,10 +63,7 @@ function createFixturePatternConfigFor( config.ignoreSourceType = config.ignoreSourceType || []; /** * The TypeScript compiler gives us the "externalModuleIndicator" to allow typescript-estree do dynamically detect the "sourceType". - * Babylon does not have an equivalent feature (although perhaps it might come in the future https://github.com/babel/babylon/issues/440), - * so we have to specify the "sourceType" we want to use. - * - * By default we have configured babylon to use "script", but for any fixtures specified in the parseWithSourceTypeModule array we need "module". + * Babel has similar feature sourceType='unambiguous' but its not perfect, and in some specific cases we sill have to enforce it. * * First merge the fixtures which need to be parsed with sourceType: "module" into the * ignore list, and then add their full config into the global array. From 2859fa2c7317fd77f37996eaa72c1cd8b91c022d Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 25 Dec 2018 01:56:17 +0100 Subject: [PATCH 13/24] chore: update comments --- tests/ast-alignment/fixtures-to-test.ts | 42 ++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index 7275a5a..ff0fd3d 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -28,9 +28,9 @@ const jsxFilesWithKnownIssues = jsxKnownIssues.map(f => f.replace('jsx/', '')); /** * Current random error difference on jsx/invalid-no-tag-name.src.js * TSEP - SyntaxError - * Babylon - RangeError + * Babel - RangeError * - * Reported here: https://github.com/babel/babylon/issues/674 + * Reported here: https://github.com/babel/babel/issues/6680 */ jsxFilesWithKnownIssues.push('invalid-no-tag-name'); @@ -122,7 +122,7 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('javascript/arrowFunctions', { ignore: [ /** - * Expected babylon parse errors - all of these files below produce parse errors in espree + * Expected babel parse errors - all of these files below produce parse errors in espree * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ @@ -144,7 +144,7 @@ let fixturePatternConfigsToTest = [ */ 'class-one-method-super', // babel parse errors /** - * Expected babylon parse errors - all of these files below produce parse errors in espree + * Expected babel parse errors - all of these files below produce parse errors in espree * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ @@ -158,7 +158,7 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('javascript/destructuring', { ignore: [ /** - * Expected babylon parse errors - all of these files below produce parse errors in espree + * Expected babel parse errors - all of these files below produce parse errors in espree * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ @@ -174,7 +174,7 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('javascript/destructuring-and-spread', { ignore: [ /** - * Expected babylon parse errors - all of these files below produce parse errors in espree + * Expected babel parse errors - all of these files below produce parse errors in espree * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ @@ -190,7 +190,7 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('javascript/forOf', { ignore: [ /** - * TypeScript, espree and acorn parse this fine - esprima, flow and babylon do not... + * TypeScript, espree and acorn parse this fine - esprima, flow and babel do not... */ 'for-of-with-function-initializer' // babel parse errors ] @@ -202,7 +202,7 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('javascript/modules', { ignore: [ /** - * Expected babylon parse errors - all of these files below produce parse errors in espree + * Expected babel parse errors - all of these files below produce parse errors in espree * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ @@ -216,7 +216,7 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('javascript/newTarget', { ignore: [ /** - * Expected babylon parse errors - all of these files below produce parse errors in espree + * Expected babel parse errors - all of these files below produce parse errors in espree * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ @@ -231,7 +231,7 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('javascript/objectLiteralDuplicateProperties', { ignore: [ /** - * Expected babylon parse errors - all of these files below produce parse errors in espree + * Expected babel parse errors - all of these files below produce parse errors in espree * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ @@ -250,7 +250,7 @@ let fixturePatternConfigsToTest = [ createFixturePatternConfigFor('javascript/restParams', { ignore: [ /** - * Expected babylon parse errors - all of these files below produce parse errors in espree + * Expected babel parse errors - all of these files below produce parse errors in espree * as well, but the TypeScript compiler is so forgiving during parsing that typescript-estree * does not actually error on them and will produce an AST. */ @@ -293,7 +293,7 @@ let fixturePatternConfigsToTest = [ fileType: 'ts', ignore: [ /** - * Other babylon parse errors relating to invalid syntax. + * Other babel parse errors relating to invalid syntax. */ 'abstract-class-with-abstract-constructor', // babel parse errors 'class-with-export-parameter-properties', // babel parse errors @@ -303,21 +303,21 @@ let fixturePatternConfigsToTest = [ 'interface-with-all-property-types', // babel parse errors 'interface-with-construct-signature-with-parameter-accessibility', // babel parse errors /** - * typescript-estree erroring, but babylon not. + * typescript-estree erroring, but babel not. */ 'arrow-function-with-type-parameters', // typescript-estree parse errors /** - * Babylon: ClassDeclaration + abstract: true + * Babel: ClassDeclaration + abstract: true * tsep: TSAbstractClassDeclaration */ 'abstract-class-with-abstract-properties', /** - * Babylon: ClassProperty + abstract: true + * Babel: ClassProperty + abstract: true * tsep: TSAbstractClassProperty */ 'abstract-class-with-abstract-readonly-property', /** - * Babylon: TSExpressionWithTypeArguments + * Babel: TSExpressionWithTypeArguments * tsep: ClassImplements */ 'class-with-implements-generic-multiple', @@ -342,20 +342,20 @@ let fixturePatternConfigsToTest = [ 'abstract-interface', 'keyof-operator', /** - * Babylon bug for optional or abstract methods? + * Babel bug for optional or abstract methods? */ 'abstract-class-with-abstract-method', // babel parse errors 'abstract-class-with-optional-method', // babel parse errors 'declare-class-with-optional-method', // babel parse errors /** - * Awaiting feedback on Babylon issue https://github.com/babel/babel/issues/6679 + * Awaiting feedback on Babel issue https://github.com/babel/babel/issues/6679 */ 'class-with-private-parameter-properties', 'class-with-protected-parameter-properties', 'class-with-public-parameter-properties', 'class-with-readonly-parameter-properties', /** - * Not yet supported in Babylon https://github.com/babel/babel/issues/7749 + * Not yet supported in Babel https://github.com/babel/babel/issues/7749 */ 'import-type', 'import-type-with-type-parameters-in-type-reference' @@ -400,7 +400,7 @@ let fixturePatternConfigsToTest = [ */ 'interface-empty-extends', /** - * TypeScript-specific tests taken from "errorRecovery". Babylon is not being as forgiving as the TypeScript compiler here. + * TypeScript-specific tests taken from "errorRecovery". Babel is not being as forgiving as the TypeScript compiler here. */ 'class-empty-extends-implements', // babel parse errors 'class-empty-extends', // babel parse errors @@ -437,7 +437,7 @@ let fixturePatternConfigsToTest = [ */ 'nested-internal-module', /** - * Babylon: TSDeclareFunction + * Babel: TSDeclareFunction * tsep: TSNamespaceFunctionDeclaration */ 'declare-namespace-with-exported-function' From 64465e3ce77d3bf5fbc17a291df4f4a53beb4f2b Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 25 Dec 2018 03:35:41 +0100 Subject: [PATCH 14/24] fix: add directive field to ExpressionStatement --- src/convert.ts | 44 +- src/node-utils.ts | 29 + tests/ast-alignment/fixtures-to-test.ts | 2 + tests/ast-alignment/utils.ts | 4 - .../javascript/directives/block.src.js | 5 + .../directives/directive-in-class.src.js | 19 + .../directives/function-non-strict.src.js | 4 + .../directives/non-directive-string.src.js | 16 + .../directives/program-order.src.js | 3 + .../javascript/directives/program.src.js | 3 + .../fixtures/javascript/directives/raw.src.js | 1 + tests/lib/__snapshots__/javascript.ts.snap | 3859 +++++++++++++++++ 12 files changed, 3982 insertions(+), 7 deletions(-) create mode 100644 tests/fixtures/javascript/directives/block.src.js create mode 100644 tests/fixtures/javascript/directives/directive-in-class.src.js create mode 100644 tests/fixtures/javascript/directives/function-non-strict.src.js create mode 100644 tests/fixtures/javascript/directives/non-directive-string.src.js create mode 100644 tests/fixtures/javascript/directives/program-order.src.js create mode 100644 tests/fixtures/javascript/directives/program.src.js create mode 100644 tests/fixtures/javascript/directives/raw.src.js diff --git a/src/convert.ts b/src/convert.ts index 00c36f3..fb7ec3b 100644 --- a/src/convert.ts +++ b/src/convert.ts @@ -82,14 +82,19 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { /** * Converts a TypeScript node into an ESTree node. - * @param {ts.Node} child the child ts.Node + * @param {ts.Node} child the child ts.Node * @returns {ESTreeNode|null} the converted ESTree node */ function convertChild(child?: ts.Node): ESTreeNode | null { if (!child) { return null; } - return convert({ node: child, parent: node, ast, additionalOptions }); + return convert({ + node: child, + parent: node, + ast, + additionalOptions + }); } /** @@ -110,6 +115,34 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { }; } + /** + * Coverts body ExpressionStatements to directives + */ + function convertBodyExpressionsToDirectives() { + if (result.body && nodeUtils.canContainDirective(node)) { + const unique: string[] = []; + + // directives has to be unique, if directive is registered twice pick only first one + result.body + .filter( + (child: ESTreeNode) => + child.type === AST_NODE_TYPES.ExpressionStatement && + child.expression && + child.expression.type === AST_NODE_TYPES.Literal && + (child.expression as any).value && + typeof (child.expression as any).value === 'string' + ) + .forEach( + (child: { directive: string; expression: { raw: string } }) => { + if (!unique.includes((child.expression as any).raw)) { + child.directive = child.expression.raw.slice(1, -1); + unique.push(child.expression.raw); + } + } + ); + } + } + /** * Converts a ts.Node's typeArguments ts.NodeArray to a flow-like typeParameters node * @param {ts.NodeArray} typeArguments ts.Node typeArguments @@ -519,6 +552,8 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { } }); + convertBodyExpressionsToDirectives(); + (result as any).range[1] = node.endOfFileToken.end; result.loc = nodeUtils.getLocFor( node.getStart(ast), @@ -532,6 +567,8 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { type: AST_NODE_TYPES.BlockStatement, body: node.statements.map(convertChild) }); + + convertBodyExpressionsToDirectives(); break; case SyntaxKind.Identifier: @@ -774,12 +811,13 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { // Expressions - case SyntaxKind.ExpressionStatement: + case SyntaxKind.ExpressionStatement: { Object.assign(result, { type: AST_NODE_TYPES.ExpressionStatement, expression: convertChild(node.expression) }); break; + } case SyntaxKind.ThisKeyword: Object.assign(result, { diff --git a/src/node-utils.ts b/src/node-utils.ts index 3a7b7d6..6ca905c 100644 --- a/src/node-utils.ts +++ b/src/node-utils.ts @@ -142,6 +142,7 @@ export default { getLocFor, getLoc, isToken, + canContainDirective, isJSXToken, getDeclarationKind, getTSNodeAccessibility, @@ -292,6 +293,34 @@ function getLocFor( }; } +/** + * Check whatever node can contain directive + * @param {ts.Node} node + * @returns {boolean} returns true if node can contain directive + */ +function canContainDirective(node: ts.Node): boolean { + switch (node.kind) { + case ts.SyntaxKind.SourceFile: + case ts.SyntaxKind.ModuleBlock: + return true; + case ts.SyntaxKind.Block: + switch (node.parent.kind) { + case ts.SyntaxKind.Constructor: + case ts.SyntaxKind.GetAccessor: + case ts.SyntaxKind.SetAccessor: + case ts.SyntaxKind.ArrowFunction: + case ts.SyntaxKind.FunctionExpression: + case ts.SyntaxKind.FunctionDeclaration: + case ts.SyntaxKind.MethodDeclaration: + return true; + default: + return false; + } + default: + return false; + } +} + /** * Returns line and column data for the given ts.Node or ts.Token, * for the given AST diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index ff0fd3d..3df88be 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -110,6 +110,8 @@ let fixturePatternConfigsToTest = [ ignore: ['**/*'] }), + createFixturePatternConfigFor('javascript/directives'), + createFixturePatternConfigFor('javascript/experimentalObjectRestSpread', { ignore: [ /** diff --git a/tests/ast-alignment/utils.ts b/tests/ast-alignment/utils.ts index f09ea70..8dbf441 100644 --- a/tests/ast-alignment/utils.ts +++ b/tests/ast-alignment/utils.ts @@ -107,10 +107,6 @@ export function preprocessBabylonAST(ast: any): any { key: 'directives', predicate: always }, - { - key: 'directive', - predicate: always - }, { key: 'innerComments', predicate: always diff --git a/tests/fixtures/javascript/directives/block.src.js b/tests/fixtures/javascript/directives/block.src.js new file mode 100644 index 0000000..8d54ee0 --- /dev/null +++ b/tests/fixtures/javascript/directives/block.src.js @@ -0,0 +1,5 @@ +function foo() { + "use strict"; + var a = 1; + "use strict"; +} diff --git a/tests/fixtures/javascript/directives/directive-in-class.src.js b/tests/fixtures/javascript/directives/directive-in-class.src.js new file mode 100644 index 0000000..2d2f36d --- /dev/null +++ b/tests/fixtures/javascript/directives/directive-in-class.src.js @@ -0,0 +1,19 @@ +"use strict"; + +class Foo { + constructor () { + "use strict"; + } + + get foo () { + "use strict"; + } + + set foo (value) { + "use strict"; + } + + method () { + "use strict"; + } +} diff --git a/tests/fixtures/javascript/directives/function-non-strict.src.js b/tests/fixtures/javascript/directives/function-non-strict.src.js new file mode 100644 index 0000000..783e003 --- /dev/null +++ b/tests/fixtures/javascript/directives/function-non-strict.src.js @@ -0,0 +1,4 @@ +function foo () { + "use smth" + 1+1; +} diff --git a/tests/fixtures/javascript/directives/non-directive-string.src.js b/tests/fixtures/javascript/directives/non-directive-string.src.js new file mode 100644 index 0000000..51697ce --- /dev/null +++ b/tests/fixtures/javascript/directives/non-directive-string.src.js @@ -0,0 +1,16 @@ +if (true) { + "use strict" +} + +switch (true) { + case false: { + "use strict" + } + default: { + "use strict" + } +} + +while (true) { + "use strict" +} diff --git a/tests/fixtures/javascript/directives/program-order.src.js b/tests/fixtures/javascript/directives/program-order.src.js new file mode 100644 index 0000000..43e689e --- /dev/null +++ b/tests/fixtures/javascript/directives/program-order.src.js @@ -0,0 +1,3 @@ +"use strict"; +"use loose"; +var a; diff --git a/tests/fixtures/javascript/directives/program.src.js b/tests/fixtures/javascript/directives/program.src.js new file mode 100644 index 0000000..6603b9c --- /dev/null +++ b/tests/fixtures/javascript/directives/program.src.js @@ -0,0 +1,3 @@ +"use strict"; +var a = 1; +"use strict"; diff --git a/tests/fixtures/javascript/directives/raw.src.js b/tests/fixtures/javascript/directives/raw.src.js new file mode 100644 index 0000000..10ecb3d --- /dev/null +++ b/tests/fixtures/javascript/directives/raw.src.js @@ -0,0 +1 @@ +"use\x20strict"; diff --git a/tests/lib/__snapshots__/javascript.ts.snap b/tests/lib/__snapshots__/javascript.ts.snap index 0e7dfb2..e7311ab 100644 --- a/tests/lib/__snapshots__/javascript.ts.snap +++ b/tests/lib/__snapshots__/javascript.ts.snap @@ -2921,6 +2921,7 @@ exports[`javascript fixtures/arrowFunctions/error-strict-default-param-eval.src Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -3275,6 +3276,7 @@ exports[`javascript fixtures/arrowFunctions/error-strict-dup-params.src 1`] = ` Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -3616,6 +3618,7 @@ Object { "body": Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -3947,6 +3950,7 @@ exports[`javascript fixtures/arrowFunctions/error-strict-eval-return.src 1`] = ` Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -4211,6 +4215,7 @@ exports[`javascript fixtures/arrowFunctions/error-strict-octal.src 1`] = ` Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -4493,6 +4498,7 @@ exports[`javascript fixtures/arrowFunctions/error-strict-param-arguments.src 1`] Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -4829,6 +4835,7 @@ exports[`javascript fixtures/arrowFunctions/error-strict-param-eval.src 1`] = ` Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -5165,6 +5172,7 @@ exports[`javascript fixtures/arrowFunctions/error-strict-param-names.src 1`] = ` Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -5501,6 +5509,7 @@ exports[`javascript fixtures/arrowFunctions/error-strict-param-no-paren-argument Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -5747,6 +5756,7 @@ exports[`javascript fixtures/arrowFunctions/error-strict-param-no-paren-eval.src Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -64970,6 +64980,3848 @@ Object { } `; +exports[`javascript fixtures/directives/block.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "directive": "use strict", + "expression": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 19, + 31, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 19, + 32, + ], + "type": "ExpressionStatement", + }, + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "name": "a", + "range": Array [ + 39, + 40, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 43, + 44, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 39, + 44, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "var", + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 35, + 45, + ], + "type": "VariableDeclaration", + }, + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 48, + 60, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 48, + 61, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 63, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 0, + 63, + ], + "type": "FunctionDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 6, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 64, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 19, + 31, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 35, + 38, + ], + "type": "Keyword", + "value": "var", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 48, + 60, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 14, + "line": 4, + }, + }, + "range": Array [ + 60, + 61, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 62, + 63, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/directives/directive-in-class.src 1`] = ` +Object { + "body": Array [ + Object { + "directive": "use strict", + "expression": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 13, + ], + "type": "ExpressionStatement", + }, + Object { + "body": Object { + "body": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "name": "constructor", + "range": Array [ + 31, + 42, + ], + "type": "Identifier", + }, + "kind": "constructor", + "loc": Object { + "end": Object { + "column": 5, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "range": Array [ + 31, + 75, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "directive": "use strict", + "expression": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "range": Array [ + 56, + 68, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 21, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "range": Array [ + 56, + 69, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 6, + }, + "start": Object { + "column": 19, + "line": 4, + }, + }, + "range": Array [ + 46, + 75, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 5, + "line": 6, + }, + "start": Object { + "column": 16, + "line": 4, + }, + }, + "params": Array [], + "range": Array [ + 43, + 75, + ], + "type": "FunctionExpression", + }, + }, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 8, + }, + "start": Object { + "column": 8, + "line": 8, + }, + }, + "name": "foo", + "range": Array [ + 85, + 88, + ], + "type": "Identifier", + }, + "kind": "get", + "loc": Object { + "end": Object { + "column": 5, + "line": 10, + }, + "start": Object { + "column": 4, + "line": 8, + }, + }, + "range": Array [ + 81, + 121, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "directive": "use strict", + "expression": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 9, + }, + "start": Object { + "column": 8, + "line": 9, + }, + }, + "range": Array [ + 102, + 114, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 21, + "line": 9, + }, + "start": Object { + "column": 8, + "line": 9, + }, + }, + "range": Array [ + 102, + 115, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 10, + }, + "start": Object { + "column": 15, + "line": 8, + }, + }, + "range": Array [ + 92, + 121, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 5, + "line": 10, + }, + "start": Object { + "column": 12, + "line": 8, + }, + }, + "params": Array [], + "range": Array [ + 89, + 121, + ], + "type": "FunctionExpression", + }, + }, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 12, + }, + "start": Object { + "column": 8, + "line": 12, + }, + }, + "name": "foo", + "range": Array [ + 131, + 134, + ], + "type": "Identifier", + }, + "kind": "set", + "loc": Object { + "end": Object { + "column": 5, + "line": 14, + }, + "start": Object { + "column": 4, + "line": 12, + }, + }, + "range": Array [ + 127, + 172, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "directive": "use strict", + "expression": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 13, + }, + "start": Object { + "column": 8, + "line": 13, + }, + }, + "range": Array [ + 153, + 165, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 21, + "line": 13, + }, + "start": Object { + "column": 8, + "line": 13, + }, + }, + "range": Array [ + 153, + 166, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 14, + }, + "start": Object { + "column": 20, + "line": 12, + }, + }, + "range": Array [ + 143, + 172, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 5, + "line": 14, + }, + "start": Object { + "column": 12, + "line": 12, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 12, + }, + "start": Object { + "column": 13, + "line": 12, + }, + }, + "name": "value", + "range": Array [ + 136, + 141, + ], + "type": "Identifier", + }, + ], + "range": Array [ + 135, + 172, + ], + "type": "FunctionExpression", + }, + }, + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 16, + }, + "start": Object { + "column": 4, + "line": 16, + }, + }, + "name": "method", + "range": Array [ + 178, + 184, + ], + "type": "Identifier", + }, + "kind": "method", + "loc": Object { + "end": Object { + "column": 5, + "line": 18, + }, + "start": Object { + "column": 4, + "line": 16, + }, + }, + "range": Array [ + 178, + 217, + ], + "static": false, + "type": "MethodDefinition", + "value": Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "directive": "use strict", + "expression": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 17, + }, + "start": Object { + "column": 8, + "line": 17, + }, + }, + "range": Array [ + 198, + 210, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 21, + "line": 17, + }, + "start": Object { + "column": 8, + "line": 17, + }, + }, + "range": Array [ + 198, + 211, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 18, + }, + "start": Object { + "column": 14, + "line": 16, + }, + }, + "range": Array [ + 188, + 217, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": null, + "loc": Object { + "end": Object { + "column": 5, + "line": 18, + }, + "start": Object { + "column": 11, + "line": 16, + }, + }, + "params": Array [], + "range": Array [ + 185, + 217, + ], + "type": "FunctionExpression", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 19, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 25, + 219, + ], + "type": "ClassBody", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "name": "Foo", + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 19, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 15, + 219, + ], + "superClass": null, + "type": "ClassDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 20, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 220, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 15, + 20, + ], + "type": "Keyword", + "value": "class", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 21, + 24, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "range": Array [ + 31, + 42, + ], + "type": "Identifier", + "value": "constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 4, + }, + "start": Object { + "column": 16, + "line": 4, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 4, + }, + "start": Object { + "column": 17, + "line": 4, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 4, + }, + "start": Object { + "column": 19, + "line": 4, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "range": Array [ + 56, + 68, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 5, + }, + "start": Object { + "column": 20, + "line": 5, + }, + }, + "range": Array [ + 68, + 69, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 74, + 75, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 8, + }, + "start": Object { + "column": 4, + "line": 8, + }, + }, + "range": Array [ + 81, + 84, + ], + "type": "Identifier", + "value": "get", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 8, + }, + "start": Object { + "column": 8, + "line": 8, + }, + }, + "range": Array [ + 85, + 88, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 8, + }, + "start": Object { + "column": 12, + "line": 8, + }, + }, + "range": Array [ + 89, + 90, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 8, + }, + "start": Object { + "column": 13, + "line": 8, + }, + }, + "range": Array [ + 90, + 91, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 8, + }, + "start": Object { + "column": 15, + "line": 8, + }, + }, + "range": Array [ + 92, + 93, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 9, + }, + "start": Object { + "column": 8, + "line": 9, + }, + }, + "range": Array [ + 102, + 114, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 9, + }, + "start": Object { + "column": 20, + "line": 9, + }, + }, + "range": Array [ + 114, + 115, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 10, + }, + "start": Object { + "column": 4, + "line": 10, + }, + }, + "range": Array [ + 120, + 121, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 12, + }, + "start": Object { + "column": 4, + "line": 12, + }, + }, + "range": Array [ + 127, + 130, + ], + "type": "Identifier", + "value": "set", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 12, + }, + "start": Object { + "column": 8, + "line": 12, + }, + }, + "range": Array [ + 131, + 134, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 12, + }, + "start": Object { + "column": 12, + "line": 12, + }, + }, + "range": Array [ + 135, + 136, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 12, + }, + "start": Object { + "column": 13, + "line": 12, + }, + }, + "range": Array [ + 136, + 141, + ], + "type": "Identifier", + "value": "value", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 12, + }, + "start": Object { + "column": 18, + "line": 12, + }, + }, + "range": Array [ + 141, + 142, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 12, + }, + "start": Object { + "column": 20, + "line": 12, + }, + }, + "range": Array [ + 143, + 144, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 13, + }, + "start": Object { + "column": 8, + "line": 13, + }, + }, + "range": Array [ + 153, + 165, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 13, + }, + "start": Object { + "column": 20, + "line": 13, + }, + }, + "range": Array [ + 165, + 166, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 14, + }, + "start": Object { + "column": 4, + "line": 14, + }, + }, + "range": Array [ + 171, + 172, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 16, + }, + "start": Object { + "column": 4, + "line": 16, + }, + }, + "range": Array [ + 178, + 184, + ], + "type": "Identifier", + "value": "method", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 16, + }, + "start": Object { + "column": 11, + "line": 16, + }, + }, + "range": Array [ + 185, + 186, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 16, + }, + "start": Object { + "column": 12, + "line": 16, + }, + }, + "range": Array [ + 186, + 187, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 16, + }, + "start": Object { + "column": 14, + "line": 16, + }, + }, + "range": Array [ + 188, + 189, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 17, + }, + "start": Object { + "column": 8, + "line": 17, + }, + }, + "range": Array [ + 198, + 210, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 17, + }, + "start": Object { + "column": 20, + "line": 17, + }, + }, + "range": Array [ + 210, + 211, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 18, + }, + "start": Object { + "column": 4, + "line": 18, + }, + }, + "range": Array [ + 216, + 217, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 19, + }, + "start": Object { + "column": 0, + "line": 19, + }, + }, + "range": Array [ + 218, + 219, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/directives/function-non-strict.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [ + Object { + "directive": "use smth", + "expression": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 20, + 30, + ], + "raw": "\\"use smth\\"", + "type": "Literal", + "value": "use smth", + }, + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 20, + 30, + ], + "type": "ExpressionStatement", + }, + Object { + "expression": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 33, + 34, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "operator": "+", + "range": Array [ + 33, + 36, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 35, + 36, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "type": "BinaryExpression", + }, + "loc": Object { + "end": Object { + "column": 6, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 33, + 37, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 4, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 39, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [], + "range": Array [ + 0, + 39, + ], + "type": "FunctionDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 40, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 12, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 20, + 30, + ], + "type": "String", + "value": "\\"use smth\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 3, + }, + "start": Object { + "column": 3, + "line": 3, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Punctuator", + "value": "+", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 3, + }, + "start": Object { + "column": 5, + "line": 3, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 4, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/directives/non-directive-string.src 1`] = ` +Object { + "body": Array [ + Object { + "alternate": null, + "consequent": Object { + "body": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 16, + 28, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 16, + 28, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 30, + ], + "type": "BlockStatement", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 30, + ], + "test": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 8, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + "type": "IfStatement", + }, + Object { + "cases": Array [ + Object { + "consequent": Array [ + Object { + "body": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 7, + }, + "start": Object { + "column": 8, + "line": 7, + }, + }, + "range": Array [ + 74, + 86, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 7, + }, + "start": Object { + "column": 8, + "line": 7, + }, + }, + "range": Array [ + 74, + 86, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 8, + }, + "start": Object { + "column": 16, + "line": 6, + }, + }, + "range": Array [ + 64, + 92, + ], + "type": "BlockStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 8, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 52, + 92, + ], + "test": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 6, + }, + "start": Object { + "column": 9, + "line": 6, + }, + }, + "range": Array [ + 57, + 62, + ], + "raw": "false", + "type": "Literal", + "value": false, + }, + "type": "SwitchCase", + }, + Object { + "consequent": Array [ + Object { + "body": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 10, + }, + "start": Object { + "column": 8, + "line": 10, + }, + }, + "range": Array [ + 116, + 128, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 10, + }, + "start": Object { + "column": 8, + "line": 10, + }, + }, + "range": Array [ + 116, + 128, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 11, + }, + "start": Object { + "column": 13, + "line": 9, + }, + }, + "range": Array [ + 106, + 134, + ], + "type": "BlockStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 5, + "line": 11, + }, + "start": Object { + "column": 4, + "line": 9, + }, + }, + "range": Array [ + 97, + 134, + ], + "test": null, + "type": "SwitchCase", + }, + ], + "discriminant": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "range": Array [ + 40, + 44, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 12, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 32, + 136, + ], + "type": "SwitchStatement", + }, + Object { + "body": Object { + "body": Array [ + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 15, + }, + "start": Object { + "column": 4, + "line": 15, + }, + }, + "range": Array [ + 157, + 169, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 16, + "line": 15, + }, + "start": Object { + "column": 4, + "line": 15, + }, + }, + "range": Array [ + 157, + 169, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 16, + }, + "start": Object { + "column": 13, + "line": 14, + }, + }, + "range": Array [ + 151, + 171, + ], + "type": "BlockStatement", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 16, + }, + "start": Object { + "column": 0, + "line": 14, + }, + }, + "range": Array [ + 138, + 171, + ], + "test": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 14, + }, + "start": Object { + "column": 7, + "line": 14, + }, + }, + "range": Array [ + 145, + 149, + ], + "raw": "true", + "type": "Literal", + "value": true, + }, + "type": "WhileStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 17, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 172, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 2, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 2, + ], + "type": "Keyword", + "value": "if", + }, + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 3, + "line": 1, + }, + }, + "range": Array [ + 3, + 4, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 8, + ], + "type": "Boolean", + "value": "true", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 16, + 28, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 32, + 38, + ], + "type": "Keyword", + "value": "switch", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 5, + }, + "start": Object { + "column": 7, + "line": 5, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 5, + }, + "start": Object { + "column": 8, + "line": 5, + }, + }, + "range": Array [ + 40, + 44, + ], + "type": "Boolean", + "value": "true", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 5, + }, + "start": Object { + "column": 12, + "line": 5, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 5, + }, + "start": Object { + "column": 14, + "line": 5, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 6, + }, + "start": Object { + "column": 4, + "line": 6, + }, + }, + "range": Array [ + 52, + 56, + ], + "type": "Keyword", + "value": "case", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 6, + }, + "start": Object { + "column": 9, + "line": 6, + }, + }, + "range": Array [ + 57, + 62, + ], + "type": "Boolean", + "value": "false", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 6, + }, + "start": Object { + "column": 14, + "line": 6, + }, + }, + "range": Array [ + 62, + 63, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 6, + }, + "start": Object { + "column": 16, + "line": 6, + }, + }, + "range": Array [ + 64, + 65, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 7, + }, + "start": Object { + "column": 8, + "line": 7, + }, + }, + "range": Array [ + 74, + 86, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 8, + }, + "start": Object { + "column": 4, + "line": 8, + }, + }, + "range": Array [ + 91, + 92, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 9, + }, + "start": Object { + "column": 4, + "line": 9, + }, + }, + "range": Array [ + 97, + 104, + ], + "type": "Keyword", + "value": "default", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 9, + }, + "start": Object { + "column": 11, + "line": 9, + }, + }, + "range": Array [ + 104, + 105, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 9, + }, + "start": Object { + "column": 13, + "line": 9, + }, + }, + "range": Array [ + 106, + 107, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 10, + }, + "start": Object { + "column": 8, + "line": 10, + }, + }, + "range": Array [ + 116, + 128, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 11, + }, + "start": Object { + "column": 4, + "line": 11, + }, + }, + "range": Array [ + 133, + 134, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 12, + }, + "start": Object { + "column": 0, + "line": 12, + }, + }, + "range": Array [ + 135, + 136, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 14, + }, + "start": Object { + "column": 0, + "line": 14, + }, + }, + "range": Array [ + 138, + 143, + ], + "type": "Keyword", + "value": "while", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 14, + }, + "start": Object { + "column": 6, + "line": 14, + }, + }, + "range": Array [ + 144, + 145, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 14, + }, + "start": Object { + "column": 7, + "line": 14, + }, + }, + "range": Array [ + 145, + 149, + ], + "type": "Boolean", + "value": "true", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 14, + }, + "start": Object { + "column": 11, + "line": 14, + }, + }, + "range": Array [ + 149, + 150, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 14, + }, + "start": Object { + "column": 13, + "line": 14, + }, + }, + "range": Array [ + 151, + 152, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 15, + }, + "start": Object { + "column": 4, + "line": 15, + }, + }, + "range": Array [ + 157, + 169, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 16, + }, + "start": Object { + "column": 0, + "line": 16, + }, + }, + "range": Array [ + 170, + 171, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/directives/program.src 1`] = ` +Object { + "body": Array [ + Object { + "directive": "use strict", + "expression": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 13, + ], + "type": "ExpressionStatement", + }, + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "a", + "range": Array [ + 18, + 19, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 22, + 23, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 18, + 23, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "var", + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 14, + 24, + ], + "type": "VariableDeclaration", + }, + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 25, + 37, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 25, + 38, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 39, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 14, + 17, + ], + "type": "Keyword", + "value": "var", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 2, + }, + "start": Object { + "column": 6, + "line": 2, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 2, + }, + "start": Object { + "column": 8, + "line": 2, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 2, + }, + "start": Object { + "column": 9, + "line": 2, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 25, + 37, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 3, + }, + "start": Object { + "column": 12, + "line": 3, + }, + }, + "range": Array [ + 37, + 38, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/directives/program-order.src 1`] = ` +Object { + "body": Array [ + Object { + "directive": "use strict", + "expression": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 13, + ], + "type": "ExpressionStatement", + }, + Object { + "directive": "use loose", + "expression": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 14, + 25, + ], + "raw": "\\"use loose\\"", + "type": "Literal", + "value": "use loose", + }, + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 14, + 26, + ], + "type": "ExpressionStatement", + }, + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "name": "a", + "range": Array [ + 31, + 32, + ], + "type": "Identifier", + }, + "init": null, + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "var", + "loc": Object { + "end": Object { + "column": 6, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 27, + 33, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 4, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 34, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 14, + 25, + ], + "type": "String", + "value": "\\"use loose\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 2, + }, + "start": Object { + "column": 11, + "line": 2, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 27, + 30, + ], + "type": "Keyword", + "value": "var", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 3, + }, + "start": Object { + "column": 5, + "line": 3, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/directives/raw.src 1`] = ` +Object { + "body": Array [ + Object { + "directive": "use\\\\x20strict", + "expression": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 15, + ], + "raw": "\\"use\\\\x20strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 16, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 17, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 15, + ], + "type": "String", + "value": "\\"use\\\\x20strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`javascript fixtures/experimentalAsyncIteration/async-generators.src 1`] = ` Object { "body": Array [ @@ -97713,6 +101565,7 @@ exports[`javascript fixtures/objectLiteralDuplicateProperties/error-proto-proper Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -98413,6 +102266,7 @@ exports[`javascript fixtures/objectLiteralDuplicateProperties/error-proto-string Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -99115,6 +102969,7 @@ exports[`javascript fixtures/objectLiteralDuplicateProperties/strict-duplicate-p Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -99636,6 +103491,7 @@ exports[`javascript fixtures/objectLiteralDuplicateProperties/strict-duplicate-s Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -103908,6 +107764,7 @@ exports[`javascript fixtures/octalLiterals/strict-uppercase.src 1`] = ` Object { "body": Array [ Object { + "directive": "use strict", "expression": Object { "loc": Object { "end": Object { @@ -112011,6 +115868,7 @@ exports[`javascript fixtures/unicodeCodePointEscapes/basic-string-literal.src 1` Object { "body": Array [ Object { + "directive": "\\\\u{714E}\\\\u{8336}", "expression": Object { "loc": Object { "end": Object { @@ -112108,6 +115966,7 @@ exports[`javascript fixtures/unicodeCodePointEscapes/complex-string-literal.src Object { "body": Array [ Object { + "directive": "\\\\u{20BB7}\\\\u{10FFFF}\\\\u{1}", "expression": Object { "loc": Object { "end": Object { From d2aada2e3a3229914c20300984a7960dfabf450c Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 25 Dec 2018 18:17:33 +0100 Subject: [PATCH 15/24] fix: add TSTypeQuery and TSIndexedAccessType to supported types add additional tests for types --- src/ast-node-types.ts | 2 + .../fixtures/typescript/types/indexed.src.ts | 1 + .../types/reference-generic-nested.src.ts | 1 + .../typescript/types/reference-generic.src.ts | 1 + .../typescript/types/reference.src.ts | 1 + .../typescript/types/tuple-empty.src.ts | 1 + .../typescript/types/tuple-optional.src.ts | 1 + tests/fixtures/typescript/types/tuple.src.ts | 1 + .../typescript/types/type-literal.src.ts | 1 + .../typescript/types/type-operator.src.ts | 2 + tests/fixtures/typescript/types/typeof.src.ts | 1 + .../types/union-intersection.src.ts | 4 + tests/lib/__snapshots__/typescript.ts.snap | 7389 ++++++++++++++--- 13 files changed, 6104 insertions(+), 1302 deletions(-) create mode 100644 tests/fixtures/typescript/types/indexed.src.ts create mode 100644 tests/fixtures/typescript/types/reference-generic-nested.src.ts create mode 100644 tests/fixtures/typescript/types/reference-generic.src.ts create mode 100644 tests/fixtures/typescript/types/reference.src.ts create mode 100644 tests/fixtures/typescript/types/tuple-empty.src.ts create mode 100644 tests/fixtures/typescript/types/tuple-optional.src.ts create mode 100644 tests/fixtures/typescript/types/tuple.src.ts create mode 100644 tests/fixtures/typescript/types/type-literal.src.ts create mode 100644 tests/fixtures/typescript/types/type-operator.src.ts create mode 100644 tests/fixtures/typescript/types/typeof.src.ts create mode 100644 tests/fixtures/typescript/types/union-intersection.src.ts diff --git a/src/ast-node-types.ts b/src/ast-node-types.ts index 9dbbc2f..fd7453f 100644 --- a/src/ast-node-types.ts +++ b/src/ast-node-types.ts @@ -115,6 +115,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = { TSExportKeyword: 'TSExportKeyword', TSImportType: 'TSImportType', TSLiteralType: 'TSLiteralType', + TSIndexedAccessType: 'TSIndexedAccessType', TSIndexSignature: 'TSIndexSignature', TSInterfaceBody: 'TSInterfaceBody', TSInterfaceDeclaration: 'TSInterfaceDeclaration', @@ -149,6 +150,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = { TSTypeParameterInstantiation: 'TSTypeParameterInstantiation', TSTypePredicate: 'TSTypePredicate', TSTypeReference: 'TSTypeReference', + TSTypeQuery: 'TSTypeQuery', TSIntersectionType: 'TSIntersectionType', TSTupleType: 'TSTupleType', TSOptionalType: 'TSOptionalType', diff --git a/tests/fixtures/typescript/types/indexed.src.ts b/tests/fixtures/typescript/types/indexed.src.ts new file mode 100644 index 0000000..4a5809f --- /dev/null +++ b/tests/fixtures/typescript/types/indexed.src.ts @@ -0,0 +1 @@ +let x: T[K]; diff --git a/tests/fixtures/typescript/types/reference-generic-nested.src.ts b/tests/fixtures/typescript/types/reference-generic-nested.src.ts new file mode 100644 index 0000000..e38dfca --- /dev/null +++ b/tests/fixtures/typescript/types/reference-generic-nested.src.ts @@ -0,0 +1 @@ +let x: Array>; diff --git a/tests/fixtures/typescript/types/reference-generic.src.ts b/tests/fixtures/typescript/types/reference-generic.src.ts new file mode 100644 index 0000000..4925bd4 --- /dev/null +++ b/tests/fixtures/typescript/types/reference-generic.src.ts @@ -0,0 +1 @@ +let x: Array; diff --git a/tests/fixtures/typescript/types/reference.src.ts b/tests/fixtures/typescript/types/reference.src.ts new file mode 100644 index 0000000..330fb1d --- /dev/null +++ b/tests/fixtures/typescript/types/reference.src.ts @@ -0,0 +1 @@ +let x: T; diff --git a/tests/fixtures/typescript/types/tuple-empty.src.ts b/tests/fixtures/typescript/types/tuple-empty.src.ts new file mode 100644 index 0000000..f7cd7b5 --- /dev/null +++ b/tests/fixtures/typescript/types/tuple-empty.src.ts @@ -0,0 +1 @@ +let x: []; diff --git a/tests/fixtures/typescript/types/tuple-optional.src.ts b/tests/fixtures/typescript/types/tuple-optional.src.ts new file mode 100644 index 0000000..3b8d21b --- /dev/null +++ b/tests/fixtures/typescript/types/tuple-optional.src.ts @@ -0,0 +1 @@ +let x: [string, number?, (string | number)?] diff --git a/tests/fixtures/typescript/types/tuple.src.ts b/tests/fixtures/typescript/types/tuple.src.ts new file mode 100644 index 0000000..53c8e72 --- /dev/null +++ b/tests/fixtures/typescript/types/tuple.src.ts @@ -0,0 +1 @@ +let x: [number, number, number]; diff --git a/tests/fixtures/typescript/types/type-literal.src.ts b/tests/fixtures/typescript/types/type-literal.src.ts new file mode 100644 index 0000000..4193f36 --- /dev/null +++ b/tests/fixtures/typescript/types/type-literal.src.ts @@ -0,0 +1 @@ +let obj: { x: number }; diff --git a/tests/fixtures/typescript/types/type-operator.src.ts b/tests/fixtures/typescript/types/type-operator.src.ts new file mode 100644 index 0000000..1d23f96 --- /dev/null +++ b/tests/fixtures/typescript/types/type-operator.src.ts @@ -0,0 +1,2 @@ +let x: keyof T; +let y: unique symbol; diff --git a/tests/fixtures/typescript/types/typeof.src.ts b/tests/fixtures/typescript/types/typeof.src.ts new file mode 100644 index 0000000..eebcd19 --- /dev/null +++ b/tests/fixtures/typescript/types/typeof.src.ts @@ -0,0 +1 @@ +let x: typeof y.z; diff --git a/tests/fixtures/typescript/types/union-intersection.src.ts b/tests/fixtures/typescript/types/union-intersection.src.ts new file mode 100644 index 0000000..93f391f --- /dev/null +++ b/tests/fixtures/typescript/types/union-intersection.src.ts @@ -0,0 +1,4 @@ +let union: number | null | undefined; +let intersection: number & string; +let precedence1: number | string & boolean; +let precedence2: number & string | boolean; diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index 39cf13a..351ad4d 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -72207,7 +72207,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 8, + "column": 15, "line": 1, }, "start": Object { @@ -76257,295 +76257,168 @@ Object { } `; -exports[`typescript fixtures/types/intersection-type.src 1`] = ` +exports[`typescript fixtures/types/indexed.src 1`] = ` Object { "body": Array [ Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 15, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "LinkedList", - "range": Array [ - 5, - 15, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 49, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 49, - ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 21, - "line": 1, - }, - }, - "range": Array [ - 21, - 48, - ], - "type": "TSIntersectionType", - "types": Array [ - Object { + "declarations": Array [ + Object { + "id": Object { "loc": Object { "end": Object { - "column": 22, + "column": 11, "line": 1, }, "start": Object { - "column": 21, + "column": 4, "line": 1, }, }, + "name": "x", "range": Array [ - 21, - 22, + 4, + 11, ], - "type": "TSTypeReference", - "typeName": Object { + "type": "Identifier", + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 22, + "column": 11, "line": 1, }, "start": Object { - "column": 21, + "column": 5, "line": 1, }, }, - "name": "T", "range": Array [ - 21, - 22, + 5, + 11, ], - "type": "Identifier", - }, - }, - Object { - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 25, - "line": 1, - }, - }, - "members": Array [ - Object { - "computed": false, - "key": Object { + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "indexType": Object { "loc": Object { "end": Object { - "column": 31, + "column": 10, "line": 1, }, "start": Object { - "column": 27, + "column": 9, "line": 1, }, }, - "name": "next", "range": Array [ - 27, - 31, + 9, + 10, ], - "type": "Identifier", + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "K", + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + }, }, "loc": Object { "end": Object { - "column": 46, + "column": 11, "line": 1, }, "start": Object { - "column": 27, + "column": 7, "line": 1, }, }, - "range": Array [ - 27, - 46, - ], - "type": "TSPropertySignature", - "typeAnnotation": Object { + "objectType": Object { "loc": Object { "end": Object { - "column": 46, + "column": 8, "line": 1, }, "start": Object { - "column": 31, + "column": 7, "line": 1, }, }, "range": Array [ - 31, - 46, + 7, + 8, ], - "type": "TSTypeAnnotation", - "typeAnnotation": Object { + "type": "TSTypeReference", + "typeName": Object { "loc": Object { "end": Object { - "column": 46, + "column": 8, "line": 1, }, "start": Object { - "column": 33, + "column": 7, "line": 1, }, }, + "name": "T", "range": Array [ - 33, - 46, + 7, + 8, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 43, - "line": 1, - }, - "start": Object { - "column": 33, - "line": 1, - }, - }, - "name": "LinkedList", - "range": Array [ - 33, - 43, - ], - "type": "Identifier", - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 46, - "line": 1, - }, - "start": Object { - "column": 43, - "line": 1, - }, - }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 45, - "line": 1, - }, - "start": Object { - "column": 44, - "line": 1, - }, - }, - "range": Array [ - 44, - 45, - ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 45, - "line": 1, - }, - "start": Object { - "column": 44, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 44, - 45, - ], - "type": "Identifier", - }, - }, - ], - "range": Array [ - 43, - 46, - ], - "type": "TSTypeParameterInstantiation", - }, + "type": "Identifier", }, }, + "range": Array [ + 7, + 11, + ], + "type": "TSIndexedAccessType", }, - ], - "range": Array [ - 25, - 48, - ], - "type": "TSTypeLiteral", + }, }, - ], - }, - "typeParameters": Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 1, - }, - "start": Object { - "column": 15, - "line": 1, + "init": null, + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, }, + "range": Array [ + 4, + 11, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, }, - "params": Array [ - Object { - "loc": Object { - "end": Object { - "column": 17, - "line": 1, - }, - "start": Object { - "column": 16, - "line": 1, - }, - }, - "name": "T", - "range": Array [ - 16, - 17, - ], - "type": "TSTypeParameter", - }, - ], - "range": Array [ - 15, - 18, - ], - "type": "TSTypeParameterDeclaration", }, + "range": Array [ + 0, + 12, + ], + "type": "VariableDeclaration", }, ], "loc": Object { @@ -76560,14 +76433,14 @@ Object { }, "range": Array [ 0, - 50, + 13, ], "sourceType": "script", "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 4, + "column": 3, "line": 1, }, "start": Object { @@ -76577,61 +76450,61 @@ Object { }, "range": Array [ 0, - 4, + 3, ], - "type": "Identifier", - "value": "type", + "type": "Keyword", + "value": "let", }, Object { "loc": Object { "end": Object { - "column": 15, + "column": 5, "line": 1, }, "start": Object { - "column": 5, + "column": 4, "line": 1, }, }, "range": Array [ + 4, 5, - 15, ], "type": "Identifier", - "value": "LinkedList", + "value": "x", }, Object { "loc": Object { "end": Object { - "column": 16, + "column": 6, "line": 1, }, "start": Object { - "column": 15, + "column": 5, "line": 1, }, }, "range": Array [ - 15, - 16, + 5, + 6, ], "type": "Punctuator", - "value": "<", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 17, + "column": 8, "line": 1, }, "start": Object { - "column": 16, + "column": 7, "line": 1, }, }, "range": Array [ - 16, - 17, + 7, + 8, ], "type": "Identifier", "value": "T", @@ -76639,636 +76512,387 @@ Object { Object { "loc": Object { "end": Object { - "column": 18, - "line": 1, - }, - "start": Object { - "column": 17, - "line": 1, - }, - }, - "range": Array [ - 17, - 18, - ], - "type": "Punctuator", - "value": ">", - }, - Object { - "loc": Object { - "end": Object { - "column": 20, + "column": 9, "line": 1, }, "start": Object { - "column": 19, + "column": 8, "line": 1, }, }, "range": Array [ - 19, - 20, + 8, + 9, ], "type": "Punctuator", - "value": "=", + "value": "[", }, Object { "loc": Object { "end": Object { - "column": 22, + "column": 10, "line": 1, }, "start": Object { - "column": 21, + "column": 9, "line": 1, }, }, "range": Array [ - 21, - 22, + 9, + 10, ], "type": "Identifier", - "value": "T", - }, - Object { - "loc": Object { - "end": Object { - "column": 24, - "line": 1, - }, - "start": Object { - "column": 23, - "line": 1, - }, - }, - "range": Array [ - 23, - 24, - ], - "type": "Punctuator", - "value": "&", + "value": "K", }, Object { "loc": Object { "end": Object { - "column": 26, + "column": 11, "line": 1, }, "start": Object { - "column": 25, + "column": 10, "line": 1, }, }, "range": Array [ - 25, - 26, + 10, + 11, ], "type": "Punctuator", - "value": "{", - }, - Object { - "loc": Object { - "end": Object { - "column": 31, - "line": 1, - }, - "start": Object { - "column": 27, - "line": 1, - }, - }, - "range": Array [ - 27, - 31, - ], - "type": "Identifier", - "value": "next", + "value": "]", }, Object { "loc": Object { "end": Object { - "column": 32, + "column": 12, "line": 1, }, "start": Object { - "column": 31, + "column": 11, "line": 1, }, }, "range": Array [ - 31, - 32, + 11, + 12, ], "type": "Punctuator", - "value": ":", + "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/intersection-type.src 1`] = ` +Object { + "body": Array [ Object { - "loc": Object { - "end": Object { - "column": 43, - "line": 1, - }, - "start": Object { - "column": 33, - "line": 1, + "id": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, }, + "name": "LinkedList", + "range": Array [ + 5, + 15, + ], + "type": "Identifier", }, - "range": Array [ - 33, - 43, - ], - "type": "Identifier", - "value": "LinkedList", - }, - Object { "loc": Object { "end": Object { - "column": 44, + "column": 49, "line": 1, }, "start": Object { - "column": 43, + "column": 0, "line": 1, }, }, "range": Array [ - 43, - 44, + 0, + 49, ], - "type": "Punctuator", - "value": "<", - }, - Object { - "loc": Object { - "end": Object { - "column": 45, - "line": 1, - }, - "start": Object { - "column": 44, - "line": 1, - }, - }, - "range": Array [ - 44, - 45, - ], - "type": "Identifier", - "value": "T", - }, - Object { - "loc": Object { - "end": Object { - "column": 46, - "line": 1, - }, - "start": Object { - "column": 45, - "line": 1, - }, - }, - "range": Array [ - 45, - 46, - ], - "type": "Punctuator", - "value": ">", - }, - Object { - "loc": Object { - "end": Object { - "column": 48, - "line": 1, - }, - "start": Object { - "column": 47, - "line": 1, - }, - }, - "range": Array [ - 47, - 48, - ], - "type": "Punctuator", - "value": "}", - }, - Object { - "loc": Object { - "end": Object { - "column": 49, - "line": 1, - }, - "start": Object { - "column": 48, - "line": 1, - }, - }, - "range": Array [ - 48, - 49, - ], - "type": "Punctuator", - "value": ";", - }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/types/nested-types.src 1`] = ` -Object { - "body": Array [ - Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "Foo", - "range": Array [ - 5, - 8, - ], - "type": "Identifier", - }, - "loc": Object { - "end": Object { - "column": 80, - "line": 1, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 80, - ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 80, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, }, "range": Array [ - 11, - 80, + 21, + 48, ], - "type": "TSUnionType", + "type": "TSIntersectionType", "types": Array [ Object { - "elementTypes": Array [ - Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, }, - "range": Array [ - 12, - 18, - ], - "type": "TSNumberKeyword", + "start": Object { + "column": 21, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 21, + 22, + ], + "type": "Identifier", + }, + }, + Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "members": Array [ Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, - }, - "range": Array [ - 20, - 27, - ], - "type": "TSOptionalType", - "typeAnnotation": Object { + "computed": false, + "key": Object { "loc": Object { "end": Object { - "column": 26, + "column": 31, "line": 1, }, "start": Object { - "column": 20, + "column": 27, "line": 1, }, }, + "name": "next", "range": Array [ - 20, - 26, + 27, + 31, ], - "type": "TSStringKeyword", + "type": "Identifier", }, - }, - Object { "loc": Object { "end": Object { - "column": 37, + "column": 46, "line": 1, }, "start": Object { - "column": 29, + "column": 27, "line": 1, }, }, "range": Array [ - 29, - 37, + 27, + 46, ], - "type": "TSOptionalType", + "type": "TSPropertySignature", "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 36, + "column": 46, "line": 1, }, "start": Object { - "column": 29, + "column": 31, "line": 1, }, }, "range": Array [ - 29, - 36, + 31, + 46, ], - "type": "TSBooleanKeyword", - }, - }, - ], - "loc": Object { - "end": Object { - "column": 38, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 38, - ], - "type": "TSTupleType", - }, - Object { - "loc": Object { - "end": Object { - "column": 80, - "line": 1, - }, - "start": Object { - "column": 41, - "line": 1, - }, - }, - "range": Array [ - 41, - 80, - ], - "type": "TSIntersectionType", - "types": Array [ - Object { - "elementTypes": Array [ - Object { - "loc": Object { - "end": Object { - "column": 44, - "line": 1, - }, - "start": Object { - "column": 42, - "line": 1, - }, - }, - "members": Array [], - "range": Array [ - 42, - 44, - ], - "type": "TSTypeLiteral", - }, - Object { + "type": "TSTypeAnnotation", + "typeAnnotation": Object { "loc": Object { "end": Object { - "column": 74, + "column": 46, "line": 1, }, "start": Object { - "column": 46, + "column": 33, "line": 1, }, }, "range": Array [ + 33, 46, - 74, ], - "type": "TSUnionType", - "types": Array [ - Object { - "elementTypes": Array [ - Object { - "loc": Object { - "end": Object { - "column": 54, - "line": 1, - }, - "start": Object { - "column": 47, - "line": 1, - }, - }, - "range": Array [ - 47, - 54, - ], - "type": "TSOptionalType", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 53, - "line": 1, - }, - "start": Object { - "column": 47, - "line": 1, - }, - }, - "range": Array [ - 47, - 53, - ], - "type": "TSNumberKeyword", - }, - }, - ], - "loc": Object { - "end": Object { - "column": 55, - "line": 1, - }, - "start": Object { - "column": 46, - "line": 1, - }, + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, }, - "range": Array [ - 46, - 55, - ], - "type": "TSTupleType", }, - Object { - "loc": Object { - "end": Object { - "column": 74, - "line": 1, - }, - "start": Object { - "column": 58, - "line": 1, - }, + "name": "LinkedList", + "range": Array [ + 33, + 43, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, }, - "range": Array [ - 58, - 74, - ], - "type": "TSIntersectionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 62, - "line": 1, - }, - "start": Object { - "column": 58, - "line": 1, - }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, }, - "range": Array [ - 58, - 62, - ], - "type": "TSNullKeyword", - }, - Object { - "elementType": Object { - "loc": Object { - "end": Object { - "column": 72, - "line": 1, - }, - "start": Object { - "column": 65, - "line": 1, - }, - }, - "range": Array [ - 65, - 72, - ], - "type": "TSBooleanKeyword", + "start": Object { + "column": 44, + "line": 1, }, + }, + "range": Array [ + 44, + 45, + ], + "type": "TSTypeReference", + "typeName": Object { "loc": Object { "end": Object { - "column": 74, + "column": 45, "line": 1, }, "start": Object { - "column": 65, + "column": 44, "line": 1, }, }, + "name": "T", "range": Array [ - 65, - 74, + 44, + 45, ], - "type": "TSArrayType", + "type": "Identifier", }, - ], - }, - ], - }, - ], - "loc": Object { - "end": Object { - "column": 75, - "line": 1, - }, - "start": Object { - "column": 41, - "line": 1, - }, - }, - "range": Array [ - 41, - 75, - ], - "type": "TSTupleType", - }, - Object { - "loc": Object { - "end": Object { - "column": 80, - "line": 1, - }, - "start": Object { - "column": 78, - "line": 1, + }, + ], + "range": Array [ + 43, + 46, + ], + "type": "TSTypeParameterInstantiation", + }, }, }, - "members": Array [], - "range": Array [ - 78, - 80, - ], - "type": "TSTypeLiteral", }, ], + "range": Array [ + 25, + 48, + ], + "type": "TSTypeLiteral", }, ], }, - }, - ], - "loc": Object { - "end": Object { - "column": 0, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 1, - }, - }, - "range": Array [ - 0, - 81, - ], - "sourceType": "script", - "tokens": Array [ + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 16, + 17, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 15, + 18, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 50, + ], + "sourceType": "script", + "tokens": Array [ Object { "loc": Object { "end": Object { @@ -77300,226 +76924,172 @@ Object { }, "range": Array [ 5, - 8, + 15, ], "type": "Identifier", - "value": "Foo", - }, - Object { - "loc": Object { - "end": Object { - "column": 10, - "line": 1, - }, - "start": Object { - "column": 9, - "line": 1, - }, - }, - "range": Array [ - 9, - 10, - ], - "type": "Punctuator", - "value": "=", + "value": "LinkedList", }, Object { "loc": Object { "end": Object { - "column": 12, + "column": 16, "line": 1, }, "start": Object { - "column": 11, + "column": 15, "line": 1, }, }, "range": Array [ - 11, - 12, + 15, + 16, ], "type": "Punctuator", - "value": "[", + "value": "<", }, Object { "loc": Object { "end": Object { - "column": 18, + "column": 17, "line": 1, }, "start": Object { - "column": 12, + "column": 16, "line": 1, }, }, "range": Array [ - 12, - 18, + 16, + 17, ], "type": "Identifier", - "value": "number", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 19, + "column": 18, "line": 1, }, "start": Object { - "column": 18, + "column": 17, "line": 1, }, }, "range": Array [ + 17, 18, - 19, ], "type": "Punctuator", - "value": ",", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { "column": 20, "line": 1, }, - }, - "range": Array [ - 20, - 26, - ], - "type": "Identifier", - "value": "string", - }, - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 26, - "line": 1, - }, - }, - "range": Array [ - 26, - 27, - ], - "type": "Punctuator", - "value": "?", - }, - Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, "start": Object { - "column": 27, + "column": 19, "line": 1, }, }, "range": Array [ - 27, - 28, + 19, + 20, ], "type": "Punctuator", - "value": ",", + "value": "=", }, Object { "loc": Object { "end": Object { - "column": 36, + "column": 22, "line": 1, }, "start": Object { - "column": 29, + "column": 21, "line": 1, }, }, "range": Array [ - 29, - 36, + 21, + 22, ], "type": "Identifier", - "value": "boolean", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 37, + "column": 24, "line": 1, }, "start": Object { - "column": 36, + "column": 23, "line": 1, }, }, "range": Array [ - 36, - 37, + 23, + 24, ], "type": "Punctuator", - "value": "?", + "value": "&", }, Object { "loc": Object { "end": Object { - "column": 38, + "column": 26, "line": 1, }, "start": Object { - "column": 37, + "column": 25, "line": 1, }, }, "range": Array [ - 37, - 38, + 25, + 26, ], "type": "Punctuator", - "value": "]", + "value": "{", }, Object { "loc": Object { "end": Object { - "column": 40, + "column": 31, "line": 1, }, "start": Object { - "column": 39, + "column": 27, "line": 1, }, }, "range": Array [ - 39, - 40, + 27, + 31, ], - "type": "Punctuator", - "value": "|", + "type": "Identifier", + "value": "next", }, Object { "loc": Object { "end": Object { - "column": 42, + "column": 32, "line": 1, }, "start": Object { - "column": 41, + "column": 31, "line": 1, }, }, "range": Array [ - 41, - 42, + 31, + 32, ], "type": "Punctuator", - "value": "[", + "value": ":", }, Object { "loc": Object { @@ -77528,16 +77098,16 @@ Object { "line": 1, }, "start": Object { - "column": 42, + "column": 33, "line": 1, }, }, "range": Array [ - 42, + 33, 43, ], - "type": "Punctuator", - "value": "{", + "type": "Identifier", + "value": "LinkedList", }, Object { "loc": Object { @@ -77555,7 +77125,7 @@ Object { 44, ], "type": "Punctuator", - "value": "}", + "value": "<", }, Object { "loc": Object { @@ -77572,31 +77142,31 @@ Object { 44, 45, ], - "type": "Punctuator", - "value": ",", + "type": "Identifier", + "value": "T", }, Object { "loc": Object { "end": Object { - "column": 47, + "column": 46, "line": 1, }, "start": Object { - "column": 46, + "column": 45, "line": 1, }, }, "range": Array [ + 45, 46, - 47, ], "type": "Punctuator", - "value": "[", + "value": ">", }, Object { "loc": Object { "end": Object { - "column": 53, + "column": 48, "line": 1, }, "start": Object { @@ -77606,443 +77176,5662 @@ Object { }, "range": Array [ 47, - 53, + 48, ], - "type": "Identifier", - "value": "number", + "type": "Punctuator", + "value": "}", }, Object { "loc": Object { "end": Object { - "column": 54, + "column": 49, "line": 1, }, "start": Object { - "column": 53, + "column": 48, "line": 1, }, }, "range": Array [ - 53, - 54, + 48, + 49, ], "type": "Punctuator", - "value": "?", + "value": ";", }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/nested-types.src 1`] = ` +Object { + "body": Array [ Object { - "loc": Object { - "end": Object { - "column": 55, - "line": 1, - }, - "start": Object { - "column": 54, - "line": 1, + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", }, - "range": Array [ - 54, - 55, - ], - "type": "Punctuator", - "value": "]", - }, - Object { "loc": Object { "end": Object { - "column": 57, + "column": 80, "line": 1, }, "start": Object { - "column": 56, + "column": 0, "line": 1, }, }, "range": Array [ - 56, - 57, + 0, + 80, ], - "type": "Punctuator", - "value": "|", - }, - Object { - "loc": Object { - "end": Object { - "column": 62, - "line": 1, + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 80, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, }, - "start": Object { - "column": 58, - "line": 1, + "range": Array [ + 11, + 80, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "elementTypes": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "TSNumberKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 27, + ], + "type": "TSOptionalType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 26, + ], + "type": "TSStringKeyword", + }, + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 37, + ], + "type": "TSOptionalType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 36, + ], + "type": "TSBooleanKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 38, + ], + "type": "TSTupleType", + }, + Object { + "loc": Object { + "end": Object { + "column": 80, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 80, + ], + "type": "TSIntersectionType", + "types": Array [ + Object { + "elementTypes": Array [ + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "members": Array [], + "range": Array [ + 42, + 44, + ], + "type": "TSTypeLiteral", + }, + Object { + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 74, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "elementTypes": Array [ + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 54, + ], + "type": "TSOptionalType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 53, + ], + "type": "TSNumberKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 55, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 55, + ], + "type": "TSTupleType", + }, + Object { + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 58, + "line": 1, + }, + }, + "range": Array [ + 58, + 74, + ], + "type": "TSIntersectionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 62, + "line": 1, + }, + "start": Object { + "column": 58, + "line": 1, + }, + }, + "range": Array [ + 58, + 62, + ], + "type": "TSNullKeyword", + }, + Object { + "elementType": Object { + "loc": Object { + "end": Object { + "column": 72, + "line": 1, + }, + "start": Object { + "column": 65, + "line": 1, + }, + }, + "range": Array [ + 65, + 72, + ], + "type": "TSBooleanKeyword", + }, + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 65, + "line": 1, + }, + }, + "range": Array [ + 65, + 74, + ], + "type": "TSArrayType", + }, + ], + }, + ], + }, + ], + "loc": Object { + "end": Object { + "column": 75, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 75, + ], + "type": "TSTupleType", + }, + Object { + "loc": Object { + "end": Object { + "column": 80, + "line": 1, + }, + "start": Object { + "column": 78, + "line": 1, + }, + }, + "members": Array [], + "range": Array [ + 78, + 80, + ], + "type": "TSTypeLiteral", + }, + ], + }, + ], + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 81, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 26, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 36, + ], + "type": "Identifier", + "value": "boolean", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 37, + "line": 1, + }, + }, + "range": Array [ + 37, + 38, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "range": Array [ + 42, + 43, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 44, + "line": 1, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 53, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 53, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 54, + "line": 1, + }, + "start": Object { + "column": 53, + "line": 1, + }, + }, + "range": Array [ + 53, + 54, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 55, + "line": 1, + }, + "start": Object { + "column": 54, + "line": 1, + }, + }, + "range": Array [ + 54, + 55, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 57, + "line": 1, + }, + "start": Object { + "column": 56, + "line": 1, + }, + }, + "range": Array [ + 56, + 57, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 62, + "line": 1, + }, + "start": Object { + "column": 58, + "line": 1, + }, + }, + "range": Array [ + 58, + 62, + ], + "type": "Keyword", + "value": "null", + }, + Object { + "loc": Object { + "end": Object { + "column": 64, + "line": 1, + }, + "start": Object { + "column": 63, + "line": 1, + }, + }, + "range": Array [ + 63, + 64, + ], + "type": "Punctuator", + "value": "&", + }, + Object { + "loc": Object { + "end": Object { + "column": 72, + "line": 1, + }, + "start": Object { + "column": 65, + "line": 1, + }, + }, + "range": Array [ + 65, + 72, + ], + "type": "Identifier", + "value": "boolean", + }, + Object { + "loc": Object { + "end": Object { + "column": 73, + "line": 1, + }, + "start": Object { + "column": 72, + "line": 1, + }, + }, + "range": Array [ + 72, + 73, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 74, + "line": 1, + }, + "start": Object { + "column": 73, + "line": 1, + }, + }, + "range": Array [ + 73, + 74, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 75, + "line": 1, + }, + "start": Object { + "column": 74, + "line": 1, + }, + }, + "range": Array [ + 74, + 75, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 77, + "line": 1, + }, + "start": Object { + "column": 76, + "line": 1, + }, + }, + "range": Array [ + 76, + 77, + ], + "type": "Punctuator", + "value": "&", + }, + Object { + "loc": Object { + "end": Object { + "column": 79, + "line": 1, + }, + "start": Object { + "column": 78, + "line": 1, + }, + }, + "range": Array [ + 78, + 79, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 80, + "line": 1, + }, + "start": Object { + "column": 79, + "line": 1, + }, + }, + "range": Array [ + 79, + 80, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/parenthesized-type.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 28, + ], + "type": "TSParenthesizedType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 27, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 27, + ], + "type": "TSNumberKeyword", + }, + ], + }, + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 29, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 27, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ")", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/reference.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 8, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 7, + 8, + ], + "type": "Identifier", + }, + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 8, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 9, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 10, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/reference-generic.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 20, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 20, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 20, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "name": "Array", + "range": Array [ + 7, + 12, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 19, + ], + "type": "TSNumberKeyword", + }, + ], + "range": Array [ + 12, + 20, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 20, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 21, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 22, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 12, + ], + "type": "Identifier", + "value": "Array", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 19, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/reference-generic-nested.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 27, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 27, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 27, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "name": "Array", + "range": Array [ + 7, + 12, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 26, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "Array", + "range": Array [ + 13, + 18, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 25, + ], + "type": "TSNumberKeyword", + }, + ], + "range": Array [ + 18, + 26, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + ], + "range": Array [ + 12, + 27, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 27, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 29, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 12, + ], + "type": "Identifier", + "value": "Array", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 18, + ], + "type": "Identifier", + "value": "Array", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 25, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/tuple.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 31, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 31, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "elementTypes": Array [ + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 14, + ], + "type": "TSNumberKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 22, + ], + "type": "TSNumberKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 30, + ], + "type": "TSNumberKeyword", + }, + ], + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 31, + ], + "type": "TSTupleType", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 31, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 32, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 33, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 14, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 22, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 30, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 31, + "line": 1, + }, + "start": Object { + "column": 30, + "line": 1, + }, + }, + "range": Array [ + 30, + 31, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 32, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/tuple-empty.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 9, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 9, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "elementTypes": Array [], + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 9, + ], + "type": "TSTupleType", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 9, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 10, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 11, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/tuple-optional.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 44, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 44, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "elementTypes": Array [ + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 14, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 23, + ], + "type": "TSOptionalType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 22, + ], + "type": "TSNumberKeyword", + }, + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 43, + ], + "type": "TSOptionalType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 42, + ], + "type": "TSParenthesizedType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 41, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 32, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 41, + ], + "type": "TSNumberKeyword", + }, + ], + }, + }, + }, + ], + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 44, + ], + "type": "TSTupleType", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 44, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 44, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 45, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 14, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 22, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 32, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "|", + }, + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 41, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "range": Array [ + 42, + 43, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Punctuator", + "value": "]", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/tuple-type.src 1`] = ` +Object { + "body": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "name": "Foo", + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "type": "TSTypeAliasDeclaration", + "typeAnnotation": Object { + "elementTypes": Array [ + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 27, + ], + "type": "TSOptionalType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 26, + ], + "type": "TSStringKeyword", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 28, + ], + "type": "TSTupleType", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 29, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 4, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 4, + ], + "type": "Identifier", + "value": "type", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 8, + ], + "type": "Identifier", + "value": "Foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 18, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 18, + "line": 1, + }, + }, + "range": Array [ + 18, + 19, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 26, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": "]", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/type-literal.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "obj", + "range": Array [ + 4, + 22, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 22, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "members": Array [ + Object { + "computed": false, + "key": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 11, + 12, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 20, + ], + "type": "TSPropertySignature", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 20, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 20, + ], + "type": "TSNumberKeyword", + }, + }, + }, + ], + "range": Array [ + 9, + 22, + ], + "type": "TSTypeLiteral", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 22, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 23, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 24, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + "value": "obj", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 20, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/type-operator.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 14, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 14, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "operator": "keyof", + "range": Array [ + 7, + 14, + ], + "type": "TSTypeOperator", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 13, + 14, + ], + "type": "Identifier", + }, + }, + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 14, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 15, + ], + "type": "VariableDeclaration", + }, + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "y", + "range": Array [ + 20, + 36, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 5, + "line": 2, + }, + }, + "range": Array [ + 21, + 36, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "operator": "unique", + "range": Array [ + 23, + 36, + ], + "type": "TSTypeOperator", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 30, + 36, + ], + "type": "TSSymbolKeyword", + }, + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 20, + 36, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 16, + 37, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 38, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 12, + ], + "type": "Identifier", + "value": "keyof", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 16, + 19, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 2, + }, + "start": Object { + "column": 5, + "line": 2, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 2, + }, + "start": Object { + "column": 7, + "line": 2, + }, + }, + "range": Array [ + 23, + 29, + ], + "type": "Identifier", + "value": "unique", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 30, + 36, + ], + "type": "Identifier", + "value": "symbol", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 2, + }, + "start": Object { + "column": 20, + "line": 2, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/typeof.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 17, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 17, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "exprName": Object { + "left": Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "name": "y", + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 17, + ], + "right": Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "name": "z", + "range": Array [ + 16, + 17, + ], + "type": "Identifier", + }, + "type": "TSQualifiedName", + }, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 17, + ], + "type": "TSTypeQuery", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 17, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 18, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 19, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 13, + ], + "type": "Keyword", + "value": "typeof", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Identifier", + "value": "y", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 15, + "line": 1, + }, + }, + "range": Array [ + 15, + 16, + ], + "type": "Punctuator", + "value": ".", + }, + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 17, + ], + "type": "Identifier", + "value": "z", + }, + Object { + "loc": Object { + "end": Object { + "column": 18, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 18, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/union-intersection.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "union", + "range": Array [ + 4, + 36, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 36, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 36, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 17, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 17, + ], + "type": "TSNumberKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 24, + ], + "type": "TSNullKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 36, + ], + "type": "TSUndefinedKeyword", + }, + ], + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 36, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 37, + ], + "type": "VariableDeclaration", + }, + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "name": "intersection", + "range": Array [ + 42, + 71, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 2, + }, + "start": Object { + "column": 16, + "line": 2, + }, + }, + "range": Array [ + 54, + 71, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 56, + 71, + ], + "type": "TSIntersectionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 2, + }, + "start": Object { + "column": 18, + "line": 2, + }, + }, + "range": Array [ + 56, + 62, + ], + "type": "TSNumberKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 2, + }, + "start": Object { + "column": 27, + "line": 2, + }, + }, + "range": Array [ + 65, + 71, + ], + "type": "TSStringKeyword", + }, + ], + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 33, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 42, + 71, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 34, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 38, + 72, + ], + "type": "VariableDeclaration", + }, + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "name": "precedence1", + "range": Array [ + 77, + 115, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 88, + 115, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 3, + }, + "start": Object { + "column": 17, + "line": 3, + }, + }, + "range": Array [ + 90, + 115, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 17, + "line": 3, + }, + }, + "range": Array [ + 90, + 96, + ], + "type": "TSNumberKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "range": Array [ + 99, + 115, + ], + "type": "TSIntersectionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "range": Array [ + 99, + 105, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 3, + }, + "start": Object { + "column": 35, + "line": 3, + }, + }, + "range": Array [ + 108, + 115, + ], + "type": "TSBooleanKeyword", + }, + ], + }, + ], + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 42, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 77, + 115, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 43, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 3, + }, + }, + "range": Array [ + 73, + 116, + ], + "type": "VariableDeclaration", + }, + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "name": "precedence2", + "range": Array [ + 121, + 159, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 15, + "line": 4, + }, + }, + "range": Array [ + 132, + 159, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 17, + "line": 4, + }, + }, + "range": Array [ + 134, + 159, + ], + "type": "TSUnionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 4, + }, + "start": Object { + "column": 17, + "line": 4, + }, + }, + "range": Array [ + 134, + 149, + ], + "type": "TSIntersectionType", + "types": Array [ + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 4, + }, + "start": Object { + "column": 17, + "line": 4, + }, + }, + "range": Array [ + 134, + 140, + ], + "type": "TSNumberKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 4, + }, + "start": Object { + "column": 26, + "line": 4, + }, + }, + "range": Array [ + 143, + 149, + ], + "type": "TSStringKeyword", + }, + ], + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 35, + "line": 4, + }, + }, + "range": Array [ + 152, + 159, + ], + "type": "TSBooleanKeyword", + }, + ], + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 42, + "line": 4, + }, + "start": Object { + "column": 4, + "line": 4, + }, + }, + "range": Array [ + 121, + 159, + ], + "type": "VariableDeclarator", }, - }, - "range": Array [ - 58, - 62, ], - "type": "Keyword", - "value": "null", - }, - Object { + "kind": "let", "loc": Object { "end": Object { - "column": 64, - "line": 1, + "column": 43, + "line": 4, }, "start": Object { - "column": 63, - "line": 1, + "column": 0, + "line": 4, }, }, "range": Array [ - 63, - 64, + 117, + 160, ], - "type": "Punctuator", - "value": "&", + "type": "VariableDeclaration", }, - Object { - "loc": Object { - "end": Object { - "column": 72, - "line": 1, - }, - "start": Object { - "column": 65, - "line": 1, - }, - }, - "range": Array [ - 65, - 72, - ], - "type": "Identifier", - "value": "boolean", + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, }, + }, + "range": Array [ + 0, + 161, + ], + "sourceType": "script", + "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 73, + "column": 3, "line": 1, }, "start": Object { - "column": 72, + "column": 0, "line": 1, }, }, "range": Array [ - 72, - 73, + 0, + 3, ], - "type": "Punctuator", - "value": "[", + "type": "Keyword", + "value": "let", }, Object { "loc": Object { "end": Object { - "column": 74, + "column": 9, "line": 1, }, "start": Object { - "column": 73, + "column": 4, "line": 1, }, }, "range": Array [ - 73, - 74, + 4, + 9, ], - "type": "Punctuator", - "value": "]", + "type": "Identifier", + "value": "union", }, Object { "loc": Object { "end": Object { - "column": 75, + "column": 10, "line": 1, }, "start": Object { - "column": 74, + "column": 9, "line": 1, }, }, "range": Array [ - 74, - 75, + 9, + 10, ], "type": "Punctuator", - "value": "]", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 77, + "column": 17, "line": 1, }, "start": Object { - "column": 76, + "column": 11, "line": 1, }, }, "range": Array [ - 76, - 77, + 11, + 17, ], - "type": "Punctuator", - "value": "&", + "type": "Identifier", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 79, + "column": 19, "line": 1, }, "start": Object { - "column": 78, + "column": 18, "line": 1, }, }, "range": Array [ - 78, - 79, + 18, + 19, ], "type": "Punctuator", - "value": "{", + "value": "|", }, Object { "loc": Object { "end": Object { - "column": 80, + "column": 24, "line": 1, }, "start": Object { - "column": 79, + "column": 20, "line": 1, }, }, "range": Array [ - 79, - 80, + 20, + 24, ], - "type": "Punctuator", - "value": "}", + "type": "Keyword", + "value": "null", }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/types/parenthesized-type.src 1`] = ` -Object { - "body": Array [ Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, - }, - "name": "Foo", - "range": Array [ - 5, - 8, - ], - "type": "Identifier", - }, "loc": Object { "end": Object { - "column": 28, + "column": 26, "line": 1, }, "start": Object { - "column": 0, + "column": 25, "line": 1, }, }, "range": Array [ - 0, - 28, + 25, + 26, ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 28, - ], - "type": "TSParenthesizedType", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, - }, - "range": Array [ - 12, - 27, - ], - "type": "TSUnionType", - "types": Array [ - Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, - }, - "range": Array [ - 12, - 18, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 21, - "line": 1, - }, - }, - "range": Array [ - 21, - 27, - ], - "type": "TSNumberKeyword", - }, - ], - }, - }, - }, - ], - "loc": Object { - "end": Object { - "column": 0, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 1, + "type": "Punctuator", + "value": "|", }, - }, - "range": Array [ - 0, - 29, - ], - "sourceType": "script", - "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 4, + "column": 36, "line": 1, }, "start": Object { - "column": 0, + "column": 27, "line": 1, }, }, "range": Array [ - 0, - 4, + 27, + 36, ], "type": "Identifier", - "value": "type", + "value": "undefined", }, Object { "loc": Object { "end": Object { - "column": 8, + "column": 37, "line": 1, }, "start": Object { - "column": 5, + "column": 36, "line": 1, }, }, "range": Array [ - 5, - 8, + 36, + 37, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 38, + 41, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 2, + }, + "start": Object { + "column": 4, + "line": 2, + }, + }, + "range": Array [ + 42, + 54, ], "type": "Identifier", - "value": "Foo", + "value": "intersection", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 1, + "column": 17, + "line": 2, }, "start": Object { - "column": 9, - "line": 1, + "column": 16, + "line": 2, }, }, "range": Array [ - 9, - 10, + 54, + 55, ], "type": "Punctuator", - "value": "=", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 12, - "line": 1, + "column": 24, + "line": 2, }, "start": Object { - "column": 11, - "line": 1, + "column": 18, + "line": 2, }, }, "range": Array [ - 11, - 12, + 56, + 62, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 2, + }, + "start": Object { + "column": 25, + "line": 2, + }, + }, + "range": Array [ + 63, + 64, ], "type": "Punctuator", - "value": "(", + "value": "&", }, Object { "loc": Object { "end": Object { - "column": 18, - "line": 1, + "column": 33, + "line": 2, }, "start": Object { - "column": 12, - "line": 1, + "column": 27, + "line": 2, }, }, "range": Array [ - 12, - 18, + 65, + 71, ], "type": "Identifier", "value": "string", @@ -78050,35 +82839,89 @@ Object { Object { "loc": Object { "end": Object { - "column": 20, - "line": 1, + "column": 34, + "line": 2, }, "start": Object { - "column": 19, - "line": 1, + "column": 33, + "line": 2, }, }, "range": Array [ - 19, - 20, + 71, + 72, ], "type": "Punctuator", - "value": "|", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 27, - "line": 1, + "column": 3, + "line": 3, }, "start": Object { - "column": 21, - "line": 1, + "column": 0, + "line": 3, }, }, "range": Array [ - 21, - 27, + 73, + 76, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 3, + }, + "start": Object { + "column": 4, + "line": 3, + }, + }, + "range": Array [ + 77, + 88, + ], + "type": "Identifier", + "value": "precedence1", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 3, + }, + "start": Object { + "column": 15, + "line": 3, + }, + }, + "range": Array [ + 88, + 89, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 3, + }, + "start": Object { + "column": 17, + "line": 3, + }, + }, + "range": Array [ + 90, + 96, ], "type": "Identifier", "value": "number", @@ -78086,273 +82929,197 @@ Object { Object { "loc": Object { "end": Object { - "column": 28, - "line": 1, + "column": 25, + "line": 3, }, "start": Object { - "column": 27, - "line": 1, + "column": 24, + "line": 3, }, }, "range": Array [ - 27, - 28, + 97, + 98, ], "type": "Punctuator", - "value": ")", + "value": "|", }, - ], - "type": "Program", -} -`; - -exports[`typescript fixtures/types/tuple-type.src 1`] = ` -Object { - "body": Array [ Object { - "id": Object { - "loc": Object { - "end": Object { - "column": 8, - "line": 1, - }, - "start": Object { - "column": 5, - "line": 1, - }, + "loc": Object { + "end": Object { + "column": 32, + "line": 3, + }, + "start": Object { + "column": 26, + "line": 3, + }, + }, + "range": Array [ + 99, + 105, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 3, + }, + "start": Object { + "column": 33, + "line": 3, }, - "name": "Foo", - "range": Array [ - 5, - 8, - ], - "type": "Identifier", }, + "range": Array [ + 106, + 107, + ], + "type": "Punctuator", + "value": "&", + }, + Object { "loc": Object { "end": Object { - "column": 28, - "line": 1, + "column": 42, + "line": 3, }, "start": Object { - "column": 0, - "line": 1, + "column": 35, + "line": 3, }, }, "range": Array [ - 0, - 28, + 108, + 115, ], - "type": "TSTypeAliasDeclaration", - "typeAnnotation": Object { - "elementTypes": Array [ - Object { - "loc": Object { - "end": Object { - "column": 18, - "line": 1, - }, - "start": Object { - "column": 12, - "line": 1, - }, - }, - "range": Array [ - 12, - 18, - ], - "type": "TSStringKeyword", - }, - Object { - "loc": Object { - "end": Object { - "column": 27, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, - }, - "range": Array [ - 20, - 27, - ], - "type": "TSOptionalType", - "typeAnnotation": Object { - "loc": Object { - "end": Object { - "column": 26, - "line": 1, - }, - "start": Object { - "column": 20, - "line": 1, - }, - }, - "range": Array [ - 20, - 26, - ], - "type": "TSStringKeyword", - }, - }, - ], - "loc": Object { - "end": Object { - "column": 28, - "line": 1, - }, - "start": Object { - "column": 11, - "line": 1, - }, - }, - "range": Array [ - 11, - 28, - ], - "type": "TSTupleType", - }, - }, - ], - "loc": Object { - "end": Object { - "column": 0, - "line": 2, - }, - "start": Object { - "column": 0, - "line": 1, + "type": "Identifier", + "value": "boolean", }, - }, - "range": Array [ - 0, - 29, - ], - "sourceType": "script", - "tokens": Array [ Object { "loc": Object { "end": Object { - "column": 4, - "line": 1, + "column": 43, + "line": 3, }, "start": Object { - "column": 0, - "line": 1, + "column": 42, + "line": 3, }, }, "range": Array [ - 0, - 4, + 115, + 116, ], - "type": "Identifier", - "value": "type", + "type": "Punctuator", + "value": ";", }, Object { "loc": Object { "end": Object { - "column": 8, - "line": 1, + "column": 3, + "line": 4, }, "start": Object { - "column": 5, - "line": 1, + "column": 0, + "line": 4, }, }, "range": Array [ - 5, - 8, + 117, + 120, ], - "type": "Identifier", - "value": "Foo", + "type": "Keyword", + "value": "let", }, Object { "loc": Object { "end": Object { - "column": 10, - "line": 1, + "column": 15, + "line": 4, }, "start": Object { - "column": 9, - "line": 1, + "column": 4, + "line": 4, }, }, "range": Array [ - 9, - 10, + 121, + 132, ], - "type": "Punctuator", - "value": "=", + "type": "Identifier", + "value": "precedence2", }, Object { "loc": Object { "end": Object { - "column": 12, - "line": 1, + "column": 16, + "line": 4, }, "start": Object { - "column": 11, - "line": 1, + "column": 15, + "line": 4, }, }, "range": Array [ - 11, - 12, + 132, + 133, ], "type": "Punctuator", - "value": "[", + "value": ":", }, Object { "loc": Object { "end": Object { - "column": 18, - "line": 1, + "column": 23, + "line": 4, }, "start": Object { - "column": 12, - "line": 1, + "column": 17, + "line": 4, }, }, "range": Array [ - 12, - 18, + 134, + 140, ], "type": "Identifier", - "value": "string", + "value": "number", }, Object { "loc": Object { "end": Object { - "column": 19, - "line": 1, + "column": 25, + "line": 4, }, "start": Object { - "column": 18, - "line": 1, + "column": 24, + "line": 4, }, }, "range": Array [ - 18, - 19, + 141, + 142, ], "type": "Punctuator", - "value": ",", + "value": "&", }, Object { "loc": Object { "end": Object { - "column": 26, - "line": 1, + "column": 32, + "line": 4, }, "start": Object { - "column": 20, - "line": 1, + "column": 26, + "line": 4, }, }, "range": Array [ - 20, - 26, + 143, + 149, ], "type": "Identifier", "value": "string", @@ -78360,38 +83127,56 @@ Object { Object { "loc": Object { "end": Object { - "column": 27, - "line": 1, + "column": 34, + "line": 4, }, "start": Object { - "column": 26, - "line": 1, + "column": 33, + "line": 4, }, }, "range": Array [ - 26, - 27, + 150, + 151, ], "type": "Punctuator", - "value": "?", + "value": "|", }, Object { "loc": Object { "end": Object { - "column": 28, - "line": 1, + "column": 42, + "line": 4, }, "start": Object { - "column": 27, - "line": 1, + "column": 35, + "line": 4, }, }, "range": Array [ - 27, - 28, + 152, + 159, + ], + "type": "Identifier", + "value": "boolean", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 4, + }, + "start": Object { + "column": 42, + "line": 4, + }, + }, + "range": Array [ + 159, + 160, ], "type": "Punctuator", - "value": "]", + "value": ";", }, ], "type": "Program", From 35e483c735943e0e39184f11545a11071f6980e9 Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 25 Dec 2018 20:57:42 +0100 Subject: [PATCH 16/24] fix: add TSConditionalType to known types --- src/ast-node-types.ts | 1 + .../typescript/types/conditional.src.ts | 1 + tests/lib/__snapshots__/typescript.ts.snap | 381 ++++++++++++++++++ 3 files changed, 383 insertions(+) create mode 100644 tests/fixtures/typescript/types/conditional.src.ts diff --git a/src/ast-node-types.ts b/src/ast-node-types.ts index fd7453f..df6b3bb 100644 --- a/src/ast-node-types.ts +++ b/src/ast-node-types.ts @@ -105,6 +105,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = { TSAsyncKeyword: 'TSAsyncKeyword', TSBooleanKeyword: 'TSBooleanKeyword', TSBigIntKeyword: 'TSBigIntKeyword', + TSConditionalType: 'TSConditionalType', TSConstructorType: 'TSConstructorType', TSConstructSignature: 'TSConstructSignature', TSDeclareKeyword: 'TSDeclareKeyword', diff --git a/tests/fixtures/typescript/types/conditional.src.ts b/tests/fixtures/typescript/types/conditional.src.ts new file mode 100644 index 0000000..da72fcb --- /dev/null +++ b/tests/fixtures/typescript/types/conditional.src.ts @@ -0,0 +1 @@ +let x: number extends string ? boolean : string; diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index 351ad4d..786aea6 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -76257,6 +76257,387 @@ Object { } `; +exports[`typescript fixtures/types/conditional.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 47, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 47, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "checkType": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 13, + ], + "type": "TSNumberKeyword", + }, + "extendsType": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "TSStringKeyword", + }, + "falseType": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 47, + ], + "type": "TSStringKeyword", + }, + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 47, + ], + "trueType": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 38, + ], + "type": "TSBooleanKeyword", + }, + "type": "TSConditionalType", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 47, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 48, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 49, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 13, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 21, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 38, + ], + "type": "Identifier", + "value": "boolean", + }, + Object { + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 47, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/types/indexed.src 1`] = ` Object { "body": Array [ From aa59b4f68d7afc357f3d96e15d5d494340fd2c07 Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 25 Dec 2018 22:53:42 +0100 Subject: [PATCH 17/24] fix: add TSRestType to known types --- src/ast-node-types.ts | 1 + src/convert.ts | 7 + .../typescript/types/tuple-rest.src.ts | 1 + tests/lib/__snapshots__/typescript.ts.snap | 383 ++++++++++++++++++ 4 files changed, 392 insertions(+) create mode 100644 tests/fixtures/typescript/types/tuple-rest.src.ts diff --git a/src/ast-node-types.ts b/src/ast-node-types.ts index df6b3bb..ee2a11e 100644 --- a/src/ast-node-types.ts +++ b/src/ast-node-types.ts @@ -139,6 +139,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = { TSQualifiedName: 'TSQualifiedName', TSQuestionToken: 'TSQuestionToken', TSReadonlyKeyword: 'TSReadonlyKeyword', + TSRestType: 'TSRestType', TSStaticKeyword: 'TSStaticKeyword', TSStringKeyword: 'TSStringKeyword', TSSymbolKeyword: 'TSSymbolKeyword', diff --git a/src/convert.ts b/src/convert.ts index fb7ec3b..d58457c 100644 --- a/src/convert.ts +++ b/src/convert.ts @@ -2593,6 +2593,13 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { }); break; } + case SyntaxKind.RestType: { + Object.assign(result, { + type: AST_NODE_TYPES.TSRestType, + typeAnnotation: convertChild(node.type) + }); + break; + } default: deeplyCopy(); diff --git a/tests/fixtures/typescript/types/tuple-rest.src.ts b/tests/fixtures/typescript/types/tuple-rest.src.ts new file mode 100644 index 0000000..d7719b2 --- /dev/null +++ b/tests/fixtures/typescript/types/tuple-rest.src.ts @@ -0,0 +1 @@ +let x: [string, ...number[]] diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index 786aea6..980115d 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -80906,6 +80906,389 @@ Object { } `; +exports[`typescript fixtures/types/tuple-rest.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 28, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 28, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "elementTypes": Array [ + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 14, + ], + "type": "TSStringKeyword", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 27, + ], + "type": "TSRestType", + "typeAnnotation": Object { + "elementType": Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 25, + ], + "type": "TSNumberKeyword", + }, + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 27, + ], + "type": "TSArrayType", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 28, + ], + "type": "TSTupleType", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 28, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 28, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 29, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 14, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ",", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 16, + "line": 1, + }, + }, + "range": Array [ + 16, + 19, + ], + "type": "Punctuator", + "value": "...", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 25, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 25, + "line": 1, + }, + }, + "range": Array [ + 25, + 26, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 27, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 27, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": "]", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/types/tuple-type.src 1`] = ` Object { "body": Array [ From 90319aabcf32150b2d89461f595ffd11453c3b0c Mon Sep 17 00:00:00 2001 From: Armano Date: Tue, 25 Dec 2018 23:37:35 +0100 Subject: [PATCH 18/24] test: fix rebase conflict --- tests/ast-alignment/fixtures-to-test.ts | 20 +++++++++++++++++++- tests/lib/__snapshots__/typescript.ts.snap | 4 ++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index 3df88be..901e8a8 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -360,7 +360,25 @@ let fixturePatternConfigsToTest = [ * Not yet supported in Babel https://github.com/babel/babel/issues/7749 */ 'import-type', - 'import-type-with-type-parameters-in-type-reference' + 'import-type-with-type-parameters-in-type-reference', + /** + * babel is not supporting it yet https://github.com/babel/babel/pull/9230 + * Babel: TSTypeReference -> Identifier + * tsep: TSBigIntKeyword + */ + 'typed-keyword-bigint', + /** + * Awaiting feedback on Babel issue https://github.com/babel/babel/issues/9228 + * Babel: BooleanLiteral + * tsep: Literal + */ + 'typed-keyword-true', + /** + * Not yet supported in Babel https://github.com/babel/babel/issues/9228 + * Babel: BooleanLiteral + * tsep: Literal + */ + 'typed-keyword-false' ], ignoreSourceType: [ // https://github.com/babel/babel/issues/9213 diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index 980115d..f9b40a8 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -72207,7 +72207,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 15, + "column": 8, "line": 1, }, "start": Object { @@ -77295,7 +77295,7 @@ Object { Object { "loc": Object { "end": Object { - "column": 8, + "column": 15, "line": 1, }, "start": Object { From 5a568c57ce931909452b06f91e3a324c19dbc36a Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 26 Dec 2018 06:35:00 +0100 Subject: [PATCH 19/24] fix: treeNodeMaps for types and add typeMode Additionally fix issue that Object literal is not TypeReference --- src/convert.ts | 144 +-- src/node-utils.ts | 38 - tests/ast-alignment/fixtures-to-test.ts | 4 + .../basics/class-with-mixin-reference.src.ts | 2 + .../types/conditional-with-null.src.ts | 1 + tests/lib/__snapshots__/typescript.ts.snap | 987 +++++++++++++++++- 6 files changed, 1048 insertions(+), 128 deletions(-) create mode 100644 tests/fixtures/typescript/basics/class-with-mixin-reference.src.ts create mode 100644 tests/fixtures/typescript/types/conditional-with-null.src.ts diff --git a/src/convert.ts b/src/convert.ts index d58457c..04dc11e 100644 --- a/src/convert.ts +++ b/src/convert.ts @@ -34,6 +34,7 @@ interface ConvertAdditionalOptions { interface ConvertConfig { node: ts.Node; parent?: ts.Node | null; + inTypeMode?: boolean; ast: ts.SourceFile; additionalOptions: ConvertAdditionalOptions; } @@ -80,23 +81,37 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { }); } - /** - * Converts a TypeScript node into an ESTree node. - * @param {ts.Node} child the child ts.Node - * @returns {ESTreeNode|null} the converted ESTree node - */ - function convertChild(child?: ts.Node): ESTreeNode | null { + function converter(child?: ts.Node, inTypeMode?: boolean): ESTreeNode | null { if (!child) { return null; } return convert({ node: child, parent: node, + inTypeMode, ast, additionalOptions }); } + /** + * Converts a TypeScript node into an ESTree node. + * @param {ts.Node} child the child ts.Node + * @returns {ESTreeNode|null} the converted ESTree node + */ + function convertChild(child?: ts.Node): ESTreeNode | null { + return converter(child, config.inTypeMode); + } + + /** + * Converts a TypeScript node into an ESTree node. + * @param {ts.Node} child the child ts.Node + * @returns {ESTreeNode|null} the converted ESTree node + */ + function convertChildType(child?: ts.Node): ESTreeNode | null { + return converter(child, true); + } + /** * Converts a child into a type annotation. This creates an intermediary * TypeAnnotation node to match what Flow does. @@ -104,7 +119,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { * @returns {ESTreeNode} The type annotation node. */ function convertTypeAnnotation(child: ts.TypeNode): ESTreeNode { - const annotation = convertChild(child); + const annotation = convertChildType(child); const annotationStartCol = child.getFullStart() - 1; const loc = nodeUtils.getLocFor(annotationStartCol, child.end, ast); return { @@ -182,32 +197,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { type: AST_NODE_TYPES.TSTypeParameterInstantiation, range: [start, end], loc: nodeUtils.getLocFor(start, end, ast), - params: typeArguments.map(typeArgument => { - if (nodeUtils.isTypeKeyword(typeArgument.kind)) { - return { - type: AST_NODE_TYPES[`TS${SyntaxKind[typeArgument.kind]}`], - range: [typeArgument.getStart(ast), typeArgument.getEnd()], - loc: nodeUtils.getLoc(typeArgument, ast) - }; - } - if (typeArgument.kind === SyntaxKind.ImportType) { - return convert({ - node: typeArgument, - parent: null, - ast, - additionalOptions - }); - } - return { - type: AST_NODE_TYPES.TSTypeReference, - range: [typeArgument.getStart(ast), typeArgument.getEnd()], - loc: nodeUtils.getLoc(typeArgument, ast), - typeName: convertChild(typeArgument.typeName || typeArgument), - typeParameters: typeArgument.typeArguments - ? convertTypeArgumentsToTypeParameters(typeArgument.typeArguments) - : undefined - }; - }) + params: typeArguments.map(typeArgument => convertChildType(typeArgument)) }; } @@ -236,36 +226,9 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { greaterThanToken!.end, ast ), - params: typeParameters.map(typeParameter => { - const name = typeParameter.name.text; - - const constraint = typeParameter.constraint - ? convert({ - node: typeParameter.constraint, - parent: typeParameter, - ast, - additionalOptions - }) - : undefined; - - const defaultParameter = typeParameter.default - ? convert({ - node: typeParameter.default, - parent: typeParameter, - ast, - additionalOptions - }) - : typeParameter.default; - - return { - type: AST_NODE_TYPES.TSTypeParameter, - range: [typeParameter.getStart(ast), typeParameter.getEnd()], - loc: nodeUtils.getLoc(typeParameter, ast), - name, - constraint, - default: defaultParameter - }; - }) + params: typeParameters.map(typeParameter => + convertChildType(typeParameter) + ) }; } @@ -2091,7 +2054,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { break; case SyntaxKind.NullKeyword: { - if (nodeUtils.isWithinTypeAnnotation(node)) { + if (config.inTypeMode) { Object.assign(result, { type: AST_NODE_TYPES.TSNullKeyword }); @@ -2279,6 +2242,45 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { // TypeScript specific + case SyntaxKind.TypeReference: { + Object.assign(result, { + type: AST_NODE_TYPES.TSTypeReference, + typeName: convertChildType(node.typeName), + typeParameters: node.typeArguments + ? convertTypeArgumentsToTypeParameters(node.typeArguments) + : undefined + }); + break; + } + + case SyntaxKind.TypeParameter: { + Object.assign(result, { + type: AST_NODE_TYPES.TSTypeParameter, + name: node.name.text, + constraint: node.constraint + ? convertChildType(node.constraint) + : undefined, + default: node.default ? convertChildType(node.default) : undefined + }); + break; + } + + case SyntaxKind.AnyKeyword: + case SyntaxKind.BigIntKeyword: + case SyntaxKind.BooleanKeyword: + case SyntaxKind.NeverKeyword: + case SyntaxKind.NumberKeyword: + case SyntaxKind.ObjectKeyword: + case SyntaxKind.StringKeyword: + case SyntaxKind.SymbolKeyword: + case SyntaxKind.UnknownKeyword: + case SyntaxKind.VoidKeyword: { + Object.assign(result, { + type: `TS${SyntaxKind[node.kind]}` + }); + break; + } + case SyntaxKind.ParenthesizedExpression: return convert({ node: node.expression, @@ -2291,7 +2293,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { Object.assign(result, { type: AST_NODE_TYPES.TSTypeAliasDeclaration, id: convertChild(node.name), - typeAnnotation: convertChild(node.type) + typeAnnotation: convertChildType(node.type) }); if (nodeUtils.hasModifier(SyntaxKind.DeclareKeyword, node)) { @@ -2561,42 +2563,42 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { case SyntaxKind.OptionalType: { Object.assign(result, { type: AST_NODE_TYPES.TSOptionalType, - typeAnnotation: convertChild(node.type) + typeAnnotation: convertChildType(node.type) }); break; } case SyntaxKind.ParenthesizedType: { Object.assign(result, { type: AST_NODE_TYPES.TSParenthesizedType, - typeAnnotation: convertChild(node.type) + typeAnnotation: convertChildType(node.type) }); break; } case SyntaxKind.TupleType: { Object.assign(result, { type: AST_NODE_TYPES.TSTupleType, - elementTypes: node.elementTypes.map(convertChild) + elementTypes: node.elementTypes.map(convertChildType) }); break; } case SyntaxKind.UnionType: { Object.assign(result, { type: AST_NODE_TYPES.TSUnionType, - types: node.types.map(convertChild) + types: node.types.map(convertChildType) }); break; } case SyntaxKind.IntersectionType: { Object.assign(result, { type: AST_NODE_TYPES.TSIntersectionType, - types: node.types.map(convertChild) + types: node.types.map(convertChildType) }); break; } case SyntaxKind.RestType: { Object.assign(result, { type: AST_NODE_TYPES.TSRestType, - typeAnnotation: convertChild(node.type) + typeAnnotation: convertChildType(node.type) }); break; } diff --git a/src/node-utils.ts b/src/node-utils.ts index 6ca905c..4b016cd 100644 --- a/src/node-utils.ts +++ b/src/node-utils.ts @@ -160,8 +160,6 @@ export default { convertToken, convertTokens, getNodeContainer, - isWithinTypeAnnotation, - isTypeKeyword, isComment, isJSDocComment, createError, @@ -357,29 +355,6 @@ function isJSXToken(node: ts.Node): boolean { ); } -/** - * Returns true if the given ts.Node.kind value corresponds to a type keyword - * @param {number} kind TypeScript SyntaxKind - * @returns {boolean} is a type keyword - */ -function isTypeKeyword(kind: number): boolean { - switch (kind) { - case SyntaxKind.AnyKeyword: - case SyntaxKind.BooleanKeyword: - case SyntaxKind.BigIntKeyword: - case SyntaxKind.NeverKeyword: - case SyntaxKind.NumberKeyword: - case SyntaxKind.ObjectKeyword: - case SyntaxKind.StringKeyword: - case SyntaxKind.SymbolKeyword: - case SyntaxKind.UnknownKeyword: - case SyntaxKind.VoidKeyword: - return true; - default: - return false; - } -} - /** * Returns the declaration kind of the given ts.Node * @param {ts.Node} node TypeScript AST node @@ -566,19 +541,6 @@ function isOptional(node: { questionToken?: ts.QuestionToken }): boolean { : false; } -/** - * Returns true if the given ts.Node is within the context of a "typeAnnotation", - * which effectively means - is it coming from its parent's `type` or `types` property - * @param {ts.Node} node ts.Node to be checked - * @returns {boolean} is within "typeAnnotation context" - */ -function isWithinTypeAnnotation(node: any): boolean { - return ( - node.parent.type === node || - (node.parent.types && node.parent.types.indexOf(node) > -1) - ); -} - /** * Fixes the exports of the given ts.Node * @param {ts.Node} node the ts.Node diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index 901e8a8..f5c30fd 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -431,6 +431,10 @@ let fixturePatternConfigsToTest = [ ] }), + createFixturePatternConfigFor('typescript/types', { + fileType: 'ts' + }), + createFixturePatternConfigFor('typescript/declare', { fileType: 'ts', ignore: [ diff --git a/tests/fixtures/typescript/basics/class-with-mixin-reference.src.ts b/tests/fixtures/typescript/basics/class-with-mixin-reference.src.ts new file mode 100644 index 0000000..9ba1bfd --- /dev/null +++ b/tests/fixtures/typescript/basics/class-with-mixin-reference.src.ts @@ -0,0 +1,2 @@ +function M>(Base: T) { +} diff --git a/tests/fixtures/typescript/types/conditional-with-null.src.ts b/tests/fixtures/typescript/types/conditional-with-null.src.ts new file mode 100644 index 0000000..c776486 --- /dev/null +++ b/tests/fixtures/typescript/types/conditional-with-null.src.ts @@ -0,0 +1 @@ +let x: number extends string ? boolean : null; diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index f9b40a8..2e785fb 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -10425,29 +10425,12 @@ Object { "line": 1, }, }, + "members": Array [], "range": Array [ 33, 35, ], - "type": "TSTypeReference", - "typeName": Object { - "loc": Object { - "end": Object { - "column": 35, - "line": 1, - }, - "start": Object { - "column": 33, - "line": 1, - }, - }, - "members": Array [], - "range": Array [ - 33, - 35, - ], - "type": "TSTypeLiteral", - }, + "type": "TSTypeLiteral", }, ], "range": Array [ @@ -12175,6 +12158,591 @@ Object { } `; +exports[`typescript fixtures/basics/class-with-mixin-reference.src 1`] = ` +Object { + "body": Array [ + Object { + "async": false, + "body": Object { + "body": Array [], + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 49, + ], + "type": "BlockStatement", + }, + "expression": false, + "generator": false, + "id": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "name": "M", + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 37, + "line": 1, + }, + }, + "name": "Base", + "range": Array [ + 37, + 44, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 44, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 43, + 44, + ], + "type": "Identifier", + }, + }, + }, + }, + ], + "range": Array [ + 0, + 49, + ], + "type": "FunctionDeclaration", + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "params": Array [ + Object { + "constraint": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 35, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "name": "Constructor", + "range": Array [ + 21, + 32, + ], + "type": "Identifier", + }, + "typeParameters": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 32, + "line": 1, + }, + }, + "params": Array [ + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "TSTypeReference", + "typeName": Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "name": "M", + "range": Array [ + 33, + 34, + ], + "type": "Identifier", + }, + }, + ], + "range": Array [ + 32, + 35, + ], + "type": "TSTypeParameterInstantiation", + }, + }, + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "name": "T", + "range": Array [ + 11, + 35, + ], + "type": "TSTypeParameter", + }, + ], + "range": Array [ + 10, + 36, + ], + "type": "TSTypeParameterDeclaration", + }, + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 3, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 50, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 8, + ], + "type": "Keyword", + "value": "function", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Identifier", + "value": "M", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 20, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 32, + ], + "type": "Identifier", + "value": "Constructor", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 32, + "line": 1, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": "<", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Identifier", + "value": "M", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Punctuator", + "value": ">", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": "(", + }, + Object { + "loc": Object { + "end": Object { + "column": 41, + "line": 1, + }, + "start": Object { + "column": 37, + "line": 1, + }, + }, + "range": Array [ + 37, + 41, + ], + "type": "Identifier", + "value": "Base", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 42, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 43, + "line": 1, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Identifier", + "value": "T", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 44, + "line": 1, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Punctuator", + "value": ")", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 2, + }, + }, + "range": Array [ + 48, + 49, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/class-with-optional-computed-property.src 1`] = ` Object { "body": Array [ @@ -76638,6 +77206,387 @@ Object { } `; +exports[`typescript fixtures/types/conditional-with-null.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "range": Array [ + 4, + 45, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 45, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "checkType": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 13, + ], + "type": "TSNumberKeyword", + }, + "extendsType": Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "TSStringKeyword", + }, + "falseType": Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 45, + ], + "type": "TSNullKeyword", + }, + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 45, + ], + "trueType": Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 38, + ], + "type": "TSBooleanKeyword", + }, + "type": "TSConditionalType", + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 45, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 46, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 47, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 5, + ], + "type": "Identifier", + "value": "x", + }, + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 5, + "line": 1, + }, + }, + "range": Array [ + 5, + 6, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 13, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 21, + ], + "type": "Keyword", + "value": "extends", + }, + Object { + "loc": Object { + "end": Object { + "column": 28, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 28, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 30, + "line": 1, + }, + "start": Object { + "column": 29, + "line": 1, + }, + }, + "range": Array [ + 29, + 30, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 38, + "line": 1, + }, + "start": Object { + "column": 31, + "line": 1, + }, + }, + "range": Array [ + 31, + 38, + ], + "type": "Identifier", + "value": "boolean", + }, + Object { + "loc": Object { + "end": Object { + "column": 40, + "line": 1, + }, + "start": Object { + "column": 39, + "line": 1, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 41, + "line": 1, + }, + }, + "range": Array [ + 41, + 45, + ], + "type": "Keyword", + "value": "null", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 45, + "line": 1, + }, + }, + "range": Array [ + 45, + 46, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/types/indexed.src 1`] = ` Object { "body": Array [ From 6ba943e56e812ea39ee90a9f13d757011acc0825 Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 26 Dec 2018 18:31:33 +0100 Subject: [PATCH 20/24] chore: remove unnecessary block scope --- src/convert.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/convert.ts b/src/convert.ts index 04dc11e..b8f0b39 100644 --- a/src/convert.ts +++ b/src/convert.ts @@ -774,13 +774,12 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { // Expressions - case SyntaxKind.ExpressionStatement: { + case SyntaxKind.ExpressionStatement: Object.assign(result, { type: AST_NODE_TYPES.ExpressionStatement, expression: convertChild(node.expression) }); break; - } case SyntaxKind.ThisKeyword: Object.assign(result, { From 00088ea469f14b3841dd4d43cc3da9b3b73f6749 Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 26 Dec 2018 20:50:19 +0100 Subject: [PATCH 21/24] test: add missing tests for literal variables --- tests/ast-alignment/fixtures-to-test.ts | 11 +- .../literal-float-negative.src.js | 1 + .../simple-literals/literal-float.src.js | 1 + .../simple-literals/literal-null.src.js | 1 + .../literal-number-negative.src.js | 1 + .../simple-literals/literal-number.src.js | 1 + .../simple-literals/literal-string.src.js | 1 + .../simple-literals/literal-undefined.src.js | 1 + tests/lib/__snapshots__/javascript.ts.snap | 1396 +++++++++++++++++ 9 files changed, 1413 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/javascript/simple-literals/literal-float-negative.src.js create mode 100644 tests/fixtures/javascript/simple-literals/literal-float.src.js create mode 100644 tests/fixtures/javascript/simple-literals/literal-null.src.js create mode 100644 tests/fixtures/javascript/simple-literals/literal-number-negative.src.js create mode 100644 tests/fixtures/javascript/simple-literals/literal-number.src.js create mode 100644 tests/fixtures/javascript/simple-literals/literal-string.src.js create mode 100644 tests/fixtures/javascript/simple-literals/literal-undefined.src.js diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index f5c30fd..b8b89aa 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -20,6 +20,8 @@ interface CreateFixturePatternConfig { ignoreSourceType?: string[]; } +const fixturesDirPath = path.join(__dirname, '../fixtures'); + /** * JSX fixtures which have known issues for typescript-estree */ @@ -57,6 +59,12 @@ function createFixturePatternConfigFor( 'fixtureSubPath was not provided for the current fixture pattern' ); } + if (!fs.existsSync(path.join(fixturesDirPath, fixturesSubPath))) { + throw new Error( + `Registered path '${path.join(__dirname, fixturesSubPath)}' was not found` + ); + } + config = config || ({} as CreateFixturePatternConfig); config.ignore = config.ignore || []; config.fileType = config.fileType || 'js'; @@ -110,6 +118,8 @@ let fixturePatternConfigsToTest = [ ignore: ['**/*'] }), + createFixturePatternConfigFor('javascript/simple-literals'), + createFixturePatternConfigFor('javascript/directives'), createFixturePatternConfigFor('javascript/experimentalObjectRestSpread', { @@ -482,7 +492,6 @@ fixturePatternConfigsToTest = ([] as FixturePatternConfig[]).concat( ); const fixturesToTest: Fixture[] = []; -const fixturesDirPath = path.join(__dirname, '../fixtures'); /** * Resolve the glob patterns into actual Fixture files that we can run assertions for... diff --git a/tests/fixtures/javascript/simple-literals/literal-float-negative.src.js b/tests/fixtures/javascript/simple-literals/literal-float-negative.src.js new file mode 100644 index 0000000..32ebbd0 --- /dev/null +++ b/tests/fixtures/javascript/simple-literals/literal-float-negative.src.js @@ -0,0 +1 @@ +const a = -1.5; diff --git a/tests/fixtures/javascript/simple-literals/literal-float.src.js b/tests/fixtures/javascript/simple-literals/literal-float.src.js new file mode 100644 index 0000000..0c12a9e --- /dev/null +++ b/tests/fixtures/javascript/simple-literals/literal-float.src.js @@ -0,0 +1 @@ +const a = 1.5; diff --git a/tests/fixtures/javascript/simple-literals/literal-null.src.js b/tests/fixtures/javascript/simple-literals/literal-null.src.js new file mode 100644 index 0000000..d6c4ab0 --- /dev/null +++ b/tests/fixtures/javascript/simple-literals/literal-null.src.js @@ -0,0 +1 @@ +const a = null; diff --git a/tests/fixtures/javascript/simple-literals/literal-number-negative.src.js b/tests/fixtures/javascript/simple-literals/literal-number-negative.src.js new file mode 100644 index 0000000..143a6b3 --- /dev/null +++ b/tests/fixtures/javascript/simple-literals/literal-number-negative.src.js @@ -0,0 +1 @@ +const a = -1; diff --git a/tests/fixtures/javascript/simple-literals/literal-number.src.js b/tests/fixtures/javascript/simple-literals/literal-number.src.js new file mode 100644 index 0000000..54b82a0 --- /dev/null +++ b/tests/fixtures/javascript/simple-literals/literal-number.src.js @@ -0,0 +1 @@ +const a = 1; diff --git a/tests/fixtures/javascript/simple-literals/literal-string.src.js b/tests/fixtures/javascript/simple-literals/literal-string.src.js new file mode 100644 index 0000000..25b4331 --- /dev/null +++ b/tests/fixtures/javascript/simple-literals/literal-string.src.js @@ -0,0 +1 @@ +const a = 'a'; diff --git a/tests/fixtures/javascript/simple-literals/literal-undefined.src.js b/tests/fixtures/javascript/simple-literals/literal-undefined.src.js new file mode 100644 index 0000000..0257085 --- /dev/null +++ b/tests/fixtures/javascript/simple-literals/literal-undefined.src.js @@ -0,0 +1 @@ +const a = undefined; diff --git a/tests/lib/__snapshots__/javascript.ts.snap b/tests/lib/__snapshots__/javascript.ts.snap index e7311ab..2e5e845 100644 --- a/tests/lib/__snapshots__/javascript.ts.snap +++ b/tests/lib/__snapshots__/javascript.ts.snap @@ -112247,6 +112247,1402 @@ Object { } `; +exports[`javascript fixtures/simple-literals/literal-float.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 13, + ], + "raw": "1.5", + "type": "Literal", + "value": 1.5, + }, + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 13, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 14, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 15, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 13, + ], + "type": "Numeric", + "value": "1.5", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/simple-literals/literal-float-negative.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "init": Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 14, + ], + "raw": "1.5", + "type": "Literal", + "value": 1.5, + }, + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "operator": "-", + "prefix": true, + "range": Array [ + 10, + 14, + ], + "type": "UnaryExpression", + }, + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 14, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 15, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 16, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "-", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 14, + ], + "type": "Numeric", + "value": "1.5", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/simple-literals/literal-null.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 14, + ], + "raw": "null", + "type": "Literal", + "value": null, + }, + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 14, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 15, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 16, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 14, + ], + "type": "Keyword", + "value": "null", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/simple-literals/literal-number.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 11, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 12, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 13, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/simple-literals/literal-number-negative.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "init": Object { + "argument": Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "operator": "-", + "prefix": true, + "range": Array [ + 10, + 12, + ], + "type": "UnaryExpression", + }, + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 12, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 13, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 14, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 11, + ], + "type": "Punctuator", + "value": "-", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/simple-literals/literal-string.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 13, + ], + "raw": "'a'", + "type": "Literal", + "value": "a", + }, + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 13, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 14, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 15, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 13, + ], + "type": "String", + "value": "'a'", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 1, + }, + "start": Object { + "column": 13, + "line": 1, + }, + }, + "range": Array [ + 13, + 14, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`javascript fixtures/simple-literals/literal-undefined.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "name": "a", + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": "undefined", + "range": Array [ + 10, + 19, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 19, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "const", + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 20, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 21, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 5, + ], + "type": "Keyword", + "value": "const", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 6, + "line": 1, + }, + }, + "range": Array [ + 6, + 7, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 8, + "line": 1, + }, + }, + "range": Array [ + 8, + 9, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 19, + ], + "type": "Keyword", + "value": "undefined", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 19, + "line": 1, + }, + }, + "range": Array [ + 19, + 20, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`javascript fixtures/spread/error-invalid-if.src 1`] = `"Expression expected."`; exports[`javascript fixtures/spread/error-invalid-sequence.src 1`] = `"Expression expected."`; From 6e96dc82f3ca8b885cb7f1c94cc41f5cfdf549ed Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 26 Dec 2018 22:23:57 +0100 Subject: [PATCH 22/24] test: enable keyof-operator alignment test --- tests/ast-alignment/fixtures-to-test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index b8b89aa..87e37e9 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -352,7 +352,6 @@ let fixturePatternConfigsToTest = [ 'typed-this', 'export-type-function-declaration', 'abstract-interface', - 'keyof-operator', /** * Babel bug for optional or abstract methods? */ From 5b6632dde136e322d60d31287dd5710153cea854 Mon Sep 17 00:00:00 2001 From: Armano Date: Thu, 27 Dec 2018 01:29:52 +0100 Subject: [PATCH 23/24] fix: mark nodes as directives in module and namespaces --- src/convert.ts | 2 + tests/ast-alignment/fixtures-to-test.ts | 12 +- .../basics/directive-in-module.src.ts | 5 + .../basics/directive-in-namespace.src.ts | 5 + tests/lib/__snapshots__/typescript.ts.snap | 920 ++++++++++++++++++ 5 files changed, 943 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/typescript/basics/directive-in-module.src.ts create mode 100644 tests/fixtures/typescript/basics/directive-in-namespace.src.ts diff --git a/src/convert.ts b/src/convert.ts index b8f0b39..66af7e3 100644 --- a/src/convert.ts +++ b/src/convert.ts @@ -1654,6 +1654,8 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { type: AST_NODE_TYPES.TSModuleBlock, body: node.statements.map(convertChild) }); + + convertBodyExpressionsToDirectives(); break; case SyntaxKind.ImportDeclaration: diff --git a/tests/ast-alignment/fixtures-to-test.ts b/tests/ast-alignment/fixtures-to-test.ts index 87e37e9..53175a9 100644 --- a/tests/ast-alignment/fixtures-to-test.ts +++ b/tests/ast-alignment/fixtures-to-test.ts @@ -387,7 +387,17 @@ let fixturePatternConfigsToTest = [ * Babel: BooleanLiteral * tsep: Literal */ - 'typed-keyword-false' + 'typed-keyword-false', + /** + * Not yet supported in Babel https://github.com/babel/babel/issues/9228 + * Directive field is not added to module and namespace + */ + 'directive-in-module', + /** + * Not yet supported in Babel https://github.com/babel/babel/issues/9228 + * Directive field is not added to module and namespace + */ + 'directive-in-namespace' ], ignoreSourceType: [ // https://github.com/babel/babel/issues/9213 diff --git a/tests/fixtures/typescript/basics/directive-in-module.src.ts b/tests/fixtures/typescript/basics/directive-in-module.src.ts new file mode 100644 index 0000000..2cb68ab --- /dev/null +++ b/tests/fixtures/typescript/basics/directive-in-module.src.ts @@ -0,0 +1,5 @@ +module foo { + "use strict"; + var a = 1; + "use strict"; +} diff --git a/tests/fixtures/typescript/basics/directive-in-namespace.src.ts b/tests/fixtures/typescript/basics/directive-in-namespace.src.ts new file mode 100644 index 0000000..80bc6c5 --- /dev/null +++ b/tests/fixtures/typescript/basics/directive-in-namespace.src.ts @@ -0,0 +1,5 @@ +namespace foo { + "use strict"; + var a = 1; + "use strict"; +} diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index 2e785fb..9c359b0 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -24974,6 +24974,926 @@ Object { } `; +exports[`typescript fixtures/basics/directive-in-module.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "directive": "use strict", + "expression": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 15, + 27, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 15, + 28, + ], + "type": "ExpressionStatement", + }, + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "name": "a", + "range": Array [ + 35, + 36, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 39, + 40, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 35, + 40, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "var", + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 31, + 41, + ], + "type": "VariableDeclaration", + }, + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 44, + 56, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 44, + 57, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 59, + ], + "type": "TSModuleBlock", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 7, + 10, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 59, + ], + "type": "TSModuleDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 6, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 60, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 6, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 6, + ], + "type": "Identifier", + "value": "module", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 10, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 15, + 27, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 27, + 28, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 31, + 34, + ], + "type": "Keyword", + "value": "var", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 37, + 38, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 39, + 40, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "range": Array [ + 40, + 41, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 44, + 56, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 14, + "line": 4, + }, + }, + "range": Array [ + 56, + 57, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 58, + 59, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/basics/directive-in-namespace.src 1`] = ` +Object { + "body": Array [ + Object { + "body": Object { + "body": Array [ + Object { + "directive": "use strict", + "expression": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 18, + 30, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 18, + 31, + ], + "type": "ExpressionStatement", + }, + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "name": "a", + "range": Array [ + 38, + 39, + ], + "type": "Identifier", + }, + "init": Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 42, + 43, + ], + "raw": "1", + "type": "Literal", + "value": 1, + }, + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 38, + 43, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "var", + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 34, + 44, + ], + "type": "VariableDeclaration", + }, + Object { + "expression": Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 47, + 59, + ], + "raw": "\\"use strict\\"", + "type": "Literal", + "value": "use strict", + }, + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 47, + 60, + ], + "type": "ExpressionStatement", + }, + ], + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 62, + ], + "type": "TSModuleBlock", + }, + "id": Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "name": "foo", + "range": Array [ + 10, + 13, + ], + "type": "Identifier", + }, + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 62, + ], + "type": "TSModuleDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 6, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 63, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 9, + ], + "type": "Identifier", + "value": "namespace", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 10, + "line": 1, + }, + }, + "range": Array [ + 10, + 13, + ], + "type": "Identifier", + "value": "foo", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 15, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 2, + }, + "start": Object { + "column": 2, + "line": 2, + }, + }, + "range": Array [ + 18, + 30, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 2, + }, + "start": Object { + "column": 14, + "line": 2, + }, + }, + "range": Array [ + 30, + 31, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 5, + "line": 3, + }, + "start": Object { + "column": 2, + "line": 3, + }, + }, + "range": Array [ + 34, + 37, + ], + "type": "Keyword", + "value": "var", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 3, + }, + "start": Object { + "column": 6, + "line": 3, + }, + }, + "range": Array [ + 38, + 39, + ], + "type": "Identifier", + "value": "a", + }, + Object { + "loc": Object { + "end": Object { + "column": 9, + "line": 3, + }, + "start": Object { + "column": 8, + "line": 3, + }, + }, + "range": Array [ + 40, + 41, + ], + "type": "Punctuator", + "value": "=", + }, + Object { + "loc": Object { + "end": Object { + "column": 11, + "line": 3, + }, + "start": Object { + "column": 10, + "line": 3, + }, + }, + "range": Array [ + 42, + 43, + ], + "type": "Numeric", + "value": "1", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 3, + }, + "start": Object { + "column": 11, + "line": 3, + }, + }, + "range": Array [ + 43, + 44, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 14, + "line": 4, + }, + "start": Object { + "column": 2, + "line": 4, + }, + }, + "range": Array [ + 47, + 59, + ], + "type": "String", + "value": "\\"use strict\\"", + }, + Object { + "loc": Object { + "end": Object { + "column": 15, + "line": 4, + }, + "start": Object { + "column": 14, + "line": 4, + }, + }, + "range": Array [ + 59, + 60, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 1, + "line": 5, + }, + "start": Object { + "column": 0, + "line": 5, + }, + }, + "range": Array [ + 61, + 62, + ], + "type": "Punctuator", + "value": "}", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/basics/export-assignment.src 1`] = ` Object { "body": Array [ From d55c3c9ef0f7dfb0f110aec031f429690ac2f489 Mon Sep 17 00:00:00 2001 From: Armano Date: Fri, 28 Dec 2018 06:14:37 +0100 Subject: [PATCH 24/24] fix: add support for mapped types --- src/ast-node-types.ts | 1 + src/convert.ts | 108 +- .../types/mapped-readonly-minus.src.ts | 1 + .../types/mapped-readonly-plus.src.ts | 1 + .../typescript/types/mapped-readonly.src.ts | 1 + tests/fixtures/typescript/types/mapped.src.ts | 1 + tests/lib/__snapshots__/typescript.ts.snap | 1844 +++++++++++++++++ 7 files changed, 1940 insertions(+), 17 deletions(-) create mode 100644 tests/fixtures/typescript/types/mapped-readonly-minus.src.ts create mode 100644 tests/fixtures/typescript/types/mapped-readonly-plus.src.ts create mode 100644 tests/fixtures/typescript/types/mapped-readonly.src.ts create mode 100644 tests/fixtures/typescript/types/mapped.src.ts diff --git a/src/ast-node-types.ts b/src/ast-node-types.ts index ee2a11e..59b684f 100644 --- a/src/ast-node-types.ts +++ b/src/ast-node-types.ts @@ -130,6 +130,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = { TSNeverKeyword: 'TSNeverKeyword', TSNullKeyword: 'TSNullKeyword', TSNumberKeyword: 'TSNumberKeyword', + TSMappedType: 'TSMappedType', TSObjectKeyword: 'TSObjectKeyword', TSParameterProperty: 'TSParameterProperty', TSPrivateKeyword: 'TSPrivateKeyword', diff --git a/src/convert.ts b/src/convert.ts index 66af7e3..5ccc6f4 100644 --- a/src/convert.ts +++ b/src/convert.ts @@ -70,17 +70,6 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { loc: nodeUtils.getLoc(node, ast) }; - /** - * Copies the result object into an ESTree node with just a type property. - * This is used only for leaf nodes that have no other properties. - * @returns {void} - */ - function simplyCopy(): void { - Object.assign(result, { - type: SyntaxKind[node.kind] - }); - } - function converter(child?: ts.Node, inTypeMode?: boolean): ESTreeNode | null { if (!child) { return null; @@ -484,14 +473,12 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { function fixTypeAnnotationParentLocation( typeAnnotationParent: ESTreeNode ): void { - const end = (node as any).type.getEnd(); - typeAnnotationParent.range[1] = end; - const loc = nodeUtils.getLocFor( + typeAnnotationParent.range[1] = (node as any).type.getEnd(); + typeAnnotationParent.loc = nodeUtils.getLocFor( typeAnnotationParent.range[0], typeAnnotationParent.range[1], ast ); - typeAnnotationParent.loc = loc; } /** @@ -2077,7 +2064,9 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { case SyntaxKind.EmptyStatement: case SyntaxKind.DebuggerStatement: - simplyCopy(); + Object.assign(result, { + type: SyntaxKind[node.kind] + }); break; // JSX @@ -2275,13 +2264,98 @@ export default function convert(config: ConvertConfig): ESTreeNode | null { case SyntaxKind.StringKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.UnknownKeyword: - case SyntaxKind.VoidKeyword: { + case SyntaxKind.VoidKeyword: + case SyntaxKind.UndefinedKeyword: { Object.assign(result, { type: `TS${SyntaxKind[node.kind]}` }); break; } + case SyntaxKind.NonNullExpression: { + Object.assign(result, { + type: AST_NODE_TYPES.TSNonNullExpression, + expression: convertChild(node.expression) + }); + break; + } + + case SyntaxKind.TypeLiteral: { + Object.assign(result, { + type: AST_NODE_TYPES.TSTypeLiteral, + members: node.members.map(convertChild) + }); + break; + } + + case SyntaxKind.ArrayType: { + Object.assign(result, { + type: AST_NODE_TYPES.TSArrayType, + elementType: convertChildType(node.elementType) + }); + break; + } + + case SyntaxKind.IndexedAccessType: { + Object.assign(result, { + type: AST_NODE_TYPES.TSIndexedAccessType, + objectType: convertChildType(node.objectType), + indexType: convertChildType(node.indexType) + }); + break; + } + + case SyntaxKind.ConditionalType: { + Object.assign(result, { + type: AST_NODE_TYPES.TSConditionalType, + checkType: convertChildType(node.checkType), + extendsType: convertChildType(node.extendsType), + trueType: convertChildType(node.trueType), + falseType: convertChildType(node.falseType) + }); + break; + } + + case SyntaxKind.TypeQuery: { + Object.assign(result, { + type: AST_NODE_TYPES.TSTypeQuery, + exprName: convertChildType(node.exprName) + }); + break; + } + + case SyntaxKind.MappedType: { + Object.assign(result, { + type: AST_NODE_TYPES.TSMappedType, + typeParameter: convertChildType(node.typeParameter) + }); + + if (node.readonlyToken) { + if (node.readonlyToken.kind === SyntaxKind.ReadonlyKeyword) { + (result as any).readonly = true; + } else { + (result as any).readonly = nodeUtils.getTextForTokenKind( + node.readonlyToken.kind + ); + } + } + + if (node.questionToken) { + if (node.questionToken.kind === SyntaxKind.QuestionToken) { + (result as any).optional = true; + } else { + (result as any).optional = nodeUtils.getTextForTokenKind( + node.questionToken.kind + ); + } + } + + if (node.type) { + result.typeAnnotation = convertChildType(node.type); + } + break; + } + case SyntaxKind.ParenthesizedExpression: return convert({ node: node.expression, diff --git a/tests/fixtures/typescript/types/mapped-readonly-minus.src.ts b/tests/fixtures/typescript/types/mapped-readonly-minus.src.ts new file mode 100644 index 0000000..a7a1183 --- /dev/null +++ b/tests/fixtures/typescript/types/mapped-readonly-minus.src.ts @@ -0,0 +1 @@ +let map: { -readonly [P in string]-?: number }; diff --git a/tests/fixtures/typescript/types/mapped-readonly-plus.src.ts b/tests/fixtures/typescript/types/mapped-readonly-plus.src.ts new file mode 100644 index 0000000..854fb5d --- /dev/null +++ b/tests/fixtures/typescript/types/mapped-readonly-plus.src.ts @@ -0,0 +1 @@ +let map: { +readonly [P in string]+?: number; }; diff --git a/tests/fixtures/typescript/types/mapped-readonly.src.ts b/tests/fixtures/typescript/types/mapped-readonly.src.ts new file mode 100644 index 0000000..ef13a05 --- /dev/null +++ b/tests/fixtures/typescript/types/mapped-readonly.src.ts @@ -0,0 +1 @@ +let map: { readonly [P in string]?: number; }; diff --git a/tests/fixtures/typescript/types/mapped.src.ts b/tests/fixtures/typescript/types/mapped.src.ts new file mode 100644 index 0000000..aca2ba1 --- /dev/null +++ b/tests/fixtures/typescript/types/mapped.src.ts @@ -0,0 +1 @@ +let map: { [P in string]: number; }; diff --git a/tests/lib/__snapshots__/typescript.ts.snap b/tests/lib/__snapshots__/typescript.ts.snap index 9c359b0..6197566 100644 --- a/tests/lib/__snapshots__/typescript.ts.snap +++ b/tests/lib/__snapshots__/typescript.ts.snap @@ -79454,6 +79454,1850 @@ Object { } `; +exports[`typescript fixtures/types/mapped.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "map", + "range": Array [ + 4, + 35, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 35, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 35, + ], + "type": "TSMappedType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 32, + ], + "type": "TSNumberKeyword", + }, + "typeParameter": Object { + "constraint": Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 23, + ], + "type": "TSStringKeyword", + }, + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "name": "P", + "range": Array [ + 12, + 23, + ], + "type": "TSTypeParameter", + }, + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 35, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 36, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 37, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + "value": "map", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 13, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 13, + ], + "type": "Identifier", + "value": "P", + }, + Object { + "loc": Object { + "end": Object { + "column": 16, + "line": 1, + }, + "start": Object { + "column": 14, + "line": 1, + }, + }, + "range": Array [ + 14, + 16, + ], + "type": "Keyword", + "value": "in", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 17, + "line": 1, + }, + }, + "range": Array [ + 17, + 23, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 24, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 24, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 25, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 32, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 32, + "line": 1, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/mapped-readonly.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "map", + "range": Array [ + 4, + 45, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 45, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "optional": true, + "range": Array [ + 9, + 45, + ], + "readonly": true, + "type": "TSMappedType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, + }, + "range": Array [ + 36, + 42, + ], + "type": "TSNumberKeyword", + }, + "typeParameter": Object { + "constraint": Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 32, + ], + "type": "TSStringKeyword", + }, + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "name": "P", + "range": Array [ + 21, + 32, + ], + "type": "TSTypeParameter", + }, + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 45, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 46, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 47, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + "value": "map", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 19, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 19, + ], + "type": "Identifier", + "value": "readonly", + }, + Object { + "loc": Object { + "end": Object { + "column": 21, + "line": 1, + }, + "start": Object { + "column": 20, + "line": 1, + }, + }, + "range": Array [ + 20, + 21, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Identifier", + "value": "P", + }, + Object { + "loc": Object { + "end": Object { + "column": 25, + "line": 1, + }, + "start": Object { + "column": 23, + "line": 1, + }, + }, + "range": Array [ + 23, + 25, + ], + "type": "Keyword", + "value": "in", + }, + Object { + "loc": Object { + "end": Object { + "column": 32, + "line": 1, + }, + "start": Object { + "column": 26, + "line": 1, + }, + }, + "range": Array [ + 26, + 32, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 32, + "line": 1, + }, + }, + "range": Array [ + 32, + 33, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 42, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, + }, + "range": Array [ + 36, + 42, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 43, + "line": 1, + }, + "start": Object { + "column": 42, + "line": 1, + }, + }, + "range": Array [ + 42, + 43, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 44, + "line": 1, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 45, + "line": 1, + }, + }, + "range": Array [ + 45, + 46, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/mapped-readonly-minus.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "map", + "range": Array [ + 4, + 46, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 46, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "optional": "-", + "range": Array [ + 9, + 46, + ], + "readonly": "-", + "type": "TSMappedType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 38, + "line": 1, + }, + }, + "range": Array [ + 38, + 44, + ], + "type": "TSNumberKeyword", + }, + "typeParameter": Object { + "constraint": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 33, + ], + "type": "TSStringKeyword", + }, + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "name": "P", + "range": Array [ + 22, + 33, + ], + "type": "TSTypeParameter", + }, + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 46, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 47, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 48, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + "value": "map", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "-", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 20, + ], + "type": "Identifier", + "value": "readonly", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Identifier", + "value": "P", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 26, + ], + "type": "Keyword", + "value": "in", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 33, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Punctuator", + "value": "-", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 38, + "line": 1, + }, + }, + "range": Array [ + 38, + 44, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 46, + "line": 1, + }, + "start": Object { + "column": 45, + "line": 1, + }, + }, + "range": Array [ + 45, + 46, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + +exports[`typescript fixtures/types/mapped-readonly-plus.src 1`] = ` +Object { + "body": Array [ + Object { + "declarations": Array [ + Object { + "id": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "name": "map", + "range": Array [ + 4, + 47, + ], + "type": "Identifier", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 47, + ], + "type": "TSTypeAnnotation", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "optional": "+", + "range": Array [ + 9, + 47, + ], + "readonly": "+", + "type": "TSMappedType", + "typeAnnotation": Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 38, + "line": 1, + }, + }, + "range": Array [ + 38, + 44, + ], + "type": "TSNumberKeyword", + }, + "typeParameter": Object { + "constraint": Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 33, + ], + "type": "TSStringKeyword", + }, + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "name": "P", + "range": Array [ + 22, + 33, + ], + "type": "TSTypeParameter", + }, + }, + }, + }, + "init": null, + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 47, + ], + "type": "VariableDeclarator", + }, + ], + "kind": "let", + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 48, + ], + "type": "VariableDeclaration", + }, + ], + "loc": Object { + "end": Object { + "column": 0, + "line": 2, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 49, + ], + "sourceType": "script", + "tokens": Array [ + Object { + "loc": Object { + "end": Object { + "column": 3, + "line": 1, + }, + "start": Object { + "column": 0, + "line": 1, + }, + }, + "range": Array [ + 0, + 3, + ], + "type": "Keyword", + "value": "let", + }, + Object { + "loc": Object { + "end": Object { + "column": 7, + "line": 1, + }, + "start": Object { + "column": 4, + "line": 1, + }, + }, + "range": Array [ + 4, + 7, + ], + "type": "Identifier", + "value": "map", + }, + Object { + "loc": Object { + "end": Object { + "column": 8, + "line": 1, + }, + "start": Object { + "column": 7, + "line": 1, + }, + }, + "range": Array [ + 7, + 8, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 10, + "line": 1, + }, + "start": Object { + "column": 9, + "line": 1, + }, + }, + "range": Array [ + 9, + 10, + ], + "type": "Punctuator", + "value": "{", + }, + Object { + "loc": Object { + "end": Object { + "column": 12, + "line": 1, + }, + "start": Object { + "column": 11, + "line": 1, + }, + }, + "range": Array [ + 11, + 12, + ], + "type": "Punctuator", + "value": "+", + }, + Object { + "loc": Object { + "end": Object { + "column": 20, + "line": 1, + }, + "start": Object { + "column": 12, + "line": 1, + }, + }, + "range": Array [ + 12, + 20, + ], + "type": "Identifier", + "value": "readonly", + }, + Object { + "loc": Object { + "end": Object { + "column": 22, + "line": 1, + }, + "start": Object { + "column": 21, + "line": 1, + }, + }, + "range": Array [ + 21, + 22, + ], + "type": "Punctuator", + "value": "[", + }, + Object { + "loc": Object { + "end": Object { + "column": 23, + "line": 1, + }, + "start": Object { + "column": 22, + "line": 1, + }, + }, + "range": Array [ + 22, + 23, + ], + "type": "Identifier", + "value": "P", + }, + Object { + "loc": Object { + "end": Object { + "column": 26, + "line": 1, + }, + "start": Object { + "column": 24, + "line": 1, + }, + }, + "range": Array [ + 24, + 26, + ], + "type": "Keyword", + "value": "in", + }, + Object { + "loc": Object { + "end": Object { + "column": 33, + "line": 1, + }, + "start": Object { + "column": 27, + "line": 1, + }, + }, + "range": Array [ + 27, + 33, + ], + "type": "Identifier", + "value": "string", + }, + Object { + "loc": Object { + "end": Object { + "column": 34, + "line": 1, + }, + "start": Object { + "column": 33, + "line": 1, + }, + }, + "range": Array [ + 33, + 34, + ], + "type": "Punctuator", + "value": "]", + }, + Object { + "loc": Object { + "end": Object { + "column": 35, + "line": 1, + }, + "start": Object { + "column": 34, + "line": 1, + }, + }, + "range": Array [ + 34, + 35, + ], + "type": "Punctuator", + "value": "+", + }, + Object { + "loc": Object { + "end": Object { + "column": 36, + "line": 1, + }, + "start": Object { + "column": 35, + "line": 1, + }, + }, + "range": Array [ + 35, + 36, + ], + "type": "Punctuator", + "value": "?", + }, + Object { + "loc": Object { + "end": Object { + "column": 37, + "line": 1, + }, + "start": Object { + "column": 36, + "line": 1, + }, + }, + "range": Array [ + 36, + 37, + ], + "type": "Punctuator", + "value": ":", + }, + Object { + "loc": Object { + "end": Object { + "column": 44, + "line": 1, + }, + "start": Object { + "column": 38, + "line": 1, + }, + }, + "range": Array [ + 38, + 44, + ], + "type": "Identifier", + "value": "number", + }, + Object { + "loc": Object { + "end": Object { + "column": 45, + "line": 1, + }, + "start": Object { + "column": 44, + "line": 1, + }, + }, + "range": Array [ + 44, + 45, + ], + "type": "Punctuator", + "value": ";", + }, + Object { + "loc": Object { + "end": Object { + "column": 47, + "line": 1, + }, + "start": Object { + "column": 46, + "line": 1, + }, + }, + "range": Array [ + 46, + 47, + ], + "type": "Punctuator", + "value": "}", + }, + Object { + "loc": Object { + "end": Object { + "column": 48, + "line": 1, + }, + "start": Object { + "column": 47, + "line": 1, + }, + }, + "range": Array [ + 47, + 48, + ], + "type": "Punctuator", + "value": ";", + }, + ], + "type": "Program", +} +`; + exports[`typescript fixtures/types/nested-types.src 1`] = ` Object { "body": Array [