mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 02:30:15 -06:00
Use filter instead of unnecessary laziness
This commit is contained in:
parent
d74820d519
commit
f1622f0dc6
@ -8389,18 +8389,11 @@ namespace ts {
|
||||
}
|
||||
// Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or
|
||||
// more mapped types with a template type `never`, '(U & V & { [P in T]: never })[K]', return a
|
||||
// transformed type that removes the never-mapped type: '(U & V)[K]'. This mirrors what would happen
|
||||
// transformed type that removes the never-mapped type: '(U & V)[K]'. This mirrors what would happen
|
||||
// eventually anyway, but it easier to reason about.
|
||||
if (objectType.flags & TypeFlags.Intersection && isGenericObjectType(objectType) && some((<IntersectionType>objectType).types, isMappedTypeToNever)) {
|
||||
let nonNeverTypes: Type[];
|
||||
for (const t of (<IntersectionType>objectType).types) {
|
||||
if (!isMappedTypeToNever(t)) {
|
||||
(nonNeverTypes || (nonNeverTypes = [])).push(t);
|
||||
}
|
||||
}
|
||||
if (nonNeverTypes) {
|
||||
return getIndexedAccessType(getIntersectionType(nonNeverTypes), type.indexType);
|
||||
}
|
||||
const nonNeverTypes = filter((<IntersectionType>objectType).types, t => !isMappedTypeToNever(t));
|
||||
return getIndexedAccessType(getIntersectionType(nonNeverTypes), type.indexType);
|
||||
}
|
||||
|
||||
// If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user