Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
Handle ref.scope.getBinding(...) returning undefined.
Browse files Browse the repository at this point in the history
The types allow for returning `undefined`, but we always assumed it
would return a reference binding.

Note: this does not fix the underlying tests, they now fail to add the
module imports for `createTemplateFactory`:

```
 FAIL  __tests__/tests.js
  ● htmlbars-inline-precompile › does not error when transpiling multiple modules with a single pl
ugin config

    expect(received).toMatchInlineSnapshot(snapshot)

    Snapshot name: `htmlbars-inline-precompile does not error when transpiling multiple modules wi
th a single plugin config 2`

    - Snapshot  - 2
    + Received  + 0

    - import { createTemplateFactory as _createTemplateFactory } from "@ember/template-factory";
    -
      var compiled = _createTemplateFactory(
      /*
        hello
      */
      "precompiled(hello)");

      84 |     );
      85 |
    > 86 |     expect(transpiled).toMatchInlineSnapshot(`
         |                        ^
      87 |       "import { createTemplateFactory as _createTemplateFactory } from \\"@ember/templa
te-factory\\";
      88 |
      89 |       var compiled = _createTemplateFactory(

      at Object.toMatchInlineSnapshot (__tests__/tests.js:86:24)
```
  • Loading branch information
rwjblue committed Mar 12, 2021
1 parent 4a0a86a commit 1a4c7e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module.exports.registerRefs = (newPath, getRefPaths) => {

for (let ref of refPaths) {
let binding = ref.scope.getBinding(ref.node.name);
binding.reference(ref);
if (binding !== undefined) {
binding.reference(ref);
}
}
};

0 comments on commit 1a4c7e3

Please sign in to comment.