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).
Bug Report
π Search Terms
hasOwn, Object.hasOwn, es2022, prototype, lib.es2022.object.d.ts
π Version & Regression Information
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
π 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
hasOwnas a boolean property.π Expected behavior
hasOwnshould be a method of theObjectconstructor (Object.hasOwn), not the prototype (foo.hasOwn).