TypeScript/tests/cases/conformance/types/spread/objectSpreadRepeatedNullCheckPerf.ts
Wesley Wigham b9689228b5
When calculating spreads, merge empty object into nonempty object to … (#34853)
* When calculating spreads, merge empty object into nonempty object to produce partial object to reduce complexity

* Actually accept remainder of baselines

* Limit simplification to single prop or partial types
2019-11-22 17:19:17 -08:00

62 lines
2.5 KiB
TypeScript

// @strict: true
interface Props {
readonly a?: string
readonly b?: string
readonly c?: string
readonly d?: string
readonly e?: string
readonly f?: string
readonly g?: string
readonly h?: string
readonly i?: string
readonly j?: string
readonly k?: string
readonly l?: string
readonly m?: string
readonly n?: string
readonly o?: string
readonly p?: string
readonly q?: string
readonly r?: string
readonly s?: string
readonly t?: string
readonly u?: string
readonly v?: string
readonly w?: string
readonly x?: string
readonly y?: string
readonly z?: string
}
function parseWithSpread(config: Record<string, number>): Props {
return {
...config.a !== undefined && { a: config.a.toString() },
...config.b !== undefined && { b: config.b.toString() },
...config.c !== undefined && { c: config.c.toString() },
...config.d !== undefined && { d: config.d.toString() },
...config.e !== undefined && { e: config.e.toString() },
...config.f !== undefined && { f: config.f.toString() },
...config.g !== undefined && { g: config.g.toString() },
...config.h !== undefined && { h: config.h.toString() },
...config.i !== undefined && { i: config.i.toString() },
...config.j !== undefined && { j: config.j.toString() },
...config.k !== undefined && { k: config.k.toString() },
...config.l !== undefined && { l: config.l.toString() },
...config.m !== undefined && { m: config.m.toString() },
...config.n !== undefined && { n: config.n.toString() },
...config.o !== undefined && { o: config.o.toString() },
...config.p !== undefined && { p: config.p.toString() },
...config.q !== undefined && { q: config.q.toString() },
...config.r !== undefined && { r: config.r.toString() },
...config.s !== undefined && { s: config.s.toString() },
...config.t !== undefined && { t: config.t.toString() },
...config.u !== undefined && { u: config.u.toString() },
...config.v !== undefined && { v: config.v.toString() },
...config.w !== undefined && { w: config.w.toString() },
...config.x !== undefined && { x: config.x.toString() },
...config.y !== undefined && { y: config.y.toString() },
...config.z !== undefined && { z: config.z.toString() }
}
}
parseWithSpread({ a: 1, b: 2, z: 26 })