Skip to content

Commit

Permalink
Update Purish aliases (#11267)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jridgewell committed Mar 16, 2020
1 parent 7b9bc7c commit 1005890
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/babel-types/src/definitions/core.js
Expand Up @@ -568,7 +568,7 @@ defineType("BooleanLiteral", {
defineType("RegExpLiteral", {
builder: ["pattern", "flags"],
deprecatedAlias: "RegexLiteral",
aliases: ["Expression", "Literal"],
aliases: ["Expression", "Pureish", "Literal"],
fields: {
pattern: {
validate: assertValueType("string"),
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-types/src/definitions/es2015.js
Expand Up @@ -124,7 +124,7 @@ defineType("ClassExpression", {
"implements",
"decorators",
],
aliases: ["Scopable", "Class", "Expression", "Pureish"],
aliases: ["Scopable", "Class", "Expression"],
fields: {
id: {
validate: assertNodeType("Identifier"),
Expand Down Expand Up @@ -175,7 +175,7 @@ defineType("ClassExpression", {

defineType("ClassDeclaration", {
inherits: "ClassExpression",
aliases: ["Scopable", "Class", "Statement", "Declaration", "Pureish"],
aliases: ["Scopable", "Class", "Statement", "Declaration"],
fields: {
declare: {
validate: assertValueType("boolean"),
Expand Down
3 changes: 1 addition & 2 deletions packages/babel-types/src/validators/generated/index.js
Expand Up @@ -3847,9 +3847,8 @@ export function isPureish(node: ?Object, opts?: Object): boolean {
"NumericLiteral" === nodeType ||
"NullLiteral" === nodeType ||
"BooleanLiteral" === nodeType ||
"RegExpLiteral" === nodeType ||
"ArrowFunctionExpression" === nodeType ||
"ClassExpression" === nodeType ||
"ClassDeclaration" === nodeType ||
"BigIntLiteral" === nodeType ||
(nodeType === "Placeholder" && "StringLiteral" === node.expectedNode)
) {
Expand Down

0 comments on commit 1005890

Please sign in to comment.