Uh oh!
There was an error while loading. Please reload this page.
Control flow analysis for element access with variable constant-like index in for statements - #60715
Conversation
…index in for statements
| function isSymbolAssignedInForStatementBody(symbol: Symbol) { | ||
| const forStatement = getRootDeclaration(symbol.valueDeclaration!).parent.parent; | ||
| Debug.assert(isForStatement(forStatement)); | ||
| return !isPastLastAssignment(symbol, forStatement.statement); | ||
| } | ||
| function isUsedInForStatementBody(symbol: Symbol, location: Node) { | ||
| const forStatement = getRootDeclaration(symbol.valueDeclaration!).parent.parent; | ||
| Debug.assert(isForStatement(forStatement)); | ||
| return location.pos >= forStatement.statement.pos && location.end <= forStatement.statement.end; | ||
| } |
There was a problem hiding this comment.
I'd love to combine those 2 but I've failed so far to figure out an elegant function name for a function that would do both 😅
Jake Bailey (jakebailey)
commented
Dec 9, 2024
TypeScript Bot (@typescript-bot) test it |
TypeScript Bot (typescript-bot)
commented
Dec 9, 2024
Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing Everything looks good! |
TypeScript Bot (typescript-bot)
commented
Dec 9, 2024
Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready. Everything looks the same! |
TypeScript Bot (typescript-bot)
commented
Dec 9, 2024
Jake Bailey (@jakebailey) Here they are:tscComparison Report - baseline..pr
System info unknown Hosts
Scenarios
Developer Information: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
TypeScript Bot (typescript-bot)
commented
Dec 9, 2024
Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing Something interesting changed - please have a look. Details
|
Mateusz Burzyński (Andarist)
commented
Dec 10, 2024
The snabbdom break isn't harmful. It boils down to a code like this: declarefunctionisPrimitive(s: any): s is string|number;exportfunctiontest(){letc: any;for(leti=0;i<c.length;++i){if(isPrimitive(c[i])){consttarget: string|undefined=c[i];}}}The problem is that declarefunctionisPrimitive(s: any): s is string|number;declareconstfoo: any;if(isPrimitive(foo)){foo;// string | number}Since now this constant-like |
TypeScript Bot (typescript-bot)
commented
Mar 24, 2026
With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies). Next steps for PRs:
|
This is a small extension of #57847
closes#58803
letvariables in for loops are special, despite them being mutable and "shared" for the loop - each iteration gets its own unique copy of that variable. A mutation in the incrementor has no effect on the loop's body so, to the best of my understanding, it can safely be ignored.