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

New TypeScript Operator Causes .ts Files to Not Parse #11

Open
CatGuardian opened this issue Jan 22, 2020 · 1 comment
Open

New TypeScript Operator Causes .ts Files to Not Parse #11

CatGuardian opened this issue Jan 22, 2020 · 1 comment

Comments

@CatGuardian
Copy link

CatGuardian commented Jan 22, 2020

There are a few new operators in TypeScript and one of them (maybe the other ones too) is causing the error "Unable to parse some files: ".

The operator I'm referring to is the optional chaining operator: ?.

If you have a file named 'cat.ts' and have somewhere the following code:

const x = { name: { first: 'ralph', last: 'pants' } };
console.log(`Pets name: ${x.name?.last}, ${x.name?.first}`);

then when you run gulp-depcheck you get an error: "Unable to parse some files: cat.ts"

These new TypeScript operators are like the holy grail and so this is very critical to get fixed.


UPDATE:

After doing some digging I discovered that this behavior is caused by the fact that gulp-depcheck has locked in an old version of depcheck itself. So in gulp-depcheck's package.json file it specifies: "depcheck": "0.6.7" But if it was updated to specify the latest version: 0.9.1, then this error doesn't come up.

WORK AROUND:

So after discovering that the issue is with an outdated version of depcheck, I noticed we can override the version of depcheck that gulp-depcheck is using.

We can do that by specifying the depcheck option when activating gulp-depcheck. See here:

var gulpDepcheck = require('gulp-depcheck');
...
gulp.task('depcheck', gulpDepcheck({
  // Override depcheck version inside gulp-depcheck.
  depcheck: require('depcheck'),

  // your other gulp-depcheck options go here still
}));

Make sure you install the version of depcheck that you want in the package that you are using gulp-depcheck: npm i depcheck --save-dev

@CatGuardian
Copy link
Author

@mcasimir @goloroden @hh10k

To fix this issue it is really simple: you just need to update the package.json file to reference the latest depcheck version.

Please let me know your thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant