-
Notifications
You must be signed in to change notification settings - Fork 604
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
[heft] Proposal: Specify tsconfig file to use for heft build/start/test #2258
Comments
@BPapp-MS Hello Ben, I think this is the issue we were discussing last Friday. Do you want to look at this and write up a design proposal for this feature? |
This sounds like an implementation choice, not a design requirement. As much as possible, don't we /want/ IntelliSense to accurately reflect the configuration used by the build?
Jest by design models its APIs as global types. This means that Jest APIs are technically accessible in product files, but would fail at runtime because they don't exist outside the test environment. This is a bit odd, but I've never heard of anyone actually being confused by it. It's not mysterious that Thus the importance of
This is already supported today via additionalModuleKindsToEmit, which does not require additional tsconfig.json files. If
Reducing the number of files compiled by File selection is a simple enough problem that, by itself, does not require a separate If there is a separate "include": ["src", "test"], For example, you mentioned...
C# actually models unit tests as its own DLL project that gets compiled separately, with a dependency on the main application assembly. I always thought it was slightly odd that TypeScript projects mix together If we separated them, then in theory |
@octogonz The reason that I would need the feature for my project, and that I imagine others needing the feature, is that it becomes easier to transition into strictNullChecks for large codebases if you're able to show those mistakes in VS Code while not enforcing them in the compiler. It pairs with the fact that VS Code also only supports reporting errors from the tsconfig.json, and this seems to be a common enough problem that I'm seeing others using their vanilla tsconfig purely for intellisense as well, with others for their actual tsc tasks. Another blog post addressing the idea of ramping up strictNullChecks on specific files, also wouldn't work for us it seems, as they're enforcing them for specific files with a separate tsconfig that targets just those files. It seems that that wouldn't add the Intellisense, still, but we wouldn't be able to support that workaround either, as it stands right now. In any case there's definitely a desire in the community to fine-tune Intellisense in VS Code and Heft users wouldn't be able to do that while both Heft and VS Code strictly use the vanilla tsconfig.json. |
Yes, but not at the expense of flexibility where it's needed. As much as possible is fine, but I'm not suggesting that each config would diverge more than is necessary. In fact, the way I actually do this is have a tsconfig.base that tsconfig and tsconfig.build extend from.
This is just a concrete example. Thinking of my examples more generously as classes of problems is likely to lead to us down a more productive path.
I need to dig deeper into this. Thank you for pointing this out.
I could be swayed one way or the other on this. Both options should be possible. Right now, I prefer colocating my unit tests with my source code. I also prefer to colocate my Storybook story files for UI component libraries. A package with 50 UI component folders, another package with the same 50 UI component test folders, and another package with the same 50 UI component story folders sounds pretty unruly to me. I take your point about the ignore globs, but, to each his own. Opinions about testing, IntelliSense, tooling such as Storybook, doc builders, etc. will be all over the place. I think an option here is valid for every reason stated in OP. I'm struggling to steel man the arguments for not allowing, encouraging even, passing separate compilation options similarly to how the first party tool, tsc, allows. Perhaps someone can take a stab at it. |
The first party So (waving hands around vaguely) the main concern with multiple
If we can find one really compelling example for supporting |
@ BPapp-MS Speaking as someone who spent several excruciating nights fixing up thousands of files to conform to stricter Lots of tools look at |
@octogonz Yes, vscode should allow customization. |
Hi All - I think this would be a really nice feature to have, I wrote up my specific use case here #2297 (comment) |
@octogonz I've made the following feature request to VSCode: Allow for highlighting of TypeScript strictness features NOT via tsconfig. This would address the problem of being able to see things like strictNullChecks in the editor without having to alter the tsconfig in ways that would break the heft compilation. Getting them to read from alternative tsconfig files seems unlikely, as that thread ended with the following comment:
|
OP here to show another example where this will be useful. Here is a next.js example where they are suggesting a Let me know if I'm missing something. |
Currently the Heft TypeScript plugin blindly and greedily assumes that any |
This is great! However, I am wondering if this is some sort of documented (and supported) feature. I've just tried that and it doesn't seem like |
@dmichon-msft I did some code reading and it looks like you dropped this functionality recently:
I believe that the usability of this goes far beyond My idea was to have two parallel
Sure, this is a possibility but I am wondering if there could be a better solution for something which really seems like a very typical scenario. |
I have the same issue with Next.js. I can't get |
I'll add my voice I guess. Our usecase is similar to some of the already described - we're migrating a large-ish JS database to typescript. We have |
I certainly agree that this would be useful for much more than |
Added "project" option in typescript.json with identical semantics to the |
@dmichon-msft Thank you so much for working on this! I tried to use the approach to support my use case, i.e. multiple build targets in separate folders, e.g. I am now wondering if it would be more useful to have a list of |
The way you would use this for that scenario is to have the typescript.json refer to a "solution" tsconfig that contains an empty |
Motivation
Passing the desired
tsconfig.json
to heft allows several workflows to exist that are either impossible or awkward without the option. Here some reasons this should be taken up:tsconfig.json
) and build tools.heft/jest
intsconfig
which is a red flag, IMO)Here an example:
Let's say we have a project with the following folder structure.
tsconfig.json
tsconfig.build.json
Other resources
--project
cli option - TypeScript HandbookWorkarounds / Other solutions
This could be addressed elsewhere such as going and filing issues with vscode/eslint/other tools that only look for
tsconfig.json
, and there are good reasons those tools should support an option. Those reasons, for the most part, are the same reasons heft should support an option.Also, my somewhat contrived example above could be worked around (maybe?) by strategically placing another tsconfig.json file in the test folder. This seems cumbersome and simply will not work for other scenarios.
The text was updated successfully, but these errors were encountered: