Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Enum types are not being generated by the Typescript Generator

Aperta
#366 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
php, typescript
Ambito
tooling

Direzione di ricerca

Inizia con il comando documentato npm init @api-platform/client usando il generatore TypeScript e un’entità come Person con l’enum Gender mostrato. Esamina l’interfaccia Person generata e traccia come la proprietà gender diventa any. Il lavoro è completato quando l’output generato rappresenta i valori dell’enum e usa quell’enum nell’interfaccia invece di any.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

API Platform version(s) affected: 3.0

Description
I'm using the Typescript Generator to generate some interfaces and I have some enum types in the Entity, for example:

<?php
//Enum
namespace App\Enum;

enum Gender: string
{
    case FEMALE = 'female';
    case MALE = 'male';
}
<?php
// Entity
class Person
{
    ...
    #[ORM\Column(type: "string", length: 6, nullable: true, enumType: Gender::class)]
    private $gender;
    ...

but when I generate the interfaces, they are generated as type any.

How to reproduce
Create an entity with an enum type. Use the Typescript generator to generate the corresponding interface:

npm init @api-platform/client http://localhost/api src/ -- --generator typescript

The interface generated will be of type any instead of having the proper enum type:

export interface Person {
 ...
 gender?: any;
 ...
}

Possible Solution

The generator should generate the corresponding enum and implement it in the interface:

export interface Person {
 ...
 gender?: gender;
 ...
}

export enum gender {
    FEMALE = 'female',
    MALE = 'male',
}

Additional Context

Lingua principale
TypeScript
Stelle
376
Fork
132
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di api-platform/create-client

Tutte le issue di api-platform/create-client

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.