-
Notifications
You must be signed in to change notification settings - Fork 1.2k
TypeScript syntax incorrectly used in JavaScript file #3935
Comments
Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
Finally, remember to use https://discuss.ipfs.io if you just need general support. |
The pull request reviewer also mentioned that this same TypeScript syntax is used in other JS files in this project. So, this pattern seems have become a convention within this project, but all of these files contain errors if directly evaluated as JavaScript, either via node or import into another JavaScript context. |
That operator is called the optional chaining operator. It's not TypeScript (see the MDN link), but is only supported by node 14+. Are you using an older version? |
Thanks @achingbrain . As you can see in the reviewer's comment linked above, Optional Chaining was explained by way of a link to the TypeScript Language page, implying that the syntax of that file (and others) was intended to be TypeScript. Yes, I'm using Node ~12 because that had the widest adoption on different cloud compute platforms up until recently (AWS Lambda did not adopt Node 14+ until this year). I will consider upgrading in order to make use of |
Version:
0.11.1
Platform:
Linux localhost.localdomain 5.8.15-301.fc33.x86_64 (Fedora 33)
Subsystem:
Severity:
Medium
Description:
Initially I read this as a typo on line 75 of
packages/ipfs-http-gateway/src/index.js
:js-ipfs/packages/ipfs-http-gateway/src/index.js
Line 75 in 5ddd0c5
,.. and tried to correct this with pull request #3918
Through discussion on that request, it now appears that the author attempted to use valid TypeScript syntax within a JavaScript file. This is not valid JavaScript syntax and this code will throw an error in certain contexts.
Steps to reproduce the error:
The simplest way to reproduce this error is to install ipfs in a project using npm and then run:
The text was updated successfully, but these errors were encountered: