SO comment

https://stackoverflow.com/questions/72488693/different-type-behaviour-while-using-function-vs-using-raw-code?noredirect=1#comment128052888_72488693
Anonymous
typescript
06/03/2022 11:30 AM
440 B
41
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`
}
Editor is loading...