microsoft / microsoft/TypeScript
Typescript ESType definition improvements
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
Hi,
The following types can be improved on to be more correct in the lib.es5.d.ts file.
These type improve typically deal with the cases on of the arrays items keys has subset of the other keys, in this case the results is the common subset, with mismatching fields made optional.
This requires functionality in typelevel-ts, however, that is only based on keys.
new methods should do and K in keyof T, T[K] extends S[K] ? K : never
// Improved more correctly helper method.
type ObjectOmit<T extends Record<string,any>, O extends Record<string,any>, KeyOfO keyof O> = Pick<T, {
[K in keyof T] : K extends KeyOfO ?
T[K] extends O[K] | undefined ? never : K // may need a two way extends comparison here.
: K
}[keyof T]
export function ObjectAssign<T extends Record<string,any>, U extends Record<string,any>>(target: T, source: U):
ObjectOverwrite<T, U>
{
return Object.assign(target, source);
}
export function ArrayConcat<A>(arrayA: A [] , arrayB : A []) : A[]
export function ArrayConcat<B, A extends B>(arrayA: A [], arrayB : B []) : B & Partial<ObjectOmit<A, keyof B>>[]
export function ArrayConcat<A, B extends A>(arrayA: A [], arrayB : B []) : A & Partial<ObjectOmit<B, keyof A>>[]
{
return arrayA.concat(arrayB) as any
}
export function FilterDefined<T>(items : Array<T> | undefined) : NonNullable<T> []
{
if (items)
return items.filter(f => f != undefined) as NonNullable<T> [];
else
return [];
}
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 mit dem Lesen von lib.es5.d.ts und der im Issue erwähnten schlüsselbasierten Funktionalität von typelevel-ts. Überprüfe die vorgeschlagenen Signaturen für ObjectAssign, ArrayConcat und FilterDefined und verifiziere anschließend, dass die Deklarationen gemeinsame Schlüssel, optionale Inkonsistenzen und das Filtern von undefined wie beabsichtigt behandeln.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- developer-experience
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100