Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot compile namespaces when the '--isolatedModules' flag is provided

I am using urigo:angular2-meteor. When I add an empty main.ts in server folder, it always shows:

Cannot compile namespaces when the '--isolatedModules' flag is provided.

Even I added the code below on the top of main.ts, it still shows same thing.

/// <reference path="../typings/angular2-meteor.d.ts" /> 
like image 480
Hongbo Miao Avatar asked Nov 28 '15 22:11

Hongbo Miao


2 Answers

I had the same problem and I added tsconfig.json into the root directory of my project.

{     "compilerOptions": {         "isolatedModules": false     } } 

I didn't have the time to dive into it, but it solved the problem.

like image 35
Guenter Guckelsberger Avatar answered Sep 20 '22 15:09

Guenter Guckelsberger


I faced similar issue in react + ts. I had commented out all my code.

Turns out A global file cannot be compiled using '--isolatedModules'. Ensure your file contains imports, exports, or an 'export {}' statement.

So, added something like:

export const foo = 'foo'; 

or

export {} 

It's a temporary solution, else you can delete the file with commented code or update tsconfig.json

like image 167
Priyanshu Chauhan Avatar answered Sep 21 '22 15:09

Priyanshu Chauhan