Skip to Content
Typescript Compatibility

TypeScript Compatibility

GenSX is designed to be compatible with TypeScript. This page has some tips and tricks for using GenSX with TypeScript.

Minimum TypeScript Version

GenSX requires TypeScript version 5.1 or higher.

TypeScript Configuration

  • target should be set to at least es6
  • module should be set to at least es6
  • jsx should be set to react-jsx
  • jsxImportSource should be set to @gensx/core

JSX Pragmas

If you are unable to change the jsx or jsxImportSource settings in your TypeScript configuration, you can use the following pragmas to enable GenSX:

/** @jsxRuntime automatic */ /** @jsxImportSource @gensx/core */

JavaScript Compatibility

GenSX is bundled with builds for both CommonJS and ESM. This means that you can use GenSX in any environment that supports either of these module formats.

When using GenSX in a TypeScript project that targets CommonJS, you may need to configure the paths so that the TypeScript compiler can properly resolve the GenSX types.

{ "compilerOptions": { "paths": { "@gensx/core/jsx-runtime": [ "./node_modules/@gensx/core/dist/cjs/jsx-runtime" ], "@gensx/core/jsx-dev-runtime": [ "./node_modules/@gensx/core/dist/cjs/jsx-dev-runtime", ], }, }, };
Last updated on