quicktype-core 23.0.114 → 23.0.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,6 +18,7 @@ export declare const tsFlowOptions: {
|
|
|
18
18
|
preferUnions: BooleanOption;
|
|
19
19
|
preferTypes: BooleanOption;
|
|
20
20
|
preferConstValues: BooleanOption;
|
|
21
|
+
readonly: BooleanOption;
|
|
21
22
|
};
|
|
22
23
|
export declare abstract class TypeScriptFlowBaseTargetLanguage extends JavaScriptTargetLanguage {
|
|
23
24
|
protected getOptions(): Option<any>[];
|
|
@@ -16,7 +16,8 @@ exports.tsFlowOptions = Object.assign({}, JavaScript_1.javaScriptOptions, {
|
|
|
16
16
|
declareUnions: new RendererOptions_1.BooleanOption("explicit-unions", "Explicitly name unions", false),
|
|
17
17
|
preferUnions: new RendererOptions_1.BooleanOption("prefer-unions", "Use union type instead of enum", false),
|
|
18
18
|
preferTypes: new RendererOptions_1.BooleanOption("prefer-types", "Use types instead of interfaces", false),
|
|
19
|
-
preferConstValues: new RendererOptions_1.BooleanOption("prefer-const-values", "Use string instead of enum for string enums with single value", false)
|
|
19
|
+
preferConstValues: new RendererOptions_1.BooleanOption("prefer-const-values", "Use string instead of enum for string enums with single value", false),
|
|
20
|
+
readonly: new RendererOptions_1.BooleanOption("readonly", "Use readonly type members", false)
|
|
20
21
|
});
|
|
21
22
|
const tsFlowTypeAnnotations = {
|
|
22
23
|
any: ": any",
|
|
@@ -39,7 +40,8 @@ class TypeScriptFlowBaseTargetLanguage extends JavaScript_1.JavaScriptTargetLang
|
|
|
39
40
|
exports.tsFlowOptions.rawType,
|
|
40
41
|
exports.tsFlowOptions.preferUnions,
|
|
41
42
|
exports.tsFlowOptions.preferTypes,
|
|
42
|
-
exports.tsFlowOptions.preferConstValues
|
|
43
|
+
exports.tsFlowOptions.preferConstValues,
|
|
44
|
+
exports.tsFlowOptions.readonly
|
|
43
45
|
];
|
|
44
46
|
}
|
|
45
47
|
get supportsOptionalClassProperties() {
|
|
@@ -123,8 +125,13 @@ class TypeScriptFlowBaseRenderer extends JavaScript_1.JavaScriptRenderer {
|
|
|
123
125
|
emitClassBlockBody(c) {
|
|
124
126
|
this.emitPropertyTable(c, (name, _jsonName, p) => {
|
|
125
127
|
const t = p.type;
|
|
128
|
+
let propertyName = name;
|
|
129
|
+
propertyName = (0, Source_1.modifySource)(quotePropertyName, name);
|
|
130
|
+
if (this._tsFlowOptions.readonly) {
|
|
131
|
+
propertyName = (0, Source_1.modifySource)(_propertyName => "readonly " + _propertyName, propertyName);
|
|
132
|
+
}
|
|
126
133
|
return [
|
|
127
|
-
[
|
|
134
|
+
[propertyName, p.isOptional ? "?" : "", ": "],
|
|
128
135
|
[this.sourceFor(t).source, ";"]
|
|
129
136
|
];
|
|
130
137
|
});
|