-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScript
Description
Bug Report
π Search Terms
hasOwn, Object.hasOwn, es2022, prototype, lib.es2022.object.d.ts
π Version & Regression Information
- This changed between versions 4.2.4 and 4.6.2
Appears to be introduced by #46291
β― Playground Link
Doesn't appear to reproduce on Playground or Bug Workbench, reproduces in VS Code 1.66.0-insider (e80a0ca) running TypeScript 4.6.2.
π» Code
interface SomeComponentProps {
requiredProp: boolean
hasOwn?: boolean;
}
const SomeComponent: React.FC<SomeComponentProps> = () => {}
return <SomeComponent requiredProp />
π Actual behavior
I ran into this issue because I was trying to upgrade the project from 4.3.5 to 4.6.2. The project has some object types with hasOwn
as a boolean property.
// TS2322: Type '{ requiredProp: boolean }' is not assignable to type 'SomeComponentProps'.
Types of property 'hasOwn' are incompatible.
Type '(o: object, v: PropertyKey) => boolean' is not assignable to type 'boolean'.
π Expected behavior
hasOwn
should be a method of the Object
constructor (Object.hasOwn
), not the prototype (foo.hasOwn
).
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScript