How to combine Browserify and Google Closure with type checks

When Browserify merges my JavaScript files, the result is something like this:

(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ // Including file contents },{"foo":3}],3:[function(require,module,exports){ // Included file contents ... 

Compiling Google Closure with type checks (--jscomp_warning = checkTypes) complains about the function s , which is called with one parameter instead of the required two.

I am currently replacing the definition of s

 function s(o,u){ 

from

 /** @param {*=} o @param {*=} u */function s(o,u){ 

as a preprocessing step.

However, there should be a more pleasant way. My question is: how to combine Browserify with the Google Closure Compiler with type checks on without finding and replacing the definition of s ?

+5
source share

Source: https://habr.com/ru/post/1204721/


All Articles