deepkit / deepkit-framework

A new full-featured and high-performance TypeScript framework
https://deepkit.io/
MIT License
3.18k stars 121 forks source link

Error: No type given #489

Closed colemars closed 10 months ago

colemars commented 10 months ago

Hello, I copy and pasted your doc example into a new project and am receiving the above error, Error: No type given.

import { valuesOf } from "@deepkit/type";

type Groups = "admin" | "user" | "guest";

const groups = valuesOf<Groups>(); // ['admin', 'user', 'guest']

console.log("groups", groups);

And the project

Any guidance would be great as I really would like to make use of this library

timvandam commented 10 months ago

You shouldn’t pass an array here as (iirc) it will be used as type instead of using the generic type

where in the docs is this example?

colemars commented 10 months ago

Sorry, that was leftover from debugging. Updated to use example from website. The result is the same with or without the array there

colemars commented 10 months ago

I'll happily just accept a repo in which the above example from the docs is working as an answer, at least that would narrow it down to my env. But i've tested in two diff repos at this point and am still getting the above err.

timvandam commented 10 months ago

The issue is probably that you do not have reflection enabled in your TSConfig. It should be a top level property, ie

{
    "compilerOptions": { ... },
    "reflection": true
}

Also make sure that the type compiler has been installed by running node_modules/.bin/deepkit-type-install

colemars commented 10 months ago

Dang, got that example working but none of the ReflectionClass examples will work now.. bummer! Will check back in in a few months maybe.

timvandam commented 10 months ago

It wirks for me 🤷‍♂️ It only works on classes compiled with the deepkit type compiler installed. So if you’re trying to use third party classes it won’t work