Skip to content

[Question] getType returns either Invalid (using getType<Type>()) or unkonwn (using getType(var)) #93

Description

@zerobytes

I recently installed rttist in my typescript library.
It's a very simple model library, where everything is just typescript classes and enums.

the generated metadata looks good.

the library is installed in a react application, where rttist is also installed

In the react app, I am calling getType, that is exported from the library through the metadata.typelib located in the library
Library index.ts

export * from './metadata.typelib'

React App

import { getType, Metadata } from 'library-root-name'

The issue is, when I log getType it is either "Invalid Invalid [::invalid::Invalid]" or "Unknown unknown [#unknown]".

console.log(getType<ClassFromLibrary>().displayName) // Outputs Invalid Invalid [::invalid::Invalid]
const instance = new ClassFromLibrary();
console.log(getType(instance ).displayName) // Outputs Unknown unknown [#unknown]

For reference, ids are respectively "::invalid::Invalid" and "#unknown"


If I log Metadata.getModules(), all the library modules are correctly there.
If I log Metadata.getTypes(), all the library types are correctly there.


1- I ran rttist init in the library
2- I ran rttist generate in the library
3- I moved the metadata.typelib to src
4- I exported all exports from metadata.typelib in my index.ts
5- I installed rttist in the react app
6- I imported the getType and Metadata that are being exported from the library
7- getType does not work as expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions