{"componentChunkName":"component---src-templates-documentation-tsx","path":"/docs/handbook/mixins.html","result":{"data":{"allSitePage":{"nodes":[{"path":"/dev-404-page/"},{"path":"/docs/handbook/nightly-builds.html"},{"path":"/docs/handbook/declaration-files/by-example.html"},{"path":"/docs/handbook/declaration-files/consumption.html"},{"path":"/docs/handbook/declaration-files/deep-dive.html"},{"path":"/docs/handbook/declaration-files/do-s-and-don-ts.html"},{"path":"/docs/handbook/declaration-files/introduction.html"},{"path":"/docs/handbook/declaration-files/library-structures.html"},{"path":"/docs/handbook/declaration-files/publishing.html"},{"path":"/docs/handbook/declaration-files/templates.html"},{"path":"/docs/handbook/typescript-in-5-minutes-func.html"},{"path":"/docs/handbook/typescript-in-5-minutes.html"},{"path":"/docs/handbook/typescript-in-5-minutes-oop.html"},{"path":"/docs/handbook/typescript-from-scratch.html"},{"path":"/docs/handbook/basic-types.html"},{"path":"/docs/handbook/classes.html"},{"path":"/docs/handbook/enums.html"},{"path":"/docs/handbook/functions.html"},{"path":"/docs/handbook/generics.html"},{"path":"/docs/handbook/interfaces.html"},{"path":"/docs/handbook/literal-types.html"},{"path":"/docs/handbook/intro.html"},{"path":"/docs/handbook/unions-and-intersections.html"},{"path":"/docs/handbook/declaration-files/dts-from-js.html"},{"path":"/docs/handbook/intro-to-js-ts.html"},{"path":"/docs/handbook/jsdoc-supported-types.html"},{"path":"/docs/handbook/type-checking-javascript-files.html"},{"path":"/docs/handbook/compiler-options-in-msbuild.html"},{"path":"/docs/handbook/compiler-options.html"},{"path":"/docs/handbook/configuring-watch.html"},{"path":"/docs/handbook/integrating-with-build-tools.html"},{"path":"/docs/handbook/project-references.html"},{"path":"/docs/handbook/tsconfig-json.html"},{"path":"/docs/handbook/advanced-types.html"},{"path":"/docs/handbook/declaration-merging.html"},{"path":"/docs/handbook/decorators.html"},{"path":"/docs/handbook/iterators-and-generators.html"},{"path":"/docs/handbook/jsx.html"},{"path":"/docs/handbook/mixins.html"},{"path":"/docs/handbook/module-resolution.html"},{"path":"/docs/handbook/modules.html"},{"path":"/docs/handbook/namespaces-and-modules.html"},{"path":"/docs/handbook/namespaces.html"},{"path":"/docs/handbook/symbols.html"},{"path":"/docs/handbook/triple-slash-directives.html"},{"path":"/docs/handbook/type-compatibility.html"},{"path":"/docs/handbook/type-inference.html"},{"path":"/docs/handbook/utility-types.html"},{"path":"/docs/handbook/variable-declarations.html"},{"path":"/docs/handbook/release-notes/typescript-1-1.html"},{"path":"/docs/handbook/release-notes/typescript-1-3.html"},{"path":"/docs/handbook/release-notes/typescript-1-4.html"},{"path":"/docs/handbook/release-notes/typescript-1-5.html"},{"path":"/docs/handbook/release-notes/typescript-1-6.html"},{"path":"/docs/handbook/release-notes/typescript-1-7.html"},{"path":"/docs/handbook/release-notes/typescript-1-8.html"},{"path":"/docs/handbook/release-notes/typescript-2-0.html"},{"path":"/docs/handbook/release-notes/typescript-2-1.html"},{"path":"/docs/handbook/release-notes/typescript-2-2.html"},{"path":"/docs/handbook/release-notes/typescript-2-3.html"},{"path":"/docs/handbook/release-notes/typescript-2-4.html"},{"path":"/docs/handbook/release-notes/typescript-2-5.html"},{"path":"/docs/handbook/release-notes/typescript-2-6.html"},{"path":"/docs/handbook/release-notes/typescript-2-7.html"},{"path":"/docs/handbook/release-notes/typescript-2-8.html"},{"path":"/docs/handbook/release-notes/typescript-2-9.html"},{"path":"/docs/handbook/release-notes/typescript-3-0.html"},{"path":"/docs/handbook/release-notes/typescript-3-1.html"},{"path":"/docs/handbook/release-notes/typescript-3-2.html"},{"path":"/docs/handbook/release-notes/typescript-3-3.html"},{"path":"/docs/handbook/release-notes/typescript-3-4.html"},{"path":"/docs/handbook/release-notes/typescript-3-5.html"},{"path":"/docs/handbook/release-notes/typescript-3-6.html"},{"path":"/docs/handbook/release-notes/typescript-3-7.html"},{"path":"/docs/handbook/release-notes/typescript-3-8.html"},{"path":"/docs/handbook/release-notes/typescript-3-9.html"},{"path":"/docs/handbook/asp-net-core.html"},{"path":"/docs/handbook/angular.html"},{"path":"/docs/handbook/babel-with-typescript.html"},{"path":"/docs/handbook/dom-manipulation.html"},{"path":"/docs/handbook/gulp.html"},{"path":"/docs/handbook/migrating-from-javascript.html"},{"path":"/docs/handbook/react.html"},{"path":"/docs/handbook/typescript-tooling-in-5-minutes.html"},{"path":"/vo/docs/handbook/basic-types.html"},{"path":"/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/global-plugin-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/global-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-class-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-function-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-plugin-d-ts.html"},{"path":"/docs/handbook/declaration-files/templates/module-d-ts.html"},{"path":"/docs/handbook/release-notes/overview.html"},{"path":"/tsconfig"},{"path":"/en/tsconfig"},{"path":"/vo/tsconfig"},{"path":"/ja/tsconfig"},{"path":"/pt/tsconfig"},{"path":"/play"},{"path":"/en/play"},{"path":"/es/play"},{"path":"/ja/play"},{"path":"/pt/play"},{"path":"/vo/play"},{"path":"/zh/play"},{"path":"/fa/play"},{"path":"/play/3-7/fixits/big-number-literals.ts"},{"path":"/play/3-7/fixits/const-to-let.ts"},{"path":"/play/3-7/fixits/infer-from-usage-changes.ts"},{"path":"/play/3-7/syntax-and-messaging/flattened-error-reporting.ts"},{"path":"/play/3-7/syntax-and-messaging/nullish-coalescing.ts"},{"path":"/play/3-7/syntax-and-messaging/optional-chaining.ts"},{"path":"/play/3-7/types-and-code-flow/assertion-functions.ts"},{"path":"/play/3-7/types-and-code-flow/recursive-type-references.ts"},{"path":"/play/3-7/types-and-code-flow/uncalled-function-checks.ts"},{"path":"/play/3-8/breaking-changes/checking-unions-with-index-signatures.ts"},{"path":"/play/3-8/jsdoc-improvements/accessibility-modifiers.js"},{"path":"/play/3-8/syntax-and-messaging/export-modules-from.ts"},{"path":"/play/3-8/syntax-and-messaging/private-class-fields.ts"},{"path":"/play/4-0/new-checks/class-constructor-code-flow.ts"},{"path":"/play/4-0/new-js-features/jsdoc-deprecated.ts"},{"path":"/play/4-0/new-js-features/logical-operators-and-assignment.ts"},{"path":"/play/4-0/new-js-features/nullish-coalescing.ts"},{"path":"/play/4-0/new-ts-features/named-tuples.ts"},{"path":"/play/4-0/new-ts-features/unknown-in-catch.ts"},{"path":"/play/4-0/new-ts-features/variadic-tuples.ts"},{"path":"/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/play/javascript/external-apis/typescript-with-node.js"},{"path":"/play/javascript/external-apis/typescript-with-web.js"},{"path":"/play/javascript/external-apis/typescript-with-webgl.js"},{"path":"/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/play/javascript/functions-with-javascript/typing-functions.ts"},{"path":"/play/javascript/helping-with-javascript/errors.ts"},{"path":"/play/javascript/helping-with-javascript/quick-fixes.ts"},{"path":"/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/play/javascript/javascript-essentials/functions.ts"},{"path":"/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/play/javascript/modern-javascript/async-await.ts"},{"path":"/play/javascript/modern-javascript/immutability.ts"},{"path":"/play/javascript/modern-javascript/import-export.ts"},{"path":"/play/javascript/modern-javascript/jsdoc-support.js"},{"path":"/play/javascript/working-with-classes/classes-101.ts"},{"path":"/play/javascript/working-with-classes/generic-classes.ts"},{"path":"/play/javascript/working-with-classes/mixins.ts"},{"path":"/play/javascript/working-with-classes/this.ts"},{"path":"/play/playground/config/javascript-playgrounds.js"},{"path":"/play/playground/config/new-compiler-defaults.ts"},{"path":"/play/playground/language/automatic-type-acquisition.ts"},{"path":"/play/playground/language/fixits.ts"},{"path":"/play/playground/tooling/mobile-support.ts"},{"path":"/play/playground/tooling/sharable-urls.ts"},{"path":"/play/playground/tooling/typescript-versions.ts"},{"path":"/play/typescript/language/soundness.ts"},{"path":"/play/typescript/language/structural-typing.ts"},{"path":"/play/typescript/language/type-guards.ts"},{"path":"/play/typescript/language/type-widening-and-narrowing.ts"},{"path":"/play/typescript/language-extensions/enums.ts"},{"path":"/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/play/typescript/meta-types/conditional-types.ts"},{"path":"/play/typescript/meta-types/discriminate-types.ts"},{"path":"/play/typescript/meta-types/indexed-types.ts"},{"path":"/play/typescript/meta-types/mapped-types.ts"},{"path":"/play/typescript/primitives/any.ts"},{"path":"/play/typescript/primitives/literals.ts"},{"path":"/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/play/typescript/primitives/unknown-and-never.ts"},{"path":"/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/play/typescript/type-primitives/nullable-types.ts"},{"path":"/play/typescript/type-primitives/tuples.ts"},{"path":"/es/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/es/play/javascript/external-apis/typescript-with-node.js"},{"path":"/es/play/javascript/external-apis/typescript-with-web.js"},{"path":"/es/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/es/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/es/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/es/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/es/play/typescript/language/soundness.ts"},{"path":"/es/play/typescript/language/structural-typing.ts"},{"path":"/es/play/typescript/language/type-guards.ts"},{"path":"/es/play/typescript/language/type-widening-and-narrowing.ts"},{"path":"/es/play/typescript/meta-types/conditional-types.ts"},{"path":"/es/play/typescript/meta-types/discriminate-types.ts"},{"path":"/es/play/typescript/meta-types/indexed-types.ts"},{"path":"/es/play/typescript/meta-types/mapped-types.ts"},{"path":"/es/play/typescript/primitives/any.ts"},{"path":"/es/play/typescript/primitives/literals.ts"},{"path":"/es/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/es/play/typescript/primitives/unknown-and-never.ts"},{"path":"/es/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/es/play/typescript/type-primitives/nullable-types.ts"},{"path":"/es/play/typescript/type-primitives/tuples.ts"},{"path":"/fa/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/ja/play/3-7/fixits/big-number-literals.ts"},{"path":"/ja/play/3-7/syntax-and-messaging/nullish-coalescing.ts"},{"path":"/ja/play/3-7/syntax-and-messaging/optional-chaining.ts"},{"path":"/ja/play/3-8/breaking-changes/checking-unions-with-index-signatures.ts"},{"path":"/ja/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/ja/play/typescript/language-extensions/enums.ts"},{"path":"/ja/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/ja/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/ja/play/typescript/primitives/any.ts"},{"path":"/ja/play/typescript/primitives/literals.ts"},{"path":"/ja/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/ja/play/typescript/primitives/unknown-and-never.ts"},{"path":"/ja/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/ja/play/typescript/type-primitives/nullable-types.ts"},{"path":"/ja/play/typescript/type-primitives/tuples.ts"},{"path":"/pt/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/pt/play/javascript/javascript-essentials/functions.ts"},{"path":"/pt/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/pt/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/vo/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/vo/play/javascript/javascript-essentials/functions.ts"},{"path":"/vo/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/vo/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/zh/play/javascript/external-apis/typescript-with-deno.ts"},{"path":"/zh/play/javascript/external-apis/typescript-with-node.js"},{"path":"/zh/play/javascript/external-apis/typescript-with-web.js"},{"path":"/zh/play/javascript/external-apis/typescript-with-webgl.js"},{"path":"/zh/play/javascript/functions-with-javascript/function-chaining.ts"},{"path":"/zh/play/javascript/functions-with-javascript/generic-functions.ts"},{"path":"/zh/play/javascript/functions-with-javascript/typing-functions.ts"},{"path":"/zh/play/javascript/helping-with-javascript/errors.ts"},{"path":"/zh/play/javascript/helping-with-javascript/quick-fixes.ts"},{"path":"/zh/play/javascript/javascript-essentials/code-flow.ts"},{"path":"/zh/play/javascript/javascript-essentials/functions.ts"},{"path":"/zh/play/javascript/javascript-essentials/hello-world.ts"},{"path":"/zh/play/javascript/javascript-essentials/objects-and-arrays.ts"},{"path":"/zh/play/javascript/modern-javascript/async-await.ts"},{"path":"/zh/play/javascript/modern-javascript/immutability.ts"},{"path":"/zh/play/javascript/modern-javascript/import-export.ts"},{"path":"/zh/play/javascript/modern-javascript/jsdoc-support.js"},{"path":"/zh/play/javascript/working-with-classes/classes-101.ts"},{"path":"/zh/play/javascript/working-with-classes/generic-classes.ts"},{"path":"/zh/play/javascript/working-with-classes/mixins.ts"},{"path":"/zh/play/javascript/working-with-classes/this.ts"},{"path":"/zh/play/playground/config/javascript-playgrounds.js"},{"path":"/zh/play/playground/config/new-compiler-defaults.ts"},{"path":"/zh/play/playground/language/automatic-type-acquisition.ts"},{"path":"/zh/play/playground/language/fixits.ts"},{"path":"/zh/play/playground/tooling/mobile-support.ts"},{"path":"/zh/play/playground/tooling/sharable-urls.ts"},{"path":"/zh/play/playground/tooling/typescript-versions.ts"},{"path":"/zh/play/typescript/language/soundness.ts"},{"path":"/zh/play/typescript/language/structural-typing.ts"},{"path":"/zh/play/typescript/language/type-guards.ts"},{"path":"/zh/play/typescript/language/type-widening-and-narrowing.ts"},{"path":"/zh/play/typescript/language-extensions/enums.ts"},{"path":"/zh/play/typescript/language-extensions/nominal-typing.ts"},{"path":"/zh/play/typescript/language-extensions/types-vs-interfaces.ts"},{"path":"/zh/play/typescript/meta-types/conditional-types.ts"},{"path":"/zh/play/typescript/meta-types/discriminate-types.ts"},{"path":"/zh/play/typescript/meta-types/indexed-types.ts"},{"path":"/zh/play/typescript/meta-types/mapped-types.ts"},{"path":"/zh/play/typescript/primitives/any.ts"},{"path":"/zh/play/typescript/primitives/literals.ts"},{"path":"/zh/play/typescript/primitives/union-and-intersection-types.ts"},{"path":"/zh/play/typescript/primitives/unknown-and-never.ts"},{"path":"/zh/play/typescript/type-primitives/built-in-utility-types.ts"},{"path":"/zh/play/typescript/type-primitives/nullable-types.ts"},{"path":"/zh/play/typescript/type-primitives/tuples.ts"},{"path":"/ja/play/3-7/syntax-and-messaging/flattened-error-reporting.ts"},{"path":"/ja/play/3-7/fixits/infer-from-usage-changes.ts"},{"path":"/ja/play/3-7/fixits/const-to-let.ts"},{"path":"/community"},{"path":"/es/community"},{"path":"/ja/community"},{"path":"/vo/community"},{"path":"/zh/community"},{"path":"/download"},{"path":"/es/download"},{"path":"/ja/download"},{"path":"/vo/download"},{"path":"/zh/download"},{"path":"/empty"},{"path":"/es/empty"},{"path":"/ja/empty"},{"path":"/vo/empty"},{"path":"/zh/empty"},{"path":"/"},{"path":"/es/"},{"path":"/ja/"},{"path":"/vo/"},{"path":"/zh/"},{"path":"/tools"},{"path":"/es/tools"},{"path":"/ja/tools"},{"path":"/vo/tools"},{"path":"/zh/tools"},{"path":"/why-create-typescript"},{"path":"/es/why-create-typescript"},{"path":"/ja/why-create-typescript"},{"path":"/vo/why-create-typescript"},{"path":"/zh/why-create-typescript"},{"path":"/docs/bootstrap"},{"path":"/es/docs/bootstrap"},{"path":"/ja/docs/bootstrap"},{"path":"/vo/docs/bootstrap"},{"path":"/zh/docs/bootstrap"},{"path":"/docs/"},{"path":"/es/docs/"},{"path":"/ja/docs/"},{"path":"/vo/docs/"},{"path":"/zh/docs/"},{"path":"/docs/handbook/"},{"path":"/es/docs/handbook/"},{"path":"/ja/docs/handbook/"},{"path":"/vo/docs/handbook/"},{"path":"/zh/docs/handbook/"},{"path":"/branding/"},{"path":"/dev/bug-workbench/"},{"path":"/dev/playground-plugins/"},{"path":"/dev/sandbox/"},{"path":"/dev/twoslash/"},{"path":"/dev/typescript-vfs/"},{"path":"/upcoming/"}]},"markdownRemark":{"id":"7a8e029c-1307-523c-ad51-d1e3ad991983","excerpt":"Along with traditional OO hierarchies, another popular way of building up classes from reusable components is to build them by combining simpler partial classes…","html":"<p>Along with traditional OO hierarchies, another popular way of building up classes from reusable components is to build them by combining simpler partial classes.\nYou may be familiar with the idea of mixins or traits for languages like Scala, and the pattern has also reached some popularity in the JavaScript community.</p>\n<h2 id=\"how-does-a-mixin-work\" style=\"position:relative;\"><a href=\"#how-does-a-mixin-work\" aria-label=\"how does a mixin work permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How Does A Mixin Work?</h2>\n<p>The pattern relies on using Generics with class inheritance to extend a base class.\nTypeScript’s best mixin support is done via the class expression pattern.\nYou can read more about how this pattern works in <a href=\"https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/\">JavaScript here</a>.</p>\n<p>To get started, we’ll need a class which will have the mixin’s applied on top of:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <data-lsp lsp='class Sprite'>Sprite</data-lsp> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Sprite.name: string'>name</data-lsp></span><span style=\"color: #000000\"> = </span><span style=\"color: #A31515\">\"\"</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Sprite.x: number'>x</data-lsp></span><span style=\"color: #000000\"> = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Sprite.y: number'>y</data-lsp></span><span style=\"color: #000000\"> = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">constructor</span><span style=\"color: #000000\">(</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) name: string'>name</data-lsp></span><span style=\"color: #000000\">: string) {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.<data-lsp lsp='(property) Sprite.name: string'>name</data-lsp> = </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) name: string'>name</data-lsp></span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">}</span></code><a href='https://www.typescriptlang.org/play/#code/MYGwhgzhAEDKAOAnAlgFwKbQN4ChrQDswBbTAXmgCJKBuPaAD2goAY78BPZ6Nne4APYEIqRAFdgqAYgAURUgC5oIlAQDmASmz18qABbIIAOnnlCJdO2gBfHNaA'>Try</a></div></pre>\n<p>Then you need a type and a class which</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// To get started, we need a type which we&apos;ll use to extend</span>\n<span style=\"color: #008000\">// other classes from. The main responsibility is to declare</span>\n<span style=\"color: #008000\">// that the type being passed in is a class.</span>\n\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> <data-lsp lsp='type Constructor = new (...args: any[]) => {}'>Constructor</data-lsp> = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> (...</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) args: any[]'>args</data-lsp></span><span style=\"color: #000000\">: any[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {};</span>\n\n<span style=\"color: #008000\">// This mixin adds a scale property, with getters and setters</span>\n<span style=\"color: #008000\">// for changing it with an encapsulated private property:</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> <data-lsp lsp='function Scale&amp;lt;TBase extends Constructor>(Base: TBase): {&amp;#13;    new (...args: any[]): Scaling;&amp;#13;    prototype: Scale&amp;lt;any>.Scaling;&amp;#13;} &amp;amp; TBase'>Scale</data-lsp>&lt;<data-lsp lsp='(type parameter) TBase in Scale&amp;lt;TBase extends Constructor>(Base: TBase): {&amp;#13;    new (...args: any[]): Scaling;&amp;#13;    prototype: Scale&amp;lt;any>.Scaling;&amp;#13;} &amp;amp; TBase'>TBase</data-lsp> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> <data-lsp lsp='type Constructor = new (...args: any[]) => {}'>Constructor</data-lsp>>(</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) Base: TBase extends Constructor'>Base</data-lsp></span><span style=\"color: #000000\">: <data-lsp lsp='(type parameter) TBase in Scale&amp;lt;TBase extends Constructor>(Base: TBase): {&amp;#13;    new (...args: any[]): Scaling;&amp;#13;    prototype: Scale&amp;lt;any>.Scaling;&amp;#13;} &amp;amp; TBase'>TBase</data-lsp>) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <data-lsp lsp='(local class) Scaling'>Scaling</data-lsp> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> <data-lsp lsp='(parameter) Base: TBase extends Constructor'>Base</data-lsp> {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// Mixins may not declare private/protected properties</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #008000\">// however, you can use ES2020 private fields</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Scaling._scale: number'>_scale</data-lsp></span><span style=\"color: #000000\"> = </span><span style=\"color: #09835A\">1</span><span style=\"color: #000000\">;</span>\n\n<span style=\"color: #000000\">    <data-lsp lsp='(method) Scaling.setScale(scale: number): void'>setScale</data-lsp>(</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) scale: number'>scale</data-lsp></span><span style=\"color: #000000\">: number) {</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Scaling._scale: number'>_scale</data-lsp></span><span style=\"color: #000000\"> = </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) scale: number'>scale</data-lsp></span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    }</span>\n\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">get</span><span style=\"color: #000000\"> <data-lsp lsp='(property) Scaling.scale: number'>scale</data-lsp>(): number {</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Scaling._scale: number'>_scale</data-lsp></span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #000000\">}</span></code><a href='https://www.typescriptlang.org/play/#code/PTAEBUHtQcwUwC6gM4IIYCcFwCYBpQB3OUAOzl1DVAQE8AHEwgCwEsBjZouAcgBs+oAK7ISCaHAAe2UjgBQIUJATM4GUOz5pko5KABmGSAFsAdBFWhjaVqVAY4yepFLJWAI1Z9WdUKz3ioDhwmphwCmAqaEgqYgwk7nC2MKD02qI4fnb+VBpaOqZycnSMoADCLqgYQuzi6gC8ZHCEoAAUph2YMMgAXFSktADaALoAlKD1AHygAN4AvgDcRYrgbHrGrJK2VDg4etTI7Gh8JPRGjFi0BIQ+XPAI2Bj7siiIj8gRBpDqnGikMMk-Egbip+qA4KQjvRkEItNhMmdWAA3aKnc5qOg9Ir6ISQhCsFygADKRxOAB5wAAhbQkKQyPblSoIaq1b6TVrU0R9Kk08YzOSgeyIIQYOyhHTE0mAukQhmckj8wWCxQAWU2tnWaFoZGUQRCWgcqQwyNRwDOyhC8KNkAu+McAqVimYkGISLUBFokCEGj+wlEoAAokSAEwABjDRpN2AMrDgfD2DsFAH1DscSI0AIxLROvBAktOtVMnPqkITGRIYPk5wUqfymFOk9MoRtLJWgOZFNv3ZsF0YlssV2bVoUIEV2WvIetFuCtpUdwWLORzIA'>Try</a></div></pre>\n<p>With these all set up, then you can create a class which represents the base class with mixins applied:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Compose a new class from the Sprite class,</span>\n<span style=\"color: #008000\">// with the Mixin Scale applier:</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> </span><span style=\"color: #1A1A1A\"><data-lsp lsp='const EightBitSprite: {&amp;#13;    new (...args: any[]): Scale&amp;lt;typeof Sprite>.Scaling;&amp;#13;    prototype: Scale&amp;lt;any>.Scaling;&amp;#13;} &amp;amp; typeof Sprite'>EightBitSprite</data-lsp> </span><span style=\"color: #000000\">= <data-lsp lsp='function Scale&amp;lt;typeof Sprite>(Base: typeof Sprite): {&amp;#13;    new (...args: any[]): Scale&amp;lt;typeof Sprite>.Scaling;&amp;#13;    prototype: Scale&amp;lt;any>.Scaling;&amp;#13;} &amp;amp; typeof Sprite'>Scale</data-lsp>(</span><span style=\"color: #1A1A1A\"><data-lsp lsp='class Sprite'>Sprite</data-lsp></span><span style=\"color: #000000\">);</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> </span><span style=\"color: #1A1A1A\"><data-lsp lsp='const flappySprite: Scale&amp;lt;typeof Sprite>.Scaling &amp;amp; Sprite'>flappySprite</data-lsp> </span><span style=\"color: #000000\">= </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> <data-lsp lsp='const EightBitSprite: new (name: string) => Scale&amp;lt;typeof Sprite>.Scaling &amp;amp; Sprite'>EightBitSprite</data-lsp>(</span><span style=\"color: #A31515\">\"Bird\"</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #1A1A1A\"><data-lsp lsp='const flappySprite: Scale&amp;lt;typeof Sprite>.Scaling &amp;amp; Sprite'>flappySprite</data-lsp></span><span style=\"color: #000000\">.<data-lsp lsp='(method) Scaling&amp;lt;typeof Sprite>.setScale(scale: number): void'>setScale</data-lsp>(</span><span style=\"color: #09835A\">0.8</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\"><data-lsp lsp='var console: Console'>console</data-lsp>.<data-lsp lsp='(method) Console.log(...data: any[]): void'>log</data-lsp>(</span><span style=\"color: #1A1A1A\"><data-lsp lsp='const flappySprite: Scale&amp;lt;typeof Sprite>.Scaling &amp;amp; Sprite'>flappySprite</data-lsp></span><span style=\"color: #000000\">.</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Scaling.scale: number'>scale</data-lsp></span><span style=\"color: #000000\">);</span></code><a href='https://www.typescriptlang.org/play/#code/MYGwhgzhAEDKAOAnAlgFwKbQN4ChrQDswBbTAXmgCJKBuPaAD2goAY78BPZ6Nne4APYEIqRAFdgqAYgAURUgC5oIlAQDmASmz18qABbIIAOnnlCJdO2gBfHLdQd4mAMJCVEqYm4F0Ad2gyRkFgiGoQSmAEHADaALpaZAB82NZ0AGZiBJLIQnDAYCDoADwAKgBCkJjoDBgEACYwrsKiHtKJMhUQ6ErllVq4+IjoqGKIBNCgkDCw+SDI6tDVtQ3QnZgD+NAA9FvQALLIDPMwxGBcBAKo0HXok0PQSMgAbmAYW0iXtxh1D4gCTohUMh0BAdNtdnoBL50E90IgADTQDgCMQTSLQMRdaAAUVgACYWATfs9Xpg0sCQA0wQB9CCzMwARjoYK6qBmBXQMjpHKUBDExAARnD+mDdAZjLT6dxuYUrPhbGC1MNlPSZBpefyhV4NptoEMRmNoPpDEZJRy5TZ6Kk7DgdtAALSO4BiVCO+223auYjwARYsCEPwTcBQaBpP7EI16TAIFAYINTeEe6C+NB6SOYA5HcbswrQMDweBzOEKHCCZo45BqPSoMpoGNoMw5zn1jAaZllkSh8AFjgtsw+fzYyvV2tsx4YGSUWuIOqUNs4NLd+C98foIyspsyFhGAAc847AkKRhAAjUMkX+eXffX9LbQA'>Try</a></div></pre>\n<h2 id=\"constrained-mixins\" style=\"position:relative;\"><a href=\"#constrained-mixins\" aria-label=\"constrained mixins permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Constrained Mixins</h2>\n<p>In the above form, the mixin’s have no underlying knowledge of the class which can make it hard to create the design you want.</p>\n<p>To model this, we modify the original constructor type to accept a generic argument.</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// This was our previous constructor:</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> <data-lsp lsp='type Constructor = new (...args: any[]) => {}'>Constructor</data-lsp> = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> (...</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) args: any[]'>args</data-lsp></span><span style=\"color: #000000\">: any[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {};</span>\n<span style=\"color: #008000\">// Now we use a generic version which can apply a constraint on</span>\n<span style=\"color: #008000\">// the class which this mixin is applied to</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> <data-lsp lsp='type GConstructor&amp;lt;T = {}> = new (...args: any[]) => T'>GConstructor</data-lsp>&lt;<data-lsp lsp='(type parameter) T in type GConstructor&amp;lt;T = {}>'>T</data-lsp> = {}> = </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> (...</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) args: any[]'>args</data-lsp></span><span style=\"color: #000000\">: any[]) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> <data-lsp lsp='(type parameter) T in type GConstructor&amp;lt;T = {}>'>T</data-lsp>;</span></code><a href='https://www.typescriptlang.org/play/#code/PTAEBUAsEsGdQO4EN4HsCuAnUAHTBTAN2g3gGNUA7WAF03TJtUwC4AoGgTx31AGEqteo2agAvKEr4EoABQA6RUkwBzWC1BJKnANoBdAJTiAfKADeAXwDcbEKAByqGQl7pYvJKBX4pmaGVBCfExYEkpEGDJIUDItTRwcABtOTRjBOiRoShpQKlswGkheMkSUeARI6MK4UABbaAAPLNAapATE6HwAE1AmDm5eAHEBajoGJkwAHnBxcwtTCSkZBSVVdU1tfSMxU3ArIA'>Try</a></div></pre>\n<p>This allows for creating classes which only work with constrained base classes:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> <data-lsp lsp='type Positionable = new (...args: any[]) => {&amp;#13;    setPos: (x: number, y: number) => void;&amp;#13;}'>Positionable</data-lsp> = <data-lsp lsp='type GConstructor&amp;lt;T = {}> = new (...args: any[]) => T'>GConstructor</data-lsp>&lt;{ <data-lsp lsp='(property) setPos: (x: number, y: number) => void'>setPos</data-lsp>: (</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) x: number'>x</data-lsp></span><span style=\"color: #000000\">: number, </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) y: number'>y</data-lsp></span><span style=\"color: #000000\">: number) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void }&gt;;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> <data-lsp lsp='type Spritable = new (...args: any[]) => typeof Sprite'>Spritable</data-lsp> = <data-lsp lsp='type GConstructor&amp;lt;T = {}> = new (...args: any[]) => T'>GConstructor</data-lsp>&lt;</span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> <data-lsp lsp='class Sprite'>Sprite</data-lsp>>;</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> <data-lsp lsp='type Loggable = new (...args: any[]) => {&amp;#13;    print: () => void;&amp;#13;}'>Loggable</data-lsp> = <data-lsp lsp='type GConstructor&amp;lt;T = {}> = new (...args: any[]) => T'>GConstructor</data-lsp>&lt;{ <data-lsp lsp='(property) print: () => void'>print</data-lsp>: () </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> void }&gt;;</span></code><a href='https://www.typescriptlang.org/play/#code/C4TwDgpgBA4gwgewHYGdgCcCuBjYD0A8AKlALxQDeAvgHxlRIQDuUAFAHScCG6A5igC4oXJCADaAXQCUZOkQDcAKGwAbLihRQAymHQBLYNAqKoDLgFto5AETWlpgB70ADPaggXSk1GzI0WXHxWJAsIIX89JF4ZY1NTYAALPRR2EMt6NIg3KkUcgHo8qABaEuxMYBKixVBIKAAFBBQDPWQuACMVK1hEVAwcPEIKKBQIYAbBNgchJExzNoh0ABp3adn59BlSOgA3BD0AEyhaJRroHX1gds76eD8+wMJThAAzbV0DCBoT8GgAGQReLwrl1br0AgMCEN3khgEJWJsdntDscgA'>Try</a></div></pre>\n<p>Then you can create mixins which only work when you have a particular base to build on:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> <data-lsp lsp='function Jumpable&amp;lt;TBase extends GConstructor&amp;lt;{&amp;#13;    setPos: (x: number, y: number) => void;&amp;#13;}>>(Base: TBase): {&amp;#13;    new (...args: any[]): Jumpable;&amp;#13;    prototype: Jumpable&amp;lt;any>.Jumpable;&amp;#13;} &amp;amp; TBase'>Jumpable</data-lsp>&lt;<data-lsp lsp='(type parameter) TBase in Jumpable&amp;lt;TBase extends GConstructor&amp;lt;{&amp;#13;    setPos: (x: number, y: number) => void;&amp;#13;}>>(Base: TBase): {&amp;#13;    new (...args: any[]): Jumpable;&amp;#13;    prototype: Jumpable&amp;lt;any>.Jumpable;&amp;#13;} &amp;amp; TBase'>TBase</data-lsp> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> <data-lsp lsp='type Positionable = new (...args: any[]) => {&amp;#13;    setPos: (x: number, y: number) => void;&amp;#13;}'>Positionable</data-lsp>>(</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) Base: TBase extends GConstructor&amp;lt;{ setPos: (x: number, y: number) => void; }>'>Base</data-lsp></span><span style=\"color: #000000\">: <data-lsp lsp='(type parameter) TBase in Jumpable&amp;lt;TBase extends GConstructor&amp;lt;{&amp;#13;    setPos: (x: number, y: number) => void;&amp;#13;}>>(Base: TBase): {&amp;#13;    new (...args: any[]): Jumpable;&amp;#13;    prototype: Jumpable&amp;lt;any>.Jumpable;&amp;#13;} &amp;amp; TBase'>TBase</data-lsp>) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <data-lsp lsp='(local class) Jumpable'>Jumpable</data-lsp> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> <data-lsp lsp='(parameter) Base: TBase extends GConstructor&amp;lt;{ setPos: (x: number, y: number) => void; }>'>Base</data-lsp> {</span>\n<span style=\"color: #000000\">    <data-lsp lsp='(method) Jumpable.jump(): void'>jump</data-lsp>() {</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #008000\">// This mixin will only work if it is passed a base</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #008000\">// class which has setPos defined because of the</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #008000\">// Positionable constraint.</span>\n<span style=\"color: #000000\">      </span><span style=\"color: #0000FF\">this</span><span style=\"color: #000000\">.<data-lsp lsp='(property) setPos: (x: number, y: number) => void'>setPos</data-lsp>(</span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">, </span><span style=\"color: #09835A\">20</span><span style=\"color: #000000\">);</span>\n<span style=\"color: #000000\">    }</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #000000\">}</span></code><a href='https://www.typescriptlang.org/play/#code/C4TwDgpgBA4gwgewHYGdgCcCuBjYD0A8AKlALxQDeAvgHxlRIQDuUAFAHScCG6A5igC4oXJCADaAXQCUZOkQDcAKGwAbLihRQAymHQBLYNAqKoDLgFto5AETWlpgB70ADPaggXSk1GzI0WXHxWJAsIIX89JF4ZY1NTYAALPRR2EMt6NIg3KkUc0EgoAAUEFAM9ZC4AIxUrWERUDBw8QgooFAhgYsE2ByEkTHNKiHQAGnc+gaH0GVI6ADcEPQATKFolfOgdfWAqmvp4P0bAwg2EADNtXQMIGnXwaAAZBF5eXdqDhoDmglarpGAhKwZvNFis1ooAPQQqAAWjh2EwwDhMMUijOmCQuHKSCgACkBmA3sQAELqaAQByGJBLTRdMoVao3Vik9pCIgsiAxbzoDqYdA41TqTT48yExlQClUmlQDmUbymABWBKBcricShUCISU05j0DkiUCYehUKigyBUHiY+AA1lA9BcDHbNISNBAVlwoJUyfL1dDBRpDUlsAkoAl1G0Ol0oEsIGdIm7PRBsFxMO0zRdEhAfaYNXTgNi3j5DuguJFgOxs1BEsl2O1OiVWM4xgAmZxSNymHKdpRUIA'>Try</a></div></pre>\n<h2 id=\"alternative-pattern\" style=\"position:relative;\"><a href=\"#alternative-pattern\" aria-label=\"alternative pattern permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Alternative Pattern</h2>\n<p>Previous versions of this document recommended a way to write mixins where you created both the runtime and type hierarchies separately, then merged them at the end:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// Each mixin is a traditional ES class</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <data-lsp lsp='class Jumpable'>Jumpable</data-lsp> {</span>\n<span style=\"color: #000000\">  <data-lsp lsp='(method) Jumpable.jump(): void'>jump</data-lsp>() {}</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <data-lsp lsp='class Duckable'>Duckable</data-lsp> {</span>\n<span style=\"color: #000000\">  <data-lsp lsp='(method) Duckable.duck(): void'>duck</data-lsp>() {}</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Including the base</span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <data-lsp lsp='class Sprite&amp;#13;interface Sprite'>Sprite</data-lsp> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Sprite.x: number'>x</data-lsp></span><span style=\"color: #000000\"> = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Sprite.y: number'>y</data-lsp></span><span style=\"color: #000000\"> = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// Then you create an interface which merges</span>\n<span style=\"color: #008000\">// the expected mixins with the same name as your base</span>\n<span style=\"color: #0000FF\">interface</span><span style=\"color: #000000\"> <data-lsp lsp='class Sprite&amp;#13;interface Sprite'>Sprite</data-lsp> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> <data-lsp lsp='class Jumpable'>Jumpable</data-lsp>, <data-lsp lsp='class Duckable'>Duckable</data-lsp> {}</span>\n<span style=\"color: #008000\">// Apply the mixins into the base class via</span>\n<span style=\"color: #008000\">// the JS at runtime</span>\n<span style=\"color: #000000\"><data-lsp lsp='function applyMixins(derivedCtor: any, constructors: any[]): void'>applyMixins</data-lsp>(</span><span style=\"color: #1A1A1A\"><data-lsp lsp='class Sprite'>Sprite</data-lsp></span><span style=\"color: #000000\">, [</span><span style=\"color: #1A1A1A\"><data-lsp lsp='class Jumpable'>Jumpable</data-lsp></span><span style=\"color: #000000\">, </span><span style=\"color: #1A1A1A\"><data-lsp lsp='class Duckable'>Duckable</data-lsp></span><span style=\"color: #000000\">]);</span>\n\n<span style=\"color: #0000FF\">let</span><span style=\"color: #000000\"> </span><span style=\"color: #1A1A1A\"><data-lsp lsp='let player: Sprite'>player</data-lsp> </span><span style=\"color: #000000\">= </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> <data-lsp lsp='constructor Sprite(): Sprite'>Sprite</data-lsp>();</span>\n<span style=\"color: #1A1A1A\"><data-lsp lsp='let player: Sprite'>player</data-lsp></span><span style=\"color: #000000\">.<data-lsp lsp='(method) Jumpable.jump(): void'>jump</data-lsp>();</span>\n<span style=\"color: #000000\"><data-lsp lsp='var console: Console'>console</data-lsp>.<data-lsp lsp='(method) Console.log(...data: any[]): void'>log</data-lsp>(</span><span style=\"color: #1A1A1A\"><data-lsp lsp='let player: Sprite'>player</data-lsp></span><span style=\"color: #000000\">.<data-lsp lsp='(property) Sprite.x: number'>x</data-lsp>, </span><span style=\"color: #1A1A1A\"><data-lsp lsp='let player: Sprite'>player</data-lsp></span><span style=\"color: #000000\">.<data-lsp lsp='(property) Sprite.y: number'>y</data-lsp>);</span>\n\n<span style=\"color: #008000\">// This can live anywhere in your codebase:</span>\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> <data-lsp lsp='function applyMixins(derivedCtor: any, constructors: any[]): void'>applyMixins</data-lsp>(</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) derivedCtor: any'>derivedCtor</data-lsp></span><span style=\"color: #000000\">: any, </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) constructors: any[]'>constructors</data-lsp></span><span style=\"color: #000000\">: any[]) {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) constructors: any[]'>constructors</data-lsp></span><span style=\"color: #000000\">.<data-lsp lsp='(method) Array&amp;lt;any>.forEach(callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any): void'>forEach</data-lsp>((</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) baseCtor: any'>baseCtor</data-lsp></span><span style=\"color: #000000\">) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">    <data-lsp lsp='var Object: ObjectConstructor'>Object</data-lsp>.<data-lsp lsp='(method) ObjectConstructor.getOwnPropertyNames(o: any): string[]'>getOwnPropertyNames</data-lsp>(<data-lsp lsp='(parameter) baseCtor: any'>baseCtor</data-lsp>.<data-lsp lsp='any'>prototype</data-lsp>).<data-lsp lsp='(method) Array&amp;lt;string>.forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void'>forEach</data-lsp>((</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) name: string'>name</data-lsp></span><span style=\"color: #000000\">) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">      <data-lsp lsp='var Object: ObjectConstructor'>Object</data-lsp>.<data-lsp lsp='(method) ObjectConstructor.defineProperty(o: any, p: string | number | symbol, attributes: PropertyDescriptor &amp;amp; ThisType&amp;lt;any>): any'>defineProperty</data-lsp>(</span>\n<span style=\"color: #000000\">        <data-lsp lsp='(parameter) derivedCtor: any'>derivedCtor</data-lsp>.<data-lsp lsp='any'>prototype</data-lsp>,</span>\n<span style=\"color: #000000\">        </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) name: string'>name</data-lsp></span><span style=\"color: #000000\">,</span>\n<span style=\"color: #000000\">        <data-lsp lsp='var Object: ObjectConstructor'>Object</data-lsp>.<data-lsp lsp='(method) ObjectConstructor.getOwnPropertyDescriptor(o: any, p: string | number | symbol): PropertyDescriptor'>getOwnPropertyDescriptor</data-lsp>(<data-lsp lsp='(parameter) baseCtor: any'>baseCtor</data-lsp>.<data-lsp lsp='any'>prototype</data-lsp>, </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) name: string'>name</data-lsp></span><span style=\"color: #000000\">)</span>\n<span style=\"color: #000000\">      );</span>\n<span style=\"color: #000000\">    });</span>\n<span style=\"color: #000000\">  });</span>\n<span style=\"color: #000000\">}</span></code><a href='https://www.typescriptlang.org/play/#code/PTAEAEGcBcCcEsDG0BcoBmBDANpApgFAigCimiAFqALbwAe8AdqPJKJqHJgCbzTwB7RjlIBlUImyZIkApOlsAUgFdqAB0wAjbHlABvAqFAArVWoAUASn0BfAnblSZoACLLEAay079h0N3cPK1t7AiIwAElGSWVeRgBzTgpdTWlCeWdRNQRoXQMjOlAAXlAABgBuPwBPYrLKh2IAFWTmKoFlCVg8TFz2ZiZc2CxEXQB3CiQqajxYeLxZYmhk0Dw6NTxkPG4aeiY2Ub4qJd1ITGnQYXPpUDblWFBU-AIBmeHdLJzdVdzGbiUzbx4AA0rkCgJCxAAgmo1NgascdgxGGwBgIkik0hInGwAG7wTDhdGgRTiHqgWDKRj8aYETAwuEAWV2yPMHz4wNAAG0VOpASC3J5AQBdSyVAg6aCgWGYKozWqMPCjUBs3JWSrS2WwAB0pnUarkQkgAh0WuwAni5g1My1dBBVu1VVFYSaEzYiEwzGw8Bxug9VXGM10TBu7XuiAE3DwjzwKAI6EpyEEzDpsKqTKRkHMkYQPu4AGFoAJYGg-SDw8i4O5C7BICXGFVOSLfEZyzAKcgi5Ategi2RKOZzNGC0XrEUAHzNoygADymmMG2gWrm0Gno0YAAVYAJ1rBoFUAHJneaDtLD7XZASFvfrSzd3vkCgDy54UcT-JToyz+fILWR9BMPBN23GY93MPwPyMbNvS2M8tQvK8qnWIFwIg59kIgqcvwXJc8BXNcgJ3PcXHmRAEDUasT3wWD4MvRCOWfSwUKMJ0PxsFjQDY+ogA'>Try</a></div></pre>\n<p>This pattern relies less on the compiler, and more on your codebase to ensure both runtime and type-system are correctly kept in sync.</p>\n<h2 id=\"constraints\" style=\"position:relative;\"><a href=\"#constraints\" aria-label=\"constraints permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Constraints</h2>\n<p>The mixin pattern is supported natively inside the TypeScript compiler by code flow analysis.\nThere are a few cases where you can hit the edges of the native support.</p>\n<h4 id=\"decorators-and-mixins-4881\" style=\"position:relative;\"><a href=\"#decorators-and-mixins-4881\" aria-label=\"decorators and mixins 4881 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Decorators and Mixins <a href=\"https://github.com/microsoft/TypeScript/issues/4881\"><code>#4881</code></a></h4>\n<p>You cannot use decorators to provide mixins via code flow analysis:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #008000\">// A decorator function which replicates the mixin pattern:</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> </span><span style=\"color: #1A1A1A\"><data-lsp lsp='const Pausable: (target: typeof Player) => typeof Pausable'>Pausable</data-lsp> </span><span style=\"color: #000000\">= (</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(parameter) target: typeof Player'>target</data-lsp></span><span style=\"color: #000000\">: </span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> <data-lsp lsp='class Player'>Player</data-lsp>) </span><span style=\"color: #0000FF\">=&gt;</span><span style=\"color: #000000\"> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <data-lsp lsp='(local class) Pausable'>Pausable</data-lsp> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> <data-lsp lsp='(parameter) target: typeof Player'>target</data-lsp> {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Pausable.shouldFreeze: boolean'>shouldFreeze</data-lsp></span><span style=\"color: #000000\"> = </span><span style=\"color: #0000FF\">false</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  };</span>\n<span style=\"color: #000000\">};</span>\n\n<span style=\"color: #000000\">@</span><span style=\"color: #1A1A1A\"><data-lsp lsp='const Pausable: (target: typeof Player) => typeof Pausable'>Pausable</data-lsp></span>\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <data-lsp lsp='class Player'>Player</data-lsp> {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Player.x: number'>x</data-lsp></span><span style=\"color: #000000\"> = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Player.y: number'>y</data-lsp></span><span style=\"color: #000000\"> = </span><span style=\"color: #09835A\">0</span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #008000\">// The Player class does not have the decorator&apos;s type merged:</span>\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> </span><span style=\"color: #1A1A1A\"><data-lsp lsp='const player: Player'>player</data-lsp> </span><span style=\"color: #000000\">= </span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> <data-lsp lsp='constructor Player(): Player'>Player</data-lsp>();</span>\n<span style=\"color: #1A1A1A\"><data-lsp lsp='const player: Player'>player</data-lsp></span><span style=\"color: #000000\">.</span><span style=\"color: #1A1A1A\"><data-err><data-lsp lsp='any'>shouldFreeze</data-lsp></data-err></span><span style=\"color: #000000\">;</span>\n<span class=\"error\"><span>Property 'shouldFreeze' does not exist on type 'Player'.</span><span class=\"code\">2339</span></span><span class=\"error-behind\">Property 'shouldFreeze' does not exist on type 'Player'.</span>\n<span style=\"color: #008000\">// It the runtime aspect could be manually replicated via</span>\n<span style=\"color: #008000\">// type composition or interface merging.</span>\n<span style=\"color: #0000FF\">type</span><span style=\"color: #000000\"> <data-lsp lsp='type FreezablePlayer = typeof Player &amp;amp; {&amp;#13;    shouldFreeze: boolean;&amp;#13;}'>FreezablePlayer</data-lsp> = </span><span style=\"color: #0000FF\">typeof</span><span style=\"color: #000000\"> <data-lsp lsp='class Player'>Player</data-lsp> &amp; { </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) shouldFreeze: boolean'>shouldFreeze</data-lsp></span><span style=\"color: #000000\">: boolean };</span>\n\n<span style=\"color: #0000FF\">const</span><span style=\"color: #000000\"> </span><span style=\"color: #1A1A1A\"><data-lsp lsp='const playerTwo: FreezablePlayer'>playerTwo</data-lsp> </span><span style=\"color: #000000\">= (</span><span style=\"color: #0000FF\">new</span><span style=\"color: #000000\"> <data-lsp lsp='constructor Player(): Player'>Player</data-lsp>() </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> unknown) </span><span style=\"color: #0000FF\">as</span><span style=\"color: #000000\"> <data-lsp lsp='type FreezablePlayer = typeof Player &amp;amp; {&amp;#13;    shouldFreeze: boolean;&amp;#13;}'>FreezablePlayer</data-lsp>;</span>\n<span style=\"color: #1A1A1A\"><data-lsp lsp='const playerTwo: FreezablePlayer'>playerTwo</data-lsp></span><span style=\"color: #000000\">.</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) shouldFreeze: boolean'>shouldFreeze</data-lsp></span><span style=\"color: #000000\">;</span></code><a href='https://www.typescriptlang.org/play/#code/PTAEAEFMA8AdIE4EsC2kB2AXAhgGwCKQDGA9gtpmQM4BQIEiC1AXKAEwDMHAnHWAIKgAJsTIUyoAGYBXdEUxIS6UAHcAFkiJrQCSLFyaKkKqExrIoFEmhJlsCpkTpmNUuiqZQABWzSq2ACNcCwBeUAAKHAQAc0hMVkwAT3gSSW9cbETEAEpQEIA+UABvGlAdOOkEZSIMqhMfP0Dg0BhHdCETKNjPErKyqjUSaVwhADFdSAAvUKk8KkgAblLQAF8ltZoacAb-IMhXWvqMrIRi5eg80AAGJbLEy5uaFc36ABVzdMzEUBrsOuESMZQOgSJ41NgAG4WMwWESkciUBAAck6yQsaBikCELjcHlA+i+pzC6EgKk+J3C2SWBJOADoBkMRuNIFNFi8wABJTwwnSyBRoUB-eDyH6MoSgALo7DoaR4XD3XT6QyOcUQpDYPimNGilCwEhUJAKJSgCS2RwISTYIjoxDRWzRWk0JLwUDMqZNSBeY7fMLOyCpcnfABkxVADOGYwm01YARIJGC0tWS1cSjxNMQrxUJEu4RJZK9hMpgpMsgA1iCVOhcn9XVGPQWTtTvQhMyR6YMI27pgsgA'>Try</a></div></pre>\n<h4 id=\"static-property-mixins-17829\" style=\"position:relative;\"><a href=\"#static-property-mixins-17829\" aria-label=\"static property mixins 17829 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Static Property Mixins <a href=\"https://github.com/microsoft/TypeScript/issues/17829\"><code>#17829</code></a></h4>\n<p>More of a gotcha then a constraint.\nThe class expression pattern creates singletons, so they can’t be mapped at the type system to support different variable types.</p>\n<p>You can work around this by using functions to return your classes which differ based on a generic:</p>\n<pre class=\"shiki twoslash\"><div class=\"language-id\">ts</div><div class='code-container'><code><span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> <data-lsp lsp='function base&amp;lt;T>(): typeof Base'>base</data-lsp>&lt;<data-lsp lsp='(type parameter) T in base&amp;lt;T>(): typeof Base'>T</data-lsp>>() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <data-lsp lsp='class Base'>Base</data-lsp> {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">static</span><span style=\"color: #000000\"> </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Base.prop: T'>prop</data-lsp></span><span style=\"color: #000000\">: <data-lsp lsp='(type parameter) T in base&amp;lt;T>(): typeof Base'>T</data-lsp>;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #1A1A1A\"><data-lsp lsp='class Base'>Base</data-lsp></span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">function</span><span style=\"color: #000000\"> <data-lsp lsp='function derived&amp;lt;T>(): typeof Derived'>derived</data-lsp>&lt;<data-lsp lsp='(type parameter) T in derived&amp;lt;T>(): typeof Derived'>T</data-lsp>>() {</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <data-lsp lsp='class Derived'>Derived</data-lsp> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> <data-lsp lsp='function base&amp;lt;T>(): typeof Base'>base</data-lsp>&lt;<data-lsp lsp='(type parameter) T in derived&amp;lt;T>(): typeof Derived'>T</data-lsp>>() {</span>\n<span style=\"color: #000000\">    </span><span style=\"color: #0000FF\">static</span><span style=\"color: #000000\"> </span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Derived.anotherProp: T'>anotherProp</data-lsp></span><span style=\"color: #000000\">: <data-lsp lsp='(type parameter) T in derived&amp;lt;T>(): typeof Derived'>T</data-lsp>;</span>\n<span style=\"color: #000000\">  }</span>\n<span style=\"color: #000000\">  </span><span style=\"color: #0000FF\">return</span><span style=\"color: #000000\"> </span><span style=\"color: #1A1A1A\"><data-lsp lsp='class Derived'>Derived</data-lsp></span><span style=\"color: #000000\">;</span>\n<span style=\"color: #000000\">}</span>\n\n<span style=\"color: #0000FF\">class</span><span style=\"color: #000000\"> <data-lsp lsp='class Spec'>Spec</data-lsp> </span><span style=\"color: #0000FF\">extends</span><span style=\"color: #000000\"> <data-lsp lsp='function derived&amp;lt;string>(): typeof Derived'>derived</data-lsp>&lt;string>() {}</span>\n\n<span style=\"color: #1A1A1A\"><data-lsp lsp='class Spec'>Spec</data-lsp></span><span style=\"color: #000000\">.</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Base&amp;lt;string>.prop: string'>prop</data-lsp></span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// string</span>\n<span style=\"color: #1A1A1A\"><data-lsp lsp='class Spec'>Spec</data-lsp></span><span style=\"color: #000000\">.</span><span style=\"color: #1A1A1A\"><data-lsp lsp='(property) Derived&amp;lt;string>.anotherProp: string'>anotherProp</data-lsp></span><span style=\"color: #000000\">; </span><span style=\"color: #008000\">// string</span></code><a href='https://www.typescriptlang.org/play/#code/GYVwdgxgLglg9mABAIwIYGcCmAeAKgPgAoBKRAbwChFEIAbDdRAIQ03KusXSlVgkQAOAJzgCAXIlwBuDgF8OQzFBBCkLLDPkVQkWAkQATTEJgA3TAbxFSlanQaIAIsbMXEmAB5RMYA4zRYViTsnFw8fIioYHBQABbGAAoi4pIy1PLUisqqTi7mBpoUFPbojADKApj8nt6+jEYm+djcJmAA5tbkWhVVAHTColKIAPTDYa1tFD0QvVEx8UJJgyNjLTDtQA'>Try</a></div></pre>","headings":[{"value":"How Does A Mixin Work?","depth":2},{"value":"Constrained Mixins","depth":2},{"value":"Alternative Pattern","depth":2},{"value":"Constraints","depth":2},{"value":"Decorators and Mixins #4881","depth":4},{"value":"Static Property Mixins #17829","depth":4}],"frontmatter":{"permalink":"/docs/handbook/mixins.html","title":"Mixins","disable_toc":null,"oneline":"Using the mixin pattern with TypeScript"}},"prev":null,"next":null},"pageContext":{"id":"mixins","slug":"/docs/handbook/mixins.html","repoPath":"/packages/documentation/copy/en/reference/Mixins.md","lang":"en","modifiedTime":"2020-08-07T17:00:36.339Z"}}}