| 1 |
/** |
| 2 |
* @license |
| 3 |
* Copyright 2024 Google LLC |
| 4 |
* SPDX-License-Identifier: BSD-3-Clause |
| 5 |
*/ |
| 6 |
|
| 7 |
import {LitElement} from 'lit'; |
| 8 |
|
| 9 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 10 |
type Constructor<T> = new (...args: any[]) => T; |
| 11 |
|
| 12 |
/** |
| 13 |
* Mixin with no parameters |
| 14 |
* @mixin |
| 15 |
*/ |
| 16 |
export const MixinWithoutParams = () => { |
| 17 |
class Mixed extends LitElement { |
| 18 |
boop() { |
| 19 |
return 808; |
| 20 |
} |
| 21 |
} |
| 22 |
return Mixed; |
| 23 |
}; |
| 24 |
|
| 25 |
/** |
| 26 |
* Mixin with literal body |
| 27 |
* @mixin |
| 28 |
*/ |
| 29 |
export const MixinWithLiteralBody = <T extends Constructor<LitElement>>( |
| 30 |
_superClass: T |
| 31 |
) => 5; |
| 32 |
|
| 33 |
/** |
| 34 |
* Mixin without a class declaration |
| 35 |
* @mixin |
| 36 |
*/ |
| 37 |
export const MixinWithoutClass = <T extends Constructor<LitElement>>( |
| 38 |
superClass: T |
| 39 |
) => { |
| 40 |
return superClass; |
| 41 |
}; |
| 42 |
|
| 43 |
/** |
| 44 |
* Mixin without a return value |
| 45 |
* @mixin |
| 46 |
*/ |
| 47 |
export const MixinWithoutReturn = <T extends Constructor<LitElement>>( |
| 48 |
superClass: T |
| 49 |
) => { |
| 50 |
// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 51 |
class Mixed extends superClass {} |
| 52 |
}; |
| 53 |
|
| 54 |
/** |
| 55 |
* Mixin with a class decl with no extends |
| 56 |
* @mixin |
| 57 |
*/ |
| 58 |
export const MixinWithoutExtends = <T extends Constructor<LitElement>>( |
| 59 |
_superClass: T |
| 60 |
) => { |
| 61 |
class Mixed {} |
| 62 |
return Mixed; |
| 63 |
}; |
| 64 |
|
| 65 |
/** |
| 66 |
* Mixin without a superclass param |
| 67 |
* @mixin |
| 68 |
*/ |
| 69 |
export const MixinWithoutSuperParam = <T extends Constructor<LitElement>>( |
| 70 |
_notASuperClass: T |
| 71 |
) => { |
| 72 |
class Mixed extends LitElement {} |
| 73 |
return Mixed; |
| 74 |
}; |