mardi 26 octobre 2021

React Typescript: Reflection (listing properties of an interface)

im writing a node-based editor for neural-nets that (currently) uses tensorflow.js for the creation of the networks themself. Tensorflow.js has a layers api with diffrent factory-functions that each have an interface for their arguments. E.g.

interface DenseLayerArgs {
    units: number, 
    useBias?: boolean, 
    ...
}
const dense(args: DenseLayerArgs): {
...
}

My goal is to load all of those factory functions automaticly and create a menu for each thats based on the Args interface. Since its not possible to access properties that might be undefined in plain TS, the solution seems to be some kind of transformer library (eg. https://www.npmjs.com/package/ts-reflection ). But i havnt been able to get any custom transformer running with my create-react-app with typescript setup.

Has anyone been able to get React working with custom transformers or has some other solution for creating a menu from an interface ?

cheers





Aucun commentaire:

Enregistrer un commentaire