Last active
March 28, 2016 17:46
-
-
Save pbjorklund/248dfbd72fb93d2723b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| The node ambient module defines a require with type NodeRequire which means that var require : any will claim that it needs type NodeRequire. | |
| Doesn't seem like requirejs typings define RequireConfig anymore either? | |
| var require = { | |
| paths: { | |
| "jquery": "../bower_components/jquery/dist/jquery" | |
| } | |
| }; | |
| will yield | |
| src\require-config.ts(1,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'any'. |
Actually I think it may be necessary to get rid of the declare statement - but otherwise I think this should work OK. The thing with declare is that it removes the emit of the var keyword entirely and then you'll be creating an accidental global which is an error in strict mode. Otherwise this should hopefully cover you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can see how that would be a problem. RequireJS functionality beyond the generic AMD functionality will require a typings file, but if you're not using much of it beyond the initial setup, it's not absolutely needed. It depends on how strict you want to be with your types - sometimes it's useful and sometimes it's just a sacrifice to the gods of type safety. This is the problem with global variables -
requiremeans different things in different parts of your program.Put this and let me know if it works: