user2227400
user2227400

Reputation:

What is "no-string-literal" rule in tslint?

The description found here is very short:

Disallows object access via string literals.

Is there any further documentation or example?

Upvotes: 21

Views: 12393

Answers (1)

Luka Jacobowitz
Luka Jacobowitz

Reputation: 23512

It means you can't access objects using the bracket notation. For example:

object["property"]

This way, a simple typo will throw an error and that's why it should be avoided. Instead, it is encouraged to use strongly-typed access.

Upvotes: 25

Related Questions