cddl2ts 0.9.1 → 0.10.0
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/build/index.js +2 -1
- package/cli-examples/local.ts +1 -1
- package/cli-examples/remote.ts +1 -1
- package/package.json +3 -3
- package/src/index.ts +2 -1
- package/tests/__snapshots__/mod.test.ts.snap +1 -1
- package/tests/__snapshots__/webdriver_local.test.ts.snap +1 -1
- package/tests/__snapshots__/webdriver_remote.test.ts.snap +1 -1
- package/tests/transform_edge_cases.test.ts +4 -1
package/build/index.js
CHANGED
|
@@ -586,7 +586,8 @@ function parseUnionType(t, options) {
|
|
|
586
586
|
else if (isNativeTypeWithOperator(t) && NATIVE_TYPES[t.Type.Type]) {
|
|
587
587
|
return NATIVE_TYPES[t.Type.Type];
|
|
588
588
|
}
|
|
589
|
-
else if (isPropertyReference(t) && t.Value === 'null') {
|
|
589
|
+
else if (isPropertyReference(t) && t.Value === 'null' && !isLiteralWithValue(t)) {
|
|
590
|
+
// a bare `null` reference is the null type; a quoted "null" is a string literal
|
|
590
591
|
return b.tsNullKeyword();
|
|
591
592
|
}
|
|
592
593
|
else if (isGroup(t)) {
|
package/cli-examples/local.ts
CHANGED
package/cli-examples/remote.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cddl2ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "A Node.js package that can generate a TypeScript definition based on a CDDL file",
|
|
5
5
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/yargs": "^17.0.35",
|
|
28
|
-
"@types/node": "^
|
|
28
|
+
"@types/node": "^26.0.1"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/parser": "^7.29.0",
|
|
32
32
|
"camelcase": "^9.0.0",
|
|
33
33
|
"recast": "^0.23.11",
|
|
34
34
|
"yargs": "^18.0.0",
|
|
35
|
-
"cddl": "0.
|
|
35
|
+
"cddl": "0.21.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"release": "release-it --config .release-it.ts --VV",
|
package/src/index.ts
CHANGED
|
@@ -680,7 +680,8 @@ function parseUnionType (t: PropertyType | Assignment, options: TransformSetting
|
|
|
680
680
|
return NATIVE_TYPES[(t as any).Type]
|
|
681
681
|
} else if (isNativeTypeWithOperator(t) && NATIVE_TYPES[(t.Type as any).Type]) {
|
|
682
682
|
return NATIVE_TYPES[(t.Type as any).Type]
|
|
683
|
-
} else if (isPropertyReference(t) && t.Value === 'null') {
|
|
683
|
+
} else if (isPropertyReference(t) && t.Value === 'null' && !isLiteralWithValue(t)) {
|
|
684
|
+
// a bare `null` reference is the null type; a quoted "null" is a string literal
|
|
684
685
|
return b.tsNullKeyword()
|
|
685
686
|
} else if (isGroup(t)) {
|
|
686
687
|
/**
|
|
@@ -285,7 +285,8 @@ describe('transform edge cases', () => {
|
|
|
285
285
|
Operator: { Type: 'default', Value: literal('mouse') }
|
|
286
286
|
}),
|
|
287
287
|
variable('bool-literal', literal(true)),
|
|
288
|
-
variable('null-literal', literal(null))
|
|
288
|
+
variable('null-literal', literal(null)),
|
|
289
|
+
variable('null-string-literal', literal('null'))
|
|
289
290
|
])
|
|
290
291
|
|
|
291
292
|
expect(output).toContain('export type TupleType = [number, string];')
|
|
@@ -297,6 +298,8 @@ describe('transform edge cases', () => {
|
|
|
297
298
|
expect(output).toContain('export type PointerType = PointerValue;')
|
|
298
299
|
expect(output).toContain('export type BoolLiteral = true;')
|
|
299
300
|
expect(output).toContain('export type NullLiteral = null;')
|
|
301
|
+
// a quoted "null" is a string literal, not the null type
|
|
302
|
+
expect(output).toContain('export type NullStringLiteral = "null";')
|
|
300
303
|
})
|
|
301
304
|
|
|
302
305
|
it('should include optional properties and default tags in object docs', () => {
|