rescript-lang / rescript-lang/rescript

Variables with reserved keywords renamed in output, but not reflected in generated typescript

Aperta
#6,871 4 commenti 1 reazione 1 assegnatario Vedi su GitHub

@cometkim ci sta già lavorando.

Dal 26/7/2024.

Lingua principale
OCaml
Stelle
7.5k
Fork
485
Merge medio
1g 2h
PR unite (30g)
55

Descrizione

In our app, we have modules representing entity permissions.
e.g:

// Permissions.res
module Products = {
    let createNew = "createPermissionString"
    let viewExisting = "viewPermissionString"
    let delete = "deletePermissionString"
}

// Permissions.resi
module Products = {
   @genType let createNew: string
   @genType let viewExisting: string
   @genType let delete: string
}

However, because delete is a reserved keyword , the compiler instead renames delete to $$delete without reflecting this in the generated tsx file.

// Permissions.gen.tsx
export const Products_createNew: string = PermissionBS.Products.createNew;
export const Products_viewExisting: string = PermissionBS.Products.viewExisting;
export const Products_delete: string = PermissionBS.Products.delete;

Thus any usage of Products_delete in our typescript code would be undefined because we're not consuming PermissionBS.Products.$$delete.

Ideally, the developer avoids reserved keywords altogether, but if the compiler will allow and rename these, I'd expect the genTyped output to reflect any renaming done by the compiler.

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.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.