Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-impalas-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ec-ts/twoslash": patch
---

Fix minor bug that caused a key to not exist due to missing undefined value
5 changes: 5 additions & 0 deletions .changeset/slimy-pots-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"expressive-code-twoslash": minor
---

Migrate to `@ec-ts/twoslash` to provide ESM-only functionality to comply with Astro/Vite
15 changes: 15 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
"matchManagers": ["npm"],
"matchFileNames": ["packages/expressive-code-twoslash/**"]
},
{
"groupName": "Twoslash Core Dependencies",
"matchManagers": ["npm"],
"matchFileNames": ["packages/@ec-ts/twoslash/**"]
},
{
"groupName": "Twoslash Vue Dependencies",
"matchManagers": ["npm"],
"matchFileNames": ["packages/@ec-ts/twoslash-vue/**"]
},
{
"groupName": "VFS Dependencies",
"matchManagers": ["npm"],
"matchFileNames": ["packages/@ec-ts/vfs/**"]
},
{
"groupName": "CSS JS Gen Dependencies",
"matchManagers": ["npm"],
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"sharp": "^0.34.5",
"starlight-package-managers": "^0.12.0",
"unist-util-visit": "^5.1.0",
"vue": "^3.5.28"
"vue": "catalog:"
},
"devDependencies": {
"@astrojs/check": "catalog:",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
"allure-js-commons": "^3.4.5",
"allure-vitest": "^3.4.5",
"tsdown": "^0.20.3",
"typescript": "^5.9.3",
"typescript": "catalog:",
"pkg-pr-new": "^0.0.63",
"publint": "^0.3.17",
"vite": "^7.3.1",
"vitest": "^4.0.18",
"vue": "^3.5.28"
"vue": "catalog:"
}
}
2 changes: 1 addition & 1 deletion packages/@ec-ts/twoslash-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"test": "vitest"
},
"peerDependencies": {
"typescript": "^5.5.0"
"typescript": "catalog:min"
},
"dependencies": {
"@vue/language-core": "catalog:twoslash",
Expand Down
6 changes: 3 additions & 3 deletions packages/@ec-ts/twoslash-vue/test/results/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@
{
"type": "hover",
"text": "namespace console\nvar console: Console",
"docs": "The `console` module provides a simple debugging console that is similar to the\nJavaScript console mechanism provided by web browsers.\n\nThe module exports two specific components:\n\n* A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream.\n* A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstdout) and\n[`process.stderr`](https://nodejs.org/docs/latest-v20.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.\n\n_**Warning**_: The global console object's methods are neither consistently\nsynchronous like the browser APIs they resemble, nor are they consistently\nasynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v20.x/api/process.html#a-note-on-process-io) for\nmore information.\n\nExample using the global `console`:\n\n```js\nconsole.log('hello world');\n// Prints: hello world, to stdout\nconsole.log('hello %s', 'world');\n// Prints: hello world, to stdout\nconsole.error(new Error('Whoops, something bad happened'));\n// Prints error message and stack trace to stderr:\n// Error: Whoops, something bad happened\n// at [eval]:5:15\n// at Script.runInThisContext (node:vm:132:18)\n// at Object.runInThisContext (node:vm:309:38)\n// at node:internal/process/execution:77:19\n// at [eval]-wrapper:6:22\n// at evalScript (node:internal/process/execution:76:60)\n// at node:internal/main/eval_string:23:3\n\nconst name = 'Will Robinson';\nconsole.warn(`Danger ${name}! Danger!`);\n// Prints: Danger Will Robinson! Danger!, to stderr\n```\n\nExample using the `Console` class:\n\n```js\nconst out = getStreamSomehow();\nconst err = getStreamSomehow();\nconst myConsole = new console.Console(out, err);\n\nmyConsole.log('hello world');\n// Prints: hello world, to out\nmyConsole.log('hello %s', 'world');\n// Prints: hello world, to out\nmyConsole.error(new Error('Whoops, something bad happened'));\n// Prints: [Error: Whoops, something bad happened], to err\n\nconst name = 'Will Robinson';\nmyConsole.warn(`Danger ${name}! Danger!`);\n// Prints: Danger Will Robinson! Danger!, to err\n```",
"docs": "The `console` module provides a simple debugging console that is similar to the\nJavaScript console mechanism provided by web browsers.\n\nThe module exports two specific components:\n\n* A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream.\n* A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstdout) and\n[`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.\n\n_**Warning**_: The global console object's methods are neither consistently\nsynchronous like the browser APIs they resemble, nor are they consistently\nasynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v22.x/api/process.html#a-note-on-process-io) for\nmore information.\n\nExample using the global `console`:\n\n```js\nconsole.log('hello world');\n// Prints: hello world, to stdout\nconsole.log('hello %s', 'world');\n// Prints: hello world, to stdout\nconsole.error(new Error('Whoops, something bad happened'));\n// Prints error message and stack trace to stderr:\n// Error: Whoops, something bad happened\n// at [eval]:5:15\n// at Script.runInThisContext (node:vm:132:18)\n// at Object.runInThisContext (node:vm:309:38)\n// at node:internal/process/execution:77:19\n// at [eval]-wrapper:6:22\n// at evalScript (node:internal/process/execution:76:60)\n// at node:internal/main/eval_string:23:3\n\nconst name = 'Will Robinson';\nconsole.warn(`Danger ${name}! Danger!`);\n// Prints: Danger Will Robinson! Danger!, to stderr\n```\n\nExample using the `Console` class:\n\n```js\nconst out = getStreamSomehow();\nconst err = getStreamSomehow();\nconst myConsole = new console.Console(out, err);\n\nmyConsole.log('hello world');\n// Prints: hello world, to out\nmyConsole.log('hello %s', 'world');\n// Prints: hello world, to out\nmyConsole.error(new Error('Whoops, something bad happened'));\n// Prints: [Error: Whoops, something bad happened], to err\n\nconst name = 'Will Robinson';\nmyConsole.warn(`Danger ${name}! Danger!`);\n// Prints: Danger Will Robinson! Danger!, to err\n```",
"tags": [
[
"see",
"[source](https://github.com/nodejs/node/blob/v20.11.1/lib/console.js)"
"[source](https://github.com/nodejs/node/blob/v22.x/lib/console.js)"
]
],
"start": 282,
Expand All @@ -196,7 +196,7 @@
{
"type": "hover",
"text": "(method) Console.log(message?: any, ...optionalParams: any[]): void (+1 overload)",
"docs": "Prints to `stdout` with newline. Multiple arguments can be passed, with the\nfirst used as the primary message and all additional used as substitution\nvalues similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)\n(the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args)).\n\n```js\nconst count = 5;\nconsole.log('count: %d', count);\n// Prints: count: 5, to stdout\nconsole.log('count:', count);\n// Prints: count: 5, to stdout\n```\n\nSee [`util.format()`](https://nodejs.org/docs/latest-v20.x/api/util.html#utilformatformat-args) for more information.",
"docs": "Prints to `stdout` with newline. Multiple arguments can be passed, with the\nfirst used as the primary message and all additional used as substitution\nvalues similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)\n(the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)).\n\n```js\nconst count = 5;\nconsole.log('count: %d', count);\n// Prints: count: 5, to stdout\nconsole.log('count:', count);\n// Prints: count: 5, to stdout\n```\n\nSee [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.",
"tags": [
[
"since",
Expand Down
2 changes: 1 addition & 1 deletion packages/@ec-ts/twoslash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"test": "vitest"
},
"peerDependencies": {
"typescript": "^5.5.0"
"typescript": "catalog:min"
},
"dependencies": {
"@ec-ts/vfs": "workspace:^",
Expand Down
1 change: 1 addition & 0 deletions packages/@ec-ts/twoslash/src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export const defaultHandbookOptions: HandbookOptions = {
noErrorValidation: false,
noStaticSemanticInfo: false,
showEmit: false,
showEmittedFile: undefined,
keepNotations: false,
};
2 changes: 1 addition & 1 deletion packages/@ec-ts/twoslash/src/types/handbook-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface HandbookOptions {
* Must be used with showEmit, lets you choose the file to present instead of the source - defaults to index.js which
* means when you just use `showEmit` above it shows the transpiled JS.
*/
showEmittedFile?: string;
showEmittedFile?: string | undefined;

/**
* Do not remove twoslash notations from output code, the nodes will have the position of the input code.
Expand Down
1 change: 1 addition & 0 deletions packages/@ec-ts/twoslash/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export function findFlagNotations(
parseFlag(name, value, index, index + match[0].length + 1, customTags, tsOptionDeclarations),
);
});

return flagNotations;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/@ec-ts/vfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
},
"devDependencies": {
"@types/jest": "^30.0.0",
"typescript": "*"
"typescript": "catalog:"
},
"peerDependencies": {
"typescript": "*"
"typescript": "catalog:min"
}
}
6 changes: 3 additions & 3 deletions packages/expressive-code-twoslash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
},
"type": "module",
"dependencies": {
"@ec-ts/twoslash": "workspace:^",
"@ec-ts/twoslash-vue": "workspace:^",
"@typescript-eslint/parser": "^8.56.0",
"css-js-gen": "workspace:^",
"mdast-util-from-markdown": "catalog:mdast",
"mdast-util-gfm": "catalog:mdast",
"mdast-util-to-hast": "catalog:mdast",
"twoslash": "catalog:twoslash",
"twoslash-eslint": "catalog:twoslash",
"twoslash-vue": "catalog:twoslash"
"twoslash-eslint": "catalog:twoslash"
},
"peerDependencies": {
"@expressive-code/core": "catalog:min",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { NodeCompletion } from "@ec-ts/twoslash";
import {
type AnnotationRenderOptions,
ExpressiveCodeAnnotation,
type ExpressiveCodeLine,
} from "@expressive-code/core";
import { h } from "@expressive-code/core/hast";
import type { NodeCompletion } from "twoslash";
import { getTextWidthInPixels } from "../helpers/index.ts";
import type { CompletionItem } from "../types.ts";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { NodeTag } from "@ec-ts/twoslash";
import {
type AnnotationRenderOptions,
ExpressiveCodeAnnotation,
type ExpressiveCodeLine,
} from "@expressive-code/core";
import { type Element, h } from "@expressive-code/core/hast";
import type { NodeTag } from "twoslash";
import { getCustomTagClass, getCustomTagString } from "../helpers/index.ts";
import { customTagsIcons } from "../icons/customTagsIcons.ts";
import type { CustomTagsIcon, TwoslashTag } from "../types.ts";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { NodeError } from "@ec-ts/twoslash";
import {
type AnnotationRenderOptions,
ExpressiveCodeAnnotation,
type ExpressiveCodeLine,
} from "@expressive-code/core";
import { type Element, h } from "@expressive-code/core/hast";
import type { NodeError } from "twoslash";
import { getErrorLevelClass, getErrorLevelString } from "../helpers/index.ts";

export class TwoslashErrorUnderlineAnnotation extends ExpressiveCodeAnnotation {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NodeHighlight } from "@ec-ts/twoslash";
import { type AnnotationRenderOptions, ExpressiveCodeAnnotation } from "@expressive-code/core";
import { type Element, h, type Root } from "@expressive-code/core/hast";
import type { NodeHighlight } from "twoslash";

/**
* Represents a highlight annotation for Twoslash.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NodeHover } from "@ec-ts/twoslash";
import { type AnnotationRenderOptions, ExpressiveCodeAnnotation } from "@expressive-code/core";
import { type Element, h, type Root } from "@expressive-code/core/hast";
import type { NodeHover } from "twoslash";
import type { RenderJSDocs } from "../types.ts";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { NodeQuery } from "@ec-ts/twoslash";
import {
type AnnotationRenderOptions,
ExpressiveCodeAnnotation,
type ExpressiveCodeLine,
} from "@expressive-code/core";
import { type Element, h } from "@expressive-code/core/hast";
import type { NodeQuery } from "twoslash";
import { getTextWidthInPixels } from "../helpers/index.ts";
import type { RenderJSDocs } from "../types.ts";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NodeCompletion, TwoslashNode } from "twoslash";
import type { NodeCompletion, TwoslashNode } from "@ec-ts/twoslash";

/**
* Checks if the given node is of type `NodeCompletion`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NodeCompletion, TwoslashReturn } from "@ec-ts/twoslash";
import type { ExpressiveCodeBlock } from "expressive-code";
import type { NodeCompletion, TwoslashReturn } from "twoslash";
import { completionIcons } from "../icons/completionIcons.ts";
import type { CompletionIcon, CompletionItem } from "../types.ts";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { NodeHover, NodeQuery } from "@ec-ts/twoslash";
import { type Element, h } from "@expressive-code/core/hast";
import type { ExpressiveCode } from "expressive-code";
import { fromMarkdown } from "mdast-util-from-markdown";
import { gfmFromMarkdown } from "mdast-util-gfm";
import { toHast } from "mdast-util-to-hast";
import type { NodeHover, NodeQuery } from "twoslash";
import type { RenderJSDocs } from "../types.ts";
import {
jsdocTags,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NodeError } from "twoslash";
import type { NodeError } from "@ec-ts/twoslash";
import type { TwoslashTag } from "../types.ts";

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/expressive-code-twoslash/src/helpers/utils.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import fs from "node:fs";
import path from "node:path";
import type { ExpressiveCodeBlock } from "@expressive-code/core";
import type {
TwoslashExecuteOptions,
TwoslashGenericFunction,
TwoslashInstance,
TwoslashOptions,
} from "twoslash";
import { createTwoslasher } from "twoslash";
} from "@ec-ts/twoslash";
import { createTwoslasher } from "@ec-ts/twoslash";
import { createTwoslasher as createTwoslasherVue } from "@ec-ts/twoslash-vue";
import type { ExpressiveCodeBlock } from "@expressive-code/core";
import {
type CreateTwoslashESLintOptions,
createTwoslasher as createTwoslasherEslint,
} from "twoslash-eslint";
import { createTwoslasher as createTwoslasherVue } from "twoslash-vue";
import ts from "typescript";
import type { PluginTwoslashOptions } from "../types.ts";
import { reTrigger, twoslashDefaultTags } from "./regex.ts";
Expand Down
6 changes: 3 additions & 3 deletions packages/expressive-code-twoslash/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import path from "node:path";
import { definePlugin, type ExpressiveCodePlugin } from "@expressive-code/core";
import { ExpressiveCode } from "expressive-code";
import type {
NodeCompletion,
NodeError,
NodeHighlight,
NodeHover,
NodeQuery,
NodeTag,
} from "twoslash";
} from "@ec-ts/twoslash";
import { definePlugin, type ExpressiveCodePlugin } from "@expressive-code/core";
import { ExpressiveCode } from "expressive-code";
import type { CompilerOptions, ModuleResolutionKind } from "typescript";
import ts from "typescript";
import {
Expand Down
4 changes: 2 additions & 2 deletions packages/expressive-code-twoslash/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TwoslashOptions } from "@ec-ts/twoslash";
import type { CreateTwoslashVueOptions } from "@ec-ts/twoslash-vue";
import type { Element } from "@expressive-code/core/hast";
import type { TwoslashOptions } from "twoslash";
import type { CreateTwoslashESLintOptions } from "twoslash-eslint";
import type { CreateTwoslashVueOptions } from "twoslash-vue";
import type { completionIcons } from "./icons/completionIcons.ts";
import type { customTagsIcons } from "./icons/customTagsIcons.ts";

Expand Down
Loading
Loading