lukehaas / RunJS

RunJS is a JavaScript playground for macOS, Windows and Linux. Write code with instant feedback and access to Node.js and browser APIs.
https://runjs.app
2.03k stars 44 forks source link

False error: `TypeError: console.log(...) is not a function` #550

Closed brandonmcconnell closed 1 year ago

brandonmcconnell commented 1 year ago

With TS enabled, the below code produces the error(s).

Errors:

In intellisense (over the console.log('{' + message.split('{').slice(1).join('{')) line):

This expression is not callable.
  Type 'void' has no call signatures.

In right (render) sidebar:

TypeError: console.log(...) is not a function

Source code:

const message = `{
  "error": {
    "message": "That model does not exist",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}`

console.log('{' + message.split('{').slice(1).join('{'))

`"error testing"`.split('"')[1]

Screenshot:

image

Diagnostics:

RunJS v2.7.4–v2.8.0 macOS v13.1 (22C65)

brandonmcconnell commented 1 year ago

I can confirm that this issue still persists after updating to RunJS v2.8.0

btecu commented 1 year ago

That's why it's important to use ; :trollface:

lukehaas commented 1 year ago

@brandonmcconnell this is one of the scenarios where a semi-colon is essential. You'll see the same error in any environment.

brandonmcconnell commented 1 year ago

Sweet, glad it was a quick fix. Thanks!