tst-reflect: [BUG] TS 4.9 - "[ERR] tst-reflect: You call getType() method directly..." error when following base usage examples.
Describe the bug
When following the README examples for using getType
I continuously get the error [ERR] tst-reflect: You call getType() method directly. You have probably wrong configuration, because tst-reflect-transformer package should replace this call by the Type instance.
I decided to clone the whole repo and to run the examples to see if maybe it was something with my configuration but I get the same issue when trying to run the base-example
.
The code causing the problem
// index.ts
import { getType } from "tst-reflect";
interface ITest {
foo: string
bar?: string
bazz: number
}
console.log(getType<ITest>());
// package.json
{
"name": "example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "npx ttsc & node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"tst-reflect": "^0.12.0"
},
"devDependencies": {
"tst-reflect-transformer": "^0.12.5",
"ttypescript": "^1.5.13"
}
}
// tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"removeComments": true,
"sourceMap": true,
"experimentalDecorators": true,
"rootDir": "./",
"plugins": [
{
"transform": "tst-reflect-transformer"
}
]
},
"reflection": {
"metadata": false,
"debugMode": false
}
}
To Reproduce Steps to reproduce the behavior:
- npm i
- npm run start
- see error…
Expected behavior I expect that the type information would print out and not get an error.
Runtime:
- Node.js version: 18.10.0
- TypeScript version: 4.9.3
- Compiler: ttypescript 1.5.13
- Bundler: N/A
Additional context I’m checking out this library because I would like to use it with an express server, if that is not possible please let me know.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 17 (8 by maintainers)
awesome thanks for the quick response, I was able to get it working with 4.8