-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
Experimentation NeededSomeone needs to try this out to see what happensSomeone needs to try this out to see what happensPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
🔎 Search Terms
"Destructuring", "Omit<Partial, "keyof type> not assignable to Partial",
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about destructuring and Omit and found a somewhat related thing under 'Add a Key Constraint to Omit' but that isn't the change necessitated here
⏯ Playground Link
💻 Code
interface Interface {
0: number;
one: string;
two: boolean;
}
function Test<dataType>(data: dataType, testKey: keyof dataType) {
let partialData: Partial<dataType> = data;
const cloneWithoutKey = (key: keyof dataType) => {
const { [key]: _, ...otherData } = partialData;
partialData = otherData;/**Type 'Omit<Partial<dataType>, keyof dataType>' is not assignable to type 'Partial<dataType>'.
Type 'keyof dataType' is not assignable to type 'Exclude<keyof dataType, keyof dataType>'.
Type 'string | number | symbol' is not assignable to type 'never'.
Type 'string' is not assignable to type 'never'.**/
};
cloneWithoutKey(testKey);
return partialData;
}
Test<Interface>({ 0: 42, one: "three", two: false }, "one");
🙁 Actual behavior
otherData resolves to never and is not assignable to partial data
🙂 Expected behavior
the rest parameter should be resolved to a partial of the datatype
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
Experimentation NeededSomeone needs to try this out to see what happensSomeone needs to try this out to see what happensPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases