Skip to main content

TS1295 and TS1287: ECMAScript imports and exports cannot be written in a CommonJS file

If your tsconfig.json file sets "verbatimModuleSyntax": true, compiling a W&B Weave CommonJS project (per the TypeScript SDK integration guide) fails with:
The setting defaults to false, which the TypeScript SDK integration guide assumes. Set the verbatimModuleSyntax field to false alongside your CommonJS module setting:
"verbatimModuleSyntax": false allows ESM-style import/export syntax in your source files while TypeScript still emits CommonJS output. For details, see TypeScript - Verbatim Module Syntax. TypeScript