Fix panic in getTsConfigObjectLiteralExpression for malformed tsconfig#3877
Fix panic in getTsConfigObjectLiteralExpression for malformed tsconfig#3877Copilot wants to merge 3 commits into
Conversation
Add IsObjectLiteralExpression check before calling AsObjectLiteralExpression to prevent panic when tsconfig.json contains a non-object expression. Fixes #1286 Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
|
Not sure about this theory of the case and I don't think this testcase repros the problem. the call stack indicates we're computing a related diagnostic. |
|
@copilot fix it |
…nfig Replace simple string-literal tsconfig with array-literal tsconfig that triggers the array recovery path. This creates a program with types ["nonexistent"] which fails to resolve, generating a processing diagnostic whose explanation path exercises getCompilerOptionsObjectLiteralSyntax → getTsConfigObjectLiteralExpression — the exact crash path from the issue. Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
You're right — the original test just hit the TS5092 path without exercising the diagnostic explanation code. Updated the test to use
Updated the test in fdfec63 to properly exercise the crash path. The guard in |
getTsConfigObjectLiteralExpressioncallsAsObjectLiteralExpression()on the first statement's expression without checking the node kind. When tsconfig.json contains a non-object expression (e.g. a string literal), this panics.ast.IsObjectLiteralExpressionguard before the cast; returnnilwhen the expression isn't an object literal (already handled by all callers)tsconfigMalformedNonObject.tsthat reproduces the crash with a string-valued tsconfig