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

Is tsconfig.json required? #2304

Closed
jcbhmr opened this issue Jun 6, 2023 · 7 comments
Closed

Is tsconfig.json required? #2304

jcbhmr opened this issue Jun 6, 2023 · 7 comments
Labels
enhancement Improved functionality good first issue Easier issue for first time contributors help wanted Contributions are especially encouraged

Comments

@jcbhmr
Copy link

jcbhmr commented Jun 6, 2023

Search terms

tsconfig required

Question

I recently had some .d.ts files that I had a bunch of documentation in. This was all generated from native Rust bindings using https://napi.rs/

Basically:

use napi_derive::napi;
 
#[napi]
/// Compute it!
fn fibonacci(n: u32) -> u32 {
  match n {
    1 | 2 => 1,
    _ => fibonacci(n - 1) + fibonacci(n - 2),
  }
}
// GENERATED FILE
/** Compute it! */
export function fibonacci(n: number): number;

And I wanted to run typedoc --entryPoints index.d.ts and have it just work. No need to have a tsconfig.json file when I'm not even using JavaScript! 😂 It's all native codegen magic.

And... I couldn't.
image

Is there a way to magically say "no i don't need a tsconfig, just give me docs" ?? sort of like how i can do tsc file.ts and it will just work even with no tsconfig.json.

@jcbhmr jcbhmr added the question Question about functionality label Jun 6, 2023
@jcbhmr
Copy link
Author

jcbhmr commented Jun 6, 2023

You can't even game the system with <() process file bash tricks 😭

image

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jun 7, 2023

Yes, it's currently required. I'd be open to a PR which made it not required, but since the vast majority of TS projects will have a tsconfig, figuring out how to match tsc's behavior there hasn't been a priority

@jcbhmr
Copy link
Author

jcbhmr commented Jun 8, 2023

A hack for anyone else to get around this is to write a temp tsconfig with just {}:

echo '{}' >tsconfig.json && typedoc --entryPoints index.d.ts; rm tsconfig.json

@typhonrt
Copy link

typhonrt commented Jun 12, 2023

Hi @Gerrit0. Thanks for all your work on TypeDoc along with other present and past maintainers!.

Cool, glad this was asked as I'm coming from the ESM native side of things and generating d.ts files from ESM source and building docs, so kind of similar angle to the OP question. However, I don't mind building a CLI around TypeDoc for this use case using the programmatic API. A potential PR on my side would be to get the programmatic API to also accept an object for the tsconfig option that defines the tsconfig.json data.

Something like this will then be possible:

// Create a new TypeDoc application instance.
const app = new Application();

await app.bootstrapWithPlugins({
   // A few other options...
   
   tsconfig: { /* TSConfig data */ }    
});

Is there any general known timing on when 0.25 might ship? I suppose a change like this doesn't require a major version. I'll get right on this with a PR this week though as this would be rather handy on my end.

And general heads up.. I do have really neat other TypeDoc related things I'll get in touch about / release / drop a note in a couple of weeks. So cool stuff incoming. :D

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jun 25, 2023

You can already set tsconfig options (app.options.setCompilerOptions)

0.25 has no planned release date yet, I've been very busy recently, so have barely even started on what I want to include with it.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jun 25, 2023

It looks like this can probably be done via ts.parseCommandLine([]), if someone wants to give a PR a shot.

@Gerrit0 Gerrit0 added enhancement Improved functionality help wanted Contributions are especially encouraged good first issue Easier issue for first time contributors and removed question Question about functionality labels Jun 25, 2023
@typhonrt
Copy link

typhonrt commented Jun 25, 2023

Yeah.. You can use ts.parseJsonConfigFileContent(). In another tool of mine I parse just compilerOptions as JSON w/ ts.convertCompilerOptionsFromJson(). I'll definitely take a look soonish. This is more for the next tool I'd like to build, so this potential PR is in the queue.

Edit: Ahh... but as you mentioned above I'll look into setCompilerOptions first as that likely solves my use case whereas the original request is slightly different.

@Gerrit0 Gerrit0 closed this as completed in 0985616 Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improved functionality good first issue Easier issue for first time contributors help wanted Contributions are especially encouraged
Projects
None yet
Development

No branches or pull requests

3 participants