If In TypeScript I have a method such as: ```read&...
# javascript
e
If In TypeScript I have a method such as:
Copy code
read<T>(ctor: new (store: KeyValueStore) => T): void;
Note the
new
for the type. What would be the corresponding Kotlin declaration?
h
What about this?
fun<T> read(ctor (KeyValueStore) -> T): Unit
e
@hfhbd unfortunately while I can pass the constructor in Kotlin (
::MyClass
), the TS declaration file ends up containing
read: (p0: KeyValueStore) => T
, which doesn't allow passing a constructor reference AFAIK
h
Hm, this is strange. At least in Kotlin each constructor call can be referenced as a function/lambda:
Copy code
val createTree: (fileName: String, procedure: CobolFIRTree.ProcedureTree) -> CobolFIRTree = ::CobolFIRTree
val tree: CobolFIRTree = createTree("myFile", procedures)