Created
February 21, 2020 13:08
-
-
Save caasi/4cdcacf6dfc995ab73c35776562d7d50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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