grantila / grantila/typeconv

[jsc-to-ts] enum with null value throws

Open
#39 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
447
Forks
10
PR merge metrics
No merged PRs in 30d

Description

Using a enum with a null value as shown [here](https://json-schema.org/understanding-json-schema/reference/generic.html#id4) throws.
```
TypeError: Cannot destructure property 'properties' of 'node' as it is null.
at tsObjectType (file:///home/ava/peach-front/node_modules/core-types-ts/dist/lib/core-types-to-ts.js:205:13)
at tsConstType (file:///home/ava/peach-front/node_modules/core-types-ts/dist/lib/core-types-to-ts.js:185:31)
at file:///home/ava/peach-front/node_modules/core-types-ts/dist/lib/core-types-to-ts.js:139:30
at Array.map ()
at tsType (file:///home/ava/peach-front/node_modules/core-types-ts/dist/lib/core-types-to-ts.js:139:18)
at tsTypeAndOrSchema (file:///home/ava/peach-front/node_modules/core-types-ts/dist/lib/core-types-to-ts.js:109:16)
at file:///home/ava/peach-front/node_modules/core-types-ts/dist/lib/core-types-to-ts.js:100:76
at Array.map ()
at tsTypeUnion (file:///home/ava/peach-front/node_modules/core-types-ts/dist/lib/core-types-to-ts.js:100:48)
at tsTypeAndOr (file:///home/ava/peach-front/node_modules/core-types-ts/dist/lib/core-types-to-ts.js:115:16)

```
```
{
"enum": ["red", "amber", "green", null, 42]
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.