Skip to content

[BUG] TS 4.9 - "[ERR] tst-reflect: You call getType() method directly..." error when following base usage examples.  #84

@aj-bartocci

Description

@aj-bartocci

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:

  1. npm i
  2. npm run start
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions