-
Notifications
You must be signed in to change notification settings - Fork 12.8k
[BUG] 'React' is referenced directly or indirectly in its own type annotation. #28924
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
@magic-akari Wrong project? |
@aminpaks Is there anything wrong in the example code? |
@magic-akari I don't know. I was just pointing out that I think you reported the issue in the wrong project. |
@aminpaks I have reproduced the issue with my code. I am not sure if it is related to DefinitelyType, for it worked in |
@magic-akari I understand.
We might not import it directly but that's how TypeScript works. We always import types from Update: |
You can clone the gist just like how to clone GitHub repo.
Yes. It is what I want to do. |
I just realized what you mean. You're right this has nothing to do with DefinitelyType project. Should not it be like this: // global.d.ts
declare namespace React {
function createRef(): any;
}
// emits.ts
console.log('hello');
React.createRef; |
For someone run into this issue, try this code below:
It works in current version typescript like the original code in Thank you for your patience @aminpaks . |
I'm getting this with 3.2.x series but with 3.1.x series it works. I use this in my own typings: declare var React: typeof import("react"); This has nothing to do with definitelytyped btw. The idea is to declare a global variable React with same type as "react" the module, for these old scripts that does not use imports. Edit The given workaround does not seem to work. If there is something wrong with the above code I gave, I'd like to know how to fix it. I kind of depend on having global variable called "React". |
TypeScript Version: 3.3.0-dev.20181208
Search Terms:
Code
Expected behavior:
compiled without error.(
[email protected]
)Actual behavior:
crashes in
[email protected]
(issue: #28762) (#28782 fixed)compiles error in
[email protected]
Playground Link:
minimal example: https://gist.github.com/magic-akari/cfc0e1c31ddcc5dd4a2f07a5da4725dc
example with
@types/react
: https://gist.github.com/magic-akari/aa10dfb809268eb4f63d5749d113a93aRelated Issues:
#28762
The text was updated successfully, but these errors were encountered: