In a create-react-app typescript project, I tried to write this just to test some stuff quickly:
// experiment.test.ts
it('experiment', () => {
console.log('test');
});
But it gives me the following error, with a red squiggly beneath it
:
All files must be modules when the ‘–isolatedModules’ flag is provided.
However, if I change the file to the following, then everything apparently is fine (except for the unused import of course):
// experiment.test.ts
import { Component} from 'react'; // literally anything, don't even have to use it
it('test', () => {
console.log('test');
});
Why? What is happening here? What does --isolatedModules
actually mean/do?