4

When I extend React.Component like this:

export default class App extends React.Component<any, any > {

    constructor (props: React.ReactPropTypes) {
        super(props);
    }

// other code
}

I got the following warnings:

./src/App.tsx [37, 50]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type, the empty type ('{}'), or suppress this occurrence. [37, 55]: Type declaration of 'any' loses type-safety. Consider replacing it with a more precise type, the empty type ('{}'), or suppress this occurrence.

Which is the best way to solve these warnings?

1
  • 3
    Try using {} instead, if your component doesn't really need anything from its props and state. If the component does demand something from its props/state, express that in the type signature. Commented Nov 30, 2017 at 12:28

1 Answer 1

1

in yout tslint.json you can put:

{"rules": {
"no-any": false
 }      
}
Sign up to request clarification or add additional context in comments.

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.