When the workspace and the staging area aren’t in sync, the differences cannot be tested because the compiler doesn’t know how to deserialize the .git/index blob. The workspace is stored as normal source files, and committing those would be better.
What would be great is a simple way to have build/lint/etc. tools look at the staging area instead of the workspace.