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 typescript@7.0.2 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.
Describe the bug
cjs-wrapper.d.tsusesexport =, so theexport * from './lib/types/models/index.js'line above it has no effect. Any TypeScript config that resolves through theexportsmap with therequirecondition (moduleResolutionnode16,nodenext, orbundlerwithmodule: commonjs) loses every named export:NylasApiError,NylasSdkTimeoutError,NylasOAuthError, and all the model types. The default import also stops working as a type, becauseexport = nylasExportwherenylasExportistypeof Nylasexposes the constructor value, not the class.The runtime wrapper is fine.
require('nylas')does expose the error classes via theObject.assign. Only the typings are wrong.This was masked under
moduleResolution: node10, which ignoresexportsand reads the top-leveltypesfield (lib/types/nylas.d.ts). TypeScript 7 removednode10, so every CommonJS consumer hits this on upgrade.To Reproduce
{ "compilerOptions": { "module": "node16", "moduleResolution": "node16", "target": "es2022", "types": ["node"], "skipLibCheck": true, "noEmit": true }, "files": ["t.ts"] }Same result with
moduleResolution: bundler+module: commonjs. Same result on TypeScript 5.9.3 withnode16. Passes on 5.9.3 withmoduleResolution: node10.With
skipLibCheckoff, the wrapper itself reportsTS2309: 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
Nylasclass type as ESM consumers.One way to do it: keep
export =but merge the named exports into it with a namespace, so the wrapper staysrequire-compatible and the names come back:plus a
declare namespaceortype Nylas = NylasClassso the default import works as a type. Happy to open a PR if you want one.SDK Version:
8.4.0 (also present on
mainas of today)Additional context
Node 22, TypeScript 7.0.2 and 5.9.3.