grunt-ts icon indicating copy to clipboard operation
grunt-ts copied to clipboard

Support TypeScript 2.0's compiler options baseUrl, paths and rootDirs

Open k7sleeper opened this issue 9 years ago • 11 comments
trafficstars

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.

k7sleeper avatar Mar 04 '16 09:03 k7sleeper

This will be added to grunt-ts vNext as soon as I get the chance to implement it. Thank you for the report.

nycdotnet avatar Mar 23 '16 03:03 nycdotnet

Do you know when this enhancement will land?

agubler avatar Aug 03 '16 15:08 agubler

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.

nycdotnet avatar Aug 03 '16 17:08 nycdotnet

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.

agubler avatar Aug 03 '16 20:08 agubler

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.

nycdotnet avatar Aug 04 '16 04:08 nycdotnet

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.

agubler avatar Aug 04 '16 09:08 agubler

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?

nycdotnet avatar Aug 04 '16 13:08 nycdotnet

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!

zemian avatar Apr 17 '19 21:04 zemian

make tsconfig an object.

tsconfig: {
  tsconfig: './tsconfig.json'
  passThrough: true
}

nycdotnet avatar Apr 18 '19 10:04 nycdotnet

Ah, that works! Thanks @nycdotnet !

zemian avatar Apr 19 '19 15:04 zemian

You can workaround the limitation as I did: https://github.com/javatlacati/liniobuzz/blob/master/typescryptimplementation/Gruntfile.js

javatlacati avatar Aug 01 '19 08:08 javatlacati