A few days ago I shared a small CLI experiment called fixmyfile that automatically fixes repetitive TypeScript errors using compiler diagnostics and AST transformations.
While testing it more, I kept running into another frustrating TypeScript pattern:
const users = data . filter ( Boolean );
users . map (( u ) => u . name );
Enter fullscreen mode
Exit fullscreen mode
Even after filtering values, TypeScript can still complain that:
'u' is possibly undefined
Enter fullscreen mode
Exit fullscreen mode
Logically the values are already filtered, but TypeScript narrowing does not always behave the way developers expect.
So I started experimenting with AST-based transformations for these cases too.
Now the CLI automatically converts:
const users = data . filter ( Boolean );
Enter fullscreen mode
Exit fullscreen mode
into:
const users = data .…