question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect emitted TS declaration

See original GitHub issue

Hi! Thanks for the great library!

Since CodeGen was merged, I switched to the emitted declaration files instead of using manually created ones based on the source code, but the issue is, the nesting is wrong!

Right now the declarations are emitted like this:

export declare const dotnet: {
    BannerlordModuleManager: { }; // The C# bindings
    BootStatus: typeof BootStatus;
    ...
};

But dotnet.js exposes the variable via exports.BannerlordModuleManager instead of exports.dotnet.BannerlordModuleManager So the correct declaration would be this:

export declare const BannerlordModuleManager: { }; // The C# bindings
export declare const dotnet: {
    BootStatus: typeof BootStatus;
    ...
};

PS: Writing it here because Discussions aren’t setup. Since we both are from Russia, I can’t setup PayPal donations via Ko-Fi because Russia<–>Russia transactions are banned. Do you know any way to bypass the restriction?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
Aragascommented, Dec 2, 2021

Sure, such test should be enough to cover TS generation! And yea, the package emits everything correctly! Closing the issue, thanks!

0reactions
Elringuscommented, Dec 1, 2021

Makes sense. Not sure if this one test justifies converting all the suite to TS, though. Maybe comparing the generated file with a reference is enough: https://github.com/Elringus/DotNetJS/blob/04dd07c4964541de7761075d769e983be1de21d9/JavaScript/dotnet-runtime/test/packed.js#L40

Anyway, latest nuget package should produce correct types now. Please let me know if it solves the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript Emits Declarations Despite Error #36169 - GitHub
d.ts typings declarations. Actual behavior: The type mismatch and error occur as expected but the incorrect typings are output anyway.
Read more >
Adding my type declaration throws an error "Typescript ...
ts) gives me an error saying "Typescript emitted no output for my.d.ts". Of course, I don't expect any code generated from this type...
Read more >
Compiler Options - TypeScript - JavaScript that scales.
Option Type Default ‑‑allowJs boolean false ‑‑allowSyntheticDefaultImports boolean module === "system" or ‑‑esModuleInterop ‑‑allowUmdGlobalAccess boolean false
Read more >
TSConfig Reference - Docs on every TSConfig option
Offers a way to configure the root directory for where declaration files are emitted. example ├── index.ts ├── package.json └── tsconfig.json.
Read more >
ae-wrong-input-file-type - API Extractor
Instead, it is designed to analyze the .d.ts files that are emitted by the compiler and exported by your NPM package. This design...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found