Skip to content

Error: Unknown type "undefined" #1977

@arthurfiorette

Description

@arthurfiorette

The generator throws this issue when running inside the code below:

import stringify from "safe-stable-stringify";

export function intersectionOfArrays<T>(a: T[], b: T[]): T[] {
    const output: T[] = [];
    const inA: Set<string> = new Set(a.map((item: T) => stringify(item!)));
    for (const value of b) {
        if (inA.has(stringify(value!))) {
            output.push(value);
        }
    }
    return output;
}

Stack trace from the branch arthur/oclif:

Error: Unknown type "undefined"
    at ChainTypeFormatter.getTypeFormatter (/home/hzk/dev/ts-json-schema-generator/src/ChainTypeFormatter.ts:32:15)
    at ChainTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/ChainTypeFormatter.ts:22:21)
    at CircularReferenceTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/CircularReferenceTypeFormatter.ts:32:50)
    at ArrayTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/TypeFormatter/ArrayTypeFormatter.ts:20:40)
    at ChainTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/ChainTypeFormatter.ts:22:44)
    at CircularReferenceTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/CircularReferenceTypeFormatter.ts:32:50)
    at /home/hzk/dev/ts-json-schema-generator/src/TypeFormatter/ObjectTypeFormatter.ts:54:59
    at Array.reduce (<anonymous>)
    at ObjectTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/TypeFormatter/ObjectTypeFormatter.ts:48:44)
    at ChainTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/ChainTypeFormatter.ts:22:44)
    at CircularReferenceTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/CircularReferenceTypeFormatter.ts:32:50)
    at FunctionTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/TypeFormatter/FunctionTypeFormatter.ts:37:52)
    at ChainTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/ChainTypeFormatter.ts:22:44)
    at CircularReferenceTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/CircularReferenceTypeFormatter.ts:32:50)
    at DefinitionTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/TypeFormatter/DefinitionTypeFormatter.ts:22:62)
    at ChainTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/ChainTypeFormatter.ts:22:44)
    at CircularReferenceTypeFormatter.getChildren (/home/hzk/dev/ts-json-schema-generator/src/CircularReferenceTypeFormatter.ts:32:50)
    at SchemaGenerator.appendRootChildDefinitions (/home/hzk/dev/ts-json-schema-generator/src/SchemaGenerator.ts:93:14)
    at SchemaGenerator.createSchemaFromNodes (/home/hzk/dev/ts-json-schema-generator/src/SchemaGenerator.ts:41:18)
    at SchemaGenerator.createSchema (/home/hzk/dev/ts-json-schema-generator/src/SchemaGenerator.ts:28:26)
    at Generate.run (/home/hzk/dev/ts-json-schema-generator/commands/generate.ts:166:53)
    at async Generate._run (/home/hzk/dev/ts-json-schema-generator/node_modules/.pnpm/@[email protected]/node_modules/@oclif/core/lib/command.js:311:22)
    at async Config.runCommand (/home/hzk/dev/ts-json-schema-generator/node_modules/.pnpm/@[email protected]/node_modules/@oclif/core/lib/config/config.js:433:25)
    at async run (/home/hzk/dev/ts-json-schema-generator/node_modules/.pnpm/@[email protected]/node_modules/@oclif/core/lib/main.js:92:16)

Metadata

Metadata

Labels

bugreleasedThis issue/pull request has been released.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions