( foundConfigResult: ReturnType<typeof findAndReadConfig> )
| 626 | |
| 627 | /** @internal */ |
| 628 | export function createFromPreloadedConfig( |
| 629 | foundConfigResult: ReturnType<typeof findAndReadConfig> |
| 630 | ): Service { |
| 631 | const { |
| 632 | configFilePath, |
| 633 | cwd, |
| 634 | options, |
| 635 | config, |
| 636 | compiler, |
| 637 | projectLocalResolveDir, |
| 638 | optionBasePaths, |
| 639 | } = foundConfigResult; |
| 640 | |
| 641 | const projectLocalResolveHelper = createProjectLocalResolveHelper( |
| 642 | projectLocalResolveDir |
| 643 | ); |
| 644 | |
| 645 | const ts = loadCompiler(compiler); |
| 646 | |
| 647 | // Experimental REPL await is not compatible targets lower than ES2018 |
| 648 | const targetSupportsTla = config.options.target! >= ts.ScriptTarget.ES2018; |
| 649 | if (options.experimentalReplAwait === true && !targetSupportsTla) { |
| 650 | throw new Error( |
| 651 | 'Experimental REPL await is not compatible with targets lower than ES2018' |
| 652 | ); |
| 653 | } |
| 654 | // Top-level await was added in TS 3.8 |
| 655 | const tsVersionSupportsTla = versionGteLt(ts.version, '3.8.0'); |
| 656 | if (options.experimentalReplAwait === true && !tsVersionSupportsTla) { |
| 657 | throw new Error( |
| 658 | 'Experimental REPL await is not compatible with TypeScript versions older than 3.8' |
| 659 | ); |
| 660 | } |
| 661 | |
| 662 | const shouldReplAwait = |
| 663 | options.experimentalReplAwait !== false && |
| 664 | tsVersionSupportsTla && |
| 665 | targetSupportsTla; |
| 666 | |
| 667 | // swc implies two other options |
| 668 | // typeCheck option was implemented specifically to allow overriding tsconfig transpileOnly from the command-line |
| 669 | // So we should allow using typeCheck to override swc |
| 670 | if (options.swc && !options.typeCheck) { |
| 671 | if (options.transpileOnly === false) { |
| 672 | throw new Error( |
| 673 | "Cannot enable 'swc' option with 'transpileOnly: false'. 'swc' implies 'transpileOnly'." |
| 674 | ); |
| 675 | } |
| 676 | if (options.transpiler) { |
| 677 | throw new Error( |
| 678 | "Cannot specify both 'swc' and 'transpiler' options. 'swc' uses the built-in swc transpiler." |
| 679 | ); |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | const readFile = options.readFile || ts.sys.readFile; |
| 684 | const fileExists = options.fileExists || ts.sys.fileExists; |
| 685 | // typeCheck can override transpileOnly, useful for CLI flag to override config file |
no test coverage detected
searching dependent graphs…