microsoft / microsoft/TypeScript
Declaration merging: remove function overloads?
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Let's say one of the libs come with a function like this:
// library:
declare module 'example' {
interface Animal { }
export function sayHello(a: Animal);
}
I want to narrow down the type to just Dog. This is my module augmentation:
// app.ts
declare module 'example' {
interface Dog extends Animal { }
export function sayHello(a: Dog);
}
This merges the declarations to two function overloads:
sayHello(a: Dog);
sayHello(a: Animal);
I'd like to remove the generic Animal one to get stricter type checking of my code.
I couldn't find if this has been discussed before but I would find it useful quite often. Some examples would be:
expressheaders (string by default, I'd use union of string literals)yargsargs (I'd limit them to args specific to my app)
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die declaration-merging- und module-augmentation-Beispiele im Issue zu untersuchen, einschließlich des Overload-Verhaltens für express headers und yargs args. Erledigt ist die Aufgabe, wenn es eine unterstützte Möglichkeit gibt, den ursprünglichen generischen Overload zu entfernen oder einzugrenzen, mit strengerer Prüfung für den augmentierten Typ.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100