-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Bizarre circular type false positive #48708
Comments
cc @ahejlsberg since you made some significant type flow analysis changes |
👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in the issue body running against the nightly TypeScript. Issue body code block by @MichaelMitchell-at ❌ Failed: -
Historical Information
|
The change between 4.6.2 and Nightly occurred at 162713f. |
Have a similar repro; was looking to file a bug and this seems like the right place for it.
|
I looked a bit into what part of 162713f caused this regression. It seems like adding I haven't looked deep enough yet to understand why the circular type resolution happens yet, but I'm sharing my findings here in case it helps someone else pick up this investigation. |
@Andarist you've been pretty capable at fixing random bugs I've stumbled upon before, so maybe this one would be of interest to you 😉 |
The error also goes away if you simply move just the initialization out of the loop: type Wrapper = {
readonly data: number | null;
};
function example(wrapper: Wrapper) {
if (wrapper.data === null) return;
const d = wrapper.data;
for (const _ of []) {
const t = d;
const list = [0];
if (list[t]) {}
}
} Also, per the Playground link, the change happened after 4.6.4. I presume 162713f is post 4.6.4? |
Bug Report
🔎 Search Terms
implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.(7022)
🕗 Version & Regression Information
This changed between versions 4.6.2 and 4.7.0-beta
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Error: implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer
🙂 Expected behavior
No error
The text was updated successfully, but these errors were encountered: