Update babel-types (flow internal slots) (#7977)

This commit is contained in:
Nicolò Ribaudo 2018-05-18 15:47:31 +02:00 committed by Brian Ng
parent 6baa36cdc5
commit 229179b8aa
4 changed files with 45 additions and 1 deletions

View File

@ -1519,7 +1519,7 @@ Aliases: `UserWhitespacable`, `Property`, `ObjectMember`
### objectTypeAnnotation
```javascript
t.objectTypeAnnotation(properties, indexers, callProperties, exact)
t.objectTypeAnnotation(properties, indexers, callProperties, internalSlots, exact)
```
See also `t.isObjectTypeAnnotation(node, opts)` and `t.assertObjectTypeAnnotation(node, opts)`.
@ -1529,6 +1529,7 @@ Aliases: `Flow`, `FlowType`
- `properties`: `Array<ObjectTypeProperty | ObjectTypeSpreadProperty>` (required)
- `indexers`: `Array<ObjectTypeIndexer>` (default: `null`)
- `callProperties`: `Array<ObjectTypeCallProperty>` (default: `null`)
- `internalSlots`: `Array<ObjectTypeInternalSlot>` (default: `null`)
- `exact`: `boolean` (default: `false`)
---
@ -1564,6 +1565,23 @@ Aliases: `Flow`, `UserWhitespacable`
---
### objectTypeInternalSlot
```javascript
t.objectTypeInternalSlot(id, value, optional, static, method)
```
See also `t.isObjectTypeInternalSlot(node, opts)` and `t.assertObjectTypeInternalSlot(node, opts)`.
Aliases: `Flow`, `UserWhitespacable`
- `id`: `Identifier` (required)
- `value`: `FlowType` (required)
- `optional`: `boolean` (required)
- `static`: `boolean` (required)
- `method`: `boolean` (required)
---
### objectTypeProperty
```javascript
t.objectTypeProperty(key, value, variance)

View File

@ -456,6 +456,12 @@ export function assertObjectTypeAnnotation(
): void {
assert("ObjectTypeAnnotation", node, opts);
}
export function assertObjectTypeInternalSlot(
node: Object,
opts?: Object = {},
): void {
assert("ObjectTypeInternalSlot", node, opts);
}
export function assertObjectTypeCallProperty(
node: Object,
opts?: Object = {},

View File

@ -421,6 +421,10 @@ export function ObjectTypeAnnotation(...args: Array<any>): Object {
return builder("ObjectTypeAnnotation", ...args);
}
export { ObjectTypeAnnotation as objectTypeAnnotation };
export function ObjectTypeInternalSlot(...args: Array<any>): Object {
return builder("ObjectTypeInternalSlot", ...args);
}
export { ObjectTypeInternalSlot as objectTypeInternalSlot };
export function ObjectTypeCallProperty(...args: Array<any>): Object {
return builder("ObjectTypeCallProperty", ...args);
}

View File

@ -1491,6 +1491,20 @@ export function isObjectTypeAnnotation(node: Object, opts?: Object): boolean {
return false;
}
export function isObjectTypeInternalSlot(node: Object, opts?: Object): boolean {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "ObjectTypeInternalSlot") {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isObjectTypeCallProperty(node: Object, opts?: Object): boolean {
if (!node) return false;
@ -3610,6 +3624,7 @@ export function isUserWhitespacable(node: Object, opts?: Object): boolean {
nodeType === "UserWhitespacable" ||
"ObjectMethod" === nodeType ||
"ObjectProperty" === nodeType ||
"ObjectTypeInternalSlot" === nodeType ||
"ObjectTypeCallProperty" === nodeType ||
"ObjectTypeIndexer" === nodeType ||
"ObjectTypeProperty" === nodeType ||
@ -3832,6 +3847,7 @@ export function isFlow(node: Object, opts?: Object): boolean {
"NumberLiteralTypeAnnotation" === nodeType ||
"NumberTypeAnnotation" === nodeType ||
"ObjectTypeAnnotation" === nodeType ||
"ObjectTypeInternalSlot" === nodeType ||
"ObjectTypeCallProperty" === nodeType ||
"ObjectTypeIndexer" === nodeType ||
"ObjectTypeProperty" === nodeType ||