Closed Skillzore closed 3 years ago
I would recommend you to target es6 and module mode es6 for a better integration with recent TS app :)
You mean with create-react-app or jsweet?
This seems to be Babel not being supportive of full typescript namespaces. https://babeljs.io/docs/en/babel-plugin-transform-typescript#impartial-namespace-support
Since using Babel is a must (whether it be with create-react-app or not), jsweet might not work out for us then. Unless we can somehow get jsweet not to use namespaces.
Also, namespaces aren't recommended to be used anymore. Even though the rumor about them being deprecated is false. https://github.com/microsoft/TypeScript/issues/30994
Even typescript themselves recommend using modules over namespaces: https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html
So why is jsweet generating a namespace from my java package and not a module?
There are multiple module mode, that's what I was talking about. Please specify module mode es2015$ https://github.com/lgrignon/jsweet-maven-plugin#basic-configuration
I recommend you to read some of the documentation. All of this is already explained.
config part of the readme: https://github.com/lgrignon/jsweet-gradle-plugin options of the maven plugin: https://github.com/lgrignon/jsweet-maven-plugin#basic-configuration some of the language specs: https://github.com/cincheo/jsweet/blob/master/doc/jsweet-language-specifications.md
and of course the examples :)
please tell me if module option fixed your problem, and close this issue if so
Yeah, I started to realize that you might have meant a jsweet setting. running module 'es2015' resolved the issue at hand but got another error. The generated file is missing a default export which results in an error:
Failed to compile.
./src/App.tsx
Attempted import error: './jsweet/typescript/com/myapp/pocjsweet/validate' does not contain a default export (imported as 'validate').
How do I get jsweet to generate a default export? I can't find a plugin option that does this.
It should generate exports for your classes. Cannot you import the generated class identifier? You should
Yeah, sorry, just had to import { validate }
instead and it works! Thanks a lot!
After transpiling my java code into typescript and hooking it into my frontend, I get the following error:
Is this caused by the babel version included with create-react-app? I am not using namespace at all in the frontend at the moment.