-
-
Notifications
You must be signed in to change notification settings - Fork 433
Cannot compile with TS 2.9.1 & "resolveJsonModule" #793
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
Comments
Hey thanks for reporting and for the repro @mbenadda! I'm afraid I'm snowed and so can't look at this right now. But I'm happy to help you dig into this. It looks like this is the code that's likely erroring: (compiled output of
Can you confirm if that is the case? That If so, the next question is "why"? Also, is Could you investigate? I'm wondering if with 2.9 there is now something extra that needs to be passed when creating a To answer that, you may want ask a question of the TypeScript team. I'll help with advice / pointers etc - but I'm not going to be able to look at this personally right now I'm afraid. |
Hey @johnnyreilly thanks for your help! I'll try to investigate but I'm not familiar with the internal structure of
This is exactly what is happening.
As far as I can see right now, no. It's only undefined when there is an actual
I started by checking required methods, arity and types and everything seems to match. There's no documented API breaking change in 2.9 either. I asked that question on the TS Gitter, will see if I get an answer there. Might there be a problem due to |
Thanks for looking into this @mbenadda
This sounds like it could be worth investigating. Be great to hear what comes out of the TS Gitter. Although she's in no way obligated to assist, I know that @sheetalkamat has often been really helpful around this area. Related to that, it could be worth checking out other projects that hook into TypeScript. in the same way that For example, it looks like fusebox might be facing the same issue: fuse-box/fuse-box#1288 (or related) |
I've just given your question a bump - hopefully that'll help! |
Hi there,
According to the stack trace ( ts-loader/src/after-compile.ts Line 84 in fb7eb9d
|
Thanks @timocov! I was wondering: with It's worth bearing in mind that for each file in the program this code will likely be run. I'm interested as to whether it always fails regardless of file type when Would someone be able to investigate? |
I think I may have located the problem.
Which causes that check to fail when trying to process a I'm not exactly sure why the I think this may relate to Line 270 in f9c5f01
Because when you look at And in Anyway, if I manually add I'd like your opinion on this @johnnyreilly before I create an issue/attempt to make a PR on the TypeScript repo. |
Well done for investigating @mbenadda! I'm on a phone right now and so clicking on the code links is proving challenging... One thing that strikes me is that when I look here: https://github.com/Microsoft/TypeScript/blob/master/src/parser/utilities.ts#L7805 I see
It's possible I've misunderstood you though. Phone and all that.
This is by far and away the most interesting thing you've found. I think you should raise an issue against the Typescript repo linking back to this and listing your findings. I think you may have caught a bug. Once again, well done for digging into this; I'm super grateful! |
As far as I can see, the part I linked is not checking script kinds, just getting file extensions directly during module name resolution. As part of getting the extensions, it checks they're in the allowed lists of extensions.
I really appreciate your help and availability on this! I will create an issue on there and hopefully we've gathered enough info to get some help from someone there! |
Great! Go you! |
When this TypeScript PR gets shipped the issue should be resolved: microsoft/TypeScript#24959 |
- @types/node v10.1.2 → 10.3.4 - ts-loader v4.3.0 → 4.4.1 https://github.com/TypeStrong/ts-loader/releases/tag/v4.3.1 https://github.com/TypeStrong/ts-loader/releases/tag/v4.4.0 https://github.com/TypeStrong/ts-loader/releases/tag/v4.4.1 - ts-node v6.0.3 → 6.1.2 https://github.com/TypeStrong/ts-node/releases/tag/v6.0.4 https://github.com/TypeStrong/ts-node/releases/tag/v6.0.5 https://github.com/TypeStrong/ts-node/releases/tag/v6.1.0 https://github.com/TypeStrong/ts-node/releases/tag/v6.1.1 https://github.com/TypeStrong/ts-node/releases/tag/v6.1.2 - typescript v2.8.3 → 2.9.2 - Some pretty exciting features like JSON typing and better support for mapped types including enum compatibility. JSON typing blocked by TypeStrong/ts-loader#793 though. - --pretty enabled by default so this patch removes it from the config. https://github.com/Microsoft/TypeScript/releases/tag/v2.8.4 https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#typescript-29 https://github.com/Microsoft/TypeScript/releases/tag/v2.9.1 https://github.com/Microsoft/TypeScript/releases/tag/v2.9.2
Working around this bug in ts-loader and the TypeScript compiler for now: TypeStrong/ts-loader#793 It looks like the fix won't be released immediately, so I'm switching instead to separately compile the TypeScript and *then* run webpack. This can be reverted when TypeScript 3.0 is released.
This issue should now be resolved with today's release of Typescript 3.0 😄 |
Awesome! |
For google juice: You get the same error message for microsoft/TypeScript#26554. It seems like both |
Yes I think so. |
If you're using vscode and have builtin TS plugins disabled, enabling those extensions will resolve the issue. |
Uh oh!
There was an error while loading. Please reload this page.
Expected Behaviour
TS 2.9 added a new option to allow JSON imports and get proper types doing so (without resorting to somewhat dirty workarounds using ambient definitions), with the
resolveJsonModule
compiler option.It should compile as usual when using this new flag.
Actual Behaviour
An error is thrown when running webpack with ts-loader:
Steps to Reproduce the Problem
Compile a project using
webpack
,ts-loader
and[email protected]
withresolveJsonModule
(andesModuleInterop
) enabled and an import for a JSON file somewhere in the project.Removing
resolveJsonModule
and using an ambient declaration works fine. I tried this with ts-[email protected]
andtypescript@next
Location of a Minimal Repository that Demonstrates the Issue.
https://github.com/mbenadda/ts-loader-issue-793-example-repo
See instructions in README, just clone,
yarn install
andyarn webpack
to see the issue.The text was updated successfully, but these errors were encountered: