Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate identifier bug from typescript node SDK #5351

Open
MasterPtato opened this issue Dec 6, 2024 · 4 comments
Open

Duplicate identifier bug from typescript node SDK #5351

MasterPtato opened this issue Dec 6, 2024 · 4 comments
Labels
bug Issues reporting bugs. language/typescript product/sdk-generator Fern's SDK Generator that outputs client libraries in 7 languages

Comments

@MasterPtato
Copy link

CLI Version from fern.config.json

0.45.3

Generator & Version from generators.yml

fernapi/fern-typescript-browser-sdk 0.42.7

Minimal API Specification

Structure:

fern
├── definition
│   ├── pkg
│   │   └── __package__.yml
│   ├── pkg2
│   │   └── __package__.yml
│   └── api.yml
├── fern.config.json
└── generators.yml

pkg/__package__.yml

imports:
  foo2: ../pkg2/__package__.yml

types:
  Both:
    properties:
      prop1: Foo
      prop2: foo2.Foo

  Foo:
    properties:
      foo: string

pkg2/__package__.yml

types:
  Foo:
    properties:
      foo: string

api.yml

name: api
auth: bearer

generators.yml

default-group: public
groups:
  public:
    generators:
      - name: fernapi/fern-typescript-browser-sdk
        version: 0.42.7
        output:
          location: local-file-system
          path: ./gen/src

Actual Generated Code

generate command errors with

...

$ tsc
src/serialization/resources/pkg/types/Both.ts(8,10): error TS2300: Duplicate identifier 'Foo'.
src/serialization/resources/pkg/types/Both.ts(9,10): error TS2300: Duplicate identifier 'Foo'.

...

With config.outputSourceFiles = true the generate command succeeds but generates the invalid TS:

/**
 * This file was auto-generated by Fern from our API Definition.
 */

import * as serializers from "../../../index";
import * as FooApi from "../../../../api/index";
import * as core from "../../../../core";
import { Foo } from "./Foo";
import { Foo } from "../../pkg2/types/Foo";

export const Both: core.serialization.ObjectSchema<serializers.pkg.Both.Raw, FooApi.pkg.Both> =
    core.serialization.object({
        prop1: Foo,
        prop2: Foo,
    });

export declare namespace Both {
    interface Raw {
        prop1: Foo.Raw;
        prop2: Foo.Raw;
    }
}

Expected Generated Code

Something like

/**
 * This file was auto-generated by Fern from our API Definition.
 */

import * as serializers from "../../../index";
import * as FooApi from "../../../../api/index";
import * as core from "../../../../core";
import { Foo as Foo } from "./Foo";
import { Foo as pkg2__Foo } from "../../pkg2/types/Foo";

export const Both: core.serialization.ObjectSchema<serializers.pkg.Both.Raw, FooApi.pkg.Both> =
    core.serialization.object({
        prop1: Foo,
        prop2: pkg2__Foo,
    });

export declare namespace Both {
    interface Raw {
        prop1: Foo.Raw;
        prop2: pkg2__Foo.Raw;
    }
}

Environment Details (Optional)

Running with npx -p fern-api fern generate --local

Npx version: 9.6.6
Node version: v20.2.0 (the generator container seems to be using v20.18.1)

@MasterPtato MasterPtato added bug Issues reporting bugs. product/sdk-generator Fern's SDK Generator that outputs client libraries in 7 languages labels Dec 6, 2024
@dannysheridan
Copy link
Member

@MasterPtato we are no longer supporting fernapi/fern-typescript-browser-sdk as we have made the fernapi/fern-typescript-node-sdk browser and Node.js compatible.

Up to try this again on the latest version of the TypeScript SDK generator and see if this problem persists?

@MasterPtato
Copy link
Author

MasterPtato commented Dec 6, 2024

@dannysheridan Thanks for the reply, getting the same result with the typescript node SDK.

@MasterPtato we are no longer supporting fernapi/fern-typescript-browser-sdk as we have made the fernapi/fern-typescript-node-sdk browser and Node.js compatible.

Is there any reason the browser SDK is still getting published? https://hub.docker.com/r/fernapi/fern-typescript-browser-sdk/tags

@MasterPtato MasterPtato changed the title Duplicate identifier bug from typescript browser SDK Duplicate identifier bug from typescript node SDK Dec 6, 2024
@dannysheridan
Copy link
Member

good quesiton. cc @dsinghvi to help answer that.

@mstade
Copy link
Contributor

mstade commented Jan 8, 2025

This may be related to the issue described in PR #5085.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues reporting bugs. language/typescript product/sdk-generator Fern's SDK Generator that outputs client libraries in 7 languages
Development

No branches or pull requests

3 participants