React using TypeScript, Don't use {} as a type. {


I am getting an ESlint error Don't use `{}` as a type. `{}` actually means "any non-nullish value". in my Contact component whiling using React and TypeScript.

The component doesn’t have any props.

export default class Contact extends React.Component<{}, MyState> {
    constructor(props = {}) {
        this.state = {
            signedUp: false,

I tried using null instead, but that threw other ESLint errors.


After a lot of digging I found the following GitHub issues.

By adding the following to your .eslintrc.js you are able to ignore the rule. It is recommended to use Configurations to have this rule only apply to React components. This will ensure strong typing everywhere else.

  "rules": {
    "@typescript-eslint/ban-types": [
        "extendDefaults": true,
        "types": {
          "{}": false


Answered By – Jordan Schnur

Answer Checked By – Marie Seifert (AngularFixing Admin)

Leave a Reply

Your email address will not be published.