fern icon indicating copy to clipboard operation
fern copied to clipboard

[Bug] Compile issue in generated typescript files

Open miwurster opened this issue 1 year ago • 1 comments

Describe the bug I'm trying to use the typescript-sdk generator. Everything worked fine so far, however I get a syntax/compile issue in the entries.ts file:

> src/sdk/core/schemas/utils/entries.ts:2:27 - error TS2769: No overload matches this call.
>       Overload 1 of 2, '(o: { [s: string]: T[keyof T]; } | ArrayLike<T[keyof T]>): [string, T[keyof T]][]', gave the following error.
>         Argument of type 'T' is not assignable to parameter of type '{ [s: string]: T[keyof T]; } | ArrayLike<T[keyof T]>'.
>           Type 'T' is not assignable to type 'ArrayLike<T[keyof T]>'.
>       Overload 2 of 2, '(o: {}): [string, any][]', gave the following error.
>         Argument of type 'T' is not assignable to parameter of type '{}'.
> 
>     2     return Object.entries(object) as [keyof T, T[keyof T]][];
>                                 ~~~~~~
> 
>       src/sdk/core/schemas/utils/entries.ts:1:25
>         1 export function entries<T>(object: T): [keyof T, T[keyof T]][] {
>                                   ~
>         This type parameter might need an `extends ArrayLike<T[keyof T]>` constraint.
>       src/sdk/core/schemas/utils/entries.ts:1:25
>         1 export function entries<T>(object: T): [keyof T, T[keyof T]][] {
>                                   ~
>         This type parameter might need an `extends { [s: string]: T[keyof T]; } | ArrayLike<T[keyof T]>` constraint.
>       src/sdk/core/schemas/utils/entries.ts:1:25
>         1 export function entries<T>(object: T): [keyof T, T[keyof T]][] {
>                                   ~
>         This type parameter might need an `extends {}` constraint.

To Reproduce Steps to reproduce the behavior:

  1. Setup a fern project with the following config:
default-group: local
groups:
  local:
    generators:
      - name: fernapi/fern-typescript-node-sdk
        version: 0.8.13
        output:
          location: local-file-system
          path: ../generated/typescript
        config:
          outputSourceFiles: true
          includeCredentialsOnCrossOriginRequests: true
  1. Use the attached OpenAPI spec: openapi.yml.zip
  2. Generate the client and try to use the SDK client

Expected behavior No such compile/syntax errors

Versions

miwurster avatar Dec 11 '23 16:12 miwurster

I managed to fix the affected files manually (quick and dirty):

image

miwurster avatar Dec 11 '23 16:12 miwurster