Skip to content

Support twoslash directives for TsConfigOnlyOption and its list #3425

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

Open
wants to merge 4 commits into
base: v2
Choose a base branch
from

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