Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align properties of TsConfigJsonResolved with TypeScript's ParsedCommandLine #38

Open
JounQin opened this issue Sep 2, 2022 · 3 comments

Comments

@JounQin
Copy link
Contributor

JounQin commented Sep 2, 2022

See also ParsedCommandLine

https://github.com/microsoft/TypeScript/blob/fd3a84c3f0c80cb201c47399a055625f919a9b91/lib/typescriptServices.d.ts#L3168-L3178


I'd like to replace parsing tsconfig.json from TypeScript to get-config more seamlessly.

It would be a BREAKING CHANGE.

@JounQin
Copy link
Contributor Author

JounQin commented Sep 9, 2022

@privatenumber Hi, WDYT about this?

@privatenumber
Copy link
Owner

The first version of get-tsconfig used to return ParsedCommandLine by directly using TypeScript. (I moved the code to the FAQ.)

However, the output is very different and incompatible with most tools that expect a tsconfig JSON. For example, since the parsed version uses enums, all the values are converted to numbers. This makes it unusable for important tools (eg. esbuild).

It also makes preparations for compilation that may not be necessary in other tools. For example, it scans the disk and detects matched files. In tools like tsx, would be wasteful because the "compiled files" are detected via dependency tree.

I'm open to adding another util function that converts the static tsconfig.json JSON to the "parsed" one. Although, I'm skeptical how useful it would be.

The function names would probably need to be renamed to make more sense:

  • Rename existing parseTsconfig to readTsconfig
  • Add parseTsconfig(tsconfig: TsconfigObject): ParsedCommandLine

@JounQin
Copy link
Contributor Author

JounQin commented Sep 10, 2022

@privatenumber

I'm working on a PR at import-js/eslint-plugin-import#2519 (comment), which aims to provide parsed tsconfig for resolvers, and also I have https://github.com/un-es/eslint-plugin-i#eslint-plugin-i to integrate with get-tsconfig.

See also import-js/eslint-import-resolver-typescript#179

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

No branches or pull requests

2 participants