update generator/babel-types printing, babylon (#6306)
* update generator printing, babylon [skip ci] * Update babel-types for TS node types
This commit is contained in:
parent
4c517a8912
commit
314bd31b85
@ -19,7 +19,7 @@
|
||||
"babel-preset-flow": "7.0.0-alpha.18",
|
||||
"babel-preset-stage-0": "7.0.0-alpha.18",
|
||||
"babel-register": "7.0.0-alpha.18",
|
||||
"babylon": "7.0.0-beta.22",
|
||||
"babylon": "7.0.0-beta.25",
|
||||
"browserify": "^13.1.1",
|
||||
"bundle-collapser": "^1.2.1",
|
||||
"chai": "^4.1.0",
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
"babel-template": "7.0.0-beta.1",
|
||||
"babel-traverse": "7.0.0-beta.1",
|
||||
"babel-types": "7.0.0-beta.1",
|
||||
"babylon": "7.0.0-beta.22",
|
||||
"babylon": "7.0.0-beta.25",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"debug": "^3.0.1",
|
||||
"json5": "^0.5.0",
|
||||
|
||||
@ -20,6 +20,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-helper-fixtures": "7.0.0-beta.1",
|
||||
"babylon": "^7.0.0-beta.22"
|
||||
"babylon": "^7.0.0-beta.25"
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,6 +311,38 @@ export function TypeAlias(node: Object) {
|
||||
this.semicolon();
|
||||
}
|
||||
|
||||
export function TypeAnnotation(node) {
|
||||
this.token(":");
|
||||
this.space();
|
||||
if (node.optional) this.token("?");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
export function TypeParameterInstantiation(node): void {
|
||||
this.token("<");
|
||||
this.printList(node.params, node, {});
|
||||
this.token(">");
|
||||
}
|
||||
|
||||
export { TypeParameterInstantiation as TypeParameterDeclaration };
|
||||
|
||||
export function TypeParameter(node) {
|
||||
this._variance(node);
|
||||
|
||||
this.word(node.name);
|
||||
|
||||
if (node.bound) {
|
||||
this.print(node.bound, node);
|
||||
}
|
||||
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(node.default, node);
|
||||
}
|
||||
}
|
||||
|
||||
export function OpaqueType(node: Object) {
|
||||
this.word("opaque");
|
||||
this.space();
|
||||
|
||||
@ -8,5 +8,4 @@ export * from "./types";
|
||||
export * from "./flow";
|
||||
export * from "./base";
|
||||
export * from "./jsx";
|
||||
export * from "./tsFlowCommon";
|
||||
export * from "./typescript";
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
export function TypeAnnotation(node) {
|
||||
this.token(":");
|
||||
this.space();
|
||||
if (node.optional) this.token("?");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
export function TypeParameterInstantiation(node): void {
|
||||
this.token("<");
|
||||
this.printList(node.params, node, {});
|
||||
this.token(">");
|
||||
}
|
||||
|
||||
export { TypeParameterInstantiation as TypeParameterDeclaration };
|
||||
|
||||
export function TypeParameter(node) {
|
||||
this._variance(node);
|
||||
|
||||
this.word(node.name);
|
||||
|
||||
if (node.bound) {
|
||||
this.print(node.bound, node);
|
||||
}
|
||||
|
||||
if (node.constraint) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.constraint, node);
|
||||
}
|
||||
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(node.default, node);
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,36 @@
|
||||
export function TSTypeAnnotation(node) {
|
||||
this.token(":");
|
||||
this.space();
|
||||
if (node.optional) this.token("?");
|
||||
this.print(node.typeAnnotation, node);
|
||||
}
|
||||
|
||||
export function TSTypeParameterInstantiation(node): void {
|
||||
this.token("<");
|
||||
this.printList(node.params, node, {});
|
||||
this.token(">");
|
||||
}
|
||||
|
||||
export { TSTypeParameterInstantiation as TSTypeParameterDeclaration };
|
||||
|
||||
export function TSTypeParameter(node) {
|
||||
this.word(node.name);
|
||||
|
||||
if (node.constraint) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.constraint, node);
|
||||
}
|
||||
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.token("=");
|
||||
this.space();
|
||||
this.print(node.default, node);
|
||||
}
|
||||
}
|
||||
|
||||
export function TSParameterProperty(node) {
|
||||
if (node.accessibility) {
|
||||
this.word(node.accessibility);
|
||||
|
||||
@ -12,7 +12,7 @@ export default function({ types: t }) {
|
||||
};
|
||||
|
||||
const referenceVisitor = {
|
||||
TypeAnnotation(path) {
|
||||
"TSTypeAnnotation|TypeAnnotation"(path) {
|
||||
path.skip();
|
||||
},
|
||||
ReferencedIdentifier(path) {
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
"dependencies": {
|
||||
"babel-traverse": "7.0.0-beta.1",
|
||||
"babel-types": "7.0.0-beta.1",
|
||||
"babylon": "7.0.0-beta.22",
|
||||
"babylon": "7.0.0-beta.25",
|
||||
"lodash": "^4.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
"babel-helper-function-name": "7.0.0-beta.1",
|
||||
"babel-messages": "7.0.0-beta.1",
|
||||
"babel-types": "7.0.0-beta.1",
|
||||
"babylon": "7.0.0-beta.22",
|
||||
"babylon": "7.0.0-beta.25",
|
||||
"debug": "^3.0.1",
|
||||
"globals": "^10.0.0",
|
||||
"invariant": "^2.2.0",
|
||||
|
||||
@ -356,7 +356,7 @@ Aliases: `Property`
|
||||
|
||||
- `key` (required)
|
||||
- `value`: `Expression` (default: `null`)
|
||||
- `typeAnnotation`: `TypeAnnotation | Noop` (default: `null`)
|
||||
- `typeAnnotation`: `TypeAnnotation | TSTypeAnnotation | Noop` (default: `null`)
|
||||
- `decorators`: `Array<Decorator>` (default: `null`)
|
||||
- `computed`: `boolean` (default: `false`)
|
||||
- `abstract`: `boolean` (default: `null`)
|
||||
@ -1551,7 +1551,7 @@ Aliases: `Expression`, `ExpressionWrapper`
|
||||
|
||||
### program
|
||||
```javascript
|
||||
t.program(body, directives)
|
||||
t.program(body, directives, sourceType)
|
||||
```
|
||||
|
||||
See also `t.isProgram(node, opts)` and `t.assertProgram(node, opts)`.
|
||||
@ -1560,8 +1560,8 @@ Aliases: `Scopable`, `BlockParent`, `Block`
|
||||
|
||||
- `body`: `Array<Statement>` (required)
|
||||
- `directives`: `Array<Directive>` (default: `[]`)
|
||||
- `sourceType`: `'script' | 'module'` (default: `'script'`)
|
||||
- `sourceFile`: `string` (default: `null`)
|
||||
- `sourceType`: `'script' | 'module'` (default: `null`)
|
||||
|
||||
---
|
||||
|
||||
@ -2301,6 +2301,17 @@ Aliases: `Statement`, `Declaration`
|
||||
|
||||
---
|
||||
|
||||
### tSTypeAnnotation
|
||||
```javascript
|
||||
t.tSTypeAnnotation(typeAnnotation)
|
||||
```
|
||||
|
||||
See also `t.isTSTypeAnnotation(node, opts)` and `t.assertTSTypeAnnotation(node, opts)`.
|
||||
|
||||
- `typeAnnotation`: `TSType` (required)
|
||||
|
||||
---
|
||||
|
||||
### tSTypeAssertion
|
||||
```javascript
|
||||
t.tSTypeAssertion(typeAnnotation, expression)
|
||||
@ -2342,6 +2353,41 @@ Aliases: `TSType`
|
||||
|
||||
---
|
||||
|
||||
### tSTypeParameter
|
||||
```javascript
|
||||
t.tSTypeParameter(constraint, default)
|
||||
```
|
||||
|
||||
See also `t.isTSTypeParameter(node, opts)` and `t.assertTSTypeParameter(node, opts)`.
|
||||
|
||||
- `constraint`: `TSType` (default: `null`)
|
||||
- `default`: `TSType` (default: `null`)
|
||||
- `name`: `string` (default: `null`)
|
||||
|
||||
---
|
||||
|
||||
### tSTypeParameterDeclaration
|
||||
```javascript
|
||||
t.tSTypeParameterDeclaration(params)
|
||||
```
|
||||
|
||||
See also `t.isTSTypeParameterDeclaration(node, opts)` and `t.assertTSTypeParameterDeclaration(node, opts)`.
|
||||
|
||||
- `params`: `Array<TSTypeParameter>` (required)
|
||||
|
||||
---
|
||||
|
||||
### tSTypeParameterInstantiation
|
||||
```javascript
|
||||
t.tSTypeParameterInstantiation(params)
|
||||
```
|
||||
|
||||
See also `t.isTSTypeParameterInstantiation(node, opts)` and `t.assertTSTypeParameterInstantiation(node, opts)`.
|
||||
|
||||
- `params`: `Array<TSType>` (required)
|
||||
|
||||
---
|
||||
|
||||
### tSTypePredicate
|
||||
```javascript
|
||||
t.tSTypePredicate(parameterName, typeAnnotation)
|
||||
@ -2549,7 +2595,7 @@ See also `t.isTypeAnnotation(node, opts)` and `t.assertTypeAnnotation(node, opts
|
||||
|
||||
Aliases: `Flow`
|
||||
|
||||
- `typeAnnotation`: `TSType | Flow` (required)
|
||||
- `typeAnnotation`: `Flow` (required)
|
||||
|
||||
---
|
||||
|
||||
@ -2569,7 +2615,7 @@ Aliases: `Flow`, `ExpressionWrapper`, `Expression`
|
||||
|
||||
### typeParameter
|
||||
```javascript
|
||||
t.typeParameter(bound, constraint, default)
|
||||
t.typeParameter(bound, default)
|
||||
```
|
||||
|
||||
See also `t.isTypeParameter(node, opts)` and `t.assertTypeParameter(node, opts)`.
|
||||
@ -2577,8 +2623,7 @@ See also `t.isTypeParameter(node, opts)` and `t.assertTypeParameter(node, opts)`
|
||||
Aliases: `Flow`
|
||||
|
||||
- `bound`: `TypeAnnotation` (default: `null`)
|
||||
- `constraint`: `TSType` (default: `null`)
|
||||
- `default`: `TSType | Flow` (default: `null`)
|
||||
- `default`: `Flow` (default: `null`)
|
||||
- `name`: `string` (default: `null`)
|
||||
|
||||
---
|
||||
@ -2605,7 +2650,7 @@ See also `t.isTypeParameterInstantiation(node, opts)` and `t.assertTypeParameter
|
||||
|
||||
Aliases: `Flow`
|
||||
|
||||
- `params`: `Array<TSType | Flow>` (required)
|
||||
- `params`: `Array<Flow>` (required)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@ -14,6 +14,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-generator": "7.0.0-beta.1",
|
||||
"babylon": "^7.0.0-beta.22"
|
||||
"babylon": "^7.0.0-beta.25"
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ export const functionCommon = {
|
||||
default: false,
|
||||
},
|
||||
returnType: {
|
||||
validate: assertNodeType("TypeAnnotation", "Noop"),
|
||||
validate: assertNodeType("TypeAnnotation", "TSTypeAnnotation", "Noop"),
|
||||
optional: true,
|
||||
},
|
||||
typeParameters: {
|
||||
@ -352,7 +352,7 @@ defineType("FunctionExpression", {
|
||||
export const patternLikeCommon = {
|
||||
typeAnnotation: {
|
||||
// TODO: babel-plugin-transform-flow-comments puts a Noop here, is there a better way?
|
||||
validate: assertNodeType("TypeAnnotation", "Noop"),
|
||||
validate: assertNodeType("TypeAnnotation", "TSTypeAnnotation", "Noop"),
|
||||
optional: true,
|
||||
},
|
||||
decorators: {
|
||||
|
||||
@ -1,4 +1,10 @@
|
||||
import defineType, { assertNodeType } from "./index";
|
||||
import defineType, {
|
||||
assertEach,
|
||||
assertNodeType,
|
||||
assertValueType,
|
||||
chain,
|
||||
} from "./index";
|
||||
import { classMethodOrPropertyCommon } from "./es2015";
|
||||
|
||||
defineType("AwaitExpression", {
|
||||
builder: ["argument"],
|
||||
@ -19,6 +25,34 @@ defineType("BindExpression", {
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ClassProperty", {
|
||||
visitor: ["key", "value", "typeAnnotation", "decorators"],
|
||||
builder: ["key", "value", "typeAnnotation", "decorators", "computed"],
|
||||
aliases: ["Property"],
|
||||
fields: {
|
||||
...classMethodOrPropertyCommon,
|
||||
value: {
|
||||
validate: assertNodeType("Expression"),
|
||||
optional: true,
|
||||
},
|
||||
typeAnnotation: {
|
||||
validate: assertNodeType("TypeAnnotation", "TSTypeAnnotation", "Noop"),
|
||||
optional: true,
|
||||
},
|
||||
decorators: {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("Decorator")),
|
||||
),
|
||||
optional: true,
|
||||
},
|
||||
readonly: {
|
||||
validate: assertValueType("boolean"),
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("Import", {
|
||||
aliases: ["Expression"],
|
||||
});
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
import defineType from "./index";
|
||||
import defineType, {
|
||||
assertEach,
|
||||
assertNodeType,
|
||||
assertValueType,
|
||||
chain,
|
||||
} from "./index";
|
||||
|
||||
defineType("AnyTypeAnnotation", {
|
||||
aliases: ["Flow", "FlowBaseAnnotation"],
|
||||
@ -217,6 +222,62 @@ defineType("NumberTypeAnnotation", {
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeAnnotation", {
|
||||
visitor: ["properties", "indexers", "callProperties"],
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeCallProperty", {
|
||||
visitor: ["value"],
|
||||
aliases: ["Flow", "UserWhitespacable"],
|
||||
fields: {
|
||||
// todo
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeIndexer", {
|
||||
visitor: ["id", "key", "value"],
|
||||
aliases: ["Flow", "UserWhitespacable"],
|
||||
fields: {
|
||||
// todo
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeProperty", {
|
||||
visitor: ["key", "value"],
|
||||
aliases: ["Flow", "UserWhitespacable"],
|
||||
fields: {
|
||||
// todo
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeSpreadProperty", {
|
||||
visitor: ["argument"],
|
||||
aliases: ["Flow", "UserWhitespacable"],
|
||||
fields: {
|
||||
// todo
|
||||
},
|
||||
});
|
||||
|
||||
defineType("OpaqueType", {
|
||||
visitor: ["id", "typeParameters", "supertype", "impltype"],
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||||
fields: {
|
||||
// todo
|
||||
},
|
||||
});
|
||||
|
||||
defineType("QualifiedTypeIdentifier", {
|
||||
visitor: ["id", "qualification"],
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
},
|
||||
});
|
||||
|
||||
defineType("StringLiteralTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
@ -260,11 +321,13 @@ defineType("TypeAlias", {
|
||||
},
|
||||
});
|
||||
|
||||
defineType("OpaqueType", {
|
||||
visitor: ["id", "typeParameters", "supertype", "impltype"],
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||||
defineType("TypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
visitor: ["typeAnnotation"],
|
||||
fields: {
|
||||
// todo
|
||||
typeAnnotation: {
|
||||
validate: assertNodeType("Flow"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -276,51 +339,47 @@ defineType("TypeCastExpression", {
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeAnnotation", {
|
||||
visitor: ["properties", "indexers", "callProperties"],
|
||||
defineType("TypeParameter", {
|
||||
aliases: ["Flow"],
|
||||
visitor: ["bound", "default"],
|
||||
fields: {
|
||||
// todo
|
||||
name: {
|
||||
validate: assertValueType("string"),
|
||||
},
|
||||
bound: {
|
||||
validate: assertNodeType("TypeAnnotation"),
|
||||
optional: true,
|
||||
},
|
||||
default: {
|
||||
validate: assertNodeType("Flow"),
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeCallProperty", {
|
||||
visitor: ["value"],
|
||||
aliases: ["Flow", "UserWhitespacable"],
|
||||
fields: {
|
||||
// todo
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeIndexer", {
|
||||
visitor: ["id", "key", "value"],
|
||||
aliases: ["Flow", "UserWhitespacable"],
|
||||
fields: {
|
||||
// todo
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeProperty", {
|
||||
visitor: ["key", "value"],
|
||||
aliases: ["Flow", "UserWhitespacable"],
|
||||
fields: {
|
||||
// todo
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeSpreadProperty", {
|
||||
visitor: ["argument"],
|
||||
aliases: ["Flow", "UserWhitespacable"],
|
||||
fields: {
|
||||
// todo
|
||||
},
|
||||
});
|
||||
|
||||
defineType("QualifiedTypeIdentifier", {
|
||||
visitor: ["id", "qualification"],
|
||||
defineType("TypeParameterDeclaration", {
|
||||
aliases: ["Flow"],
|
||||
visitor: ["params"],
|
||||
fields: {
|
||||
// todo
|
||||
params: {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("TypeParameter")),
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TypeParameterInstantiation", {
|
||||
aliases: ["Flow"],
|
||||
visitor: ["params"],
|
||||
fields: {
|
||||
params: {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("Flow")),
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -5,5 +5,4 @@ import "./flow";
|
||||
import "./jsx";
|
||||
import "./misc";
|
||||
import "./experimental";
|
||||
import "./tsFlowCommon";
|
||||
import "./typescript";
|
||||
|
||||
@ -1,96 +0,0 @@
|
||||
// @flow
|
||||
|
||||
import defineType, {
|
||||
assertEach,
|
||||
assertNodeType,
|
||||
assertValueType,
|
||||
chain,
|
||||
} from "./index";
|
||||
import { classMethodOrPropertyCommon } from "./es2015";
|
||||
|
||||
defineType("TypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
visitor: ["typeAnnotation"],
|
||||
fields: {
|
||||
typeAnnotation: {
|
||||
validate: assertNodeType("TSType", "Flow"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TypeParameterInstantiation", {
|
||||
visitor: ["params"],
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
params: {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("TSType", "Flow")),
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TypeParameterDeclaration", {
|
||||
aliases: ["Flow"],
|
||||
visitor: ["params"],
|
||||
fields: {
|
||||
params: {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("TypeParameter")),
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TypeParameter", {
|
||||
aliases: ["Flow"],
|
||||
visitor: ["bound", "constraint", "default"],
|
||||
fields: {
|
||||
name: {
|
||||
validate: assertValueType("string"),
|
||||
},
|
||||
bound: {
|
||||
validate: assertNodeType("TypeAnnotation"),
|
||||
optional: true,
|
||||
},
|
||||
constraint: {
|
||||
validate: assertNodeType("TSType"),
|
||||
optional: true,
|
||||
},
|
||||
default: {
|
||||
validate: assertNodeType("TSType", "Flow"),
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ClassProperty", {
|
||||
visitor: ["key", "value", "typeAnnotation", "decorators"],
|
||||
builder: ["key", "value", "typeAnnotation", "decorators", "computed"],
|
||||
aliases: ["Property"],
|
||||
fields: {
|
||||
...classMethodOrPropertyCommon,
|
||||
value: {
|
||||
validate: assertNodeType("Expression"),
|
||||
optional: true,
|
||||
},
|
||||
typeAnnotation: {
|
||||
validate: assertNodeType("TypeAnnotation", "Noop"),
|
||||
optional: true,
|
||||
},
|
||||
decorators: {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("Decorator")),
|
||||
),
|
||||
optional: true,
|
||||
},
|
||||
readonly: {
|
||||
validate: assertValueType("boolean"),
|
||||
optional: true,
|
||||
},
|
||||
// todo: Has optional "variance" property for flow plugin
|
||||
},
|
||||
});
|
||||
@ -87,7 +87,7 @@ defineType("TSQualifiedName", {
|
||||
const signatureDeclarationCommon = {
|
||||
typeParameters: validateOptionalType("TypeParameterDeclaration"),
|
||||
parameters: validateArrayOfType(["Identifier", "RestElement"]),
|
||||
typeAnnotation: validateOptionalType("TypeAnnotation"),
|
||||
typeAnnotation: validateOptionalType("TSTypeAnnotation"),
|
||||
};
|
||||
|
||||
const callConstructSignatureDeclaration = {
|
||||
@ -114,7 +114,7 @@ defineType("TSPropertySignature", {
|
||||
fields: {
|
||||
...namedTypeElementCommon,
|
||||
readonly: validateOptional(bool),
|
||||
typeAnnotation: validateOptionalType("TypeAnnotation"),
|
||||
typeAnnotation: validateOptionalType("TSTypeAnnotation"),
|
||||
initializer: validateOptionalType("Expression"),
|
||||
},
|
||||
});
|
||||
@ -134,7 +134,7 @@ defineType("TSIndexSignature", {
|
||||
fields: {
|
||||
readonly: validateOptional(bool),
|
||||
parameters: validateArrayOfType("Identifier"), // Length must be 1
|
||||
typeAnnotation: validateOptionalType("TypeAnnotation"),
|
||||
typeAnnotation: validateOptionalType("TSTypeAnnotation"),
|
||||
},
|
||||
});
|
||||
|
||||
@ -188,7 +188,7 @@ defineType("TSTypePredicate", {
|
||||
visitor: ["parameterName", "typeAnnotation"],
|
||||
fields: {
|
||||
parameterName: validateType(["Identifier", "TSThisType"]),
|
||||
typeAnnotation: validateType("TypeAnnotation"),
|
||||
typeAnnotation: validateType("TSTypeAnnotation"),
|
||||
},
|
||||
});
|
||||
|
||||
@ -424,3 +424,53 @@ defineType("TSNamespaceExportDeclaration", {
|
||||
id: validateType("Identifier"),
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TSTypeAnnotation", {
|
||||
visitor: ["typeAnnotation"],
|
||||
fields: {
|
||||
typeAnnotation: {
|
||||
validate: assertNodeType("TSType"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TSTypeParameterInstantiation", {
|
||||
visitor: ["params"],
|
||||
fields: {
|
||||
params: {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("TSType")),
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TSTypeParameterDeclaration", {
|
||||
visitor: ["params"],
|
||||
fields: {
|
||||
params: {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("TSTypeParameter")),
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TSTypeParameter", {
|
||||
visitor: ["constraint", "default"],
|
||||
fields: {
|
||||
name: {
|
||||
validate: assertValueType("string"),
|
||||
},
|
||||
constraint: {
|
||||
validate: assertNodeType("TSType"),
|
||||
optional: true,
|
||||
},
|
||||
default: {
|
||||
validate: assertNodeType("TSType"),
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -1017,9 +1017,9 @@ babylon@7.0.0-beta.18:
|
||||
version "7.0.0-beta.18"
|
||||
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.18.tgz#5c23ee3fdb66358aabf3789779319c5b78a233c7"
|
||||
|
||||
babylon@7.0.0-beta.22:
|
||||
version "7.0.0-beta.22"
|
||||
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.22.tgz#74f0ad82ed7c7c3cfeab74cf684f815104161b65"
|
||||
babylon@7.0.0-beta.25:
|
||||
version "7.0.0-beta.25"
|
||||
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.25.tgz#5fff5062b7082203b1bc5cab488e154cfee0202a"
|
||||
|
||||
babylon@^6.17.4, babylon@^6.18.0:
|
||||
version "6.18.0"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user