microsoft / microsoft/TypeScript
Extract function parameters or change function return type in mapped types
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
Search Terms
extract function parameters
change function return type
Suggestion
Allow mapped types to change the return type of a function
Use Cases
I am writing a mocking framework. My system under test might be like this:
MyClass{
myClassFunction(paramOne: string, paramTwo: number): string{}
}
but in my mocking framework I want to do this:
mockedObject
.withFunction("myClassFunction")
.withParameters("paramOneValue", 123)
.wasCalled();
to do the withParameters I need to type a function with the same parameters as defined on my class but with a different return type.
Checklist
My suggestion meets these guidelines:
[ ] This wouldn't be a breaking change in existing TypeScript / JavaScript code
[ ] This wouldn't change the runtime behavior of existing JavaScript code
[ ] This could be implemented without emitting different JS based on the types of the expressions
[ ] This isn't a runtime feature (e.g. new expression-level syntax)
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 esaminando le funzionalità di TypeScript relative a mapped types e function types usando l'esempio di mocking-framework. Determina come esprimere l'estrazione dei parametri e la sostituzione del tipo restituito, preservando al contempo il comportamento esistente di TypeScript e JavaScript. Il lavoro è completo quando la trasformazione di tipo richiesta è supportata e i parametri della funzione mockata dell'esempio vengono verificati correttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100