-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
mock set to null when interface and namespace have the same name #792
Comments
This is true of exported namespaces/interfaces as well, and I also noticed that creating a copy of the type: Thanks in advance!! |
I confirmed the bug, I'll take care of it! The last thing you said is normal, for the transformer |
@egriff38 new version released, let me know if that fixes the issue! |
So I'm seeing a different issue now. I use Wallaby.js for testing, and for all of the tests I am now seeing the following error generated in the console:
This issue is not occurring when I run the |
If it doesn't happen with jest it may be that wallaby.js is doing something fancy when compiling typescript to make it faster that breaks the transformer (or maybe it's using a different typescript version?)... I've never used it though and it seems to need a license to be able to use it... Can you give me an example of interface that breaks when using wallaby and also the stacktrace? The smaller the interface the better obviously but any would be fine, at least I can start looking at where it fails and for what reason and maybe patch the issue without having to use wallaby |
It very well might be some fanciness, but it ceases to fail when I change the version back from 3.2.3 to 3.2.2. The runtime is actually throwing these errors before the tests even begin to execute, so I'm not entirely sure how I'd go about reproducing, unfortunately
If you're still not sure of anything that might have changed from 3.2.2 to 3.2.3 that caused type.symbol to be undefined in the above reference, I'll go ahead and open a ticket on the wallaby side. As an aside, they do offer free access to OSS owners and contributers, so if you'd like to test with the suite they'll hook you up pro bono.
@Pmyl I really appreciate the assist up to this point! You've been very responsive and super helpful EDIT: I found there is a block in place in a similar use case in another place in the code: ts-auto-mock/src/transformer/descriptor/typeQuery/typeQuery.ts Lines 29 to 31 in a503b4a
Would this pattern make sense in the typeParameters function? It would likely solve the undefined issue I'm running into |
My guess is that since in 3.2.2 it didn't pick up the interface correctly (because it was considering it to be null) it didn't get to the error, now in 3.2.3 the interface works correctly and one of the properties (or even deeper than that) there is a weird type that make the code explode. If you can tell me what's the interface that breaks it I can research on it, I can fix the error handling when the symbol is undefined to just return null but that would mean sweeping the bug under the rug instead of fixing it (i.e. we will have a type that generates null and it's not written anywhere in the docs). It's definitely better than what we have but I would like to try and fix it if you have an interface ready to reproduce the bug. I get it that it may be not possible due to not wanting to expose your code or it's just time consuming and you don't want to do it, let me know! I'll investigate a bit by myself as well in the meantime |
Wow, this bug seems interesting! There is a trial license in wallaby js but I think we still need the interface and which type of wallaby integration you are using (vscode, intellij, ...) in order to find the issue |
I will try to reproduce a minimal repository the causes the bug sometime today. As I said, the errors are actually occurring before any of the tests actually run, so if that's the case in general it should be a fairly lean example. |
Should we open a new ticket for the wallaby-related issue? |
Not at the moment, I want to make sure it's not our fault first |
I have been able to reproduce running just |
@egriff38 Any updates on this? |
Subject of the issue
When there is a namespace and an interface with the same name, with the namespace declared first, mocking that interface returns null.
Your environment
Steps to reproduce
Expected behavior
Should log
{b: ""}
Actual behavior
Actually logs
null
The text was updated successfully, but these errors were encountered: