3

I get this tslint error, which I don't understand why. The interface does start with a capital letter.

29 col 11 error| interface name must start with a capitalized I (interface-name) [typescript/tslint]

S> 29 interface Props {
   30   answerQuestion: (answerQuestion: AnswerQuestion) => void;

3 Answers 3

9

The interface-name rule requires that all interfaces being with the capital letter I. This is to distinguish interfaces from classes (since an interface is not a value, but a class is). In your case, you could correct your code by naming your interface IProps.

Sign up to request clarification or add additional context in comments.

1 Comment

If you need to, you can add this line above the interface declaration to ignore the error: // tslint:disable-next-line:interface-name
3

You can try adding below code in your tslint.json =>

{
  "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
  "linterOptions": {
    "exclude": [
      "config/**/*.js",
      "node_modules/**/*.ts",
      "coverage/lcov-report/*.js"
    ]
  },
  "rules": {
    "interface-name" : [true, "never-prefix"]
  }
}


Comments

1

Modify Your tslint.json

{
  "extends": [
    "tslint:recommended",
    "tslint-react",
    "tslint-config-prettier"
  ],
  "linterOptions": {
    "exclude": [
      "config/**/*.js",
      "node_modules/**/*.ts"
    ]
  },
  "interface-name" : [true, "never-prefix"] // <-- Include this line
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.