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

Remove Typescript warnings and use cascading tsconfigs or cli switches instead #552

Closed
2 tasks done
shamilovtim opened this issue May 8, 2024 · 3 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@shamilovtim
Copy link
Contributor

shamilovtim commented May 8, 2024

Description

Problem

When various settings are specified in tsconfig the prepare command throws warnings:

⚠ Found following options in the config file which can conflict with the CLI options. Please remove them from tsconfig.json:

These warnings conflict with being able to properly use tsc in the project for type-checking and are a source of confusion for contributors and maintainers.

Example:

  • Warning users not to use noEmit to make sure files are never accidentally emitted. Rather than do this the prepare script can either just pass --noEmit false or use its own tsconfig rather than rely on the user's tsconfig. Indeed because of the way bob handles compilation it requires noEmit to be true because the user cannot run yarn tsc and emit the same artifacts that bob does which is way more complex than yarn tsc can do on its own with one tsconfig. It doesn't make sense to warn users not to use noEmit when that's what they should be using.

Desired functionality:

The build tool should use the cascading and extending of tsconfigs and/or cli switches to enforce its requirements rather than print warnings in the CLI.

Packages

  • create-react-native-library
  • react-native-builder-bob

Selected options

N?A

Link to repro

N/A

Environment

N/A

@shamilovtim shamilovtim added the bug Something isn't working label May 8, 2024
@shamilovtim shamilovtim changed the title Remove Typescript warnings and use cascading tsconfigs instead Remove Typescript warnings and use cascading tsconfigs or cli switches instead May 8, 2024
@satya164
Copy link
Member

satya164 commented May 8, 2024

either just pass --noEmit false

It's not possible to pass --noEmit when using --emitDeclarationOnly which we need to be able to generate type declarations.

or use its own tsconfig rather than rely on the user's tsconfig

This means user may have errors when compiling that don't show up in their editor or when running tsc. Which is not a good experience.

bob already supports specifying a different tsconfig.json file. You can create a different config file used for bob, and your own tsconfig.json can extend that and noEmit if you want.

@satya164 satya164 closed this as not planned Won't fix, can't repro, duplicate, stale May 8, 2024
@shamilovtim
Copy link
Contributor Author

shamilovtim commented May 10, 2024

@satya164

see my screengrab. this has happened to me working on many react-native-builder-bob based packages. harmlessly run yarn tsc through simple muscle memory. end up with my directories polluted with dozens of files because bob's settings are not propagated to the underlying tsconfig file. bob compiles to /lib/common, lib/module/ and lib/typescript but does not reflect its configuration in the tsconfig, so the underlying tsconfig erroneously compiles a bunch of stuff and pollutes people's working state. there has to be a better way than this, which is why i opened my issue. one might argue "why didn't you run yarn tsc --noEmit" but I don't think it's fair to expect thousands of people to know that the tsconfig bob uses is outputting typescript differently from bob.

Screenshot 2024-05-10 at 12 13 38 PM

this would all be cleaned up if bob uses its own tsconfig that it overrides from the user, including overriding --noEmit or --emitDeclarationOnly rather than requiring users not to use them.

@satya164
Copy link
Member

PR welcome to override whatever options can be overridden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants