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
2k stars 43 forks source link

Bug: Generic breaks code highlights #584

Closed RodrigoTomeES closed 4 months ago

RodrigoTomeES commented 8 months ago

Hi,

Write a generic function break the code highlights, looks:

https://github.com/lukehaas/RunJS/assets/13077343/598ec768-af8b-4f4f-9ab9-abff12dcf74a

The code:

export const isNumber = <T,>(value: T): value is NonNullable<T> =>
  value !== '' &&
  typeof value !== 'object' &&
  typeof value !== 'boolean' &&
  !Number.isNaN(Number(value));

SO:

Captura de pantalla 2023-10-20 a las 14 15 47

Version: 2.9.0 Config (is in spanish, I can't change the language of RunJS): Captura de pantalla 2023-10-20 a las 14 13 43

Captura de pantalla 2023-10-20 a las 14 14 17

Captura de pantalla 2023-10-20 a las 14 14 29

Captura de pantalla 2023-10-20 a las 14 14 45

Captura de pantalla 2023-10-20 a las 14 14 58

btecu commented 8 months ago

Seems to work fine for me (2.9.0):

image
RodrigoTomeES commented 8 months ago

Mmm I am also in 2.9.0. I update the issue with my config.

lukehaas commented 8 months ago

@RodrigoTomeES turn off the react-preset when this is on; it thinks you're writing JSX.

RodrigoTomeES commented 8 months ago

@lukehaas one question, as you said if I disable react-preset it works well but why react preset should break generic in TS? I use it in my .tsx files in vscode

lukehaas commented 8 months ago

It works in VS Code due to the comma before the closing bracket <T,>. Unfortunately, this is not supported in Codemirror.

lukehaas commented 8 months ago

Reopening as I will try and get this supported.

lukehaas commented 5 months ago

@RodrigoTomeES this is now resolved in the latest version of RunJS - version 2.10.0