Unused '@ts-expect-error' directive in 6.2.0
See original GitHub issueSummary
I use lighthouse in a typescript project with the following ts configs
"allowJs": true,
"maxNodeModuleJsDepth": 1,
The JSDoc types in lighthouse has been working nicely before 6.2.0.
On version 6.2.0, I start to see Unused '@ts-expect-error' directive
errors
node_modules/lighthouse/lighthouse-core/gather/driver.js:296:5 - error TS2578: Unused '@ts-expect-error' directive.
296 // @ts-expect-error TODO(bckenny): tsc can't type event.params correctly yet,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/lighthouse/lighthouse-core/gather/gatherers/gatherer.js:25:5 - error TS2578: Unused '@ts-expect-error' directive.
25 // @ts-expect-error - assume that class name has been added to LH.GathererArtifacts.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/lighthouse/lighthouse-core/lib/dependency-graph/base-node.js:132:5 - error TS2578: Unused '@ts-expect-error' directive.
132 // @ts-expect-error - in checkJs, ts doesn't know that CPUNode and NetworkNode *are* BaseNodes.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/lighthouse/lighthouse-core/lib/dependency-graph/base-node.js:267:5 - error TS2578: Unused '@ts-expect-error' directive.
267 // @ts-expect-error - only traverses graphs of Node, so force tsc to treat `this` as one
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/lighthouse/lighthouse-core/lib/dependency-graph/base-node.js:273:7 - error TS2578: Unused '@ts-expect-error' directive.
273 // @ts-expect-error - queue has length so it's guaranteed to have an item
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/lighthouse/lighthouse-core/lib/dependency-graph/base-node.js:309:7 - error TS2578: Unused '@ts-expect-error' directive.
309 // @ts-expect-error - toVisit has length so it's guaranteed to have an item
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
It seems the errors are happening because I don’t have "checkJs": true
ts config set, as a result typescript raises errors for all the @ts-expect-error
in js files. However setting"checkJs": true
would cause typescript to raise errors all over the place for other js libraries.
I’m wondering if it’s possible to change @ts-expect-error
back to @ts-ignore
? Or are there other ways to work around it?
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
error TS2578: Unused '@ts-expect-error' directive
Simple answer. You used // @ts-expect-error where is no error. I recommend replace it in VS Code via regex \s*\/\/\s*@ts-expect-error (to ...
Read more >Build error: error TS2578: Unused '@ts-expect-error' directive
Hi, team, I receive error building redash. Have tried many options but failed to successfully build. ... src/visualizations/table/Renderer.tsx:125 ...
Read more >ts-expect-error will report if there is no error. Unused '@ts ...
Discussion on: Getting Started With TypeScript ts-expect-error will report if there is no error. True Sorry my mistake. Object keys is always a ......
Read more >Bug listing with status RESOLVED with resolution OBSOLETE ...
Bug:1523 - "[IDEA] Offload work by distributing trivial ebuild maintenance to users, introduce a simple stability voting system and have a core team...
Read more >March 2020 (version 1.44) - Visual Studio Code
Suggestions for the // @ts-expect-error directive. ... In addition, new versions of the LSP client (6.2.0-next.2) and server (6.2.0-next.2) libraries have ...
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
Hi @oddui
I’m not sure if there’s a great way for us to fix this:
@ts-expect-error
(like self-alerting when they can be removed), so I don’t think we’ll want to move back to@ts-ignore
.network-recorder
because we don’t necessarily want to commit to their current interface as a public API/requiring major version bumps for changes.Possible other options:
.d.ts
declarations for those files (possibly automatically generated with--emitDeclarationOnly
?). Annoying to do yourself and possibly fragile, but it should work@ts-expect-error
in js files whencheckJs
isn’t enabled. This does seem bug-like from at least your description of the situation (although I could be missing some of the pieces), but I also think there’s a good chance the issue would be closed with the recommendation to always used.ts
files for dependencies (either from the dependency itself or from DefinitelyTyped). Maybe worth trying, though?Anyone reading this have other ideas?
Fixed in https://github.com/microsoft/TypeScript/pull/40046
Thanks @k-yle!