Skip to content

Instantly share code, notes, and snippets.

@Stradivario
Created February 17, 2023 10:30
Show Gist options
  • Save Stradivario/19fb7bdd2b732b42d55c0a46b623c54f to your computer and use it in GitHub Desktop.
Save Stradivario/19fb7bdd2b732b42d55c0a46b623c54f to your computer and use it in GitHub Desktop.
How to emit type declarations in esbuild using tsc
// esbuild.js
import { execSync } from 'child_process'
import { build } from 'esbuild'
build({
...options,
plugins: [
{
name: 'TypeScriptDeclarationsPlugin',
setup(build) {
build.onEnd((result) => {
if (result.errors.length > 0) return
execSync('tsc')
})
}
}
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment