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

Compiler errors with @paths compiler option #197

Open
vecerek opened this issue Oct 20, 2024 · 0 comments
Open

Compiler errors with @paths compiler option #197

vecerek opened this issue Oct 20, 2024 · 0 comments

Comments

@vecerek
Copy link

vecerek commented Oct 20, 2024

Disclaimer: I'm still new to twoslash. It may be that I'm doing something wrong.

I'm trying to render HTML for the following markdown code with shiki twoslash in a monorepo using TS path aliases:

```ts twoslash title="example.ts"
import { Schema } from "@effect/schema"
import { ULID } from "@myorg/schema-extended"
import { Effect } from "effect"

const decode = Schema.decodeUnknown(ULID)

const program = decode("01HZT9JC9RY11PPAY429ZDZ46X")

void Effect.runPromise(program).then(console.log, console.error)
```

This results in the following error:

Twoslash error: Errors were thrown in the sample, but not included in an errors tag
These errors were not marked as being expected: 2345. 
Expected: // @errors: 2345
Compiler Errors:

index.ts
  [2345] 155 - Argument of type 'brand<typeof ULID, "ULID">' is not assignable to parameter of type 'Schema<unknown, unknown, unknown>'.
  [2345] 239 - Argument of type 'Effect<unknown, ParseError, unknown>' is not assignable to parameter of type 'Effect<unknown, ParseError, never>'.

This can also be reproduced using the twoslash CLI1 if the @paths compiler option is inlined in the code example like so:

```ts twoslash title="example.ts"
// @paths: { "@myorg/schema-extended": ["../../packages/schema-extended/src"] }
import { Schema } from "@effect/schema"
import { ULID } from "@myorg/schema-extended"
import { Effect } from "effect"

const decode = Schema.decodeUnknown(ULID)

const program = decode("01HZT9JC9RY11PPAY429ZDZ46X")

void Effect.runPromise(program).then(console.log, console.error)
```

I'm not going to provide the whole context in this issue. I've created the following reproduction repo instead: https://github.com/vecerek/docusaurus-shiki-twoslash-example. You shall find all relevant information (including the precise reproduction steps) in its README.

I think this is a twoslash issue because the TS code compiles correctly outside the documentation, i.e.:

// docs/src/this-compiles.ts
import { Schema } from "@effect/schema"
import { ULID } from "@myorg/schema-extended"
import { Effect } from "effect"

const decode = Schema.decodeUnknown(ULID)

const program = decode("01HZT9JC9RY11PPAY429ZDZ46X")

void Effect.runPromise(program).then(console.log, console.error)

Footnotes

  1. It requires a small patch to @typescript/twoslash (also described in the reproduction repo's README) because the current version of twoslash CLI doesn't work with the inlined @paths compiler option

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

1 participant