Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

read properties of undefined #158

Closed
tmkx opened this issue Feb 4, 2022 · 2 comments
Closed

read properties of undefined #158

tmkx opened this issue Feb 4, 2022 · 2 comments

Comments

@tmkx
Copy link

tmkx commented Feb 4, 2022

jest --coverage output:

FAIL src/pages/pc/tests/app.node.spec.tsx
● Test suite failed to run

TypeError: .../player/dist/cjs/index.js: Cannot read properties of undefined (reading 'originalPositionFor')

  at SourceMapTree.originalPositionFor (../../node_modules/.pnpm/@ampproject+remapping@2.0.1/node_modules/@ampproject/src/source-map-tree.ts:138:19)
  at trace (../../node_modules/.pnpm/@ampproject+remapping@2.0.1/node_modules/@ampproject/src/source-map-tree.ts:70:25)
  at EncodedSourceMapImpl.map (../../node_modules/.pnpm/@jridgewell+trace-mapping@0.2.2/node_modules/@jridgewell/src/encoded-map.ts:43:24)
  at TraceMap.map (../../node_modules/.pnpm/@jridgewell+trace-mapping@0.2.2/node_modules/@jridgewell/src/trace-mapping.ts:85:23)
  at SourceMapTree.traceMappings (../../node_modules/.pnpm/@ampproject+remapping@2.0.1/node_modules/@ampproject/src/source-map-tree.ts:42:26)
  at remapping (../../node_modules/.pnpm/@ampproject+remapping@2.0.1/node_modules/@ampproject/src/remapping.ts:37:30)
  at mergeSourceMap (../../node_modules/.pnpm/@babel+core@7.17.0/node_modules/@babel/core/lib/transformation/file/merge-map.js:19:30)
  at generateCode (../../node_modules/.pnpm/@babel+core@7.17.0/node_modules/@babel/core/lib/transformation/file/generate.js:72:39)
  at run (../../node_modules/.pnpm/@babel+core@7.17.0/node_modules/@babel/core/lib/transformation/index.js:55:33)
      at run.next (<anonymous>)

should ensure not nil before call the source.originalPositionFor?

const source = this.sources[segment[1]];
return source.originalPositionFor(
segment[2],
segment[3],
segment.length === 5 ? this.map.names[segment[4]] : name
);

@jridgewell
Copy link
Collaborator

Hi @tmkx: This is actually a bug in @jridgewell/trace-mapping, which was fixed in v0.2.3. You currently have v0.2.2 installed. If you run npm update, does the issue still happen?

@jridgewell
Copy link
Collaborator

See also babel/babel#14229

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants