Closed jloganolson closed 3 weeks ago
Yep you should be able to use the JS (via WASM) version of the checker with
import { check } from 'ezno/initialised';
const fs_handler = (_path) => "const x: string = t ? 4 : 5;";
const output = check("input.ts", fs_handler);
console.dir(output.diagnostics, { depth: 5 });
Since the addition of the playground #115, check
also returns a lookup table for getting the type name of expressions at a position, thus .diagnostics
is needed.
Ah yes I see there is outdated documentation (and check
is missing) of this. Will update
I also wonder if there a way to make the console.log
more informative...?
Yeah, is there something i can do to that WASMCheckOutput to actually see/log typecheck errors (or that it passes)? Or is that the '.diagnostics' in the example code above?
Yep .diagnostics
contains type checker errors with reasons and there byte origin position in the source.
It also contains information and warnings. So you might want to filter on .kind
.
Have updated in the documentation in #155
Do you have an example of how I could run type checking on a string or file of typescript from within code?
I tried
It ran, but didn't seem to produce the desired output. I've been looking for awhile so figure i'd just ask.