Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] a new option to ignore Non-null assertion operator #80

Closed
JounQin opened this issue Feb 22, 2021 · 8 comments
Closed
Labels
duplicate This issue or pull request already exists enhancement New feature or request fixed and released

Comments

@JounQin
Copy link
Contributor

JounQin commented Feb 22, 2021

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#non-null-assertion-operator

Sometimes, we can just confirm the value is non null.

transform('async function main() {}', {
  filename: 'fast-async.test.js',
  presets: ['@1stg'],
})!.code

Expected:

Pass

Actual:

Fail

@plantain-00
Copy link
Owner

It's duplicated as #62
Since it's more needed than I expected, I will add it in the next few days.

@plantain-00 plantain-00 added duplicate This issue or pull request already exists enhancement New feature or request labels Feb 22, 2021
plantain-00 added a commit that referenced this issue Feb 22, 2021
@plantain-00
Copy link
Owner

v2.16.0 should support it.

@JounQin
Copy link
Contributor Author

JounQin commented Feb 22, 2021

I tried but it seems not working. 😂

/Users/JounQin/Workspaces/GitHub/configs/tests/test.spec.ts:6:7: transform('async function main() {}', {
        filename: 'fast-async.test.js',
        presets: ['@1stg'],
      })!
109 / 110 99.09%
The type coverage rate(99.09%) is lower than the target(100%).

@plantain-00
Copy link
Owner

Did you use --ignore-non-null-assertion?

@JounQin
Copy link
Contributor Author

JounQin commented Feb 22, 2021

It should be ralted to cache. I used type-coverage --ignore-xxx before, and changed to use config settings in package.json after upgrading.

{
  "typeCoverage": {
    "atLeast": 100,
    "cache": true,
    "detail": true,
    "ignoreCatch": true,
    "ignoreFiles": "*.d.ts",
    "ignoreNonNullAssertion": true,
    "strict": true
  }
}

I tried to run type-coverage --ignore-non-null-assertion again, it works, and then run type-coverage no error too, but I doubt the cache is correct, so I decide to delete .type-coverage folder, now it should work as expected.

@JounQin
Copy link
Contributor Author

JounQin commented Feb 23, 2021

@plantain-00 Are you going to check the problem of cache, or should I close this issue?

@plantain-00
Copy link
Owner

I will check it in next few days, I don't have time now.

@plantain-00
Copy link
Owner

In v2.16.1, it should work with --cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request fixed and released
Projects
None yet
Development

No branches or pull requests

2 participants