Skip to content

fix type exports #546

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

Merged
merged 1 commit into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/dl-center/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the module resolution settings you pass to the ts compiler settings it might fall back to the types at the root level or it might not. With node16 rules it now tells you about the types at the root level, but doesn't use it. 🙄 I don't think it affects every package because we don't use them all in mongosh, but I figured for consistency I'm just specifying the types everywhere we specify exports. We already did it in a bunch of packages anyway.

},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions packages/dl-center/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './download-center';
export * from './download-center-config';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a line in mongosh that's importing from '@mongodb-js/dl-center/dist/download-center-config' which was never great, but now breaks with ts compiler options "module": "node16",
"moduleResolution": "node16"

3 changes: 2 additions & 1 deletion packages/download-url/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"main": "lib/index.js",
"exports": {
"require": "./lib/index.js",
"import": "./.esm-wrapper.mjs"
"import": "./.esm-wrapper.mjs",
"types": "./lib/index.d.ts"
},
"typings": "lib/index.d.ts",
"bin": {
Expand Down
3 changes: 2 additions & 1 deletion packages/get-os-info/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/mongodb-cloud-info/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/mongodb-constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/mongodb-downloader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/mongodb-redact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/mongodb-ts-autocomplete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With new ts compiler options:

src/index.ts:428:5 - error TS7016: Could not find a declaration file for module '@mongodb-js/mongodb-ts-autocomplete'. '/Users/leroux.bodenstein/mongo/mongosh/packages/autocomplete/node_modules/@mongodb-js/mongodb-ts-autocomplete/dist/.esm-wrapper.mjs' implicitly has an 'any' type.
  There are types at '/Users/leroux.bodenstein/mongo/mongosh/packages/autocomplete/node_modules/@mongodb-js/mongodb-ts-autocomplete/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@mongodb-js/mongodb-ts-autocomplete' library may need to update its package.json or typings.

I just changed the others where we had types at the top but not inside exports too. It is a bit of a mixed bag across the packages.

},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/mql-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"main": "dist/index.js",
"exports": {
"./schema": {
"types": "./dist/schema/schema.d.ts"
"types": "./out/schema.d.ts"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We missed this in the mql typescript PR. dist/schema/schema.d.ts is not a thing. We write the schema to out. So this export is not working when imported from mongosh:

src/collection.ts:99:27 - error TS2307: Cannot find module '@mongodb-js/mql-typescript/schema' or its corresponding type declarations.

99 import type * as mql from '@mongodb-js/mql-typescript/schema';

}
},
"types": "./dist/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion packages/node-webpack-startup-snapshot-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"bin": {
Expand Down
3 changes: 2 additions & 1 deletion packages/oidc-http-server-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/oidc-mock-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/query-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/sbom-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/signing-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/ts-autocomplete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"main": "dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./dist/.esm-wrapper.mjs"
"import": "./dist/.esm-wrapper.mjs",
"types": "./dist/index.d.ts"
},
"types": "./dist/index.d.ts",
"scripts": {
Expand Down