grunt-ts
grunt-ts copied to clipboard
Support TypeScript 2.0's compiler options baseUrl, paths and rootDirs
I'd appreciate grunt-ts to support compiler options baseUrl, paths and rootDirs of the next TypeScript release.
Currently, it works for me using passThrough but that's a bit cumbersome.
This will be added to grunt-ts vNext as soon as I get the chance to implement it. Thank you for the report.
Do you know when this enhancement will land?
It's possible to pass any arguments you wish to tsc with grunt-ts. Please see the documentation for the additionalFlags feature here:
https://github.com/TypeStrong/grunt-ts#additionalflags
Native support for TypeScript flags are generally added to grunt-ts shortly after the official release due to churn/flags getting renamed or pulled, etc.
Hi @nycdotnet thanks for the response, yes you can pass any argument to tsc with the additionalFlags feature unfortunately for paths it would need more integrated support from grunt-ts as you cannot pass the paths argument via the command line only through the tsconfig.json
tsc --paths returns error TS6064: Option 'paths' can only be specified in 'tsconfig.json' file.
I see. If that is the case, it may be difficult to support other than using the passthrough option. I will have to look into why the TypeScript team decided to not support that option from the command-line.
Indeed. I suspected that it would be difficult to support, I did have a look through the code and issue and didn't find any specific reasoning behind not supporting the option on the command line. Perhaps it could be because maps are hard to represent as a command line option.
Yes currently I am using the passThrough options generating a target specific tsconfig.json using the projects tsconfig.json as a base in order to get this to work using paths.
I almost wonder if we need to get into the business of writing out a temporary tsconfig.json file based on the grunt setup, and then essentially always using pass-through. Do you see a downside there?
Hi there, I face this same problem still. My project needs the --paths pass to tsc, but there is no way to set it. I tried passThrough options, but it still not working. Can someone give a working example of Grunfile.js that works with passThrough options?
Here is my Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
ts: {
default : {
tsconfig: './tsconfig.json',
passThrough: true
}
}
});
grunt.loadNpmTasks("grunt-ts");
grunt.registerTask("default", ["ts"]);
};
Much thanks!
make tsconfig an object.
tsconfig: {
tsconfig: './tsconfig.json'
passThrough: true
}
Ah, that works! Thanks @nycdotnet !
You can workaround the limitation as I did: https://github.com/javatlacati/liniobuzz/blob/master/typescryptimplementation/Gruntfile.js