‘this’ implicitly has type ‘any’ because it does not have a type annotation

When I enable noImplicitThis in tsconfig.json, I get this error for the following code: ‘this’ implicitly has type ‘any’ because it does not have a type annotation. class Foo implements EventEmitter { on(name: string, fn: Function) { } emit(name: string) { } } const foo = new Foo(); foo.on(‘error’, function(err: any) { console.log(err); this.emit(‘end’); // … Read more

TypeScript and React – children type?

I have a very simple functional component as follows: import * as React from ‘react’; export interface AuxProps { children: React.ReactNode } const aux = (props: AuxProps) => props.children; export default aux; And another component: import * as React from “react”; export interface LayoutProps { children: React.ReactNode } const layout = (props: LayoutProps) => ( … Read more