forked from ianstormtaylor/superstruct
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
A regression is introduced by upgrading TypeScript to v5.0. This is caused by a breaking change in TypeScript's type narrowing behavior.
- Example:
type Type = number | Date | ...
let value: Type
if (typeof value === 'number' || value instanceof Date) {
// Type of 'value' is not `number | Date`, but `(Type & number) | (Type & Date)`.
}
- Error:
TypeScriptError: Failed to initialise the project.
src/structs/refinements.ts:165:10 - error TS2365: Operator '<=' cannot be applied to types 'number' and '(Type & number) | (Type & Date)'.
165 (minimum <= value && value <= maximum) ||
~~~~~~~~~~~~~~~~
src/structs/refinements.ts:165:30 - error TS2365: Operator '<=' cannot be applied to types '(Type & number) | (Type & Date)' and 'number'.
165 (minimum <= value && value <= maximum) ||
~~~~~~~~~~~~~~~~
at getProgram (file:///Volumes/Code/metamask/superstruct/node_modules/@ts-bridge/cli/dist/build.js:36:15)
at buildHandler (file:///Volumes/Code/metamask/superstruct/node_modules/@ts-bridge/cli/dist/build.js:69:21)
at Object.handler (file:///Volumes/Code/metamask/superstruct/node_modules/@ts-bridge/cli/dist/cli.js:53:16)
at /Volumes/Code/metamask/superstruct/node_modules/yargs/build/index.cjs:1:8993
at j (/Volumes/Code/metamask/superstruct/node_modules/yargs/build/index.cjs:1:4956)
at _.handleValidationAndGetResult (/Volumes/Code/metamask/superstruct/node_modules/yargs/build/index.cjs:1:8962)
at _.applyMiddlewareAndGetResult (/Volumes/Code/metamask/superstruct/node_modules/yargs/build/index.cjs:1:9604)
at _.runCommand (/Volumes/Code/metamask/superstruct/node_modules/yargs/build/index.cjs:1:7231)
at [runYargsParserAndExecuteCommands] (/Volumes/Code/metamask/superstruct/node_modules/yargs/build/index.cjs:1:58912)
at te.parse (/Volumes/Code/metamask/superstruct/node_modules/yargs/build/index.cjs:1:40478)