Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(typescript): alias imported types in (de)serialization schemas
This fixes an issue where a type imported in a (de)serialization schema has the same name as the exported schema, causing build errors. Without this fix, we'd have schemas generated looking like so: ```ts /** * This file was auto-generated by Fern from our API Definition. */ import * as serializers from "../../../index"; import * as Engine from "../../../../api/index"; import * as core from "../../../../core"; import { SecurityFinding } from "../../ocsf/resources/v110/resources/securityfinding/resources/classes/types/SecurityFinding"; export const SecurityFinding: core.serialization.ObjectSchema<serializers.SecurityFinding.Raw, Engine.SecurityFinding> = SecurityFinding; export declare namespace SecurityFinding { type Raw = SecurityFinding.Raw; } ``` The imported `SecurityFinding` type shares the same name as the serialization schema, which then causes build errors that are hard and awkward to fix in post processing of the generated source code. After this fix, the generated code looks like so: ```ts /** * This file was auto-generated by Fern from our API Definition. */ import * as serializers from "../../../index"; import * as Engine from "../../../../api/index"; import * as core from "../../../../core"; import { SecurityFinding as SecurityFindingType } from "../../ocsf/resources/v110/resources/securityfinding/resources/classes/types/SecurityFinding"; export const SecurityFinding: core.serialization.ObjectSchema<serializers.SecurityFinding.Raw, Engine.SecurityFinding> = SecurityFindingType; export declare namespace SecurityFinding { type Raw = SecurityFindingType.Raw; } ``` The added `Type` suffix ensures the names do not conflict, solving any build issues that would otherwise arise.
- Loading branch information