question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript: error TS6133: 'tw' is declared but its value is never read.

See original GitHub issue

If you use tw just as an element prop, TypeScript doesn’t think it’s being used if I have noUnusedLocals: true in my tsconfig.json.

I could disable this warning in TS, or // @ts-ignore, but is there a better way of dealing with it?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
danielkczcommented, May 7, 2020

My solution is to get rid of noUnusedLocals and use ESLint instead for tracking unused variables which can be configured for exceptions.

rules:
  '@typescript-eslint/no-unused-vars': ['warn', { varsIgnorePattern: 'tw|css' }]
1reaction
danielkczcommented, May 18, 2020

It is not recommended to remove noUnusedLocals option in TypeScript as the main usage of it is not to allow building if unused local is found.

Relying on Eslint won’t get that done.

It will work if your CI runs tests & lint before building which is the pretty usual pattern.

Nonetheless, an unused variable is not a reason why build should fail. With tree shaking in place, it will be removed anyway from the resulting bundle. Not that it would matter in case of twin.macro at all since it doesn’t have any runtime footprint 😃

Ultimately, #70 will be a better solution, of course. Just pointing out that my workaround is pretty good for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'X' is declared but its value is never read in TypeScript
To solve the 'is declared but its value is never read' error in TypeScript, prefix any unused parameter name with an underscore, or...
Read more >
tslint how to disable error "someVariable is declared but its ...
'myVariable' is declared but its value is never read. I went to the website that documents the rules https://palantir.github.io/tslint/rules/ ...
Read more >
TypeScript, disable checks for `declared but its value is never ...
If you declare a variable but never use it, TypeScript will not compile, saying '<variable>' is declared but its value is never read...
Read more >
I have this problem: is declared but its value is never read(6133)
Tell us what's happening: I don´t know why my code says to me that a value is declared but its value in never...
Read more >
TypeScript errors and how to fix them
You can also follow TypeScript TV on Twitter to stay up to date. ... error TS1371: This import is never used as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found