Skip to content

Conversation

64qq
Copy link

@64qq 64qq commented Jul 31, 2025

This PR adds support for twoslash directives (e.g., @path) for TsConfigOnlyOption and its list.

Currently, twoslasher doesn't correctly handle the cases where type is "object". This code example triggers a runtime exception: TypeError: optMap.get is not a function

// @filename: module-a.ts
export const variable: number = 0

// @filename: module-b.ts
// @paths: { "@/*": ["./*"] }
import { variable } from "@/module-a";

This problem comes from missing internal API types (ts.optionDeclarations is any).

I've added a patch to manage those type definitions in a single project (ts-internals) and added handling for missing cases based on them. Due to type consistency requirements, twoslasher now throws an error when an option with a list of booleans is passed, but that shouldn't be a problem since it's unreachable.

Related: #1555
Related: shikijs/twoslash#197 (comment)

@64qq
Copy link
Author

64qq commented Jul 31, 2025

@microsoft-github-policy-service agree

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

Successfully merging this pull request may close these issues.

1 participant