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

[question] Can esbuild generate types.d.ts ? #855

Closed
mesqueeb opened this issue Feb 20, 2021 · 1 comment
Closed

[question] Can esbuild generate types.d.ts ? #855

mesqueeb opened this issue Feb 20, 2021 · 1 comment

Comments

@mesqueeb
Copy link

I could not find info on this in the documentation nor in the current existing issues.

Does ESBuild support generating a single types.d.ts file when I bundle (with format esm) a index.ts file?

I'm currently using rollup which does it, but I wanna evaluate if I can switch out to esbuild?

an example of a types.d.ts generated by rollup look like the snippet below.

Please note it retains the correct type information as well as the JSDocs.

/**
 * Returns whether the payload is undefined
 *
 * @param {*} payload
 * @returns {payload is undefined}
 */
export declare function isUndefined(payload: any): payload is undefined;
/**
 * Returns whether the payload is null
 *
 * @param {*} payload
 * @returns {payload is null}
 */
export declare function isNull(payload: any): payload is null;

I believe that a types.d.ts file is useful for when other devs use my utils to get autocompletion and popup documentation in their editors.

If this is not possible with esbuild, am I correct to assume that my use case:

  • bundling JS utils which I host on NPM in esm format with autocompletion and popup documentation

is not the target use case for esbuild? I'm keen to know!

@mesqueeb
Copy link
Author

previously I searched for generate types which didn't get good results in the issues, but now I did find the answer here:
#95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant