microsoft / microsoft/TypeScript

When using typeof for the interface, it is hoped that the jsdoc comments of the expression can inherit typeof by default

Aperta
#60,403 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Experience Enhancement Help Wanted Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔍 Search Terms

"typeof","jsdoc"

✅ Viability Checklist
⭐ 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
  1. JSDoc comments can be included when declaring a merge interface
  2. The type obtained by the typeof instance is missing the jsdoc annotation
  3. Manually copy a jsdoc comment onto the interface field

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci gli esempi usando JSDoc1 su test, quindi confronta i commenti mancanti su testInInterface e test2.test. La modifica è completa quando i commenti di un’espressione typeof vengono ereditati sia nei casi di interfaccia sia in quelli di accesso a una proprietà, senza richiedere JSDoc2 o JSDoc3.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, 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
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.