From ff003eb666c32521619f9c590bc11d221402ed47 Mon Sep 17 00:00:00 2001 From: Songkeys Date: Tue, 17 Aug 2021 15:17:29 +0800 Subject: [PATCH] fix: be completely independent from typescript Or: to resolve typescript module correctly. The current code still has a "hard" top-level requiring for typescript, which may cause issues when installing ts-node globally and installing typescript locally (i.e. you have to install them both globally or both locally). Since we've already resolving typescript smartly in the code using `loadCompiler`, why not resolving `ScriptTarget` from the resolved one? --- src/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 165c14354..e1db16cac 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,6 @@ import { ModuleTypeClassifier, } from './module-type-classifier'; import { createResolverFunctions } from './resolver-functions'; -import { ScriptTarget } from 'typescript'; export { TSCommon }; export { @@ -551,7 +550,7 @@ export function create(rawOptions: CreateOptions = {}): Service { ]; // Experimental REPL await is not compatible targets lower than ES2018 - const targetSupportsTla = config.options.target! >= ScriptTarget.ES2018; + const targetSupportsTla = config.options.target! >= ts.ScriptTarget.ES2018; if (options.experimentalReplAwait === true && !targetSupportsTla) { throw new Error( 'Experimental REPL await is not compatible with targets lower than ES2018'