-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
When using the JS API, the type for the entryPoints
option currently is
Line 162 in f4159a7
entryPoints?: string[] | Record<string, string> | { in: string, out: string }[] |
However, based on the logic in lib/shared/common.ts...
Lines 341 to 362 in f4159a7
if (entryPoints) { | |
if (Array.isArray(entryPoints)) { | |
for (let i = 0, n = entryPoints.length; i < n; i++) { | |
let entryPoint = entryPoints[i] | |
if (typeof entryPoint === 'object' && entryPoint !== null) { | |
let entryPointKeys: OptionKeys = Object.create(null) | |
let input = getFlag(entryPoint, entryPointKeys, 'in', mustBeString) | |
let output = getFlag(entryPoint, entryPointKeys, 'out', mustBeString) | |
checkForInvalidFlags(entryPoint, entryPointKeys, 'in entry point at index ' + i) | |
if (input === undefined) throw new Error('Missing property "in" for entry point at index ' + i) | |
if (output === undefined) throw new Error('Missing property "out" for entry point at index ' + i) | |
entries.push([output, input]) | |
} else { | |
entries.push(['', validateStringValue(entryPoint, 'entry point at index ' + i)]) | |
} | |
} | |
} else { | |
for (let key in entryPoints) { | |
entries.push([key, validateStringValue(entryPoints[key], 'entry point', key)]) | |
} | |
} | |
} |
the code is currently able to handle a mixed array of strings and objects as well, a signature more akin to:
entryPoints?: Record<string, string> | (string | { in: string, out: string })[]
Indeed, by bypassing the typechecking on the property in the current build, passing such an array works just fine.
Metadata
Metadata
Assignees
Labels
No labels