Why is tslint:recommended not allowing modules?

Diego Gago picture Diego Gago · May 26, 2017 · Viewed 10.8k times · Source

We are using typescript v2.3.2 and TSLint v4.5.1 with VS Code to create a SPA. Codebase is growing and we need to modularize it someway.

I tried to do the modularization using typescript modules but found the following lint error when transpiling the app.

[tslint] 'namespace' and 'module' are disallowed (no-namespace)

I'm using this configuration for the linter:

{
  "extends": "tslint:recommended",
  "rules": {
    "no-var-requires": false,
    "no-console": ["error", false],
    "max-line-length": [false]
  }
}

The recommended rules file at line 89 shows this rule:

"no-namespace": true,

I wonder if there is something wrong and what would be the best way to modularize a SPA, following good practices that are not obsolete soon.

Examples of code will be welcomed. Thank you very much.

Answer

basarat picture basarat · May 29, 2017

[tslint] 'namespace' and 'module' are disallowed (no-namespace)

Because the are not standard JavaScript syntax.

More