microsoft / microsoft/TypeScript
Expose MappedType in typescript.d.ts
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
🔍 Search Terms
mappedtype interface typeParameter constraintType templateType
✅ Viability Checklist
- 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. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
Coming over from typescript-eslint, we need to look at the properties on mapped types for the @typescript-eslint/no-unnecessary-type-parameters ("Golden Rule of Generics") rule. But, MappedType is marked as @internal in TypeScript's definition:
Could we have that interface be public, please? Even if all the fields other than constraintType, templateType, and typeParameter are switched to @internal. I don't know of a more sanctioned way to access those type properties. Is there one?
📃 Motivating Example
Marking MappedType as public would provide a way for type checker API consumers to reason about mapped types.
💻 Use Cases
See https://github.com/typescript-eslint/typescript-eslint/pull/8173 & https://github.com/typescript-eslint/typescript-eslint/pull/9530: in typescript-eslint, we need to access a few properties of mapped types to check if they're uses of a type parameter. We ended up writing our own interface MappedType extends ts.ObjectType:
interface MappedType extends ts.ObjectType {
typeParameter?: ts.Type; // #8173
constraintType?: ts.Type; // #9530
templateType?: ts.Type; // #9530
}
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 mit src/compiler/types.ts rund um das interne MappedType-Interface und vergleiche dessen aktuelle Felder mit der angeforderten öffentlichen API. Sieh dir die verknüpften Beispiele für typescript-eslint-Regeln an, um die Anforderungen der Verbraucher zu verstehen. Erledigt ist die Aufgabe, wenn MappedType über typescript.d.ts mit dem angeforderten Zugriff auf typeParameter, constraintType und templateType offengelegt wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 35/100