Skip to content

Commit 02b8dc2

Browse files
authoredJun 19, 2024··
Merge pull request #229 from mkantor/newer-twoslash-target
Use `ESNext` target for twoslash
2 parents dd55858 + e46fc94 commit 02b8dc2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎src/modules/twoslash.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { Message } from 'discord.js';
22
import { twoslasher, TwoSlashReturn } from '@typescript/twoslash';
3+
import { ScriptTarget, type CompilerOptions } from 'typescript';
34
import { makeCodeBlock, findCode } from '../util/codeBlocks';
45
import { sendWithMessageOwnership } from '../util/send';
56
import { getTypeScriptModule, TypeScript } from '../util/getTypeScriptModule';
67
import { splitCustomCommand } from '../util/customCommand';
78
import { Bot } from '../bot';
89

10+
const defaultCompilerOptions: CompilerOptions = {
11+
target: ScriptTarget.ESNext,
12+
};
13+
914
// Preload typescript@latest
1015
getTypeScriptModule('latest');
1116

@@ -81,6 +86,7 @@ async function twoslash(msg: Message, version: string, content: string) {
8186
try {
8287
ret = twoslasher(redactNoErrorTruncation(code), 'ts', {
8388
tsModule,
89+
defaultCompilerOptions,
8490
defaultOptions: { noErrorValidation: true },
8591
});
8692
} catch (e) {
@@ -119,6 +125,7 @@ async function twoslashBlock(msg: Message, code: string, tsModule: TypeScript) {
119125
try {
120126
ret = twoslasher(redactNoErrorTruncation(code), 'ts', {
121127
tsModule,
128+
defaultCompilerOptions,
122129
defaultOptions: {
123130
noErrorValidation: true,
124131
noStaticSemanticInfo: false,

0 commit comments

Comments
 (0)
Please sign in to comment.