-
Notifications
You must be signed in to change notification settings - Fork 4
Description
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