Cleaning up some TS parsing tests (#7184)

This commit is contained in:
Maaz Syed Adeeb 2018-01-09 23:07:05 +05:30 committed by Brian Ng
parent f694b5d034
commit 9e384f3915
4 changed files with 104 additions and 923 deletions

View File

@ -1,10 +1 @@
interface ResponseBody { (a as number) = 42;
name: string
age: number
}
let response;
(response as ResponseBody) = {
name: 'Alice',
age: 23,
}

View File

@ -1,482 +1,132 @@
{ {
"type": "File", "type": "File",
"start": 0, "start": 0,
"end": 131, "end": 19,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 10, "line": 1,
"column": 1 "column": 19
} }
}, },
"program": { "program": {
"type": "Program", "type": "Program",
"start": 0, "start": 0,
"end": 131, "end": 19,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 10, "line": 1,
"column": 1 "column": 19
} }
}, },
"sourceType": "module", "sourceType": "module",
"body": [ "body": [
{ {
"type": "TSInterfaceDeclaration", "type": "ExpressionStatement",
"start": 0, "start": 0,
"end": 55, "end": 19,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 4, "line": 1,
"column": 1 "column": 19
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 22
},
"identifierName": "ResponseBody"
},
"name": "ResponseBody"
},
"body": {
"type": "TSInterfaceBody",
"start": 23,
"end": 55,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "TSPropertySignature",
"start": 27,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 14
}
},
"key": {
"type": "Identifier",
"start": 27,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 6
},
"identifierName": "name"
},
"name": "name"
},
"computed": false,
"typeAnnotation": {
"type": "TSTypeAnnotation",
"start": 31,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 14
}
},
"typeAnnotation": {
"type": "TSStringKeyword",
"start": 33,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 14
}
}
}
}
},
{
"type": "TSPropertySignature",
"start": 42,
"end": 53,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 13
}
},
"key": {
"type": "Identifier",
"start": 42,
"end": 45,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 5
},
"identifierName": "age"
},
"name": "age"
},
"computed": false,
"typeAnnotation": {
"type": "TSTypeAnnotation",
"start": 45,
"end": 53,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 13
}
},
"typeAnnotation": {
"type": "TSNumberKeyword",
"start": 47,
"end": 53,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 13
}
}
}
}
}
]
}
},
{
"type": "VariableDeclaration",
"start": 57,
"end": 70,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 6,
"column": 13
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 61,
"end": 69,
"loc": {
"start": {
"line": 6,
"column": 4
},
"end": {
"line": 6,
"column": 12
}
},
"id": {
"type": "Identifier",
"start": 61,
"end": 69,
"loc": {
"start": {
"line": 6,
"column": 4
},
"end": {
"line": 6,
"column": 12
},
"identifierName": "response"
},
"name": "response"
},
"init": null
}
],
"kind": "let"
},
{
"type": "ExpressionStatement",
"start": 71,
"end": 131,
"loc": {
"start": {
"line": 7,
"column": 0
},
"end": {
"line": 10,
"column": 1
} }
}, },
"expression": { "expression": {
"type": "AssignmentExpression", "type": "AssignmentExpression",
"start": 71, "start": 0,
"end": 131, "end": 18,
"loc": { "loc": {
"start": { "start": {
"line": 7, "line": 1,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 10, "line": 1,
"column": 1 "column": 18
} }
}, },
"operator": "=", "operator": "=",
"left": { "left": {
"type": "TSAsExpression", "type": "TSAsExpression",
"start": 72, "start": 1,
"end": 96, "end": 12,
"loc": { "loc": {
"start": { "start": {
"line": 7, "line": 1,
"column": 1 "column": 1
}, },
"end": { "end": {
"line": 7, "line": 1,
"column": 25 "column": 12
} }
}, },
"expression": { "expression": {
"type": "Identifier", "type": "Identifier",
"start": 72, "start": 1,
"end": 80, "end": 2,
"loc": { "loc": {
"start": { "start": {
"line": 7, "line": 1,
"column": 1 "column": 1
}, },
"end": { "end": {
"line": 7, "line": 1,
"column": 9 "column": 2
}, },
"identifierName": "response" "identifierName": "a"
}, },
"name": "response" "name": "a"
}, },
"typeAnnotation": { "typeAnnotation": {
"type": "TSTypeReference", "type": "TSNumberKeyword",
"start": 84, "start": 6,
"end": 96, "end": 12,
"loc": { "loc": {
"start": { "start": {
"line": 7, "line": 1,
"column": 13 "column": 6
}, },
"end": { "end": {
"line": 7, "line": 1,
"column": 25 "column": 12
} }
},
"typeName": {
"type": "Identifier",
"start": 84,
"end": 96,
"loc": {
"start": {
"line": 7,
"column": 13
},
"end": {
"line": 7,
"column": 25
},
"identifierName": "ResponseBody"
},
"name": "ResponseBody"
} }
}, },
"extra": { "extra": {
"parenthesized": true, "parenthesized": true,
"parenStart": 71 "parenStart": 0
} }
}, },
"right": { "right": {
"type": "ObjectExpression", "type": "NumericLiteral",
"start": 100, "start": 16,
"end": 131, "end": 18,
"loc": { "loc": {
"start": { "start": {
"line": 7, "line": 1,
"column": 29 "column": 16
}, },
"end": { "end": {
"line": 10, "line": 1,
"column": 1 "column": 18
} }
}, },
"properties": [ "extra": {
{ "rawValue": 42,
"type": "ObjectProperty", "raw": "42"
"start": 104, },
"end": 117, "value": 42
"loc": {
"start": {
"line": 8,
"column": 2
},
"end": {
"line": 8,
"column": 15
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 104,
"end": 108,
"loc": {
"start": {
"line": 8,
"column": 2
},
"end": {
"line": 8,
"column": 6
},
"identifierName": "name"
},
"name": "name"
},
"computed": false,
"shorthand": false,
"value": {
"type": "StringLiteral",
"start": 110,
"end": 117,
"loc": {
"start": {
"line": 8,
"column": 8
},
"end": {
"line": 8,
"column": 15
}
},
"extra": {
"rawValue": "Alice",
"raw": "'Alice'"
},
"value": "Alice"
}
},
{
"type": "ObjectProperty",
"start": 121,
"end": 128,
"loc": {
"start": {
"line": 9,
"column": 2
},
"end": {
"line": 9,
"column": 9
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 121,
"end": 124,
"loc": {
"start": {
"line": 9,
"column": 2
},
"end": {
"line": 9,
"column": 5
},
"identifierName": "age"
},
"name": "age"
},
"computed": false,
"shorthand": false,
"value": {
"type": "NumericLiteral",
"start": 126,
"end": 128,
"loc": {
"start": {
"line": 9,
"column": 7
},
"end": {
"line": 9,
"column": 9
}
},
"extra": {
"rawValue": 23,
"raw": "23"
},
"value": 23
}
}
]
} }
} }
} }

View File

@ -1,11 +1 @@
interface A { (a as number as any) = 42;
name: string
}
interface B extends A {
age: number
}
let a;
(a as A as B) = {
name: 'Alice',
age: 23
}

View File

@ -1,410 +1,101 @@
{ {
"type": "File", "type": "File",
"start": 0, "start": 0,
"end": 124, "end": 26,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 11, "line": 1,
"column": 1 "column": 26
} }
}, },
"program": { "program": {
"type": "Program", "type": "Program",
"start": 0, "start": 0,
"end": 124, "end": 26,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 11, "line": 1,
"column": 1 "column": 26
} }
}, },
"sourceType": "module", "sourceType": "module",
"body": [ "body": [
{ {
"type": "TSInterfaceDeclaration", "type": "ExpressionStatement",
"start": 0, "start": 0,
"end": 30, "end": 26,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 3, "line": 1,
"column": 1 "column": 26
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"body": {
"type": "TSInterfaceBody",
"start": 12,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "TSPropertySignature",
"start": 16,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 14
}
},
"key": {
"type": "Identifier",
"start": 16,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 6
},
"identifierName": "name"
},
"name": "name"
},
"computed": false,
"typeAnnotation": {
"type": "TSTypeAnnotation",
"start": 20,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 14
}
},
"typeAnnotation": {
"type": "TSStringKeyword",
"start": 22,
"end": 28,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 14
}
}
}
}
}
]
}
},
{
"type": "TSInterfaceDeclaration",
"start": 31,
"end": 70,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 6,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 41,
"end": 42,
"loc": {
"start": {
"line": 4,
"column": 10
},
"end": {
"line": 4,
"column": 11
},
"identifierName": "B"
},
"name": "B"
},
"extends": [
{
"type": "TSExpressionWithTypeArguments",
"start": 51,
"end": 52,
"loc": {
"start": {
"line": 4,
"column": 20
},
"end": {
"line": 4,
"column": 21
}
},
"expression": {
"type": "Identifier",
"start": 51,
"end": 52,
"loc": {
"start": {
"line": 4,
"column": 20
},
"end": {
"line": 4,
"column": 21
},
"identifierName": "A"
},
"name": "A"
}
}
],
"body": {
"type": "TSInterfaceBody",
"start": 53,
"end": 70,
"loc": {
"start": {
"line": 4,
"column": 22
},
"end": {
"line": 6,
"column": 1
}
},
"body": [
{
"type": "TSPropertySignature",
"start": 57,
"end": 68,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 13
}
},
"key": {
"type": "Identifier",
"start": 57,
"end": 60,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 5
},
"identifierName": "age"
},
"name": "age"
},
"computed": false,
"typeAnnotation": {
"type": "TSTypeAnnotation",
"start": 60,
"end": 68,
"loc": {
"start": {
"line": 5,
"column": 5
},
"end": {
"line": 5,
"column": 13
}
},
"typeAnnotation": {
"type": "TSNumberKeyword",
"start": 62,
"end": 68,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 5,
"column": 13
}
}
}
}
}
]
}
},
{
"type": "VariableDeclaration",
"start": 71,
"end": 77,
"loc": {
"start": {
"line": 7,
"column": 0
},
"end": {
"line": 7,
"column": 6
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 75,
"end": 76,
"loc": {
"start": {
"line": 7,
"column": 4
},
"end": {
"line": 7,
"column": 5
}
},
"id": {
"type": "Identifier",
"start": 75,
"end": 76,
"loc": {
"start": {
"line": 7,
"column": 4
},
"end": {
"line": 7,
"column": 5
},
"identifierName": "a"
},
"name": "a"
},
"init": null
}
],
"kind": "let"
},
{
"type": "ExpressionStatement",
"start": 78,
"end": 124,
"loc": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 11,
"column": 1
} }
}, },
"expression": { "expression": {
"type": "AssignmentExpression", "type": "AssignmentExpression",
"start": 78, "start": 0,
"end": 124, "end": 25,
"loc": { "loc": {
"start": { "start": {
"line": 8, "line": 1,
"column": 0 "column": 0
}, },
"end": { "end": {
"line": 11, "line": 1,
"column": 1 "column": 25
} }
}, },
"operator": "=", "operator": "=",
"left": { "left": {
"type": "TSAsExpression", "type": "TSAsExpression",
"start": 79, "start": 1,
"end": 90, "end": 19,
"loc": { "loc": {
"start": { "start": {
"line": 8, "line": 1,
"column": 1 "column": 1
}, },
"end": { "end": {
"line": 8, "line": 1,
"column": 12 "column": 19
} }
}, },
"expression": { "expression": {
"type": "TSAsExpression", "type": "TSAsExpression",
"start": 79, "start": 1,
"end": 85, "end": 12,
"loc": { "loc": {
"start": { "start": {
"line": 8, "line": 1,
"column": 1 "column": 1
}, },
"end": { "end": {
"line": 8, "line": 1,
"column": 7 "column": 12
} }
}, },
"expression": { "expression": {
"type": "Identifier", "type": "Identifier",
"start": 79, "start": 1,
"end": 80, "end": 2,
"loc": { "loc": {
"start": { "start": {
"line": 8, "line": 1,
"column": 1 "column": 1
}, },
"end": { "end": {
"line": 8, "line": 1,
"column": 2 "column": 2
}, },
"identifierName": "a" "identifierName": "a"
@ -412,201 +103,60 @@
"name": "a" "name": "a"
}, },
"typeAnnotation": { "typeAnnotation": {
"type": "TSTypeReference", "type": "TSNumberKeyword",
"start": 84, "start": 6,
"end": 85, "end": 12,
"loc": { "loc": {
"start": { "start": {
"line": 8, "line": 1,
"column": 6 "column": 6
}, },
"end": { "end": {
"line": 8, "line": 1,
"column": 7 "column": 12
} }
},
"typeName": {
"type": "Identifier",
"start": 84,
"end": 85,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 8,
"column": 7
},
"identifierName": "A"
},
"name": "A"
} }
} }
}, },
"typeAnnotation": { "typeAnnotation": {
"type": "TSTypeReference", "type": "TSAnyKeyword",
"start": 89, "start": 16,
"end": 90, "end": 19,
"loc": { "loc": {
"start": { "start": {
"line": 8, "line": 1,
"column": 11 "column": 16
}, },
"end": { "end": {
"line": 8, "line": 1,
"column": 12 "column": 19
} }
},
"typeName": {
"type": "Identifier",
"start": 89,
"end": 90,
"loc": {
"start": {
"line": 8,
"column": 11
},
"end": {
"line": 8,
"column": 12
},
"identifierName": "B"
},
"name": "B"
} }
}, },
"extra": { "extra": {
"parenthesized": true, "parenthesized": true,
"parenStart": 78 "parenStart": 0
} }
}, },
"right": { "right": {
"type": "ObjectExpression", "type": "NumericLiteral",
"start": 94, "start": 23,
"end": 124, "end": 25,
"loc": { "loc": {
"start": { "start": {
"line": 8, "line": 1,
"column": 16 "column": 23
}, },
"end": { "end": {
"line": 11, "line": 1,
"column": 1 "column": 25
} }
}, },
"properties": [ "extra": {
{ "rawValue": 42,
"type": "ObjectProperty", "raw": "42"
"start": 98, },
"end": 111, "value": 42
"loc": {
"start": {
"line": 9,
"column": 2
},
"end": {
"line": 9,
"column": 15
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 98,
"end": 102,
"loc": {
"start": {
"line": 9,
"column": 2
},
"end": {
"line": 9,
"column": 6
},
"identifierName": "name"
},
"name": "name"
},
"computed": false,
"shorthand": false,
"value": {
"type": "StringLiteral",
"start": 104,
"end": 111,
"loc": {
"start": {
"line": 9,
"column": 8
},
"end": {
"line": 9,
"column": 15
}
},
"extra": {
"rawValue": "Alice",
"raw": "'Alice'"
},
"value": "Alice"
}
},
{
"type": "ObjectProperty",
"start": 115,
"end": 122,
"loc": {
"start": {
"line": 10,
"column": 2
},
"end": {
"line": 10,
"column": 9
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 115,
"end": 118,
"loc": {
"start": {
"line": 10,
"column": 2
},
"end": {
"line": 10,
"column": 5
},
"identifierName": "age"
},
"name": "age"
},
"computed": false,
"shorthand": false,
"value": {
"type": "NumericLiteral",
"start": 120,
"end": 122,
"loc": {
"start": {
"line": 10,
"column": 7
},
"end": {
"line": 10,
"column": 9
}
},
"extra": {
"rawValue": 23,
"raw": "23"
},
"value": 23
}
}
]
} }
} }
} }