Enforce the use of Typescript
Unanswered
Horned oak gall posted this in #help-forum
Horned oak gallOP
Say I have a file called Grid.tsx. It is intented to be React component in Typescript.
At this moment, if I use Javascript inside the file, Next.js/The linter doesn't warn me at all.
How do I enforce that, if it is a Typescript file, it must only contain Typescript and not Javscript?
At this moment, if I use Javascript inside the file, Next.js/The linter doesn't warn me at all.
How do I enforce that, if it is a Typescript file, it must only contain Typescript and not Javscript?
9 Replies
TypeScript is a super set on top of JavaScript, all JavaScript syntax is valid TypeScript syntax so it won’t warn you at all when the Types can be inferred automatically by Typescript at compile time
Use a stricter linter. My eslint moans if I’m not properly typing stuff, but as @luis_llanes most can be inferred so js is valid ts most of the time!
Yea the way to enforce the use of TypeScript is by setting linter rules that complain until you explicitly type your stuff, but honestly, It’s better to just let TypeScript infer what it can out of the box, it’s smarter than us anyway
Yeah and I do use a fairly strict linter that I run through before committing but if it was popping up red all the time in vs code I’d shoot my computer 😂 so I don’t have vs code use my eslint config!
@adam.birds I gotta know how you do that, I’ve never set up a linter as a pre commit checker honestly
@Horned oak gall solved?
@luis_llanes <@173003137211170816> solved?
Horned oak gallOP
Thanks,I understand the idea and it is kind of solved. I still need to look into what linter I should use.
Horned oak gallOP
Maybe I should say "linter rules"? I think I am using eslint already