nyc-config-typescript and decorators
See original GitHub issueConsidering a simple TS file like src/main.ts
function Foo(constructorFunction: Function) {
console.log('Foo decorator')
}
@Foo
class Main {
constructor() {
console.log('Running')
}
}
new Main();
then trying to instrument it by running:
yarn nyc instrument --compact=false src instrumented
with the following configuration:
"nyc": {
"extends": "@istanbuljs/nyc-config-typescript",
"all": true
}
then the result file instrumented/main.ts
is not instrumented.
If we comment the @Foo
decorator, then the file is instrumented again.
function Foo(constructorFunction: Function) {
console.log('Foo decorator')
}
// @Foo
class Main {
constructor() {
console.log('Running')
}
}
new Main();
result instrumented/main.ts
:
// ...
function Foo(constructorFunction: Function) {
cov_1eomntdplb.f[0]++;
cov_1eomntdplb.s[0]++;
console.log('Foo decorator');
} // @Foo
class Main {
constructor() {
cov_1eomntdplb.f[1]++;
cov_1eomntdplb.s[1]++;
console.log('Running');
}
}
cov_1eomntdplb.s[2]++;
new Main();
Am I missing something or is there an issue with decorators?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
nyc-config-typescript and decorators · Issue #1437 · istanbuljs ...
where i will find nyc config i just need to instrument a simple .ts file with decorator . i had installed nyc and...
Read more >@istanbuljs/nyc-config-typescript - npm
nyc configuration that works with typescript. ... Start using @istanbuljs/nyc-config-typescript in your project by running `npm i ...
Read more >getting nyc/istanbul coverage report to work with typescript
Recently I found a satisfiable solution by using "target": "es6" instead of es5 in tsconfig.json 's compilerOptions .
Read more >sequelize-typescript | Yarn - Package Manager
sequelize-typescript. Build Status codecov NPM. Decorators and some other features for sequelize (v6). Installation; Model Definition.
Read more >@istanbuljs/nyc-config-typescript - npm package | Snyk
nyc -config-typescript ... Handy default configuration for instrumenting your TypeScript-backed project with test coverage using nyc. ... Your tsconfig.json must be ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found that
extends
will replaceparser-plugins
in loading nyc config.So two way to solve this problem.
First one, use
parser-plugins
and removeextends
from your nyc config.Second one, new
nyc-config.js
andextends
from this file.hey All, @wyp0011 i have tried the first option that you suggested. That does instrument the .ts files with decorators but it does not work properly. It is giving the issue export is moved before decorators which gives error for compiling
Can anyone please help me with this.