rescript-lang / rescript-lang/rescript
Emitted JS / Gentype double-escapes output
Nessuno ha ancora preso questa issue.
- Lingua principale
- OCaml
- Stelle
- 7.5k
- Fork
- 485
- Merge medio
- 1g 2h
- PR unite (30g)
- 55
Descrizione
Thank you for filing! Check list:
- Is it a bug? Usage questions should often be asked in the forum instead.
- Concise, focused, friendly issue title & description.
- A minimal, reproducible example.
- OS and browser versions, if relevant.
- Is it already fixed in master? Instructions
When using the @as attribute with a value containing escape sequences (e.g., @as("with\"dquote")), the generated JavaScript incorrectly double-escapes the string. Additionally the parser can't handle exotic identifiers with a \".
I found this while looking at #8086 and removing String.escaped from this line:
This existing test with an escaped double-quote \" in the @as annotation
Results it being double-escaped in the generated typescript types and javascript:
There's also a parser bug:
Error in @tests/gentype-react-example:
Syntax error!
/rescript-compiler/tests/gentype_tests/typescript-react-example/src/Records.res:135:11-17
133 ┆ @as("with\"dquote")
134 ┆ withDQuote: string,
135 ┆ \"with\"dquote2": string,
136 ┆ @as("with'squote")
137 ┆ withSQuote: string,
Did you forget a `,` here?
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da compiler/gentype/TranslateTypeDeclarations.ml, intorno alla riga 48, poi esamina i casi @as in tests/gentype_tests/typescript-react-example/src/Records.res e i relativi output generati .gen.tsx e .res.js. Esegui il test gentype esistente e riproduci entrambi i casi di virgolette con escape. Il lavoro è completato quando il JavaScript e il TypeScript generati non eseguono un doppio escape del valore e il parser accetta l'identificatore esotico.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, ocaml, typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 55/100