Closed daniacedue closed 2 months ago
.NET types tagged with [JSExport]
are not namespaced in JavaScript/TypeScript - that is by design and follows modern JS conventions in which it is preferable to organize JS APIs by modules and not by namespaces.
On the other hand, .NET namespaces are preserved when dynamically loading pre-existing .NET assemblies (with no [JSExport]
attributes), because .NET types are conventionally organized by namespace and it would not work well to reorganize them by assembly/module. There is some more explanation here about the differences between these 2 approaches, but I need to document this better.
All that said, there is clearly a bug in the generated typedefes: it should not be using those namespace prefixes when referencing other exported types. I'll fix that.
Hello,
I am trying to use class composition like this:
but it generates this d.ts:
As you can see:
DuckGreet
should belong to anAnimalGreetings
namespaceMainEntry
andHumanGreet
are in the same namespace,MainEntry
'shuman
property is prefixed with the same namespace (which is not necessary)Thanks in advance!
P.S: As a workaround I am using the same global namespace for all my project's classes + a script to post-process the output d.ts file (it replaces the unnecessary namespace strings with an empty one) which is laborious.