Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type definition is missing optional runtime configuration parameter #1742

Open
NReilingh opened this issue Jan 11, 2025 · 1 comment
Open

Comments

@NReilingh
Copy link

I'm experimenting with asciidoctor.js in Deno, and Deno happens to reject running a .ts file that has type checker errors in it (even if the program would execute just fine). If I try to pass a runtime configuration object, I get Expected 0 arguments, but got 1. [2554] as a typechecker error.

import Asciidoctor from 'npm:@asciidoctor/core';
const asciidoctor = Asciidoctor({ // Error [2554]
  runtime: {
    framework: 'webworker'
  }
});

I can work around this with some fancy casting, e.g.

import Asciidoctor from 'npm:@asciidoctor/core';
const asciidoctor: ReturnType<typeof Asciidoctor> = (Asciidoctor as any)({
  runtime: {
    framework: 'webworker'
  }
});

... and this executes, and the expected configuration is shown in asciidoctor.getRuntime(), so I believe my assessment is correct that this is just a problem in the type definition:

export default function asciidoctor(): Asciidoctor;

Two additional notes:

  1. I'm actually not sure what runtime.framework is supposed to do, so this definitely is not a blocker in any way, but I think it could use some explanation in https://docs.asciidoctor.org/asciidoctor.js/latest/setup/runtime/
  2. I think there may be a similar type definition issue with import Asciidoctor from 'asciidoctor'; Asciidoctor() (using the non-namespace-prefixed package), as this results in This expression is not callable. Type [...] has no call signatures. [2349] -- and can be similarly worked around by casting to any. But I haven't done enough testing on how this works with vanilla tsserver in Node to be sure that this isn't a Deno-specific issue (rel. Run the tests suite against Deno #981).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants