Add static parameter to class property builder (#10248)
This commit is contained in:
parent
1e7ed5c461
commit
4506590557
@ -403,8 +403,8 @@ export const classMethodOrPropertyCommon = {
|
|||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
static: {
|
static: {
|
||||||
|
default: false,
|
||||||
validate: assertValueType("boolean"),
|
validate: assertValueType("boolean"),
|
||||||
optional: true,
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
default: false,
|
default: false,
|
||||||
|
|||||||
@ -33,7 +33,14 @@ defineType("BindExpression", {
|
|||||||
|
|
||||||
defineType("ClassProperty", {
|
defineType("ClassProperty", {
|
||||||
visitor: ["key", "value", "typeAnnotation", "decorators"],
|
visitor: ["key", "value", "typeAnnotation", "decorators"],
|
||||||
builder: ["key", "value", "typeAnnotation", "decorators", "computed"],
|
builder: [
|
||||||
|
"key",
|
||||||
|
"value",
|
||||||
|
"typeAnnotation",
|
||||||
|
"decorators",
|
||||||
|
"computed",
|
||||||
|
"static",
|
||||||
|
],
|
||||||
aliases: ["Property"],
|
aliases: ["Property"],
|
||||||
fields: {
|
fields: {
|
||||||
...classMethodOrPropertyCommon,
|
...classMethodOrPropertyCommon,
|
||||||
|
|||||||
@ -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": false,
|
||||||
|
"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,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`;
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user