Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions tsc/internal/bundled/libs/lib.decorators.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@ interface ClassDecoratorContext<
*
* @example
* ```ts
* function customElement(name: string): ClassDecoratorFunction {
* return (target, context) => {
* function customElement(name: string) {
* return <Class extends CustomElementConstructor>(
* target: Class,
* context: ClassDecoratorContext<Class>,
* ) => {
* context.addInitializer(function () {
* customElements.define(name, this);
* });
* }
* };
* }
*
* @customElement("my-element")
* class MyElement {}
* class MyElement extends HTMLElement {}
* ```
*/
addInitializer(initializer: (this: Class) => void): void;
Expand Down Expand Up @@ -114,10 +117,14 @@ interface ClassMethodDecoratorContext<
*
* @example
* ```ts
* const bound: ClassMethodDecoratorFunction = (value, context) {
* function bound<This, Value extends (...args: any) => any>(
* value: Value,
* context: ClassMethodDecoratorContext<This, Value>,
* ) {
* if (context.private) throw new TypeError("Not supported on private methods.");
* context.addInitializer(function () {
* this[context.name] = this[context.name].bind(this);
* context.addInitializer(function (this: This) {
* const self = this as Record<PropertyKey, any>;
* self[context.name] = self[context.name].bind(this);
* });
* }
*
Expand Down