microsoft / microsoft/TypeScript
When using typeof for the interface, it is hoped that the jsdoc comments of the expression can inherit typeof by default
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
"typeof","jsdoc"
✅ 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
/** JSDoc1 */
const test = { a: 0 }
declare module 'vue' {
interface ComponentCustomProperties {
/** JSDoc2 */
testInInterface: typeof test,
}
}
const test2 = {
/** JSDoc3 */
test
}
I hope that when not writing JSDoc2 or JSDoc3, testInInterface and test2.test can have comments for const test in JSDoc1
📃 Motivating Example
The interface has the feature of declaring and merging, allowing developers to extend the interfaces defined in the component library. In front-end development, extending Vue's global components, directives, and properties is often used.
Taking a Vue component as an example, including its global and local usage schemes, there is currently a lack of JSDoc comments
- global
import vueComponentWithJsDoc from './test.vue'
declare module 'vue' {
interface GlobalComponents {
vueComponentWithoutJsDoc: typeof vueComponentWithJsDoc
}
}
- local
import vueComponentWithJsDoc from './test.vue'
import { defineComponent } from 'vue'
export default defineComponent({
components: { vueComponentWithoutJsDoc: vueComponentWithJsDoc }
})
When using components in the template, both of the above schemes lack JSDoc comments
<template>
<vue-component-without-js-doc />
</template>
💻 Use Cases
- JSDoc comments can be included when declaring a merge interface
- The type obtained by the typeof instance is missing the jsdoc annotation
- Manually copy a jsdoc comment onto the interface field
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
Reproduziere die Beispiele mit JSDoc1 auf test und vergleiche dann die fehlenden Kommentare bei testInInterface und test2.test. Die Änderung ist abgeschlossen, wenn Kommentare aus einem typeof-Ausdruck sowohl im Interface- als auch im Property-Access-Fall geerbt werden, ohne JSDoc2 oder JSDoc3 zu erfordern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100