Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

typescript pass a function as an argunetn

class Foo {
    save(callback: (n: number) => any) : void {
        callback(42);
    }
}
var foo = new Foo();

var strCallback = (result: string) : void => {
    alert(result);
}
var numCallback = (result: number) : void => {
    alert(result.toString());
}

foo.save(strCallback); // not OK
foo.save(numCallback); // OK
Comment

PREVIOUS NEXT
Code Example
Typescript :: typescript get object property by name 
Typescript :: listobjects vba 
Typescript :: create npm module typescript 
Typescript :: typescript get all enum keys 
Typescript :: typescript object get value by key 
Typescript :: the android gradle plugin supports only kotlin gradle plugin version 1.3.10 and higher 
Typescript :: set up react with typescript 
Typescript :: content script matches all 
Typescript :: angular build router-outlet not working 
Typescript :: how to remove the last item from a collection powerapps 
Typescript :: google scripts docs highlight 
Typescript :: when a vector in c++ is resized what happens to the elements of the vector 
Typescript :: mat datepicker timezone not correct 
Typescript :: eliminar un elemento de un array typescript 
Typescript :: ng idle issue ERROR in node_modules/@ng-idle/core/lib/eventtargetinterruptsource.d.ts(29,9): error TS1086: An accessor cannot be declared in an ambient context. 
Typescript :: find common elements in two flutter 
Typescript :: set constraints for UIView swift 
Typescript :: promise.all inside useEffect 
Typescript :: any typescript 
Typescript :: No type arguments expected for interface Callback 
Typescript :: user acceptance testing vs system testing 
Typescript :: typescript deep partial 
Typescript :: How to use the Generic Type Format for Arrays in Typescript 
Typescript :: servlets meaning 
Typescript :: Create 2 set A and B of size n1 and n2 . Print sets A and B. 
Typescript :: how to restart ts intellisense vscode 
Typescript :: whats the name of that game that got taken down from the app store about a box person 
Typescript :: flutter too many positional arguments 0 expected but 1 found 
Typescript :: How to join all url segments to make a url in javascipt 30seconds of code 
Typescript :: google sheets script save A RANGE to csv 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =