Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions fern/products/sdks/generators/typescript/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ const bar: MyRootType.Foo.Bar = {};
```
</ParamField>

<ParamField path="esmOnly" type="boolean" default="false" toc={true}>
Ships only the ECMAScript module (ESM) build of the generated package. By default, the generator publishes both CommonJS and ESM builds, which exposes consumers to the [dual package hazard](https://github.com/GeoffreyBooth/dual-package-hazard). When enabled, `package.json` sets `"type": "module"`, `main`, `module`, and `types` point at `./dist/esm/index.mjs` and `./dist/esm/index.d.mts`, the `exports` map (including subpackage exports) has no `require` conditions, and no `tsconfig.cjs.json` or `build:cjs` script is generated.
Comment thread
nerminamiller-postman marked this conversation as resolved.
Comment thread
nerminamiller-postman marked this conversation as resolved.

`esmOnly` can't be combined with `useLegacyExports: true` or `bundle: true`; generation fails with an error.

```yml title="generators.yml"
groups:
ts-sdk:
generators:
- name: fern-typescript-sdk
version: <Markdown src="/snippets/version-number-ts.mdx"/>
config:
esmOnly: true
```
</ParamField>

<ParamField path="exactOptionalPropertyTypes" type="boolean" default="false" toc={true}>
When enabled, every optional property in the generated SDK is emitted as `prop?: T | undefined`, and the generated `tsconfig` files enable TypeScript's [`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes) compiler option. This covers model types, inlined request types, client options, errors, and the `core/` utilities, so consumers whose own `tsconfig` sets `exactOptionalPropertyTypes: true` can use the SDK without type errors.

Expand Down
Loading