Revisit JSX syntax
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 38/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript, ocaml
Direzione di ricerca
Inizia dalla documentazione sulle differenze di ReScript JSX e dalla specifica ufficiale JSX collegata nell’issue. Segui i punti di ingresso del formatter e del parser per determinare come vengono gestiti attualmente i figli JSX. Il lavoro sarà considerato completato quando il comportamento proposto di formatter e parser sarà definito e coperto per testo semplice, identificatori, espressioni e figli di componenti personalizzati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Proposal: Bring ReScript JSX Closer to the JavaScript JSX Spec
Currently, ReScript JSX differs from JavaScript’s JSX in a few key ways (docs).
I propose moving ReScript JSX closer to the official JSX spec in a future release.
Example
// Current
let foo = <p>{React.string("Hello")}</p>
// Proposed
let foo = <p>Hello</p>
Right now, Hello is treated as a React.element rather than as JSXText.
This means plain text inside JSX must be wrapped in React.string(...), unlike in JavaScript JSX.
Suggested Path Forward
Step 1: Formatter update
The formatter could automatically insert braces for identifiers used as children, making the output more consistent.
// Original
let foo = <p>children</p>
// After format
// (notice how there's no space before the opening curly brace and after the closing one)
let foo = <p>{children}</p>
Step 2: Parser update
Next, the parser could be extended to handle JSXText as valid child input—bringing ReScript JSX semantics in line with the JSX spec.
[!NOTE]
This change will only affect syntax and won't change the type of JSX children.
Inside curly braces you'll still need React.string:<div> {switch count { | 1 => "once" | n => `Int.toString(n) times` }->React.string} </div>This could also affect custom components where children are not typed as JSX element and that are often used with literals, eg before:
<Counter>6</Counter>after:
<Counter>{6}</Counter>
This is still an early-stage idea, so feedback is welcome. Don't hesitate to chime in if you think your codebase would be affected by this change.
Please use 👍 / 👎 / 👀 to indicate your opinion.
This is just a signal, not a binding vote.
- Lingua principale
- OCaml
- Stelle
- 7.5k
- Fork
- 485
- Merge medio
- 1g 2h
- PR unite (30g)
- 55
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.
Altre issue di rescript-lang/rescript
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
rescript-lang/rescript#8659 · 2 commenti · 2 reazioni ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
rescript-lang/rescript#8647 ·
-
rescript-lang/rescript#8632 · 1 assegnatario ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
rescript-lang/rescript#8624 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
rescript-lang/rescript#8596 · 2 commenti ·
Tutte le issue di rescript-lang/rescript
Issue simili
-
`String.Parser.chompUntilEndOr` leaves the column one short when it runs to the end past a newline Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
enhancement PyCDE
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
llvm:support
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
llvm/llvm-project#226296 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
abseil/abseil-cpp#2176 ·