gustavoguichard / string-ts

Strongly typed string functions
MIT License
1.19k stars 17 forks source link

fix: better literal differentiation #107

Closed jly36963 closed 10 months ago

jly36963 commented 10 months ago

Based on this discussion

gustavoguichard commented 10 months ago

FYI https://twitter.com/ssalbdivad/status/1720565747171131776

jly36963 commented 10 months ago

FYI https://twitter.com/ssalbdivad/status/1720565747171131776

There are multiple ways to write numbers in javascript

Playground

type NumString = `${number}`
let t1: NumString
t1 = '1'
t1 = '3.5e11'
t1 = '0xff'
t1 = '0b11111111'
t1 = 'abc' // Bad
console.log(t1)