Closed WankkoRee closed 1 year ago
I declare enum in typings like it:
// src/typings/main/index.d.ts declare const enum Test { hello = 'world', }
and tsconfig.json like it:
tsconfig.json
{ "compilerOptions": { "typeRoots": ["src/typings"] } }
and then I try to use enums like it:
// src/main.ts console.log(Test.hello);
then it will be ReferenceError: Test is not defined.
ReferenceError: Test is not defined
print world just like if I run it by ts-node.
world
ts-node
I run it by ts-node without problem, so I think may it is a bug for tsx ?
tsx
ts-node behavior: https://codesandbox.io/p/sandbox/tsx-bug-in-ts-node-r9h985
tsx behavior: https://codesandbox.io/p/sandbox/tsx-bug-rl55dz
because StackBlitz does not support ts-node, I use CodeSandbox.
StackBlitz
CodeSandbox
https://codesandbox.io/p/sandbox/tsx-bug-rl55dz
v3.12.6
v16.17.0
yarn
Windows
This doesn't seem relevant here. Did you mean to file this in tsx?
sorry, is my mistake, i dont know why I filed this here.
Problem
I declare enum in typings like it:
and
tsconfig.json
like it:and then I try to use enums like it:
then it will be
ReferenceError: Test is not defined
.Expected behavior
print
world
just like if I run it byts-node
.I run it by
ts-node
without problem, so I think may it is a bug fortsx
?ts-node behavior: https://codesandbox.io/p/sandbox/tsx-bug-in-ts-node-r9h985
tsx behavior: https://codesandbox.io/p/sandbox/tsx-bug-rl55dz
Minimal reproduction URL
https://codesandbox.io/p/sandbox/tsx-bug-rl55dz
Version
v3.12.6
Node.js version
v16.17.0
Package manager
yarn
Operating system
Windows
Contributions