Closed thynson closed 4 years ago
The original intent with the peer dependency was to indicate that there's no point in using ts-enum-util
in a plain javascript project, because the whole purpose of ts-enum-util
is to provide type-safe typescript utilities around the compiled-time types and run-time structures of typescript's enums.
What is your use case? Are you working in a javascript (not typescript) project where one of your dependencies was developed in typescript and has a dependency on ts-enum-util
? That's a use case I hadn't thought of before.
That's another case that would confuse people, but not exactly my case.
Being also a Typescript developer, I just surprised that when i was trying to prune dev-dependencies for prepareing a release bundle, where final bundle size matters here, I was alerted that "typescript" is a peer dependencies of this project, which make me think of that an hard decision had to be made, additionally this project enforces strict-peer-dependencies
(a feature of pnpm) which strictly checks if all peer dependencies was satisified.
The other goal of the peer dependency was to help ensure that you are using a compatible version of typescript. ts-enum-util
will cause strange compiler errors if used with an older version of typescript, so I wanted the peer dependency to be a first line of defense to warn developers that ts-enum-util
isn't going to work.
The more I think about it, the more it seems I've been mis-using peer dependencies for this. Dependencies and peer dependencies are all about what is necessary at run-time. In this case, a particular version of typescript is required at compile time. It's like a dev dependency for projects that use ts-enum-util
.
Do you think it would make sense to change it to an optional dependency on typescript? Or better to simply remove the dependency altogether?
Do you think it would make sense to change it to an optional dependency on typescript? Or better to simply remove the dependency altogether?
Personally I would prefer to put it on document, rather than list it in peer dependencies. And you have to use peer dependencies if that is your goal because optional dependency does not guarantee same instance of dependency is installed. Note that peer dependencies can also be optional, at least it eliminates all warning.
Fixed and published as v4.0.2. I simply removed the peer dependency. README documentation already describes supported TypeScript versions.
I just checked the src/ directory and fount no file import typescript. It would be great if it can be removed peer dependencies list.