phetsims / molecule-shapes

"Molecule Shapes" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/molecule-shapes
GNU General Public License v3.0
5 stars 6 forks source link

VSEPRConfiguration.js:37:7 - error TS9006: Declaration emit for this file requires using private name 'ResultMapping' #185

Closed samreid closed 3 years ago

samreid commented 3 years ago

While working on https://github.com/phetsims/chipper/issues/1055, I saw this error for Molecule Shapes:

~/apache-document-root/main/chipper/tsconfig/molecule-shapes$ tsc -b
../../../molecule-shapes/js/common/model/VSEPRConfiguration.js:37:7 - error TS9006: Declaration emit for this file requires using private name 'ResultMapping' from module '"/Users/samreid/apache-document-root/main/molecule-shapes/js/common/model/AttractorModel"'. An explicit type annotation may unblock declaration emit.

37 class VSEPRConfiguration {
         ~~~~~~~~~~~~~~~~~~

Found 1 error.

I don't really understand this problem (if it is really a problem), but it seems to be related TypeScript parsing this JSDoc:

  /**
   * For finding ideal rotations including matching for 'bond-vs-bond' and 'lone pair-vs-lone pair'.
   * @public
   *
   * @param {Array.<PairGroup>} groups
   * @returns {AttractorModel.ResultMapping}
   */
  getIdealGroupRotationToPositions( groups ) {

And thinking it's referring to a private non-exported variable name ResultMapping.

samreid commented 3 years ago

I worked around the problem by inlining the class declaration, and it seems to have corrected the problem. I didn't devote more time to understanding the root of the problem since it only seems to affect a few files across our codebase, and there is a straightforward workaround. @jonathanolson would you like to review?

jonathanolson commented 3 years ago

That seems like a decent workaround, and looks good. Presumably we'll handle in a better way with typescript in the future?

samreid commented 3 years ago

Yes, I think this problem occurs in JS but not TS, since in TS you import files to provide them in type annotations. Closing.