cjs-wrapper.d.ts drops all named exports and the Nylas class type under exports-map resolution
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- developer-experience
Hướng nghiên cứu
Bắt đầu với cjs-wrapper.d.ts, exports map và lib/types/nylas.d.ts để so sánh các entry point kiểu CommonJS và ESM. Chạy t.ts và tsconfig.json được cung cấp với cơ chế phân giải node16 và bundler, bao gồm cả khi tắt skipLibCheck; hoàn thành khi các consumer CommonJS vẫn giữ được các exports có tên và kiểu lớp Nylas mà không có lỗi khai báo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
cjs-wrapper.d.ts uses export =, so the export * from './lib/types/models/index.js' line above it has no effect. Any TypeScript config that resolves through the exports map with the require condition (moduleResolution node16, nodenext, or bundler with module: commonjs) loses every named export: NylasApiError, NylasSdkTimeoutError, NylasOAuthError, and all the model types. The default import also stops working as a type, because export = nylasExport where nylasExport is typeof Nylas exposes the constructor value, not the class.
The runtime wrapper is fine. require('nylas') does expose the error classes via the Object.assign. Only the typings are wrong.
This was masked under moduleResolution: node10, which ignores exports and reads the top-level types field (lib/types/nylas.d.ts). TypeScript 7 removed node10, so every CommonJS consumer hits this on upgrade.
To Reproduce
// t.ts
import Nylas, { NylasApiError, NylasSdkTimeoutError } from "nylas";
let client: Nylas | undefined;
{
"compilerOptions": {
"module": "node16",
"moduleResolution": "node16",
"target": "es2022",
"types": ["node"],
"skipLibCheck": true,
"noEmit": true
},
"files": ["t.ts"]
}
$ npx -p [email protected] tsc -p tsconfig.json
t.ts(1,17): error TS2305: Module '"nylas"' has no exported member 'NylasApiError'.
t.ts(1,32): error TS2305: Module '"nylas"' has no exported member 'NylasSdkTimeoutError'.
t.ts(2,13): error TS2749: 'Nylas' refers to a value, but is being used as a type here. Did you mean 'typeof Nylas'?
Same result with moduleResolution: bundler + module: commonjs. Same result on TypeScript 5.9.3 with node16. Passes on 5.9.3 with moduleResolution: node10.
With skipLibCheck off, the wrapper itself reports TS2309: An export assignment cannot be used in a module with other exported elements, which is the root cause.
Expected behavior
CommonJS consumers get the same named exports and the same Nylas class type as ESM consumers.
One way to do it: keep export = but merge the named exports into it with a namespace, so the wrapper stays require-compatible and the names come back:
import NylasClass from './lib/types/nylas.js';
import * as models from './lib/types/models/index.js';
declare const nylasExport: typeof NylasClass & typeof models;
export = nylasExport;
plus a declare namespace or type Nylas = NylasClass so the default import works as a type. Happy to open a PR if you want one.
SDK Version:
8.4.0 (also present on main as of today)
Additional context
Node 22, TypeScript 7.0.2 and 5.9.3.
- Ngôn ngữ chính
- TypeScript
- Star
- 180
- Fork
- 126
- Merge trung bình
- 4 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nylas/nylas-nodejs
-
Response body read errors bypass the SDK's typed error handlingCó thể làm lại được @radenkovic đã nhận 84 ngày trước và không có pull request nào đang mở. Đang mở
nylas/nylas-nodejs#757 · 1 người được giao ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
nylas/nylas-nodejs#755 ·
-
mock mode supportCó thể làm lại được @AaronDDM đã nhận 406 ngày trước và không có pull request nào đang mở. Đang mởenhancement
nylas/nylas-nodejs#462 · 1 bình luận · 1 reaction · 1 người được giao ·
Tất cả issue của nylas/nylas-nodejs
Issue tương tự
-
Area/Cloud Needs Triage Type/Bug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
wso2/product-integrator#2847 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
bluesky-social/social-app#12118 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
heygen-com/hyperframes#6021 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Edit: Tele Posadas HDĐang mởcheck:passed streams:edit
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày