Auto fix TSLint Warnings

You can use the –fix option of TSLint to automatically fix most warnings. This might look something like this in a common use case: tslint –fix -c ./config/tslint.json ‘src/**/*{.ts,.tsx}’ Keep in mind that this will overwrite your source code. While this is safe 99.9% of the time, I recommend the following workflow: Commit the changes … Read more

What is the standard for use of quotes in Typescript?

This was the first result in my google search for: “double vs single quotes typescript.” Considering the accepted answer is a little old (but still valid from the docs) I would like to add this quote from: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines updated on November 27, 2015: Use double quotes for strings. Granted “the code is more what you’d … Read more

What does it mean when TsLint says “expected callSignature to have a typedef.”

“Missing Type definition” See : https://github.com/palantir/tslint/blob/master/src/rules/typedefRule.ts for details. Basically some annotation (for a function because callSignature) is missing. Probably the fix (specify the return type explicitly) : networkStop = (action: string = null):void => { this.action[action] = false; this.net = false; this.netd = false; }

How to rewrite code to avoid TSLint “object access via string literals”

You have a couple options here: 1) Just disable the rule /* tslint:disable:no-string-literal */ whatever.codeHere() /* tslint:enable:no-string-literal */ 2) Use a variable instead of a string literal // instead of fields[‘ECStruct1’] = … // do something like let key = ‘ECStruct1′; fields[key] = … 3) Write/Generate an explicit interface See MartylX’s answer above. Essentially: interface … Read more

What could this be about? [TsLint Error: “Promises must be handled appropriately”]

That’s a crappy error message. A better one might be, every expression of type Promise must end with a call to .catch or a call to .then with a rejection handler (source). So, for example, if you do PromiseFunction() .catch(err => handle(err)) .then(() => console.log(‘this will succeed’)) then you will still have a tslint problem, … Read more

How to ignore a particular directory or file for tslint?

Update for tslint v5.8.0 As mentioned by Saugat Acharya, you can now update tslint.json CLI Options: { “extends”: “tslint:latest”, “linterOptions”: { “exclude”: [ “bin”, “lib/*generated.js” ] } } More information in this pull request. This feature has been introduced with tslint 3.6 tslint \”src/**/*.ts\” -e \”**/__test__/**\” You can now add –exclude (or -e) see PR … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)