types function typescript
interface Safer_Easy_Fix {
title: string;
callback: () => void;
}
interface Alternate_Syntax_4_Safer_Easy_Fix {
title: string;
callback(): void;
}
types function typescript
interface Safer_Easy_Fix {
title: string;
callback: () => void;
}
interface Alternate_Syntax_4_Safer_Easy_Fix {
title: string;
callback(): void;
}
typescript function as parameter
function createPerson(name: string, doAction: () => void): void {
console.log(`Hi, my name is ${name}.`);
doAction(); // doAction as a function parameter.
}
// Hi, my name is Bob.
// performs doAction which is waveHands function.
createPerson('Bob', waveHands());
types function typescript
interface Easy_Fix_Solution {
title: string;
callback: Function;
}
types function typescript
interface Param {
title: string;
callback: function;
}
types function typescript
interface Alternate_Syntax_4_Advanced {
title: string;
callback<T extends unknown[], R = unknown>(...args?: T): R;
}
types function typescript
interface Better_still_safe_but_way_more_flexible_fix {
title: string;
callback: <T = unknown, R = unknown>(args?: T) => R;
}
interface Alternate_Syntax_4_Better_still_safe_but_way_more_flexible_fix {
title: string;
callback<T = unknown, R = unknown>(args?: T): R;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us