stc: stc doesn't validate the type alias assignment in some cases
Given the following code
type A = Uppercase<42>;
stc will not check whether the rhs Uppercase<42> is a valid type or not (in this case it is not). I haven’t verified if this happens for all type aliases or not.
Edit: Issue updated, original bug report was incorrect. See https://github.com/dudykr/stc/issues/771#issuecomment-1455024083
if you run stc on it you’ll notice that stc does not report an error. Upon further investigation it looks like stc fails to find the built-in type Uppercase in this case. I think it is because self.config.builtin is set to false.
Note that it only fails to find the type in some cases, in most cases (like then Uppercase is a type of a function param, stc finds the type)
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 16 (16 by maintainers)
You can do
t.validate_with(self)wheretisRTsTypeandselfisAnalyzer.Yes, I think that’s the problem.
Ah, it’s a problem with the log message.
https://github.com/dudykr/stc/blob/1b605ab81770ea9db2d76bf3857d06a5a5d540fc/crates/stc_ts_file_analyzer/src/analyzer/scope/mod.rs#L1164
The function name is
find_local_type, which is only responsible for finding type in the local scope.Type aliases are implemented
I’m not sure about
noLib, but I think we can exclude it for now. I don’t expect someone to use it for a real-world project