inspect-js / node-deep-equal

node's assert.deepEqual algorithm
MIT License
778 stars 109 forks source link

deep-equal 2.0.1 throws is-weakmap compiler error, 'return' outside of function (12:1) #79

Closed n8sabes closed 4 years ago

n8sabes commented 4 years ago

Related to #78, deep-equal v2.0.1 is now causing a 'return' outside of function (12:1) compiler error from is-weakmap, subsequent fixes to is-map and is-set.

STEPS

yarn create react-app my-app --template typescript
cd my-app
yarn add deep-equal
vi src/index.tsx

# Add lines to index.tsx before render()
    import deepEqual from "deep-equal"; // NEW LINE
    deepEqual({}, {});                  // NEW LINE

yarn build

COMPILER ERROR:

Failed to compile.

./node_modules/is-weakmap/index.js
SyntaxError: .../my-app/node_modules/is-weakmap/index.js: 'return' outside of function (12:1)

  10 |      return false;
  11 |  };
> 12 |  return;
     |  ^
  13 | }
  14 |
  15 | var $mapHas = $WeakMap ? $WeakMap.prototype.has : null;

error Command failed with exit code 1.
ljharb commented 4 years ago

Looks like I need to make the same changes to is-weakmap and is-weakset.

n8sabes commented 4 years ago

@ljharb, Just did a yarn upgrade --latest on the vanilla my-app CRA project and got the same is-weakmap error (below). To be extra-sure, did a clean CRA install, following initial post.

./node_modules/is-weakmap/index.js
SyntaxError: .../my-app/node_modules/is-weakmap/index.js: 'return' outside of function (12:1)

  10 |      return false;
  11 |  };
> 12 |  return;
     |  ^
  13 | }
  14 |
  15 | var $mapHas = $WeakMap ? $WeakMap.prototype.has : null;

error Command failed with exit code 1.

I'm skilled (enough) with the package manager (yarn / npm), but no expert. Is there something special I need to do to get the fixes?

ljharb commented 4 years ago

@n8sabes that's because the fixes aren't released yet. issues get closed when the fix lands on master, not when they're released.

ljharb commented 4 years ago

v2.0.1 of is-weakmap and is-weakset are released.

n8sabes commented 4 years ago

Thank you @ljharb -- Everything is working quite nicely again!!