type-crafter 0.16.0 → 0.16.1
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.
package/dist/index.js
CHANGED
|
@@ -22547,7 +22547,7 @@ async function runner(language, inputFilePath, outputDirectory, _typesWriterMode
|
|
|
22547
22547
|
}
|
|
22548
22548
|
}
|
|
22549
22549
|
greeting();
|
|
22550
|
-
const program = new Command().version('0.16.
|
|
22550
|
+
const program = new Command().version('0.16.1');
|
|
22551
22551
|
program
|
|
22552
22552
|
.command('generate')
|
|
22553
22553
|
.description('Generate types for your language from a type spec file')
|
|
@@ -50,7 +50,7 @@ export function decode{{typeName}}(rawInput: unknown): {{typeName}} | null {
|
|
|
50
50
|
{{#if this.optional}}_{{/if}}decode{{{toPascalCase this.type}}}(rawInput[{{{indexKey @key}}}]);
|
|
51
51
|
{{~else~}}
|
|
52
52
|
{{~#if (eq this.primitiveType 'array')~}}
|
|
53
|
-
decodeArray(rawInput[{{{indexKey @key}}}], {{~> nestedArrayDecoder depth=this.arrayNestingDepth composerType=this.composerType~}})
|
|
53
|
+
decodeArray(rawInput[{{{indexKey @key}}}], {{~> nestedArrayDecoder depth=this.arrayNestingDepth composerType=this.composerType~}}){{#if this.optional}} ?? undefined{{/if}}
|
|
54
54
|
{{~else~}}
|
|
55
55
|
{{#if this.optional}}_{{/if}}decode{{{toPascalCase this.type}}}(rawInput[{{{indexKey @key}}}])
|
|
56
56
|
{{~/if~}};
|
|
@@ -85,9 +85,11 @@ export function decode{{typeName}}(rawInput: unknown): {{typeName}} | null {
|
|
|
85
85
|
const decodedValue = decode{{{toPascalCase additionalProperties.valueType}}}(rawInput[key]);
|
|
86
86
|
{{/if}}
|
|
87
87
|
{{/if}}
|
|
88
|
+
{{#unless (eq additionalProperties.valuePrimitiveType 'unknown')}}
|
|
88
89
|
if (decodedValue === null) {
|
|
89
90
|
return null;
|
|
90
91
|
}
|
|
92
|
+
{{/unless}}
|
|
91
93
|
decodedAdditionalProperties[key] = decodedValue;
|
|
92
94
|
}
|
|
93
95
|
return decodedAdditionalProperties;
|
|
@@ -109,9 +111,11 @@ export function decode{{typeName}}(rawInput: unknown): {{typeName}} | null {
|
|
|
109
111
|
const decodedValue = decode{{{toPascalCase additionalProperties.valueType}}}(rawInput[key]);
|
|
110
112
|
{{/if}}
|
|
111
113
|
{{/if}}
|
|
114
|
+
{{#unless (eq additionalProperties.valuePrimitiveType 'unknown')}}
|
|
112
115
|
if (decodedValue === null) {
|
|
113
116
|
return null;
|
|
114
117
|
}
|
|
118
|
+
{{/unless}}
|
|
115
119
|
decodedAdditionalProperties[key] = decodedValue;
|
|
116
120
|
}
|
|
117
121
|
}
|
|
@@ -177,9 +181,11 @@ export function _decode{{typeName}}(rawInput: unknown): {{typeName}} | undefined
|
|
|
177
181
|
const decodedValue = decode{{{toPascalCase additionalProperties.valueType}}}(rawInput[key]);
|
|
178
182
|
{{/if}}
|
|
179
183
|
{{/if}}
|
|
184
|
+
{{#unless (eq additionalProperties.valuePrimitiveType 'unknown')}}
|
|
180
185
|
if (decodedValue === null) {
|
|
181
186
|
return;
|
|
182
187
|
}
|
|
188
|
+
{{/unless}}
|
|
183
189
|
decodedAdditionalProperties[key] = decodedValue;
|
|
184
190
|
}
|
|
185
191
|
return decodedAdditionalProperties;
|
|
@@ -201,9 +207,11 @@ export function _decode{{typeName}}(rawInput: unknown): {{typeName}} | undefined
|
|
|
201
207
|
const decodedValue = decode{{{toPascalCase additionalProperties.valueType}}}(rawInput[key]);
|
|
202
208
|
{{/if}}
|
|
203
209
|
{{/if}}
|
|
210
|
+
{{#unless (eq additionalProperties.valuePrimitiveType 'unknown')}}
|
|
204
211
|
if (decodedValue === null) {
|
|
205
212
|
return;
|
|
206
213
|
}
|
|
214
|
+
{{/unless}}
|
|
207
215
|
decodedAdditionalProperties[key] = decodedValue;
|
|
208
216
|
}
|
|
209
217
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{{#each (getReferencedTypeModules referencedTypes writtenAt)}}
|
|
2
2
|
import { {{#each this.referencedTypes}}type {{this}}, decode{{this}}{{#unless @last}}, {{/unless}} {{/each}} } from '{{this.moduleRelativePath}}';
|
|
3
3
|
{{/each}}
|
|
4
|
-
import { isJSON, {{#each primitives}}decode{{{toPascalCase this}}}, _decode{{{toPascalCase this}}} {{#unless @last}}, {{/unless}}{{/each}} } from 'type-decoder';
|
|
4
|
+
import { isJSON, {{#each primitives}}decode{{{toPascalCase this}}}{{#unless (eq this 'unknown')}}, _decode{{{toPascalCase this}}}{{/unless}} {{#unless @last}}, {{/unless}}{{/each}} } from 'type-decoder';
|
|
5
5
|
|
|
6
6
|
{{{typesContent}}}
|
|
7
7
|
|