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

unable to generate type alias containing an array of another type #153

Open
mnbf9rca opened this issue Aug 7, 2023 · 4 comments
Open

unable to generate type alias containing an array of another type #153

mnbf9rca opened this issue Aug 7, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@mnbf9rca
Copy link

mnbf9rca commented Aug 7, 2023

Bug description

unable to generate array type

Input

export namespace TfLResponse {

  export interface StopPoint {
    naptanId: string;
    // some other stuff
    }

  export interface StopPointArray extends Array<StopPoint> {}

}

i also tried the following but get the same error:

export namespace TfLResponse {

  export interface StopPoint {
    naptanId: string;
    // some other stuff
    }

  export type StopPointArray = StopPoint[];
}

Expected output

i expect the type to be generated:

export const tfLResponseStopPointSchema = z.object({
  naptanId: z.string(),
  // some other stuff
});
export const tfLResponseStopPointArraySchema = z.array(tfLResponseStopPointSchema);

Actual output

zod is giving me this warning, and the StopPointArray type is not being converted:

DeprecationWarning: 'updateInterfaceDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'updateTypeAliasDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
 ›   Warning: Some schemas can't be generated due to direct or indirect missing dependencies:
 ›   tfLResponseStopPointArraySchema
⠋ Validating generated typesDeprecationWarning: 'createTypeAliasDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an overload that does not accept a 'decorators' parameter.
✔ Validating generated types
🎉 Zod schemas generated!

Versions

  • Typescript: v5.1.6
  • Zod: v3.21.4
@fabien0102
Copy link
Owner

Interesting, this version is working:

export namespace TfLResponse {
  export interface StopPoint {
    naptanId: string;
    // some other stuff
  }

  export type StopPointArray = Array<StopPoint>;
}

Thanks for the issue!

@fabien0102
Copy link
Owner

export interface StopPoint {
  naptanId: string;
  // some other stuff
}

export type StopPointArray = StopPoint[];

This one is also working, so probably an issue around array + namespace

@mnbf9rca
Copy link
Author

mnbf9rca commented Aug 8, 2023

thanks for figuring something out :)

@imaitland
Copy link

imaitland commented Nov 13, 2023

Also ran into this issue.
namespace -> SomeType[] 🔴
namespace -> Array<SomeType> 🟢

@tvillaren tvillaren added the bug Something isn't working label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants