Closed dearlordylord closed 1 year ago
@Firfi this is "undefined behaviour":
prismNonNegative.getOption('0.5' as unknown as number)
since you are breaking the precondition (input must be a number
)
I also noticed that prismNonNegative.getOption('a' as unknown as number) would return None so it looks more of a bug than of a feature and me breaking typing with 'as unknown'
this is because
console.log('0.5' >= 0) // true
console.log('a' >= 0) // false
🐛 Bug report
tried to a prism to define some parsing/validation behavior, and found out that
prismNonNegative.getOption('0.5' as unknown as number)
would return Some('0.5') whereas '0.5' is a stringCurrent Behavior
Some('0.5')
Expected behavior
None
Reproducible example
prismNonNegative.getOption('0.5' as unknown as number)
Suggested solution(s)
return None
Additional context
I also noticed that
prismNonNegative.getOption('a' as unknown as number)
would return None so it looks more of a bug than of a feature and me breaking typing with 'as unknown'Your environment