Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is tslint:recommended not allowing modules?

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.

like image 886
Diego Gago Avatar asked May 26 '17 13:05

Diego Gago


People also ask

What is TSLint rules?

TSLint is an extensible static analysis tool that checks Javascript and TypeScript code for readability, maintainability, and functionality errors. It can be integrated into build systems and editors. It has a set of core rules built into and configuration that allows it to be extended with custom rules.

What is the use of TSLint?

TSLint is an extensible static analysis tool that checks TypeScript code for readability, maintainability, and functionality errors. It is widely supported across modern editors & build systems and can be customized with your own lint rules, configurations, and formatters.

What is TSLint json file?

When using the CLI or many third-party tools, a file named tslint. json or tslint. yaml is used to configure which rules get run and each of their options.


1 Answers

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

Because the are not standard JavaScript syntax.

More

  • Namespace is a special TypeScript only syntax for a common JS pattern : https://basarat.gitbook.io/typescript/docs/project/namespaces.html
  • Do not use namespaces with outFile : https://basarat.gitbook.io/typescript/docs/tips/outFile.html
like image 104
basarat Avatar answered Oct 11 '22 17:10

basarat