-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed as not planned
Closed as not planned
Copy link
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
π Search Terms
"spread interface prototype chain"
"spread native classes includes properties from prototype chain"
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about spreading objects and properties from prototype chain
β― Playground Link
π» Code
const a = new Map<string, string>();
const b = {...a};
function c(map: Map<string, string>) {
console.log(map.keys());
}
c(b);
π Actual behavior
Typescript compiles without errors. It computes that the type of b satisfies the Map interface. Calling the function c with b as the only argument causes map.keys() to crash at runtime.
[ERR]: "Executed JavaScript Failed:"
[ERR]: map.keys is not a function
π Expected behavior
Spreading into an object should only include own enumerable properties from the spread values in the type, nothing from the prototype chain.
Additional information about the issue
Is there any way to get the latest version of TypeScript to complain about the function call?
dzmitry-zhukouksi
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created