paketo
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Paketo

A tiny library for importing your package.json, with proper types!

Why?

  • You could do like JSON.parse ( fs.readFileSync ( 'package.json', 'utf8' ) ), but the output will be of type any, not the type that you want. Also that's annoying to write.
  • You could do import Package from './package.json' assert { type: 'json' }, but that's kinda weird, it's not supported everywhere yet, and the path to write will change depending on where you are importing it from, which is inconvenient.

How?

  • After reading the package.json file this library rewrites its own types with the content of that file.

Limitations

  • After the first run, and after you edit your package.json file, you might have to restart TS' LSP before you can see the updated types.
  • If your dependencies are not installed in a local node_modules folder this library may not work properly.

Install

npm install --save paketo

Usage

import Package from 'paketo';

console.log ( Package.name ); // => paketo

License

MIT © Fabio Spampinato

Readme

Keywords

Package Sidebar

Install

npm i paketo

Weekly Downloads

0

Version

1.0.1

License

none

Unpacked Size

5.88 kB

Total Files

15

Last publish

Collaborators

  • fabiospampinato