Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Array.prototype.map called on null or undefined #573

Closed
pandaomeng opened this issue Dec 3, 2020 · 2 comments
Closed

Array.prototype.map called on null or undefined #573

pandaomeng opened this issue Dec 3, 2020 · 2 comments

Comments

@pandaomeng
Copy link

Hello,

I've wrote a demo.ts below

[1, 2, 3]?.map?.(x => x).filter(x => x);

then, I have a index.js

const { startService } = require('esbuild');

(async () => {
  const code = require('fs').readFileSync('./demo.ts', 'utf-8');
  const service = await startService();
  const result = await service.transform(code, {
    loader: 'tsx',
    target: 'es2019',
  });
  console.log(result.code);
  eval(result.code);
})()

after I run

node index.js

I got a log as below

var _a, _b;
(_b = (_a = [1, 2, 3]) == null ? void 0 : _a.map) == null ? void 0 : _b((x) => x).filter((x) => x);

(node:44126) UnhandledPromiseRejectionWarning: TypeError: Array.prototype.map called on null or undefined
    at map (<anonymous>)
    at eval (eval at <anonymous> (/test/esbuild-issue/index.js:11:3), <anonymous>:2:70)
    at workspace/test/esbuild-issue/index.js:11:3
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:44126) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:44126) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@evanw evanw closed this as completed in 9f5e37e Dec 4, 2020
@PIMBA
Copy link

PIMBA commented Dec 4, 2020

I had same problem, why it's closed ? @evanw

@evanw
Copy link
Owner

evanw commented Dec 4, 2020

You have come across this issue after it has been fixed but before the fix has been released. I plan to release the fix later tonight.

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

No branches or pull requests

3 participants