Closed ghost closed 8 years ago
Precision: the issue only appears when the Foo
class is in a @Root
package (on in an empty package) and that the module
option is on. In that cases only, it is a bug. For other cases (which were supposed to be the most common scenarios) it works fine.
Note that this issue is a side effect of #63.
There should not be an issue any more (if you use the latest snapshot). Now the behavior when using modules, is to always export and to allow one @Root
package only. If several @Root
packages are found, or if one @Root
package is found and that some packages are not within that @Root
package, then an error will be reported by JSweet. The reason for this constraint is that it is too complex to have several roots when using modules because modules refer to each others using relative paths. So it is ok to change the root globally for all modules at once, but it is not ok to have several path changes cohabitating.
When turning off the module option, the export
disappears as well. Is there a reason why a public
class is not transpiled to an export
'ed class?
I assume that your class has no namespace (top-level class). I don't remember exactly, but yes there was a reason why a top-level class should not be exported (because it is not in a namespace). I did not understand the exact reason but tsc complains in some cases when exporting top-level classes. I advise to have a namespace for your classes... it is still better and you will get the export
.
OK, I see. Indeed, my Java class is in a package, but that package is annotated with the @Root annotation, hence it appears out of any module.
If I move the class one level down in the the package path it appears in a module and the export is there as well. Thanks for your hints.
2016-02-17 21:06 GMT+01:00 Renaud Pawlak notifications@github.com:
I assume that your class has no namespace (top-level class). I don't remember exactly, but yes there was a reason why a top-level class should not be exported (because it is not in a namespace). I did not understand the exact reason but tsc complains in some cases when exporting top-level classes. I advise to have a namespace for your classes... it is still better and you will get the export.
— Reply to this email directly or view it on GitHub https://github.com/cincheo/jsweet/issues/64#issuecomment-185380713.
When compiling a simple Java class such as:
The generated typescript is either (depending on whether the
module
option was turned on or not): module.ts:or Foo.ts:
but in any case, the
export
keyword is missing so that the file is not a module and theFoo
type cannot be used from another TypeScript file.