-
-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to feed .js files to TypeScript when the allowJs
flag is provided?
#123
Comments
No, it's not possible today. It would be a nice addition. |
👍 Awesome stuff! thanks :) |
@kruncher If you get a chance, I'd love for someone to test it before I release 😄 |
@blakeembrey I am trying to get this to work but having difficulties with passing the
I suspect that I am not properly understanding the instructions on the readme page. |
@kruncher You can not pass options into a Mocha register like that. It expects a file, so you're just passing options to |
@blakeembrey I created a script file to register ts-node, startup mocha and then start the test running process and it seems to be working 😃 There was one slight false alarm:
I was able to take the batteries out by specifying a path for It would be really awesome if there were a way to set up ts-node to work with mocha without having to create the bootstrap; perhaps with the environment variables. Here is the bootstrap script that I threw together to try this out: // /abc/scripts/test.js
require('ts-node').register({
compilerOptions: {
outDir: "../test-js",
allowJs: true
}
});
// from: https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically
var Mocha = require('mocha'),
fs = require('fs'),
path = require('path');
// Instantiate a Mocha instance.
var mocha = new Mocha();
var testDir = path.join(__dirname, '../test');
// Add each .js file to the mocha instance
fs.readdirSync(testDir).filter(function(file){
// Only keep the .js files
return file.substr(-3) === '.js';
}).forEach(function(file){
mocha.addFile(
path.join(testDir, file)
);
});
// Run the tests.
mocha.run(function(failures){
process.on('exit', function () {
process.exit(failures); // exit with non-zero status if there were failures
});
}); |
@kruncher Thanks for the catch, I've run into this on another module before. I think we just need to fake the |
@kruncher Did you want to try https://github.com/TypeStrong/ts-node/releases/tag/v0.9.1? |
@blakeembrey Awesome stuff; the Cheers! |
Looking at the source for
ts-node
I see that it filters against the extensions.ts
and.tsx
.In my case I would like it to also treat the
.js
extension in this way but only within a certain path of my node application since I do not want any.js
scripts from withinnode_modules
to be put through the TypeScript compiler in this way.Is there a way to do this that I am perhaps missing?
Many thanks!
The text was updated successfully, but these errors were encountered: