cjs-wrapper.d.ts drops all named exports and the Nylas class type under exports-map resolution
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- developer-experience
Direzione di ricerca
Inizia da cjs-wrapper.d.ts, dalla mappa degli exports e da lib/types/nylas.d.ts per confrontare gli entry point dei tipi CommonJS ed ESM. Esegui i t.ts e tsconfig.json forniti con la risoluzione node16 e bundler, incluso skipLibCheck disattivato; il lavoro è completato quando i consumer CommonJS conservano gli exports denominati e il tipo della classe Nylas senza errori di dichiarazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 180
- Fork
- 126
- Merge medio
- 4g 6h
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nylas/nylas-nodejs
-
Response body read errors bypass the SDK's typed error handlingForse di nuovo libera @radenkovic l’ha presa 83 giorni fa e non c’è nessuna pull request aperta. Aperta
nylas/nylas-nodejs#757 · 1 assegnatario ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
nylas/nylas-nodejs#755 ·
-
mock mode supportForse di nuovo libera @AaronDDM l’ha presa 404 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
nylas/nylas-nodejs#462 · 1 commento · 1 reazione · 1 assegnatario ·
Tutte le issue di nylas/nylas-nodejs
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
simkimsia/netlify-axi#19 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
subhranshudash13-dotcom/Contribo#74 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement frontend good first issue Stellar Wave trivial
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Godgift-care/sci-healthcare-frontend#166 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue security Stellar Wave trivial
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
Godgift-care/sci-healthcare-backend#171 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno