json-schema-to-typescript icon indicating copy to clipboard operation
json-schema-to-typescript copied to clipboard

[Regression] Parsing web types schema throws a JS error starting from 15.0.0

Open vursen opened this issue 11 months ago • 0 comments

Starting from version 15.0.0, parsing the web types schema with the following script:

import { compile } from 'json-schema-to-typescript';

const schema = await fetch('https://json.schemastore.org/web-types').then((response) => response.json());
const ts = await compile(schema, 'WebTypes');

throws the error:

/Users/vursen/dev/vaadin/react-components/node_modules/json-schema-to-typescript/dist/src/parser.js:22
            ast.params.push(parseAsTypeWithCache(schema, type, options, keyName, processed, usedNames));
                       ^

TypeError: Cannot read properties of undefined (reading 'push')
    at /Users/vursen/dev/vaadin/react-components/node_modules/json-schema-to-typescript/dist/src/parser.js:22:24
    at Set.forEach (<anonymous>)
    at parse (/Users/vursen/dev/vaadin/react-components/node_modules/json-schema-to-typescript/dist/src/parser.js:21:15)
    at /Users/vursen/dev/vaadin/react-components/node_modules/json-schema-to-typescript/dist/src/parser.js:305:14
    at /Users/vursen/dev/vaadin/react-components/node_modules/lodash/lodash.js:3585:27
    at /Users/vursen/dev/vaadin/react-components/node_modules/lodash/lodash.js:4967:15
    at baseForOwn (/Users/vursen/dev/vaadin/react-components/node_modules/lodash/lodash.js:3032:24)
    at /Users/vursen/dev/vaadin/react-components/node_modules/lodash/lodash.js:4936:18
    at baseMap (/Users/vursen/dev/vaadin/react-components/node_modules/lodash/lodash.js:3584:7)
    at map (/Users/vursen/dev/vaadin/react-components/node_modules/lodash/lodash.js:9622:14)

vursen avatar Dec 25 '24 07:12 vursen