mixin-patch
v0.4.1
Published
Patch the mixin problem #28799
Downloads
50
Readme
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.
secondary goal
Copy files from known positions (i.e. /src/**
) to public positions (i.e. /dist/client
) in a controlated way.
Never copies .ts files.
usage
- include in
package.json ⟶ devDependencies
- add
& mixin-patch
at the end of the"build"
script (for example:"build": "tsc & mixin-patch"
) - turn on options in
package.json
mixin-patch
property.
mixin-patch
Mixin-patch patch all of .d.ts
with these steps:
- It reads
package.json
of the project in the current work directory - Take the directories of the
"files"
entry - Search for
.d.ts
files in those directories (recursively) - Patch each
.d.ts
adding a comment// mixin-patch
at the beginning of each offending line - Uses
/^(\s+)(\w+:\s*\([^;]*\) => [^;]*;\s*)$/mg
regex to detect offending lines
config
In package.json mixin-path
can have the value true
for getting all the default values:
"mixin-patch": {
"patch": true,
"copy": [
{"from": "src", "to": "dist"}
]
}
caveats
- multiline emitted member function are not patched
- in some very complex mixins,
mixin-patch
can not patch in reasonable time, then if others capabilities are used (i.e.copy
)patch
must be turned off.
"mixin-patch": {
"patch": false,
"copy": [
{"from": "src/client", "to": "dist/client"},
{"from": "src/unlogged", "to": "dist/unlogged"}
]
}
license
- MIT