Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

cjs-wrapper.d.ts drops all named exports and the Nylas class type under exports-map resolution

Aperta
#760 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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

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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nylas/nylas-nodejs

Tutte le issue di nylas/nylas-nodejs

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.