# class-mix

> change from https://github.com/Microsoft/TypeScript/pull/13743#issuecomment-299540915

Latest version **0.1.0** (published 2018-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install class-mix
pnpm add class-mix
yarn add class-mix
bun add class-mix
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-08-04 |
| First published | 2018-08-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | zetaplus006 |
| Maintainers | zetaplus006 |
| Keywords | typescript |

## Links

- npm: https://www.npmjs.com/package/class-mix
- Repository: https://github.com/zetaplus006/class-mix
- Homepage: https://github.com/zetaplus006/class-mix#readme
- Issues: https://github.com/zetaplus006/class-mix/issues
- npm.io page: https://npm.io/package/class-mix

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2018-08-04

## README

# 类型混合

change from  https://github.com/Microsoft/TypeScript/pull/13743#issuecomment-299540915

```typescript
    class A {
        text = 'A'

        get A () {
            return 'A'
        }

        method_A () {
            return 'A'
        }

        static a = 'a'
    }

    class B {
        text = 'B'

        get B () {
            return 'B'
        }

        method_B () {
            return 'B'
        }

        static b = 'b'
    }

    class C {
        text = 'C'

        get C () {
            return 'C'
        }

        method_C () {
            return 'C'
        }

        static c = 'c'
    }

    // B和C可以视为java中带有默认实现的接口
    class S extends mix(A).with(B, C) {

    }

    const obj = new S();

    t.true(obj instanceof A)
    t.false(obj instanceof B)
    t.false(obj instanceof C)

    //property
    t.true(obj.text === 'A')
    t.false(obj.text === 'B')
    t.false(obj.text === 'C')

    //getter
    t.true(obj.A === 'A')
    t.true(obj.B === 'B')
    t.true(obj.C === 'C')

    //method
    t.true(obj.method_A() === 'A')
    t.true(obj.method_B() === 'B')
    t.true(obj.method_C() === 'C')

    //static
    t.true(S.a === 'a')
    t.true(S.b === 'b')
    t.true(S.c === 'c')
```

---
_Source: https://npm.io/package/class-mix · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
