shikijs / twoslash

You take some Shiki, add a hint of TypeScript compiler, and 🎉 incredible static code samples
https://shikijs.github.io/twoslash/
MIT License
1.09k stars 53 forks source link

The "path" argument must be of type string. Received an instance of Array #111

Closed ghoshnirmalya closed 3 years ago

ghoshnirmalya commented 3 years ago

The highlighting is working fine when I'm rendering the following content:

{ "json": true }

It is also working fine when I'm rendering the following content:

for (let x in [0]) console.log(x)

However, I'm getting the error The "path" argument must be of type string. Received an instance of Array when I'm trying to render the following content:

```ts twoslash
interface IdLabel {id: number, /* some fields */ }
interface NameLabel {name: string, /* other fields */ }
type NameOrId<T extends number | string> = T extends number ? IdLabel : NameLabel;
// This comment should not be included

// ---cut---
function createLabel<T extends number | string>(idOrName: T): NameOrId<T> {
  throw "unimplemented"
}

let a = createLabel("typescript");


<img width="609" alt="Screenshot 2021-09-01 at 11 40 28 PM" src="https://user-images.githubusercontent.com/6391763/131722044-efc686c0-fa58-495b-94a1-2c7b5be6ac12.png">
ghoshnirmalya commented 3 years ago

I ran twoslash-cli on a markdown file with the following content and got a similar error:

```ts twoslash
interface IdLabel {id: number, /* some fields */ }
interface NameLabel {name: string, /* other fields */ }
type NameOrId<T extends number | string> = T extends number ? IdLabel : NameLabel;
// This comment should not be included

// ---cut---
function createLabel<T extends number | string>(idOrName: T): NameOrId<T> {
  throw "unimplemented"
}

let a = createLabel("typescript");


<img width="1680" alt="Screenshot 2021-09-01 at 11 55 16 PM" src="https://user-images.githubusercontent.com/6391763/131723941-c0d34209-5f55-4069-b2a5-d8f5ea7ae47f.png">
orta commented 3 years ago

Interesting, that doesn't look like an error message I have wrote - perhaps it lives at shiki level?

ghoshnirmalya commented 3 years ago

@orta Thank you for your reply. Should I close this and create a new issue in the Shiki repository?

frencojobs commented 3 years ago

Nope. This is an error from within remark-shiki-twoslash. Not sure why. I'll get back to this after work hours.

image