Open shadskii opened 1 year ago
i like this idea, and it's definitely something i've thought about before.
we could implement this by doing a similar comptime hashmap approach as to what our default trusted dependency allow list uses. this would make it very fast to find if there is a package has types (no network request needed), but at the cost of very new packages not being present.
the question is when do we want to automatically install type defintions, maybe an option in bunfig? and/or --types
/--save-types
-t
or something. @colinhacks what do you think about the interface for this?
It might be unrelated but somehow it makes me thing of npm optionalDependencies and peerDependenciesMeta
What is the problem this feature would solve?
Installing a package in a typescript project is typically a three step operation because of external type definitions. You have to install the package, check if it ships with types, and if it doesn't install the types from DefinitelyTyped. This can annoying and it seems like something your package manager should handle for you.
This is definitely a pain point for many devs because the Typescript LSP has a warning for it
What is the feature you are proposing to solve the problem?
Bun should add an optional flag to automatically install the type definitions for a package if the package doesn't ship with them. The
types
field in package.json could probably be used for this.What alternatives have you considered?
https://github.com/ewgenius/typac