microsoft / microsoft/TypeScript
Typescript ESType definition improvements
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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 [];
}
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia leggendo lib.es5.d.ts e la funzionalità basata sulle chiavi di typelevel-ts menzionata nell’issue. Esamina le firme proposte di ObjectAssign, ArrayConcat e FilterDefined, quindi verifica che le dichiarazioni gestiscano le chiavi comuni, le incompatibilità opzionali e il filtraggio di undefined come previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- developer-experience
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100