stc
stc copied to clipboard
stc fails to find type alias circular references
Given this input
type A = A2;
type A2 = A;
stc will print

Log
ERROR (1) Failed to find type: A2#2
at crates/stc_ts_file_analyzer/src/analyzer/scope/mod.rs:2261
in Expander::expand_ref
in Expander::expand_type
in Expander::expand_type
in Expander::expand_ref
in Expander::expand_type
in expand
in normalize with ty: A;
in normalize with ty: A;
in Stmt with line_col: "(2017:1-2017:13)"
but for a non-circular reference stc will find the type just fine
type A = A2;
type A2 = number;
declare var x: A;
x = "" // error cant assign string to type number
My guess is that having a self-referencing type breaks how type aliases are hoisted (which I presume they are hoisted), but i haven't been able to confirm.
stc calculated evaluation order based on the dependency graph, but it can't handle cycles yet.