-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Cannot find name 'Promise' & Cannot find name 'require' #7788
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
For import something = require('something'); Notice the only change is that we used the To use The good news is that with 2.0 we're going to support scenarios where your standard library has ES2015 features like |
Oh excellent, I'll try import first and see if that works. Just had some scenarios where webpack lazy loads things later didn't know if import could be used I'll try. Thanks Dan |
You're welcome!
// "Elided" import.
import _foo = require("foo");
declare function require(name: string): any;
if (/*...*/) {
// Conditionally require the module "foo".
// Use the shape of '_foo' to describe the variable 'foo'.
let foo: typeof _foo = require("foo");
} Here, we won't emit a call to |
Like as mentioned above, this will be fixed in 2.0. Until then, you can use the es6 shim: typings install dt~es6-shim --global This will clear up the issues with Promise not being found, as well as Map not being found. |
@gregoryagu Installing es6 shim typings doesn't solve the issue for me. I'm using TS 2.0.6 and my es6-shim typings are included in my tsconfig.json
|
I am getting the same issue as @jogjayr |
TypeScript Version: 1.8.9
Expected behavior:
TS should be aware of
require
&Promise
Actual behavior:
TS errors appear for require & Promise.
I'm able to work around the
require
issue by simply declaring a custom typing for it, but not with Promise. I'm wondering if these should be more of a default part of TypeScript?The text was updated successfully, but these errors were encountered: