microsoft / microsoft/TypeScript
Declare type to be an import depending on a string literal argument: typeof import(name);
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
Hello,
It's seems to be difficult to do but there's now a lot of possibilities with the typescript compiler that I wouldn't have thought possible before, so I prefer to ask.
Is there a chance to have this kind of definition:
declare function require(name: string): typeof import(name) | undefined;
I mean declaring the return type as the type coming from the import of module "name". So we could have the type returned by require:
var module = require("my module");
I guess if it's feasible, it will also be possible to add more typing on this kind of javascript code
define("myModule, ["deps1", "deps2", "deps3"], (deps1, deps2, deps3) => {
// deps1, deps2, deps3 have the right type !!
});
like this
define("myModule, ["deps1", "deps2", "deps3"], (deps1: typeof import("deps1"), deps2: typeof import("deps2"), deps3: : typeof import("deps3")) => {
// deps1, deps2, deps3 have the right type !!
});
Thanks for your help,
--
Laurent
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit zu untersuchen, ob der TypeScript-Compiler typeof import(name) von einem Stringliteral abhängig machen und dieses Ergebnis für require- und define-Aufrufe verwenden kann. Prüfe die Beispiele des Issues und ermittle die erforderlichen Änderungen an Sprache und Typprüfung; abgeschlossen wäre dies, wenn die angeforderten Modultypen aus Literalargumenten abgeleitet werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100