Why is tslint:recommended not allowing modules?
Asked Answered
A

1

27

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.

Anissa answered 26/5, 2017 at 13:1 Comment(2)
Use standard ES6 modules. typescriptlang.org/docs/handbook/modules.htmlLucey
If you want to use namespaces, which could be appropriate for a large codebase, then turn off the rule.Reunite
L
10

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

Because the are not standard JavaScript syntax.

More

Laughlin answered 29/5, 2017 at 1:10 Comment(2)
github.com/typescript-eslint/typescript-eslint/blob/master/… states that [module/namespace] are considered outdated ways to organize TypeScript code. ES2015 module syntax is now preferred (import/export) but they don't explain whyValle
also, they don't provide a way for those who needs to keep using "outFile"Tarpeia

© 2022 - 2024 — McMap. All rights reserved.