You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] 'React' is referenced directly or indirectly in its own type annotation. #28924
Expected behavior:
compiled without error.(typescript@3.1.6) Actual behavior:
crashes in typescript@3.2.1 (issue: #28762) (#28782 fixed) compiles error in typescript@3.3.0-dev.20181208
'React' is referenced directly or indirectly in its own type annotation.
magic-akari I don't know. I was just pointing out that I think you reported the issue in the wrong project.
This project is TypeScript language, DefinitelyType project is maintaining React types, to track the issue and fix it you need to open this issue in that project.
Amin Pakseresht (@aminpaks) I have reproduced the issue with my code.
The only things related to React is that I use the React as the variable name and its logic is the same as the definition of @types/react.
There is no module imported from react or @types/react.
I am not sure if it is related to DefinitelyType, for it worked in typescript@3.1.6.
magic-akari I understand.
React itself is a javascript library, it doesn't include any typings (facebook doesn't like TypeScript?) Anyways this means every time there is a new TypeScript version (current 3.2) there is a chance that types created by DefinitelyTypes project are not compatible anymore.
There is no module imported from react or @types/react.
We might not import it directly but that's how TypeScript works. We always import types from @types/react (based on tsconfig and typeRoot) otherwise VSCode (runs TypeScript language server) can't understand the semantics of React.
Update:
Can you push your code in a repo?
Looking at the second link you posted, are we importing @types/react to global namespace?
I'm getting this with 3.2.x series but with 3.1.x series it works.
I use this in my own typings:
declarevarReact: typeofimport("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".
Activity
aminpaks commentedon Dec 9, 2018
magic-akari Wrong project?
You should report here I guess.
magic-akari commentedon Dec 9, 2018
Amin Pakseresht (@aminpaks) Is there anything wrong in the example code?
aminpaks commentedon Dec 9, 2018
magic-akari I don't know. I was just pointing out that I think you reported the issue in the wrong project.
This project is TypeScript language, DefinitelyType project is maintaining React types, to track the issue and fix it you need to open this issue in that project.
magic-akari commentedon Dec 9, 2018
Amin Pakseresht (@aminpaks) I have reproduced the issue with my code.
The only things related to React is that I use the
Reactas the variable name and its logic is the same as the definition of@types/react.There is no module imported from
reactor@types/react.I am not sure if it is related to DefinitelyType, for it worked in
typescript@3.1.6.aminpaks commentedon Dec 9, 2018
magic-akari I understand.
React itself is a javascript library, it doesn't include any typings (facebook doesn't like TypeScript?) Anyways this means every time there is a new TypeScript version (current 3.2) there is a chance that types created by DefinitelyTypes project are not compatible anymore.
We might not import it directly but that's how TypeScript works. We always import types from
@types/react(based on tsconfig andtypeRoot) otherwise VSCode (runs TypeScript language server) can't understand the semantics of React.Update:
Can you push your code in a repo?
Looking at the second link you posted, are we importing
@types/reactto global namespace?magic-akari commentedon Dec 9, 2018
Amin Pakseresht (@aminpaks)
You can clone the gist just like how to clone GitHub repo.
Yes. It is what I want to do.
Please clone and play with the first gist link which is the key to this issue.
The first gist only depends on Typescript.
aminpaks commentedon Dec 9, 2018
I just realized what you mean. You're right this has nothing to do with DefinitelyType project.
Should not it be like this:
magic-akari commentedon Dec 10, 2018
For someone run into this issue, try this code below:
It works in current version typescript like the original code in
typescrip@3.1.6.Not sure if the original code is wrong or not.
Thank you for your patience Amin Pakseresht (@aminpaks) .
Ciantic commentedon Jan 9, 2019
I'm getting this with 3.2.x series but with 3.1.x series it works.
I use this in my own typings:
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".