refactor: move @babel/helper-validator-identifier to ts (#12409)

* refactor: rename helper-validator-identifier to ts

* fix flow errors
This commit is contained in:
Huáng Jùnliàng
2020-12-11 17:41:56 -05:00
committed by GitHub
parent a46cd643ab
commit fc82169b4e
6 changed files with 21 additions and 10 deletions

View File

@@ -522,7 +522,7 @@ defineType("Identifier", {
// Ideally we should call isStrictReservedWord if this node is a descendant
// of a block in strict mode. Also, we should pass the inModule option so
// we can disable "await" in module.
(isKeyword(node.name) || isReservedWord(node.name)) &&
(isKeyword(node.name) || isReservedWord(node.name, false)) &&
// Even if "this" is a keyword, we are using the Identifier
// node to represent it.
node.name !== "this"

View File

@@ -15,10 +15,8 @@ export default function isValidIdentifier(
if (typeof name !== "string") return false;
if (reserved) {
if (isKeyword(name) || isStrictReservedWord(name)) {
return false;
} else if (name === "await") {
// invalid in module, valid in script; better be safe (see #4952)
// "await" is invalid in module, valid in script; better be safe (see #4952)
if (isKeyword(name) || isStrictReservedWord(name, true)) {
return false;
}
}