-
Notifications
You must be signed in to change notification settings - Fork 607
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
[api-extractor] Generate .d.ts with fully compiled and inlined types #5032
Comments
@iclanton sorry for the ping, but would you mind taking a look if you would be able to introduce such feature in the future by any chance or no plans to do so? Appreciate it 🙇 |
We're facing the same, so very curious what you've ended up going with! Just like you, I'm seeing that certain libraries such as Zod do not get inlined at all, remaining as With certain other libraries it does seem to work, so the unexpected behaviour with zod may just be something particular to certain large libraries. However.. If those libraries' types use types that are imported from yet other libraries, it still doesn't seem to work. |
Hey @JeongJuhyeon I'm using a custom made script for now which is awful and only does some of what I need, so the best thing would be to get attention from one of the maintainers and see what they have to say about this. Addressing this issue and adding the ability to fully inline all types would be an awesome feature. |
We have ended up succeeding by using the In the package we're looking to run the bundler on, we install the the packages with the types as devdependencies and the following {
"compilationOptions": {
"preferredConfigPath": "./tsconfig-bundler.json",
"followSymlinks": true
},
"entries": [
{
"filePath": "./src/index.ts",
"outFile": "./dist/index.d.ts",
"libraries": {
"inlinedLibraries": [
// here go all of the external deps we want to inline, you can look at the output and put the ones that still get imported here
]
},
"output": {
"inlineDeclareGlobals": true,
"exportReferencedTypes": false
}
}
]
} And the following {
"extends": "../../tsconfig-base.json",
"include": [
"src/**/*"
],
"exclude": [
"*/dist",
"dist",
"node_modules"
],
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "nodenext",
"outDir": "dist-bundler",
"types": [
"node"
]
},
"paths": {
"backend": [
"../backend"
]
}
} And then the trick was to, when importing from the internal
This way everything gets inlined if you desire so. |
@JeongJuhyeon |
Summary
I would like to be able to generate a fully compiled and inlined .d.ts with only the exported types of the main file.
Details
Let's say I have an input file of:
And want simply just:
Without any external libraries being put inside the declaration file. I want all the external things to be compiled.
The above would contain compiled types like usage of
zod
for example.Currently instead I get a copy of the actual code.. Example:
Thank you and really appreciate the work on the tool! 🙇
The text was updated successfully, but these errors were encountered: