rename assertsModifier to asserts (#10613)

see https://github.com/babel/babel/pull/10543#issuecomment-547571501
This commit is contained in:
Georgii Dolzhykov 2019-10-29 22:25:42 +02:00 committed by Huáng Jùnliàng
parent 3a5e8a8dd4
commit 63f9a3c946
7 changed files with 19 additions and 19 deletions

View File

@ -197,7 +197,7 @@ export function TSTypeReference(node) {
} }
export function TSTypePredicate(node) { export function TSTypePredicate(node) {
if (node.assertsModifier) { if (node.asserts) {
this.word("asserts"); this.word("asserts");
this.space(); this.space();
} }

View File

@ -904,8 +904,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
const t: N.TsTypeAnnotation = this.startNode(); const t: N.TsTypeAnnotation = this.startNode();
this.expect(returnToken); this.expect(returnToken);
const assertsModifier = this.tsTryParse( const asserts = this.tsTryParse(
this.tsParseTypePredicateAssertsModifier.bind(this), this.tsParseTypePredicateAsserts.bind(this),
); );
const typePredicateVariable = const typePredicateVariable =
@ -913,7 +913,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this)); this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));
if (!typePredicateVariable) { if (!typePredicateVariable) {
if (!assertsModifier) { if (!asserts) {
// : type // : type
return this.tsParseTypeAnnotation(/* eatColon */ false, t); return this.tsParseTypeAnnotation(/* eatColon */ false, t);
} }
@ -921,7 +921,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// : asserts foo // : asserts foo
const node = this.startNodeAtNode(t); const node = this.startNodeAtNode(t);
node.parameterName = this.parseIdentifier(); node.parameterName = this.parseIdentifier();
node.assertsModifier = assertsModifier; node.asserts = asserts;
t.typeAnnotation = this.finishNode(node, "TSTypePredicate"); t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
return this.finishNode(t, "TSTypeAnnotation"); return this.finishNode(t, "TSTypeAnnotation");
} }
@ -931,7 +931,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
const node = this.startNodeAtNode(t); const node = this.startNodeAtNode(t);
node.parameterName = typePredicateVariable; node.parameterName = typePredicateVariable;
node.typeAnnotation = type; node.typeAnnotation = type;
node.assertsModifier = assertsModifier; node.asserts = asserts;
t.typeAnnotation = this.finishNode(node, "TSTypePredicate"); t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
return this.finishNode(t, "TSTypeAnnotation"); return this.finishNode(t, "TSTypeAnnotation");
}); });
@ -959,7 +959,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
} }
} }
tsParseTypePredicateAssertsModifier(): boolean { tsParseTypePredicateAsserts(): boolean {
if (!this.tsIsIdentifier()) { if (!this.tsIsIdentifier()) {
return false; return false;
} }

View File

@ -164,7 +164,7 @@
} }
} }
}, },
"assertsModifier": true "asserts": true
} }
}, },
"id": null, "id": null,
@ -346,7 +346,7 @@
}, },
"name": "value" "name": "value"
}, },
"assertsModifier": true "asserts": true
} }
}, },
"id": null, "id": null,
@ -607,4 +607,4 @@
], ],
"directives": [] "directives": []
} }
} }

View File

@ -156,7 +156,7 @@
}, },
"name": "value" "name": "value"
}, },
"assertsModifier": true "asserts": true
} }
}, },
"declare": true "declare": true
@ -164,4 +164,4 @@
], ],
"directives": [] "directives": []
} }
} }

View File

@ -186,7 +186,7 @@
} }
} }
}, },
"assertsModifier": true "asserts": true
} }
}, },
"declare": true "declare": true
@ -194,4 +194,4 @@
], ],
"directives": [] "directives": []
} }
} }

View File

@ -186,7 +186,7 @@
} }
} }
}, },
"assertsModifier": true "asserts": true
} }
}, },
"body": { "body": {
@ -334,7 +334,7 @@
}, },
"name": "value" "name": "value"
}, },
"assertsModifier": true "asserts": true
} }
}, },
"body": { "body": {
@ -505,4 +505,4 @@
], ],
"directives": [] "directives": []
} }
} }

View File

@ -175,11 +175,11 @@ defineType("TSTypeReference", {
defineType("TSTypePredicate", { defineType("TSTypePredicate", {
aliases: ["TSType"], aliases: ["TSType"],
visitor: ["parameterName", "typeAnnotation", "assertsModifier"], visitor: ["parameterName", "typeAnnotation", "asserts"],
fields: { fields: {
parameterName: validateType(["Identifier", "TSThisType"]), parameterName: validateType(["Identifier", "TSThisType"]),
typeAnnotation: validateOptionalType("TSTypeAnnotation"), typeAnnotation: validateOptionalType("TSTypeAnnotation"),
assertsModifier: validate(bool), asserts: validate(bool),
}, },
}); });