profile
viewpoint

Ask questionsFeature Request --noAnyProperties

What I would like is a compiler option that throws an error if an object (even if typed as any) tries to access a property. This would allow overriding 3rd party declarations that use the any type to force a more specific type.

$.ajax({ type: "POST",
success: function(response:any) {
let columns: response.columns <==compiler error },
});

Microsoft/TypeScript

Answer questions kitsonk

This is already well covered by linting rules in both eslint and tslint:

  • https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-explicit-any.md
  • https://palantir.github.io/tslint/rules/no-any/