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

Stop creating .baseDir.ts file

Open jpevarnek opened this issue 10 years ago • 11 comments
trafficstars

Creating the .baseDir.ts file now causes issues if the isolatedModules option is specified, and my understanding of it is that, with the rootDir option in Typescript, it should no longer be necessary.

I can submit a PR for this, I just wanted to double-check that my assumptions are correct before doing so.

jpevarnek avatar Oct 16 '15 18:10 jpevarnek

This is definitely something I have been meaning to look into. We do still need to support legacy TypeScript versions, but perhaps if rootDir is specified, we can skip the emit.

Before coding anything, can you explain what you intend to do and how the new functionality still addresses the original use-case?

Thanks for contributing!

nycdotnet avatar Oct 16 '15 19:10 nycdotnet

Ah, I had not considered backwards compatibility, that's fair.

In that case, I think all that would be required would be to include !options.rootDir in the if statement to check for whether the .baseDir.ts file should be created. That way, for people using a compiler older than the baseDir option, nothing will change. For anyone using a newer compiler, and manually specifying baseDir, that file will not exist and it will be perfectly fine to use isolatedModules.

jpevarnek avatar Oct 16 '15 20:10 jpevarnek

I've never fully understood this feature and there's no tests written around it, so I'll have to think about this a bit. If you feel confident that this solution will work, please go ahead and implement the change and send a PR.

Please include two integration tests. One that should emit a .baseDir.ts file and one that should not emit one. The tests are in the Gruntfile.js - a good example that you can copy is outDir_with_spaces.

Then, add an assertion to test/test.ts for your new targets. By convention, we use the test/expected folder to compare against any compilation artifacts created in test.

Submit the PR for that and we'll go from there. Feel free to ask any questions you may have. We need to document this all better. Thanks!

nycdotnet avatar Oct 16 '15 20:10 nycdotnet

Creating the .baseDir.ts file now causes issues if the isolatedModules option is specified, and my understanding of it is that, with the rootDir option in Typescript, it should no longer be necessary.

Indeed .baseDir.ts was a hack around the lack of official support for something like rootDir or tsconfig.json. The original discussion which resulted in this feature : https://github.com/TypeStrong/grunt-ts/issues/77

To be honest I feel that once we had tsconfig.json there wasn't a need for another option (e.g. rootDir) and I did resist it ... but not enough : https://github.com/Microsoft/TypeScript/pull/2034#issuecomment-94649963 as I might be wrong ¯\_(ツ)_/¯ I still recommend thinking of tsconfig.json as your rootDir and not using this option explicitly.

basarat avatar Oct 19 '15 00:10 basarat

I have tried to set a bunch of different options to try and get rid of the .baseDir.ts file. The fact that it is generated in the source and not the target directory means all of our developers have to specifically ignore it. I am setting rootDir, so hoping we can get this removed. If there is a way to do it now, that would be great. It looks like this issue is still open?

greenGoby avatar Dec 31 '15 21:12 greenGoby

Hi - yes it's still open. It's mainly a lack of time to dig into it rather than intent. PRs definitely accepted that provide reasonable functionality for old TS (perhaps, but not necessarily using the existing feature) and new TS with native rootDir support.

nycdotnet avatar Dec 31 '15 23:12 nycdotnet

After looking into this further, I think that the baseDir feature is not doing much for us anymore with the implementation of rootDir. I am going to work on getting the .baseDir functionality removed as long as rootDir is specified (will not worry about backwards compat by revving major version)

nycdotnet avatar Jan 15 '16 04:01 nycdotnet

Is there any way with current versions to not generate the .basedir.ts ?

pksorensen avatar Feb 28 '16 01:02 pksorensen

Did this ever get fixed? I am researching all the various threads about this, but even with the latest beta, I still get a .baseDir.ts file in my source directory. Is there an option or something I can do to suppress that with grunt-ts?

greenGoby avatar Apr 11 '17 17:04 greenGoby

Hi, It's not fixed. I recommend adding .baseDir.ts to your .gitignore file (or similar) and ignore it if at all possible. It's just a matter of digging in to this and I haven't had the energy, to be honest. Pull requests gladly accepted. :-)

nycdotnet avatar Apr 11 '17 17:04 nycdotnet

This should be fixed now thanks to @nobuoka and an additional tweak I've implemented. Please try on grunt-ts 6.0.0-beta.16. You will have to also specify rootDir in your options object when you specify outDir.

nycdotnet avatar May 29 '17 04:05 nycdotnet