Internal slot properties (#7947)

* Support internalSlots to babel-types and babel-generator

* Parsing support for internal slot properties

* Print internal slots in babel-generator

* Add whitespace before first internal slot property
This commit is contained in:
Sam Goldman 2018-05-17 04:48:12 +01:00 committed by Brian Ng
parent 8dcfabd0d7
commit b396cdcbe5
111 changed files with 1232 additions and 10 deletions

View File

@ -384,6 +384,7 @@ export function ObjectTypeAnnotation(node: Object) {
const props = node.properties.concat(
node.callProperties || [],
node.indexers || [],
node.internalSlots || [],
);
if (props.length) {
@ -413,6 +414,23 @@ export function ObjectTypeAnnotation(node: Object) {
}
}
export function ObjectTypeInternalSlot(node: Object) {
if (node.static) {
this.word("static");
this.space();
}
this.token("[");
this.token("[");
this.print(node.id, node);
this.token("]");
this.token("]");
if (!node.method) {
this.token(":");
this.space();
}
this.print(node.value, node);
}
export function ObjectTypeCallProperty(node: Object) {
if (node.static) {
this.word("static");

View File

@ -209,6 +209,22 @@ nodes.ObjectTypeIndexer = function(node: Object, parent): ?WhitespaceObject {
}
};
nodes.ObjectTypeInternalSlot = function(
node: Object,
parent,
): ?WhitespaceObject {
if (
parent.internalSlots[0] === node &&
(!parent.properties || !parent.properties.length) &&
(!parent.callProperties || !parent.callProperties.length) &&
(!parent.indexers || !parent.indexers.length)
) {
return {
before: true,
};
}
};
/**
* Returns lists from node types that need whitespace.
*/

View File

@ -0,0 +1,6 @@
declare class C { static [[foo]]: T }
declare class C { [[foo]]: T }
interface T { [[foo]]: X }
interface T { [[foo]](): X }
type T = { [[foo]]: X }
type T = { [[foo]](): X }

View File

@ -0,0 +1,18 @@
declare class C {
static [[foo]]: T
}
declare class C {
[[foo]]: T
}
interface T {
[[foo]]: X
}
interface T {
[[foo]]() => X
}
type T = {
[[foo]]: X
};
type T = {
[[foo]]() => X
};

View File

@ -304,6 +304,7 @@ describe("programmatic generation", function() {
[t.objectTypeProperty(t.identifier("bar"), t.stringTypeAnnotation())],
null,
null,
null,
);
const output = generate(objectStatement).code;
@ -317,6 +318,7 @@ describe("programmatic generation", function() {
[t.objectTypeProperty(t.identifier("bar"), t.stringTypeAnnotation())],
null,
null,
null,
true,
);
@ -336,6 +338,7 @@ describe("programmatic generation", function() {
t.numberTypeAnnotation(),
),
],
null,
);
const output = generate(objectStatement).code;

View File

@ -248,15 +248,22 @@ defineType("NumberTypeAnnotation", {
});
defineType("ObjectTypeAnnotation", {
visitor: ["properties", "indexers", "callProperties"],
visitor: ["properties", "indexers", "callProperties", "internalSlots"],
aliases: ["Flow", "FlowType"],
builder: ["properties", "indexers", "callProperties", "exact"],
builder: [
"properties",
"indexers",
"callProperties",
"internalSlots",
"exact",
],
fields: {
properties: validate(
arrayOfType(["ObjectTypeProperty", "ObjectTypeSpreadProperty"]),
),
indexers: validateOptional(arrayOfType("ObjectTypeIndexer")),
callProperties: validateOptional(arrayOfType("ObjectTypeCallProperty")),
internalSlots: validateOptional(arrayOfType("ObjectTypeInternalSlot")),
exact: {
validate: assertValueType("boolean"),
default: false,
@ -264,6 +271,17 @@ defineType("ObjectTypeAnnotation", {
},
});
defineType("ObjectTypeInternalSlot", {
visitor: ["id", "value", "static", "method"],
aliases: ["Flow", "UserWhitespacable"],
fields: {
id: validateType("Identifier"),
value: validateType("FlowType"),
static: validate(assertValueType("boolean")),
method: validate(assertValueType("boolean")),
},
});
defineType("ObjectTypeCallProperty", {
visitor: ["value"],
aliases: ["Flow", "UserWhitespacable"],

View File

@ -621,7 +621,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
): N.FlowObjectTypeIndexer {
node.static = isStatic;
this.expect(tt.bracketL);
// Note: bracketL has already been consumed
if (this.lookahead().type === tt.colon) {
node.id = this.flowParseObjectPropertyKey();
node.key = this.flowParseTypeInitialiser();
@ -636,6 +636,27 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return this.finishNode(node, "ObjectTypeIndexer");
}
flowParseObjectTypeInternalSlot(
node: N.FlowObjectTypeInternalSlot,
isStatic: boolean,
): N.FlowObjectTypeInternalSlot {
node.static = isStatic;
// Note: both bracketL have already been consumed
node.id = this.flowParseObjectPropertyKey();
this.expect(tt.bracketR);
this.expect(tt.bracketR);
if (this.isRelational("<") || this.match(tt.parenL)) {
node.method = true;
node.value = this.flowParseObjectTypeMethodish(
this.startNodeAt(node.start, node.loc.start),
);
} else {
node.method = false;
node.value = this.flowParseTypeInitialiser();
}
return this.finishNode(node, "ObjectTypeInternalSlot");
}
flowParseObjectTypeMethodish(
node: N.FlowFunctionTypeAnnotation,
): N.FlowFunctionTypeAnnotation {
@ -689,6 +710,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
nodeStart.callProperties = [];
nodeStart.properties = [];
nodeStart.indexers = [];
nodeStart.internalSlots = [];
let endDelim;
let exact;
@ -720,10 +742,19 @@ export default (superClass: Class<Parser>): Class<Parser> =>
const variance = this.flowParseVariance();
if (this.match(tt.bracketL)) {
nodeStart.indexers.push(
this.flowParseObjectTypeIndexer(node, isStatic, variance),
);
if (this.eat(tt.bracketL)) {
if (this.eat(tt.bracketL)) {
if (variance) {
this.unexpected(variance.start);
}
nodeStart.internalSlots.push(
this.flowParseObjectTypeInternalSlot(node, isStatic),
);
} else {
nodeStart.indexers.push(
this.flowParseObjectTypeIndexer(node, isStatic, variance),
);
}
} else if (this.match(tt.parenL) || this.isRelational("<")) {
if (variance) {
this.unexpected(variance.start);

View File

@ -915,6 +915,7 @@ export type FlowInterfaceExtends = Node;
export type FlowTypeAlias = Node;
export type FlowOpaqueType = Node;
export type FlowObjectTypeIndexer = Node;
export type FlowObjectTypeInternalSlot = Node;
export type FlowFunctionTypeAnnotation = Node;
export type FlowObjectTypeProperty = Node;
export type FlowObjectTypeSpreadProperty = Node;

View File

@ -154,6 +154,7 @@
],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -154,6 +154,7 @@
],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -305,6 +305,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -254,6 +254,7 @@
],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -130,6 +130,7 @@
],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -654,6 +654,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -151,6 +151,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -234,6 +234,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -234,6 +234,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -147,6 +147,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -148,6 +148,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -114,6 +114,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -147,6 +147,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -114,6 +114,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -262,6 +262,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
},

View File

@ -94,6 +94,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
},

View File

@ -145,6 +145,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
},

View File

@ -145,6 +145,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
},

View File

@ -145,6 +145,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
},

View File

@ -143,6 +143,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -196,6 +196,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -189,6 +189,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -202,6 +202,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -145,6 +145,7 @@
"variance": null
}
],
"internalSlots": [],
"exact": false
}
}

View File

@ -130,6 +130,7 @@
],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -196,6 +196,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -241,6 +241,7 @@
"variance": null
}
],
"internalSlots": [],
"exact": false
}
}

View File

@ -133,6 +133,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
},
@ -292,6 +293,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -178,6 +178,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -237,6 +237,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -130,6 +130,7 @@
],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
},
@ -235,6 +236,7 @@
],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -265,6 +265,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -80,6 +80,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -249,6 +249,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -420,6 +420,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -80,6 +80,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -235,6 +235,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -114,6 +114,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -278,6 +278,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -151,6 +151,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -198,6 +198,7 @@
"variance": null
}
],
"internalSlots": [],
"exact": false
}
}

View File

@ -80,6 +80,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -133,6 +133,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -0,0 +1 @@
declare class C { static [[foo]]: T }

View File

@ -0,0 +1,158 @@
{
"type": "File",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"program": {
"type": "Program",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareClass",
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 37
}
},
"id": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "C"
},
"name": "C"
},
"typeParameters": null,
"extends": [],
"implements": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 16,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 37
}
},
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [
{
"type": "ObjectTypeInternalSlot",
"start": 18,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 35
}
},
"static": true,
"id": {
"type": "Identifier",
"start": 27,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 30
},
"identifierName": "foo"
},
"name": "foo"
},
"method": false,
"value": {
"type": "GenericTypeAnnotation",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 34
},
"end": {
"line": 1,
"column": 35
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 34
},
"end": {
"line": 1,
"column": 35
},
"identifierName": "T"
},
"name": "T"
}
}
}
],
"exact": false
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
declare class C { [[foo]]: T }

View File

@ -0,0 +1,158 @@
{
"type": "File",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 30
}
},
"program": {
"type": "Program",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 30
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareClass",
"start": 0,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 30
}
},
"id": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "C"
},
"name": "C"
},
"typeParameters": null,
"extends": [],
"implements": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 16,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 30
}
},
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [
{
"type": "ObjectTypeInternalSlot",
"start": 18,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 28
}
},
"static": false,
"id": {
"type": "Identifier",
"start": 20,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 23
},
"identifierName": "foo"
},
"name": "foo"
},
"method": false,
"value": {
"type": "GenericTypeAnnotation",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 28
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 28
},
"identifierName": "T"
},
"name": "T"
}
}
}
],
"exact": false
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
interface T { [[foo]](): X }

View File

@ -0,0 +1,176 @@
{
"type": "File",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 28
}
},
"program": {
"type": "Program",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 28
}
},
"sourceType": "module",
"body": [
{
"type": "InterfaceDeclaration",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 28
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "T"
},
"name": "T"
},
"typeParameters": null,
"extends": [],
"implements": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 12,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 28
}
},
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [
{
"type": "ObjectTypeInternalSlot",
"start": 14,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 26
}
},
"static": false,
"id": {
"type": "Identifier",
"start": 16,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 19
},
"identifierName": "foo"
},
"name": "foo"
},
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 14,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 26
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "GenericTypeAnnotation",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 26
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 26
},
"identifierName": "X"
},
"name": "X"
}
}
}
}
],
"exact": false
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
interface T { +[[foo]](): X }

View File

@ -0,0 +1,3 @@
{
"throws": "Unexpected token (1:14)"
}

View File

@ -0,0 +1 @@
interface T { [[foo]]: X }

View File

@ -0,0 +1,158 @@
{
"type": "File",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"program": {
"type": "Program",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"sourceType": "module",
"body": [
{
"type": "InterfaceDeclaration",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "T"
},
"name": "T"
},
"typeParameters": null,
"extends": [],
"implements": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 12,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 26
}
},
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [
{
"type": "ObjectTypeInternalSlot",
"start": 14,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 24
}
},
"static": false,
"id": {
"type": "Identifier",
"start": 16,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 19
},
"identifierName": "foo"
},
"name": "foo"
},
"method": false,
"value": {
"type": "GenericTypeAnnotation",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 24
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 24
},
"identifierName": "X"
},
"name": "X"
}
}
}
],
"exact": false
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
type T = { [[foo]](): X }

View File

@ -0,0 +1,173 @@
{
"type": "File",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 25
}
},
"program": {
"type": "Program",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 25
}
},
"sourceType": "module",
"body": [
{
"type": "TypeAlias",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 25
}
},
"id": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "T"
},
"name": "T"
},
"typeParameters": null,
"right": {
"type": "ObjectTypeAnnotation",
"start": 9,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 25
}
},
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [
{
"type": "ObjectTypeInternalSlot",
"start": 11,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 23
}
},
"static": false,
"id": {
"type": "Identifier",
"start": 13,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 16
},
"identifierName": "foo"
},
"name": "foo"
},
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 11,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 23
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "GenericTypeAnnotation",
"start": 22,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 23
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 22,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 23
},
"identifierName": "X"
},
"name": "X"
}
}
}
}
],
"exact": false
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
type T = { +[[foo]]: X }

View File

@ -0,0 +1,3 @@
{
"throws": "Unexpected token (1:11)"
}

View File

@ -0,0 +1 @@
type T = { [[foo]]: X }

View File

@ -0,0 +1,155 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"sourceType": "module",
"body": [
{
"type": "TypeAlias",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"id": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "T"
},
"name": "T"
},
"typeParameters": null,
"right": {
"type": "ObjectTypeAnnotation",
"start": 9,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 23
}
},
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [
{
"type": "ObjectTypeInternalSlot",
"start": 11,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 21
}
},
"static": false,
"id": {
"type": "Identifier",
"start": 13,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 16
},
"identifierName": "foo"
},
"name": "foo"
},
"method": false,
"value": {
"type": "GenericTypeAnnotation",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
},
"identifierName": "X"
},
"name": "X"
}
}
}
],
"exact": false
}
}
],
"directives": []
}
}

View File

@ -217,6 +217,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -217,6 +217,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -165,6 +165,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
},

View File

@ -165,6 +165,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
},

View File

@ -217,6 +217,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -217,6 +217,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -230,6 +230,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -150,6 +150,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
},
{
@ -227,6 +228,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
]
@ -618,6 +620,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
},
{
@ -695,6 +698,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
]
@ -704,6 +708,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
},
@ -879,6 +884,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
},
{
@ -956,6 +962,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
]
@ -965,6 +972,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -209,6 +209,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": true
}
}
@ -525,6 +526,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": true
}
}
@ -736,6 +738,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": true
}
}
@ -991,6 +994,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": true
},
"variance": null,
@ -1050,6 +1054,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}
@ -1519,6 +1524,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
},
"variance": null,
@ -1578,6 +1584,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": true
}
}

View File

@ -163,6 +163,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -163,6 +163,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -193,6 +193,7 @@
}
}
],
"internalSlots": [],
"exact": false
}
}

View File

@ -193,6 +193,7 @@
}
}
],
"internalSlots": [],
"exact": false
}
}

View File

@ -126,6 +126,7 @@
"variance": null
}
],
"internalSlots": [],
"exact": false
}
}

View File

@ -158,6 +158,7 @@
"variance": null
}
],
"internalSlots": [],
"exact": false
}
}

View File

@ -108,6 +108,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -127,6 +127,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
},
"variance": null,
@ -163,11 +164,13 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -274,6 +274,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -94,6 +94,7 @@
"callProperties": [],
"properties": [],
"indexers": [],
"internalSlots": [],
"exact": false
}
},

View File

@ -157,6 +157,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -157,6 +157,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -222,6 +222,7 @@
"variance": null
}
],
"internalSlots": [],
"exact": false
}
}

View File

@ -171,6 +171,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -209,6 +209,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -207,6 +207,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
},
"variance": null,
@ -214,6 +215,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -221,6 +221,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
},
@ -229,6 +230,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -209,6 +209,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -209,6 +209,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -233,6 +233,7 @@
"variance": null
}
],
"internalSlots": [],
"exact": false
}
}

View File

@ -319,6 +319,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -292,6 +292,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -212,6 +212,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

View File

@ -212,6 +212,7 @@
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}

Some files were not shown because too many files have changed in this diff Show More