A handful set of package.json types and interfaces to improve working with dynamically imported package.json files.
A handful set of package.json types and interfaces to improve working with dynamically imported package.json files. @types/package-json became deprecated as package.json files imported by typescript come with it’s own type definitions. Sometimes though, when you import files dynamically type becomes any and that’s when this package becomes useful.
Based on npm package.json documentation: https://docs.npmjs.com/files/package.json
npm i -D types-package-json
import { IPackageJson } from 'types-package-json';
const packageJsonPath = path.resolve(process.cwd(), `package.json`);
const packageJson: Partial<IPackageJson> = await import(packageJsonPath);