1717 * along with this program. If not, see <https://www.gnu.org/licenses/>.
1818 */
1919
20- const esbuild = require ( " esbuild" ) ;
20+ import * as esbuild from ' esbuild' ;
2121
22- const production = process . argv . includes ( '--production' ) ;
23- const watch = process . argv . includes ( '--watch' ) ;
22+ const production : boolean = process . argv . includes ( '--production' ) ;
23+ const watch : boolean = process . argv . includes ( '--watch' ) ;
2424
25- /**
26- * @type {import('esbuild').Plugin }
27- */
28- const esbuildProblemMatcherPlugin = {
25+ const esbuildProblemMatcherPlugin : esbuild . Plugin = {
2926 name : 'esbuild-problem-matcher' ,
3027
31- setup ( build ) {
28+ setup ( build : esbuild . PluginBuild ) : void {
3229 build . onStart ( ( ) => {
3330 console . log ( '[watch] build started' ) ;
3431 } ) ;
35- build . onEnd ( ( result ) => {
32+ build . onEnd ( ( result : esbuild . BuildResult ) => {
3633 result . errors . forEach ( ( { text, location } ) => {
3734 console . error ( `✘ [ERROR] ${ text } ` ) ;
38- console . error ( ` ${ location . file } :${ location . line } :${ location . column } :` ) ;
35+ if ( location ) {
36+ console . error ( ` ${ location . file } :${ location . line } :${ location . column } :` ) ;
37+ }
3938 } ) ;
4039 console . log ( '[watch] build finished' ) ;
4140 } ) ;
4241 } ,
4342} ;
4443
45- async function main ( ) {
44+ async function main ( ) : Promise < void > {
4645 // Build extension
47- const extensionCtx = await esbuild . context ( {
46+ const extensionCtx : esbuild . BuildContext = await esbuild . context ( {
4847 entryPoints : [ 'src/extension.ts' ] ,
4948 bundle : true ,
5049 format : 'cjs' ,
@@ -59,7 +58,7 @@ async function main() {
5958 } ) ;
6059
6160 // Build tests
62- const testCtx = await esbuild . context ( {
61+ const testCtx : esbuild . BuildContext = await esbuild . context ( {
6362 entryPoints : [ 'src/test/*.test.ts' ] ,
6463 bundle : true ,
6564 format : 'cjs' ,
@@ -72,6 +71,7 @@ async function main() {
7271 logLevel : 'silent' ,
7372 plugins : [ esbuildProblemMatcherPlugin ] ,
7473 } ) ;
74+
7575 if ( watch ) {
7676 await Promise . all ( [
7777 extensionCtx . watch ( ) ,
@@ -85,7 +85,7 @@ async function main() {
8585 }
8686}
8787
88- main ( ) . catch ( e => {
88+ main ( ) . catch ( ( e : Error ) => {
8989 console . error ( e ) ;
9090 process . exit ( 1 ) ;
9191} ) ;
0 commit comments