-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Uncaught ReferenceError: exports is not defined #575
Comments
I think in your tsconfig.json you have selected the wrong module system... i think this is a TypeScript issue and not an NSwag issue |
@RSuter yes I believe you must be right... Could you help me chose the best approach for building the interface? Maybe this one? |
The link is not working... The problem is that the tooling is not correctly working in your JS project |
I always use class in my project, because it converts to properties to lower case (JS-style) and also correctly converts date objects correctly. But you cannot use duck-typing - you need to pass instances of the expected classes. And yes, you can choose "Interface" as Type Style, this way you just have to provide an object which satisfies the interface... |
but the problem with exports remains |
Yes, this is a problem with your TypeScript compiler settings in your project... I think it is configured to compile to AMD modules but your module loader cannot use this |
what can I do then? I'm kinda newbie with this, I have no idea |
swagger specification:
|
is there anyway to typescript does not generate the exports? |
What module loader are you using in your AngJS project? |
@RSuter I don't think I am using any, but If I am, probably is Angular DI. |
Then myabe you have to define None in the module parameter: https://www.typescriptlang.org/docs/handbook/compiler-options.html |
@RSuter think that is the problem... unfortunately can't compile with none :/ tsc typescriptclient.ts --module None |
Any more suggestions? |
Maybe try: https://www.npmjs.com/package/typescript-bundle this generates a JS bundle which you can directly import and use without a module loader... |
microsoft/TypeScript#6319 "Solved finally" follow this ..i was also getting same error i changed module:"commonjs" to "module": "es6", because targeting ES5 remove the import/export statements, so these tools cannot remove unused exports. |
@umesh190690 where do I change that? In compilation?
I compiled that way and I got ApiBackendClient.js:555 Uncaught SyntaxError: Unexpected token export beucase it still has an export :( |
Closed because this is a TS tooling issue and not an nswag issue... |
In the Swagger Code Generation there is a few exports that are being added to the code on compile. Like this one for instance:
exports.AuthClient = AuthClient;
I have no idea what this exports is doing, I just know that I am having a problem with it:
Uncaught ReferenceError: exports is not defined
Anyone could explain me what is the exports for and why am I getting that error and how to fix/avoid it?
The text was updated successfully, but these errors were encountered: