list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

E9221 JavaScript Reserved Name

A name that JavaScript reserves or that generated code uses

The JavaScript generator reports this error, and does not generate the class, for a name it would have to bind:

  • A class named with a word JavaScript reserves, such as class, function, delete, new or static: the generated class declaration would not parse. A class body is strict code, so the words reserved only in strict mode, such as interface, package, private, arguments and eval, are rejected as well. The same applies to a class whose superclass has such a name, since the generated module binds the superclass with const.
  • A class named like one of the variables Node gives a CommonJS module: module, exports, require, __dirname or __filename. Such a class would be bound in place of the variable the module itself uses, so module.exports would never receive the class and require would return an empty object.
  • A parameter of a method written in the model whose name JavaScript reserves, or that repeats the name of another parameter of that method, which strict code does not allow.

Rename the element. Attributes, association role names, states and events are not concerned: generated code reaches them as properties and as method names, where any word is allowed.

Example

// JavaScript cannot name a class delete, so generating JavaScript
// from this model reports E9221 and writes no file for the class
generate JavaScript;
class delete {
  reason;
}

      

Load the above code into classic UmpleOnline
Load the above code into UmpleOnline V2

 

Solution to The Above So the Message No Longer Appears

// A name JavaScript does not reserve is generated. A reserved word is
// still fine for an attribute or a role name, which are properties
generate JavaScript;
class Removal {
  reason;
  Boolean static;
}

      

Load the above code into classic UmpleOnline
Load the above code into UmpleOnline V2