diff --git a/packages/babel-types/src/definitions/experimental.js b/packages/babel-types/src/definitions/experimental.js index ed088af74bd6..040f6ff53f53 100644 --- a/packages/babel-types/src/definitions/experimental.js +++ b/packages/babel-types/src/definitions/experimental.js @@ -33,7 +33,7 @@ defineType("BindExpression", { defineType("ClassProperty", { visitor: ["key", "value", "typeAnnotation", "decorators"], - builder: ["key", "value", "typeAnnotation", "decorators", "computed"], + builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"], aliases: ["Property"], fields: { ...classMethodOrPropertyCommon, diff --git a/packages/babel-types/test/builders/experimental/__snapshots__/classProperty.js.snap b/packages/babel-types/test/builders/experimental/__snapshots__/classProperty.js.snap new file mode 100644 index 000000000000..9f9c7c29ca8e --- /dev/null +++ b/packages/babel-types/test/builders/experimental/__snapshots__/classProperty.js.snap @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`builders experimental classProperty should validate 1`] = ` +Object { + "computed": false, + "decorators": null, + "key": Object { + "type": "StringLiteral", + "value": "test", + }, + "static": null, + "type": "ClassProperty", + "typeAnnotation": null, + "value": Object { + "type": "NumericLiteral", + "value": 1, + }, +} +`; + +exports[`builders experimental classProperty should validate 2`] = ` +Object { + "computed": false, + "decorators": null, + "key": Object { + "type": "StringLiteral", + "value": "test", + }, + "static": true, + "type": "ClassProperty", + "typeAnnotation": null, + "value": Object { + "type": "NumericLiteral", + "value": 1, + }, +} +`; diff --git a/packages/babel-types/test/builders/experimental/classProperty.js b/packages/babel-types/test/builders/experimental/classProperty.js new file mode 100644 index 000000000000..075678da1a3e --- /dev/null +++ b/packages/babel-types/test/builders/experimental/classProperty.js @@ -0,0 +1,27 @@ +import * as t from "../../.."; + +describe("builders", function() { + describe("experimental", function() { + describe("classProperty", function() { + it("should validate", function() { + expect( + t.classProperty( + t.stringLiteral("test"), + t.numericLiteral(1), + ), + ).toMatchSnapshot(); + + expect( + t.classProperty( + t.stringLiteral("test"), + t.numericLiteral(1), + null, + null, + false, + true + ), + ).toMatchSnapshot(); + }); + }); + }); +});