Update Purish aliases (#11267)

* Update Purish aliases

- Adds `Purish` to `RegexLiteral`, since it can't cause any side-effects.
- Removes `Purish` from `ClassExpression` and `ClassDeclaration`, since they can be impure with static class fields.

* Update types
This commit is contained in:
Justin Ridgewell 2020-03-16 11:30:38 -04:00 committed by GitHub
parent 7b9bc7c28b
commit 10058901d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 5 deletions

View File

@ -568,7 +568,7 @@ defineType("BooleanLiteral", {
defineType("RegExpLiteral", { defineType("RegExpLiteral", {
builder: ["pattern", "flags"], builder: ["pattern", "flags"],
deprecatedAlias: "RegexLiteral", deprecatedAlias: "RegexLiteral",
aliases: ["Expression", "Literal"], aliases: ["Expression", "Pureish", "Literal"],
fields: { fields: {
pattern: { pattern: {
validate: assertValueType("string"), validate: assertValueType("string"),

View File

@ -124,7 +124,7 @@ defineType("ClassExpression", {
"implements", "implements",
"decorators", "decorators",
], ],
aliases: ["Scopable", "Class", "Expression", "Pureish"], aliases: ["Scopable", "Class", "Expression"],
fields: { fields: {
id: { id: {
validate: assertNodeType("Identifier"), validate: assertNodeType("Identifier"),
@ -175,7 +175,7 @@ defineType("ClassExpression", {
defineType("ClassDeclaration", { defineType("ClassDeclaration", {
inherits: "ClassExpression", inherits: "ClassExpression",
aliases: ["Scopable", "Class", "Statement", "Declaration", "Pureish"], aliases: ["Scopable", "Class", "Statement", "Declaration"],
fields: { fields: {
declare: { declare: {
validate: assertValueType("boolean"), validate: assertValueType("boolean"),

View File

@ -3847,9 +3847,8 @@ export function isPureish(node: ?Object, opts?: Object): boolean {
"NumericLiteral" === nodeType || "NumericLiteral" === nodeType ||
"NullLiteral" === nodeType || "NullLiteral" === nodeType ||
"BooleanLiteral" === nodeType || "BooleanLiteral" === nodeType ||
"RegExpLiteral" === nodeType ||
"ArrowFunctionExpression" === nodeType || "ArrowFunctionExpression" === nodeType ||
"ClassExpression" === nodeType ||
"ClassDeclaration" === nodeType ||
"BigIntLiteral" === nodeType || "BigIntLiteral" === nodeType ||
(nodeType === "Placeholder" && "StringLiteral" === node.expectedNode) (nodeType === "Placeholder" && "StringLiteral" === node.expectedNode)
) { ) {