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

Handle rest types for @typedef for `createTypeFromMapping` #154

Open kungfooman opened 1 month ago

kungfooman commented 1 month ago

Example:

/**
 * @typedef {{a: 'aa', b: 'bb', c: 'cc'}} Obj
 * @typedef {Obj[Keys]} ObjKeys
 * @typedef {{[Key in ObjKeys]: [1, 2, 3, Key, ...[1, 2, 3]]}} ArrayTest
 */
const t2 = createTypeFromMapping(typedefs.ArrayTest, console.warn);
console.log(JSON.stringify(t2, null, 2));

RTI REPL

Current errors:

getTypeKeys: Couldn't get keys for type {type: 'indexedAccess', index: 'Keys', object: 'Obj'}
createTypeFromMapping: validateMapping: missing typeKeys

image