Skip to content

Instantly share code, notes, and snippets.

@caasi
Created February 21, 2020 13:08
Show Gist options
  • Save caasi/4cdcacf6dfc995ab73c35776562d7d50 to your computer and use it in GitHub Desktop.
Save caasi/4cdcacf6dfc995ab73c35776562d7d50 to your computer and use it in GitHub Desktop.
type ICallback = (i: number) => string
class Foo {
cb: ICallback = () => ''
registerCb(cb: ICallback) {
this.cb = cb
}
}
const foo = new Foo()
function correctCb(i: number): string {
return 'Hello world ' + i ** 2 + ''
}
function wrongCb(): string {
return ''
}
function wrongCb2(): void {
return
}
function wrongCb3(s: string): string {
return '';
}
foo.registerCb(correctCb)
foo.registerCb(wrongCb)
foo.registerCb(wrongCb2)
foo.registerCb(wrongCb3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment