mixin-patch

Patch the mixin problem #28799

mixin-patch

Patch the mixin problem #28799

main goal

Patch the problem described in issue #28799 of Typescript development team

When you use several stacked Mixins using TypeScript 2.2+ Support for Mix-in classes you can get this kind of error:

- error TS2425: Class '{ someName(): ... } & { someName:(()....' defines instance member property 'someName', but extended class 'className' defines it as instance member function.

usage

  • include in package.json ⟶ devDependencies
  • add & mixin-patch at the end of the "build" script (for example: "build": "tsc & mixin-patch")

mixin-patch

Mixin-patch patch all of .d.ts with these steps:

  1. It reads package.json of the project in the current work directory
  2. Take the directories of the "files" entry
  3. Search for .d.ts files in those directories (recursively)
  4. Patch each .d.ts adding a comment // mixin-patch at the beginning of each offending line
  5. Uses /^(\s+)(\w+:\s*\([^;]*\) => [^;]*;\s*)$/mg regex to detect offending lines

caveats

  • multiline emitted member function are not patched

license

  • MIT

Repository

emilioplatzer/mixin-patch


相关推荐