2

Using Angular 2, I'm getting a warning in Chrome console:

TypeScript [Warning] transpiling to CommonJS, consider setting module: "system" in typescriptOptions to transpile directly to System.register format

I've serached the web thoroughly but couldn't find a solution or an article about this issue.

I did find this site, that mentions using:

--allowSyntheticDefaultImports  (boolean)   

as

module === "system"

I added to my tsconfig.json file:

{
  "compilerOptions": {
    "target": "es5",
    //"module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noEmitHelpers": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "allowSyntheticDefaultImports": true,
    "module": "system"
  }
}

But it did not help.

Any suggestions ?

2 Answers 2

3

You could set module to system option by setting compilerOptions of of tsconfig.json option.

tsconfig.json

{
    "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "module": "system",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "sourceMap": true
    }
}

Find tsconfig.json docs here

Also you can do the same via command line by adding --module system in your command args.

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

1 Comment

@KobyDouek try removing comment(//"module": "commonjs",) from tsconfig.json.It makes JSON is invalid.
0

It should go into tsconfig.json They contain the settings and configurations for typescript transpilation Check here.

 "compilerOptions": {
    "allowSyntheticDefaultImports": true,
         "module": "system",

    //other settings
   }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.