Expected Behavior
No error occured, and use the new register instance compile the .ts file once when create a new register instance to cover an old one, the old one may be created by third-party library(e.g. karma cli).
The reason for create a new register is that, I want to use a special RegisterOptions for .test.ts files.
Actual Behavior
By debugging the source code, I found that if create two register, the require.extensions[.ts] handler was nested registration by registerExtensions function twice. And the .ts file was compiled twice, the old register's output as the new register's input, then some error occured, like below:
TSError: ⨯UnabletocompileTypeScript:
errorTS7022: '__awaiter'implicitlyhastype'any'becauseitdoesnothaveatypeannotationandisreferenceddirectlyorindirectlyinitsowninitializer.2var__awaiter=(this&&this.__awaiter)||function(thisArg,_arguments,P,generator){
......Steps to reproduce the problem
- First, create a
test.ts for test the problem. - Then, create a
index.js, and create two register instances directly in order to simplify the problem, then require the test.ts file. - Finally, run the
node index.js command.
Minimal reproduction
ts-node-test
Specifications
- ts-node version: 9.0.0
- node version: 13.9.0
- TypeScript version: 4.0.5
- Operating system and version: win7-64bit
Expected Behavior
No error occured, and use the new register instance compile the
.tsfile once when create a new register instance to cover an old one, the old one may be created by third-party library(e.g.karma cli).The reason for create a new register is that, I want to use a special
RegisterOptionsfor.test.tsfiles.Actual Behavior
By debugging the source code, I found that if create two register, the
require.extensions[.ts]handler was nested registration byregisterExtensions functiontwice. And the.tsfile was compiled twice, the old register's output as the new register's input, then some error occured, like below:Steps to reproduce the problem
test.tsfor test the problem.index.js, and create two register instances directly in order to simplify the problem, thenrequirethetest.tsfile.node index.jscommand.Minimal reproduction
ts-node-test
Specifications