bozdoz
bozdoz3w ago

What does deno lint do, if not type check?

Maybe I'm misunderstanding this, but I see in my IDE that there's a type problem. If I run deno lint on that directory, I'd expect it to complain about it, but it doesn't. See screenshot. Also, this is my attempt at adding Deno 2 to a project, and seenig what I can remove. I expected to be able to remove eslint and tsc type check, but doesn't seem like I can, unless I'm misunderstanding.
No description
13 Replies
bartlomieju
bartlomieju3w ago
deno lint statically analyzes the code for common problems - it's equivalent to eslint deno check will typecheck your code just like tsc does
bozdoz
bozdoz3w ago
gotcha; I guess I can't easily add deno check to an old project due to needing imports to explicitly have ".ts" extensions Thanks, that helps!
bartlomieju
bartlomieju3w ago
Try adding deno.json file with { "unstable": ["sloppy-imports"] } I think it should work then
bozdoz
bozdoz3w ago
Yeah that seems to work. I can't seem to get jest types working, or any node types. I copiied over some of the tsconfig to deno.json, but it's not helping:
"lib": ["DOM"],
"types": ["jest", "node"]
"lib": ["DOM"],
"types": ["jest", "node"]
So why wouldn’t deno check work like tsc noEmit?
bartlomieju
bartlomieju3w ago
Unfortunately types setting is currently not supported. You'll need to supply // @deno-types="npm:DefinitelyTyped/jest" pragma comment in the relevant file What do you mean?
bozdoz
bozdoz3w ago
that seems to have worked I only needed to add the @deno-types to one file not all test files the declaration files are now a bit of a problem. I think I'm going to leave them as
declare var process: NodeJS.Process
declare var process: NodeJS.Process
^ And I'll just ignore them for linting I need it for testing, but deno lint complains with:
error[no-var]: var keyword is not allowed. --> /dev/typewritesomething/src/global.d.ts:5:1 | 5 | declare var process: NodeJS.Process | ^^^^^^^ docs: https://lint.deno.land/rules/no-var
bartlomieju
bartlomieju3w ago
Yeah, that should do the job Ah you can also exclude it from being linted, using lint.exclude property
bozdoz
bozdoz3w ago
Thanks for your help @bartlomieju ! @bartlomieju I've seen this a few times now, and I have no idea when/why it happens:
TS2304 [ERROR]: Cannot find name 'Date'.
This is happening now in deno check
bartlomieju
bartlomieju3w ago
Ah you probably only have dom in libs setting right?
bozdoz
bozdoz3w ago
yes but deno check was working fine before if I do git checkout HEAD~1, my previous commit works fine now it's complaining:
error: TS2318 [ERROR]: Cannot find global type 'Array'.
TS2552 [ERROR]: Cannot find name 'Boolean'. Did you mean 'GLboolean'?
TS2318 [ERROR]: Cannot find global type 'CallableFunction'.
bartlomieju
bartlomieju3w ago
Yeah - so in libs setting you need to specify ["deno.ns", "dom"] And it should work correctly
bozdoz
bozdoz3w ago
now it's complaining about: declare var process: NodeJS.Process;
error: TS2503 [ERROR]: Cannot find namespace 'NodeJS'
this was working last commit though; I may just have to try to chanage things one by one Think I resolved this with:
/// <reference types="npm:@types/node" />
still weird
bartlomieju
bartlomieju3w ago
@dsherret is there a better way to do it?