SO comment
https://stackoverflow.com/questions/72488693/different-type-behaviour-while-using-function-vs-using-raw-code?noredirect=1#comment128052888_72488693unknown
typescript
2 years ago
329 B
8
Indexable
function narrowUnknownTostring(rawParam: string | number): void { const narrowedParamError: string = rawParam; // Type 'string | number' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'.` rawParam = castString(rawParam);` const narrowedParamOk: string = rawParam; // Everything's fine` }