Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Saeris
Copy link

@Saeris Saeris commented Mar 15, 2021

This addresses both oclif/oclif#299 and oclif/oclif#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 microsoft/TypeScript#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.

This addresses both oclif/oclif#299 and oclif/oclif#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 microsoft/TypeScript#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`.
@salesforce-cla
Copy link

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

@Saeris
Copy link
Author

Saeris commented Mar 15, 2021

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
Copy link
Author

Saeris commented Mar 15, 2021

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.

@AKK9
Copy link

AKK9 commented Apr 18, 2021

Is oclif actively maintained?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants