Fix missing ClassificationType.regularExpressionLiteral cases in classifier switch statements#61775
Conversation
…sifier - Add missing case for ClassificationType.regularExpressionLiteral in convertClassification function - Add missing case for ClassificationType.regularExpressionLiteral in getClassificationTypeName function - Maps regularExpressionLiteral to stringLiteral classification to match existing behavior - Fixes compilation errors and makes switch statements exhaustive
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
|
Hi maintainers! 👋 While this PR doesn't address a tracked issue, it's a low-risk, high-value improvement: Enables compile-time exhaustiveness checks Fixes missing case handling for ClassificationType.regularExpressionLiteral Resolves TODOs in the code Keeps behavior consistent (maps to existing stringLiteral classification) Fully passes CI, and improves type safety without breaking changes Would love your review and consideration to merge this small but meaningful quality fix. Thanks |
|
Hi @typescript-maintainers / @microsoft/typescript-team 👋 This PR improves classifier exhaustiveness with minimal, safe changes and resolves existing TODOs. It:
Would appreciate a review or assignment when possible 🙏 Thanks! |
Summary
Fixes compilation errors and enables proper exhaustiveness checking in the TypeScript classifier service by adding missing switch cases for
ClassificationType.regularExpressionLiteral.Problem
The
convertClassification()andgetClassificationTypeName()functions insrc/services/classifier.tshad incomplete switch statements missing handlers forClassificationType.regularExpressionLiteral. This caused:Debug.assertNever()for proper exhaustiveness checkingreturn undefined!instead of compile-time safetySolution
Added the missing switch cases in both functions:
In
convertClassification():In
getClassificationTypeName():Benefits
✅ Fixes compilation errors in TypeScript services
✅ Enables exhaustiveness checking - can now replace
return undefined!withDebug.assertNever(type)✅ Improves type safety with compile-time guarantees
✅ Maintains compatibility - maps to existing
stringLiteralclassification (consistent with line 1169 behavior)✅ Addresses TODO comments referencing GH#18217 about exhaustiveness improvements
Testing
npm run build:compiler)This small but important fix eliminates compilation errors while enabling better type safety practices in the TypeScript codebase.