If we consider a scenario where there is a JavaScript class
/**
* @element my-element
*/
export class MyElement extends HTMLElement {
publicMethod() {}
/** @private */
privateMethod() {}
}
customElements.define('my-element', MyElement);
along with a declaration file that has been generated using declaration
and allowJs
:
export class MyElement extends HTMLElement {
publicMethod(): void;
/** @private */
privateMethod(): void
}
In addition, as part of a post-build script, this is concatenated to the declaration file:
declare global { interface HTMLElementTagNameMap { 'my-element': MyElement; } }
Now, when utilizing this element in a TypeScript file, accessing privateMethod
is available in autocomplete.
import 'my-element'
const me = document.createElement("my-element")
me.// autocompletes `privateMethod`
The question arises on how to direct tsc
to designate any methods, fields, or properties marked with the @private
JSDoc tag as private?