You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a situation I've encountered that actually has an easy workaround, but I thought I'd share it in case anyone else is trying to do the same.
Use-case
I want to discover the tsconfig for a directory, get the parsed compiler options, and get a list of source files.
Right now, the API leads one to believe that they must know the name of a source file first, rather than discovering the source files from the tsconfig.
Workaround
Try to parse a .ts file that you know does not exist. This will trigger tsconfig discovery and the creation of a language service.
import{TypeScriptService}from'@ts-tools/service';constservice=newTypeScriptService();service.transpileFile('DOES NOT EXIST.ts',{tsconfigFileName : 'tsconfig.json',getCompilerOptions=(baseHost,tsconfigOptions)=>tsconfigOptions
});construnningService=service.runningServices.get('tsconfig.json')!;// Grab parsed compilerOptionsconsole.dir(runningService.languageService.getProgram()!.getCompilerOptions());// Grab parsed set of source filesconsole.dir(runningService.rootFileNames);
The text was updated successfully, but these errors were encountered:
This is a situation I've encountered that actually has an easy workaround, but I thought I'd share it in case anyone else is trying to do the same.
Use-case
I want to discover the tsconfig for a directory, get the parsed compiler options, and get a list of source files.
Right now, the API leads one to believe that they must know the name of a source file first, rather than discovering the source files from the tsconfig.
Workaround
Try to parse a .ts file that you know does not exist. This will trigger tsconfig discovery and the creation of a language service.
The text was updated successfully, but these errors were encountered: