Search Terms:
Intl
NumberFormatPartsType
Code
constformatter=newIntl.NumberFormat('en',{style: 'unit',unit: 'kilobyte'});returnformatter.formatToParts(0).find(part=>part.type==='unit').value;Expected behavior:
Compiles cleanly. See, for example, this MDN doc for Intl.formatByParts() which lists "unit" as a possible part type
Actual behavior:
tsc throws an error: This condition will always return 'false' since the types 'NumberFormatPartTypes' and '"unit"' have no overlap.
Playground Link:
https://www.typescriptlang.org/play?target=99&ts=4.2.0-dev.20201211#code/KYDwDg9gTgLgBAMwK4DsDGMCWEVwLYCGA1sAKoqYwBi0hMMwUAFKpQFxwDOMUmKA5gBo4AGwICkBfsA7deAgJRwA3gCg4cKMBhIouFMADucAJIoYIgHQA5JHgBGjGlDpMxEqcGHLuATxEycADkrDBBwqEAvgoA3KqRqqqgkLCIqBjYuAi0BPTAACbklCwUMLI8fEKi4vyS0uXy-EpqGmg43Ig5eVBwALz4xGSlznQMzKHC7rWeseqa2rpZXWOW2S65ACoQAAoEsJxMAAwKq3z5TExge-C9AHxwV7CWML5gwH29-SGlQQonAG4EERIYBxSJAA
Related Issues:
Search Terms:
Intl
NumberFormatPartsType
Code
Expected behavior:
Compiles cleanly. See, for example, this MDN doc for Intl.formatByParts() which lists "unit" as a possible part type
Actual behavior:
tsc throws an error: This condition will always return 'false' since the types 'NumberFormatPartTypes' and '"unit"' have no overlap.
Playground Link:
https://www.typescriptlang.org/play?target=99&ts=4.2.0-dev.20201211#code/KYDwDg9gTgLgBAMwK4DsDGMCWEVwLYCGA1sAKoqYwBi0hMMwUAFKpQFxwDOMUmKA5gBo4AGwICkBfsA7deAgJRwA3gCg4cKMBhIouFMADucAJIoYIgHQA5JHgBGjGlDpMxEqcGHLuATxEycADkrDBBwqEAvgoA3KqRqqqgkLCIqBjYuAi0BPTAACbklCwUMLI8fEKi4vyS0uXy-EpqGmg43Ig5eVBwALz4xGSlznQMzKHC7rWeseqa2rpZXWOW2S65ACoQAAoEsJxMAAwKq3z5TExge-C9AHxwV7CWML5gwH29-SGlQQonAG4EERIYBxSJAA
Related Issues: