Enhance type definition for XMLParser `isArray` option when using TypeScript
I maintainer di solito rispondono entro 4 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript, typescript
- Ambito
- developer-experience
Direzione di ricerca
Inizia dalla definizione del tipo XMLParser per l’opzione isArray e confrontala con l’esempio collegato di TypeScript Playground. Aggiorna i tipi in modo che jPath true o undefined selezioni string e jPath false selezioni Matcher, quindi verifica che gli utenti TypeScript non abbiano più bisogno di controlli condizionali o asserzioni.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
- Are you running the latest version?
- Have you included sample input, output, error, and expected output?
- Have you checked if you are using correct configuration?
- Did you try online tool?
- Have you checked the docs for helpful APIs and examples?
Description
When creating an instance of XMLParser using the isArray option, the method arguments are currently defined as the following, with the jPathOrMatcher argument being either a string or Matcher type:
The behaviour as documented is that if the jPath option is set to true (or undefined since the default is true), then the type of jPathOrMatcher will be a string, and if jPath is false then the type of jPathOrMatcher will be a Matcher.
However, since the type of jPathOrMatcher is currently string | Matcher, to satisfy TypeScript I either have to add unnecessary conditional logic to check whether the type is string or Matcher, or add in a type assertion like (jPathOrMatcher as string).includes("blah").
I would like to propose updating the types so that it can smartly detect whether the jPath option is true or false, and set the type of isArray based on that. I've found that this can be achieved using union types, and I have a minimal working example using the TypeScript Playground:
Would you like to work on this issue?
- Yes
- No
Bookmark this repository for further updates. Visit SoloThought to know about recent features.
- Lingua principale
- JavaScript
- Stelle
- 3.1k
- Fork
- 400
- Merge medio
- 3g 9h
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi 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 NaturalIntelligence/fast-xml-parser
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
NaturalIntelligence/fast-xml-parser#890 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
NaturalIntelligence/fast-xml-parser#888 · 2 commenti ·
I maintainer di solito rispondono entro 4 giorni
-
ignoreDeclaration does not ignore lower case doctype declarationForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NaturalIntelligence/fast-xml-parser#870 · 2 commenti ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
NaturalIntelligence/fast-xml-parser#892 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
Feature-Request
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
NaturalIntelligence/fast-xml-parser#779 · 9 commenti ·
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di NaturalIntelligence/fast-xml-parser
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
subhranshudash13-dotcom/Contribo#74 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 67/100
ThatGuySam/doesitarm#1114 ·
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
laaielichter/Reverseport#44 ·
I maintainer di solito rispondono entro 1 giorno
-
failed for an unknown reason
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
OpenTermsArchive/contrib-declarations#4148 ·
I maintainer di solito rispondono entro 1 giorno