32

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" />

6 Answers 6

52

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

Sign up to request clarification or add additional context in comments.

5 Comments

In my case, I just had some empty files ready for stubbing out.
and what to update there in the tsconfig.json file?
@PardeepJain the accepted answer is all about that only
You can do it without exporting anything: add "export {}" at the end of the file
Where should I place it??
27

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.

1 Comment

you won't get alerts if you have components you aren't using if you term this off... how much that matters is up to you!
3

I was getting this error when file was not imported in any other file. Importing it in any other file (import {} from "/the-filename-having-compilation-error"), removed this error.

Comments

0

I had the same problem. I was made a component and never use that. When I imported that component In one of my page and use that and RERUN the project again , error was disappear.

Comments

0

This error occurs mostly when working with React + TypeScript Simplest Solution for the same is to add 'export' keyword before the class creation or export the class in the end using

export default className;

Comments

-2

If you have eslint installed check the rules section in .eslintrc.json file for any contradicting action.If the action you perforned is against the rule defined then error appears.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.