-
Notifications
You must be signed in to change notification settings - Fork 38
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
Ability to generate .d.ts types file #24
Comments
Interesting idea! It would be nice if this was an Estrella build option, like In the meantime I think you could accomplish this by using the typescript API Something like this: #!/usr/bin/env node
const { build } = require("estrella")
const pkg = require("./package.json")
const ts = require("typescript")
function generateTypeDefs() {
const filenames = [ ... ]
const compilerOptions = { optionsFromTSConfigFile..., declaration: true }
const program = ts.createProgram(filenames, compilerOptions)
const emitResult = program.emit()
// check emitResult.diagnostics and .emittedFiles
}
build({
bundle: true,
sourcemap: true,
format: "esm",
entry: "src/index.ts",
outfile: pkg.module,
onStart: generateTypeDefs,
}) |
The best-performing way (probably) to do this would be for tsc to do it while type-checking. I hacked this together by modifying estrella locally; it was a little messy with the current design but it did work. Edit: I came up with this minimally-invasive change that let me do what I needed with --- a/src/tslint.js
+++ b/src/tslint.js
@@ -107,8 +107,9 @@ export function tslint(options /*:TSLintOptions*/) {
}
// CLI arguments
+ const noEmit = !(options.args || []).includes('--emitDeclarationOnly');
let args = [
- "--noEmit",
+ noEmit && "--noEmit",
options.colors && "--pretty",
options.watch && "--watch",
tsconfigFile && "--project", tsconfigFile, |
Thanks a lot for the example @rsms ❤️ I guess I will wait for an implementation in Estrella then. For now, it seems to be more straight forward to use |
Nice @lann! If you'd like to take on adding this "for real" in a PR (preferably with test; I can help you in the PR with this) that would be ace. |
Sure, I'd be happy to not carry the patch myself. Is the approach alright? Another possibility would be to add a |
23dcb87 adds an example of how to generate type declaration files.
|
Would be great if this was just an option to estrella! |
I wonder how to use estrella correctly to generate a types file. I've set up a very simple example to show the issue:
https://github.com/holtwick/estrella-ts-module
I would like to add the working result to https://github.com/holtwick/create-estrella
The text was updated successfully, but these errors were encountered: