top | item 45885230

(no title)

mpoteat | 3 months ago

Actually, it's even simpler: you should just be able to use signature overloading:

  myFunc(x: true): number
  myFunc(x: false): string
The article's assertion that TypeScript can't represent this is quite false.

discuss

order

codebje|3 months ago

Alas, no:

    foo.ts:1:10 - error TS2393: Duplicate function implementation.