Skip to content

Generated .d.ts and .js are for dynamic invoke, don't work for module projects #260

Closed
@jasongin

Description

@jasongin

The TypeScript generator tool takes an assembly as input and produces a .d.ts file with type definitions for the assembly along with a small .js file that loads and exports the assembly. Currently those generated files are designed primarily for the dynamic invoke scenario: they augment the node-api-dotnet module by adding namespaced .NET types to it whenever a .NET assembly is loaded.

But in the .NET Node module scenario (with or without AOT), there is actually no namespacing or module augmentation at runtime. The types and methods tagged with [JSExport] are exported directly from the module, not as augmentations. So the generated loader code and typedefs are not right in that case.

The "module" example projects (dotnet-module, aot-module, aot-npm-package) don't even use the generated .js files. The type definitions can work, but only with explicit /** @type */ hints.

Now that I'm looking more closely at this, I'm remembering it is something I had planned to address over a year ago after initially setting up the TS generator, then I got distracted by other priorities, forgot about this, and later documented it as if it was working. But it is broken, and I will fix it soon.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions