Skip to content

Commit

Permalink
Merge pull request #229 from mkantor/newer-twoslash-target
Browse files Browse the repository at this point in the history
Use `ESNext` target for twoslash
  • Loading branch information
robertt authored Jun 19, 2024
2 parents dd55858 + e46fc94 commit 02b8dc2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/modules/twoslash.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Message } from 'discord.js';
import { twoslasher, TwoSlashReturn } from '@typescript/twoslash';
import { ScriptTarget, type CompilerOptions } from 'typescript';
import { makeCodeBlock, findCode } from '../util/codeBlocks';
import { sendWithMessageOwnership } from '../util/send';
import { getTypeScriptModule, TypeScript } from '../util/getTypeScriptModule';
import { splitCustomCommand } from '../util/customCommand';
import { Bot } from '../bot';

const defaultCompilerOptions: CompilerOptions = {
target: ScriptTarget.ESNext,
};

// Preload typescript@latest
getTypeScriptModule('latest');

Expand Down Expand Up @@ -81,6 +86,7 @@ async function twoslash(msg: Message, version: string, content: string) {
try {
ret = twoslasher(redactNoErrorTruncation(code), 'ts', {
tsModule,
defaultCompilerOptions,
defaultOptions: { noErrorValidation: true },
});
} catch (e) {
Expand Down Expand Up @@ -119,6 +125,7 @@ async function twoslashBlock(msg: Message, code: string, tsModule: TypeScript) {
try {
ret = twoslasher(redactNoErrorTruncation(code), 'ts', {
tsModule,
defaultCompilerOptions,
defaultOptions: {
noErrorValidation: true,
noStaticSemanticInfo: false,
Expand Down

0 comments on commit 02b8dc2

Please sign in to comment.