@@ -9,10 +9,7 @@ import * as vpath from "./_namespaces/vpath.js";
99import { LoggerWithInMemoryLogs } from "./tsserverLogger.js" ;
1010
1111import ArrayOrSingle = FourSlashInterface . ArrayOrSingle ;
12- import {
13- harnessSessionLibLocation ,
14- harnessTypingInstallerCacheLocation ,
15- } from "./harnessLanguageService.js" ;
12+ import { harnessTypingInstallerCacheLocation } from "./harnessLanguageService.js" ;
1613import { ensureWatchablePath } from "./watchUtils.js" ;
1714
1815export const enum FourSlashTestType {
@@ -105,7 +102,7 @@ const enum MetadataOptionNames {
105102const fileMetadataNames = [ MetadataOptionNames . fileName , MetadataOptionNames . emitThisFile , MetadataOptionNames . resolveReference , MetadataOptionNames . symlink ] ;
106103
107104function convertGlobalOptionsToCompilerOptions ( globalOptions : Harness . TestCaseParser . CompilerSettings ) : ts . CompilerOptions {
108- const settings : ts . CompilerOptions = { target : ts . ScriptTarget . ES5 , newLine : ts . NewLineKind . CarriageReturnLineFeed } ;
105+ const settings : ts . CompilerOptions = { ... ts . getDefaultCompilerOptions ( ) , jsx : undefined , newLine : ts . NewLineKind . CarriageReturnLineFeed } ;
109106 Harness . Compiler . setCompilerOptionsFromHarnessSetting ( globalOptions , settings ) ;
110107 return settings ;
111108}
@@ -367,11 +364,6 @@ export class TestState {
367364 }
368365 }
369366
370- const libName = ( name : string ) =>
371- this . testType !== FourSlashTestType . Server ?
372- name :
373- `${ harnessSessionLibLocation } /${ name } ` ;
374-
375367 let configParseResult : ts . ParsedCommandLine | undefined ;
376368 if ( configFileName ) {
377369 const baseDir = ts . normalizePath ( ts . getDirectoryPath ( configFileName ) ) ;
@@ -422,24 +414,6 @@ export class TestState {
422414 const importedFilePath = this . basePath + "/" + importedFile . fileName ;
423415 this . addMatchedInputFile ( importedFilePath , exts ) ;
424416 } ) ;
425-
426- this . languageServiceAdapterHost . addScript (
427- libName ( Harness . Compiler . defaultLibFileName ) ,
428- Harness . Compiler . getDefaultLibrarySourceFile ( ) ! . text ,
429- /*isRootFile*/ false ,
430- ) ;
431-
432- compilationOptions . lib ?. forEach ( fileName => {
433- const libFile = Harness . Compiler . getDefaultLibrarySourceFile ( fileName ) ;
434- ts . Debug . assertIsDefined ( libFile , `Could not find lib file '${ fileName } '` ) ;
435- if ( libFile ) {
436- this . languageServiceAdapterHost . addScript (
437- libName ( fileName ) ,
438- libFile . text ,
439- /*isRootFile*/ false ,
440- ) ;
441- }
442- } ) ;
443417 }
444418 else {
445419 // resolveReference file-option is not specified then do not resolve any files and include all inputFiles
@@ -452,24 +426,6 @@ export class TestState {
452426 this . languageServiceAdapterHost . addScript ( fileName , file , isRootFile ) ;
453427 }
454428 } ) ;
455-
456- if ( ! compilationOptions . noLib ) {
457- const seen = new Set < string > ( ) ;
458- const addSourceFile = ( fileName : string ) => {
459- if ( seen . has ( fileName ) ) return ;
460- seen . add ( fileName ) ;
461- const libFile = Harness . Compiler . getDefaultLibrarySourceFile ( fileName ) ;
462- ts . Debug . assertIsDefined ( libFile , `Could not find lib file '${ fileName } '` ) ;
463- this . languageServiceAdapterHost . addScript ( libName ( fileName ) , libFile . text , /*isRootFile*/ false ) ;
464- if ( ! ts . some ( libFile . libReferenceDirectives ) ) return ;
465- for ( const directive of libFile . libReferenceDirectives ) {
466- addSourceFile ( `lib.${ directive . fileName } .d.ts` ) ;
467- }
468- } ;
469-
470- addSourceFile ( Harness . Compiler . defaultLibFileName ) ;
471- compilationOptions . lib ?. forEach ( addSourceFile ) ;
472- }
473429 }
474430
475431 for ( const file of testData . files ) {
@@ -557,7 +513,13 @@ export class TestState {
557513 }
558514 private tryGetFileContent ( fileName : string ) : string | undefined {
559515 const script = this . languageServiceAdapterHost . getScriptInfo ( fileName ) ;
560- return script && script . content ;
516+ if ( script ) return script . content ;
517+ try {
518+ return this . languageServiceAdapterHost . vfs . readFileSync ( fileName , "utf8" ) ;
519+ }
520+ catch {
521+ return undefined ;
522+ }
561523 }
562524
563525 // Entry points from fourslash.ts
@@ -4870,18 +4832,6 @@ function parseTestData(basePath: string, contents: string, fileName: string): Fo
48704832 }
48714833 }
48724834
4873- // @Filename is the only directive that can be used in a test that contains tsconfig.json file.
4874- const config = ts . find ( files , isConfig ) ;
4875- if ( config ) {
4876- let directive = getNonFileNameOptionInFileList ( files ) ;
4877- if ( ! directive ) {
4878- directive = getNonFileNameOptionInObject ( globalOptions ) ;
4879- }
4880- if ( directive ) {
4881- throw Error ( `It is not allowed to use ${ config . fileName } along with directive '${ directive } '` ) ;
4882- }
4883- }
4884-
48854835 return {
48864836 markerPositions,
48874837 markers,
@@ -4896,24 +4846,6 @@ function isConfig(file: FourSlashFile): boolean {
48964846 return Harness . getConfigNameFromFileName ( file . fileName ) !== undefined ;
48974847}
48984848
4899- function getNonFileNameOptionInFileList ( files : FourSlashFile [ ] ) : string | undefined {
4900- return ts . forEach ( files , f => getNonFileNameOptionInObject ( f . fileOptions ) ) ;
4901- }
4902-
4903- function getNonFileNameOptionInObject ( optionObject : { [ s : string ] : string ; } ) : string | undefined {
4904- for ( const option in optionObject ) {
4905- switch ( option ) {
4906- case MetadataOptionNames . fileName :
4907- case MetadataOptionNames . baselineFile :
4908- case MetadataOptionNames . emitThisFile :
4909- break ;
4910- default :
4911- return option ;
4912- }
4913- }
4914- return undefined ;
4915- }
4916-
49174849const enum State {
49184850 none ,
49194851 inSlashStarMarker ,
0 commit comments