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

Converting generic types does not go so well #123

Open
PerfectlyNormal opened this issue Jan 11, 2025 · 0 comments
Open

Converting generic types does not go so well #123

PerfectlyNormal opened this issue Jan 11, 2025 · 0 comments

Comments

@PerfectlyNormal
Copy link
Owner

Input:

public class OverridableDto<T>
{
    public T? Value { get; set; }
    public bool IsOverridden { get; set; }
}

public class ItemResponseDto
{
    public Guid OriginalId { get; set; }
    public OverridableDto<string> Name { get; set; }
}

Expected output:

export interface OverridableDto<T> {
   value?: T;
   isOverridden: boolean;
}

export const OverridableDtoSchema = z.object({
  value: z.any().nullable(), // Would actually be nice to have a better type here, but any works for now
  isOverridden: z.boolean(),
});

//

import { OverridableDto, OverridableDtoSchema } from './overridable-dto';
export interface ItemResponseDto {
  originalId: string;
  name: OverridableDto<string>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant