Open marcj opened 7 months ago
Also, when reflection is not set to true in tsconfig.json
, the following error is returned (in this case when testing with valuesOf
):
deepkit-framework/packages/type/src/reflection/reflection.ts:136
throw new Error('No type given');
^
Error: No type given
at typeOf (deepkit-framework/packages/type/src/reflection/reflection.ts:136:11)
at valuesOf (deepkit-framework/packages/type/src/reflection/reflection.ts:98:18)
at Object.<anonymous> (deepkit-test/src/main.ts:41:21)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module.m._compile (deepkit-test/node_modules/ts-node/src/index.ts:1618:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Object.require.extensions.<computed> [as .ts] (deepkit-test/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Function.Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
Edit: this might be specific to valuesOf
(and/or typeOf
) in any case
good catch. we should make sure we don't have several different error messages meaning the same thing
https://github.com/deepkit/deepkit-framework/blob/92315f91ed4295d77b8c7bb693e8cbf8d5d32b23/packages/type/src/reflection/processor.ts#L363
@SamJakob had a great idea about improving this error message. Quote from discord:
it's not always possible to detect tsconfig.json options or paths (since they might be provided by a build tool, or when run in the browser), but we could describe in a general way what needs to be enabled. And if the code runs in the server maybe try to check if there is a tsconfig.json and just read that file (works for beginners well enough that have likely a single tsconfig.json)