Literally just supporting JavaScript Object() in TypeScript
npm install types-objectLiterally just supporting JavaScript Object() in TypeScript.
This includes typing for:
- Object()
- new Object()
- Object.create()
- Object.hasOwn()
- Object.getPrototypeOf()
- Object.setPrototypeOf()
``ts
const love = { is: 'real' } as const
const real = Object(love)
const know = Object.hasOwn(love, 'is')
love.is / (property) is: "real" /
real /* const real: {
readonly is: "real";
} */
know / const know: true /
`
Add types-object to the array of types in compilerOptions, in either tsconfig.json or jsconfig.json.
`ts`
{
"compilerOptions": {
"types": ["types-object"]
}
}
Alternatively, use types-object/constructor if you only wish to include types for Object() and new Object()
`ts``
{
"compilerOptions": {
"types": ["types-object/constructor"]
}
}