Skip to content

Commit

Permalink
Add static parameter to class property builder
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-karadzhov committed Jul 22, 2019
1 parent fced5ce commit dc9ff74
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/babel-types/src/definitions/experimental.js
Expand Up @@ -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,
Expand Down
@@ -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,
},
}
`;
27 changes: 27 additions & 0 deletions 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();
});
});
});
});

0 comments on commit dc9ff74

Please sign in to comment.