Add optional properties
This commit is contained in:
parent
5f0a1e970b
commit
a7ccc1b052
|
@ -161,7 +161,8 @@ const ModulePropertyKind NodeKind = "ModuleProperty"
|
|||
type ClassProperty struct {
|
||||
VariableNode
|
||||
ClassMemberNode
|
||||
Primary *bool `json:"primary,omitempty"`
|
||||
Primary *bool `json:"primary,omitempty"`
|
||||
Optional *bool `json:"optional,omitempty"`
|
||||
}
|
||||
|
||||
var _ Node = (*ClassProperty)(nil)
|
||||
|
|
|
@ -88,8 +88,9 @@ export type ModulePropertyKind = "ModuleProperty";
|
|||
|
||||
// A class property is just like a module property with some extra attributes.
|
||||
export interface ClassProperty extends Variable, ClassMember {
|
||||
kind: ClassPropertyKind;
|
||||
primary?: boolean;
|
||||
kind: ClassPropertyKind;
|
||||
primary?: boolean;
|
||||
optional?: boolean;
|
||||
}
|
||||
export const classPropertyKind = "ClassProperty";
|
||||
export type ClassPropertyKind = "ClassProperty";
|
||||
|
|
|
@ -1343,6 +1343,7 @@ export class Transformer {
|
|||
name: this.transformPropertyName(node.name),
|
||||
access: this.getClassAccessibility(node),
|
||||
readonly: !!(mods & ts.ModifierFlags.Readonly),
|
||||
optional: !!(node.questionToken),
|
||||
static: !!(mods & ts.ModifierFlags.Static),
|
||||
type: this.resolveTypeTokenFromTypeLike(node),
|
||||
},
|
||||
|
|
|
@ -734,6 +734,7 @@
|
|||
},
|
||||
"access": "public",
|
||||
"readonly": true,
|
||||
"optional": false,
|
||||
"static": false,
|
||||
"type": {
|
||||
"kind": "TypeToken",
|
||||
|
@ -770,6 +771,7 @@
|
|||
},
|
||||
"access": "public",
|
||||
"readonly": true,
|
||||
"optional": false,
|
||||
"static": false,
|
||||
"type": {
|
||||
"kind": "TypeToken",
|
||||
|
|
Loading…
Reference in a new issue