Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stc fails to find type alias circular references #997

Open
awareness481 opened this issue Apr 17, 2023 · 1 comment
Open

stc fails to find type alias circular references #997

awareness481 opened this issue Apr 17, 2023 · 1 comment

Comments

@awareness481
Copy link
Contributor

Given this input

type A = A2;
type A2 = A;

stc will print
image

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.

@kdy1 kdy1 added this to the v0.0.1: Correctness milestone Apr 17, 2023
@kdy1
Copy link
Member

kdy1 commented Apr 17, 2023

stc calculated evaluation order based on the dependency graph, but it can't handle cycles yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants