config icon indicating copy to clipboard operation
config copied to clipboard

feat: Add support for Custom tsconfig.json, Resolve extended configs

Open Saeris opened this issue 4 years ago • 4 comments

This addresses both https://github.com/oclif/oclif/issues/299 and https://github.com/oclif/oclif/issues/488

loadTSConfig() in src/ts-node.ts was not properly resolving extended configuration files, because while parseConfigFileTextToJson will load and parse a given tsconfig.json file, it does not merge compilerOptions from configs specified in the extends option.

This implementation is based on the solutions suggested in https://github.com/microsoft/TypeScript/issues/5276 and https://stackoverflow.com/questions/53804566/how-to-get-compileroptions-from-tsconfig-json which rely on Typescript's utilities for loading and parsing tsconfig.json files.

Specifically, by adding a call to parseJsonConfigFileContent(), the merged compilerOptions will be resolved as expected.

Additionally, this adds support for user-defined tsconfig files through the tsConfig option under oclif key in their package.json.

Saeris avatar Mar 15 '21 21:03 Saeris

Thanks for the contribution! Before we can merge this, we need @Saeris to sign the Salesforce.com Contributor License Agreement.

salesforce-cla[bot] avatar Mar 15 '21 21:03 salesforce-cla[bot]

I'm not sure what is causing the tests in https://github.com/oclif/config/blob/master/test/typescript.test.ts to fail. Some guidance here would be appreciated.

Saeris avatar Mar 15 '21 21:03 Saeris

Should also be noted that I bumped typescript up to the latest version. This facilitates importing the official CompilerOptions type definition. It should also allow for ts-node to compile the latest supported syntax/typescript features. In my own development with Oclif I've noticed that it won't compile commands that use Optional Chaining syntax. I haven't tested whether this change resolves that specific issue.

Saeris avatar Mar 15 '21 21:03 Saeris

Is oclif actively maintained?

AKK9 avatar Apr 18 '21 15:04 AKK9