Skip to content

ERROR - [JSC_UNDEFINED_VARIABLE] variable process is undeclared #227

Answered by niloc132
faveoled asked this question in Q&A
Discussion options

You must be logged in to vote

Unfortunately, defining a JsType is only part of the process - this only tells j2cl what the type is, and how to accurately generate references to it from other types (plus also how to work out constants, some helper methods, etc).

The other part of the puzzle you need is to give the closure compiler the externs for the type. See https://developers.google.com/closure/compiler/docs/externs-and-exports for a quick summary, and https://github.com/google/closure-compiler/tree/master/contrib/externs for some other example files.

In your case, add a js file to the project that looks something like this:

/**
 * @externs 
 */

function process() {}

/**
 * @returns number[]
 */
process.hrtime = f…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@faveoled
Comment options

Answer selected by faveoled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants