|
1 | 1 | import { Message } from 'discord.js';
|
2 | 2 | import { twoslasher, TwoSlashReturn } from '@typescript/twoslash';
|
| 3 | +import { ScriptTarget, type CompilerOptions } from 'typescript'; |
3 | 4 | import { makeCodeBlock, findCode } from '../util/codeBlocks';
|
4 | 5 | import { sendWithMessageOwnership } from '../util/send';
|
5 | 6 | import { getTypeScriptModule, TypeScript } from '../util/getTypeScriptModule';
|
6 | 7 | import { splitCustomCommand } from '../util/customCommand';
|
7 | 8 | import { Bot } from '../bot';
|
8 | 9 |
|
| 10 | +const defaultCompilerOptions: CompilerOptions = { |
| 11 | + target: ScriptTarget.ESNext, |
| 12 | +}; |
| 13 | + |
9 | 14 | // Preload typescript@latest
|
10 | 15 | getTypeScriptModule('latest');
|
11 | 16 |
|
@@ -81,6 +86,7 @@ async function twoslash(msg: Message, version: string, content: string) {
|
81 | 86 | try {
|
82 | 87 | ret = twoslasher(redactNoErrorTruncation(code), 'ts', {
|
83 | 88 | tsModule,
|
| 89 | + defaultCompilerOptions, |
84 | 90 | defaultOptions: { noErrorValidation: true },
|
85 | 91 | });
|
86 | 92 | } catch (e) {
|
@@ -119,6 +125,7 @@ async function twoslashBlock(msg: Message, code: string, tsModule: TypeScript) {
|
119 | 125 | try {
|
120 | 126 | ret = twoslasher(redactNoErrorTruncation(code), 'ts', {
|
121 | 127 | tsModule,
|
| 128 | + defaultCompilerOptions, |
122 | 129 | defaultOptions: {
|
123 | 130 | noErrorValidation: true,
|
124 | 131 | noStaticSemanticInfo: false,
|
|
0 commit comments