Open Raynos opened 4 years ago
Btw; great project.
I'm impressed the ./packages/cli
package compiles and passes the HegelJS type checker.
It looks like the ./packages/core
itself uses flow for bootstrapping atm.
Thank you. Yes, @hegel.core
is developed with Hegel 😄
When trying to debug the behavior of the TypeChecker it would be useful to be able to turn on tracing.
I have an example of tracing behavior in https://github.com/Raynos/jsig
The method that checks function calls or checks that LHS & RHS are the same types should add traces, for example ( https://github.com/Raynos/jsig/blob/master/type-checker/meta.js#L513-L521 ).
Aka
Whatever code checks
number
andstring
should keep a trace of all checks even if they succeed the type checker. It should always trace, they are useful and cheap to keep around in memoryIf tracing is enabled at the CLI, you can ask it to print errors with tracing, for example ( https://github.com/Raynos/jsig/blob/master/bin/jsig.js#L232-L238 ).
When printing errors I grab the
start
andend
location of the error, for example above it would be line 31 and I loop over alltraces
in theModuleScope
/GlobalScope
etc and if the location of a trace is within the location of an error I print them.I also found it useful to have an extra CLI flag called
--full-trace
which just loops over the traces and prints them all ( https://github.com/Raynos/jsig/blob/4ec14c2039924243671d16d8a6c3a5318679cf0e/bin/jsig.js#L220-L224 ).When printing a trace I would print something like