@@ -517,7 +517,8 @@ namespace ts {
517
517
let deferredGlobalTemplateStringsArrayType: ObjectType;
518
518
let deferredGlobalImportMetaType: ObjectType;
519
519
let deferredGlobalExtractSymbol: Symbol;
520
- let deferredGlobalRestSymbol: Symbol;
520
+ let deferredGlobalExcludeSymbol: Symbol;
521
+ let deferredGlobalPickSymbol: Symbol;
521
522
522
523
const allPotentiallyUnusedIdentifiers = createMap<PotentiallyUnusedIdentifier[]>(); // key is file name
523
524
@@ -4602,10 +4603,16 @@ namespace ts {
4602
4603
}
4603
4604
const omitKeyType = getUnionType(map(properties, getLiteralTypeFromPropertyName));
4604
4605
if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) {
4605
- const restTypeAlias = getGlobalRestSymbol();
4606
- return !restTypeAlias ? errorType :
4607
- omitKeyType.flags & TypeFlags.Never ? source :
4608
- getTypeAliasInstantiation(restTypeAlias, [source, omitKeyType]);
4606
+ if (omitKeyType.flags & TypeFlags.Never) {
4607
+ return source;
4608
+ }
4609
+ const pickTypeAlias = getGlobalPickSymbol();
4610
+ const excludeTypeAlias = getGlobalExcludeSymbol();
4611
+ if (!pickTypeAlias || !excludeTypeAlias) {
4612
+ return errorType;
4613
+ }
4614
+ const pickKeys = getTypeAliasInstantiation(excludeTypeAlias, [getIndexType(source), omitKeyType]);
4615
+ return getTypeAliasInstantiation(pickTypeAlias, [source, pickKeys]);
4609
4616
}
4610
4617
const members = createSymbolTable();
4611
4618
for (const prop of getPropertiesOfType(source)) {
@@ -8640,8 +8647,12 @@ namespace ts {
8640
8647
return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract" as __String, SymbolFlags.TypeAlias, Diagnostics.Cannot_find_global_type_0)!); // TODO: GH#18217
8641
8648
}
8642
8649
8643
- function getGlobalRestSymbol(): Symbol {
8644
- return deferredGlobalRestSymbol || (deferredGlobalRestSymbol = getGlobalSymbol("Rest" as __String, SymbolFlags.TypeAlias, Diagnostics.Cannot_find_global_type_0)!); // TODO: GH#18217
8650
+ function getGlobalExcludeSymbol(): Symbol {
8651
+ return deferredGlobalExcludeSymbol || (deferredGlobalExcludeSymbol = getGlobalSymbol("Exclude" as __String, SymbolFlags.TypeAlias, Diagnostics.Cannot_find_global_type_0)!); // TODO: GH#18217
8652
+ }
8653
+
8654
+ function getGlobalPickSymbol(): Symbol {
8655
+ return deferredGlobalPickSymbol || (deferredGlobalPickSymbol = getGlobalSymbol("Pick" as __String, SymbolFlags.TypeAlias, Diagnostics.Cannot_find_global_type_0)!); // TODO: GH#18217
8645
8656
}
8646
8657
8647
8658
/**
@@ -9227,9 +9238,8 @@ namespace ts {
9227
9238
}
9228
9239
9229
9240
function getLiteralTypeFromPropertyName(name: PropertyName) {
9230
- return isComputedPropertyName(name) ? checkComputedPropertyName(name) :
9231
- isIdentifier(name) ? getLiteralType(unescapeLeadingUnderscores(name.escapedText)) :
9232
- checkExpression(name);
9241
+ return isIdentifier(name) ? getLiteralType(unescapeLeadingUnderscores(name.escapedText)) :
9242
+ getRegularTypeOfLiteralType(isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name));
9233
9243
}
9234
9244
9235
9245
function getLiteralTypeFromProperty(prop: Symbol, include: TypeFlags) {
0 commit comments