-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: publish first-party type declarations #1490
Conversation
I don't think there's any need for a separate command/step to output types - they can just be done as part of the standard build by adding the I'd suggest there needs to be a CI step to verify the types are indeed being build in this separate step. I note your JSON file has comments, which I don't believe are valid in JSON, so would need removing |
You perform build step using Babel, not TSC.
Not sure it's that important, unless you want to prevent other people to accidentally disable it
TypeScript config files are interpreted as JSONC command, which support comments |
Not sure why CI is failing, seems to me you're building on a Windows machine, I guess it has some problems with the command format
Maybe it needs to be Yet, other commands work, not sure what's the cause then |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1490 +/- ##
==========================================
- Coverage 78.41% 78.25% -0.17%
==========================================
Files 93 93
Lines 4860 4860
Branches 934 934
==========================================
- Hits 3811 3803 -8
- Misses 751 757 +6
- Partials 298 300 +2 ☔ View full report in Codecov by Sentry. |
Any chance this PR can be revisited? There's a big PR open over at DefinitelyTyped to update cc @lohart13 |
Okay, so I pushed a few changes to this PR in preparation for merging this. A few notes. Bundling the type definitions with But the dependency on These dependencies in turn mean that each installation of |
Not active within this project itself, but I've seen plenty of projects that do have |
Personally I don't think it's ok to have packages list dev dependencies as prod dependencies just to let types be exported. Consumers of the library should already have those types pulled in themselves. If there are effectively "peer" typings needed, it's for the root project to be pulling those in, really. I wouldn't want |
I agree on adding TS deps as devDependencies as @dhensby said, not prod ones You could mark as peer deps the ones you need to re-expose and ask the end user to install them, if they use TS or want proper autocomplete |
I've spent some time looking around and there's various posts around this topic. The recommended approach by the TypeScript project itself is to list For examples of this see this discussion DefinitelyTyped/DefinitelyTyped#44777, microsoft/types-publisher#81 (comment), and other popular packages like If we didn't export any of the types contained within |
Well, it's definitely a matter of opinion - I just know I'd never want to be forcing downstream packages to be pulling in Typings are an inherently development dependencies and are not needed for production, which is why I would strongly advocate they are never included as production deps.
This is only true if consumers of the tedious types didn't include the |
Just to add, for the |
That is true, but I think a misunderstanding or difference in interpretation around the difference between So, if we start bundling types inside the Otherwise, the whole dependency management for type definitions breaks down, and users will have to spend a troubling amount of work of piecing together which |
@IlCallo I know it's been a while since you worked on this, but can you help me understand what the problem around the import from |
Honestly I don't remember much, but if you don't have any strange generation issue, then the problem is probably solved already IIRC the problem with importing the package.json was that you would then end up with broken types and generation as a deeply nested folder |
I think that's right, the devDeps are for development and the deps are for running in procuction. Types are not needed to run in production, so they should be listed as devDeps. I know devDeps don't cascade down, and that's the reason why this typing issue comes up and it's intended behaviour in the dependency management - but it does lead to these kind of edge-cases. The only reason to require the types is so that people who develop with tedious (and need the types) don't get errors if they fail to install the node types themselves - that's entirely a development environment issue (hence my view this is a devDependency).
Unfortunately, I don't quite think this is right,(if you look at the Perhaps the middle-ground here is to add the typings as a peerDependency, which means devs get a hint that they need it installed, but the tedious package is not bloated with development packages in prod? |
To solve at least one of the problems of adding the types as deps instead of devDeps, in particular the types mismatch in case another version is used in the project root, you could define it as It doesn't solve the "bloat" in production, but types are usually removed in a project build step anyway, when the project is transpiled to JS |
@mShan0, @MichaelSun90 and I double checked, and If that changes in the future, we can re-visit this, but for now, I'd just go ahead and merge this in it's current state. |
🎉 This PR is included in version 18.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I could not run tests, as they expect a
.tedious/test-connection.json
to exist in my home folderI haven't changed anything into the code anyway, so that's not a big problem
Some notes:
your package-lock.json version is outdatedI noticed there's an recent PR to address that/src/
because you import the projectpackage.json
into one of your files and this automatically change TSrootDir
. Consider removing the following import to avoid this problemtedious/src/connection.ts
Line 48 in cbe31af
For everyone coming here to get updated types:
npm install
tedious/src/connection.ts
Line 48 in cbe31af
"declarationDir": "lib/types"
with"outFile": "lib/tedious.d.ts"
intotsconfig.build-types.json
npm run build:types
lib/tedious.d.ts
file into your project@types/es-aggregate-error
andnode-abort-controller
as devDependencies of your project