DanielXMoore / Civet

A TypeScript superset that favors more types and less typing
https://civet.dev
MIT License
1.36k stars 29 forks source link

Exported function with overrides adds blank implementation #1401

Open edemaine opened 1 week ago

edemaine commented 1 week ago

Civet has a feature where, if you declare a function without a body (possibly multiple times for an overload), one of the functions gets an empty body {}.

This feature does the wrong thing in this scenario where one version is exported:

function f(x: number): number
export function f(x: string): string
  return x
↓↓↓
function f(x: number): number {}
export function f(x: string): string {
  return x;
}

Note the added {}, which means f gets implemented twice.

By contrast, the following is valid TypeScript for an exported function with overloads:

function f(x: number): number
export function f(x: string): string {
  return x
}