kungfooman / RuntimeTypeInspector.js

Checking JSDoc types at runtime for high-quality types - Trust is good, control is better.
MIT License
8 stars 0 forks source link

Fix unhandled case in `replaceType` (used by createTypeFromMapping) #119

Closed kungfooman closed 8 months ago

kungfooman commented 8 months ago

Example:

const str = `{
  [Key in 1|2|3]: {
    testkey: [Key, Key, Key],
    bla: Key,
    Key: number
  }
}`;
const mapping = expandType(str);
const type = createTypeFromMapping(mapping, console.warn);
const key = type.properties[1].properties.bla;
console.log(`The key should be 1: ${key} (${key === 1})`, {type});
setRight(JSON.stringify(type, null, 2));

REPL

Console output:

image