@@ -51,6 +51,7 @@ export type FileURI = string & { __brand: "FileURI" };
5151 * @returns The normalized path, or null if input was null
5252 */
5353export function normalizePath ( filePath : string | null ) : NormalizedPath | null {
54+ // `path.normalize` ensures we can assume string is now NormalizedPath
5455 return filePath != null ? ( path . normalize ( filePath ) as NormalizedPath ) : null ;
5556}
5657
@@ -77,6 +78,7 @@ let tempFileId = 0;
7778export let createFileInTempDir = ( extension = "" ) : NormalizedPath => {
7879 let tempFileName = tempFilePrefix + tempFileId + extension ;
7980 tempFileId = tempFileId + 1 ;
81+ // `os.tmpdir` returns an absolute path, so `path.join` ensures we can assume string is now NormalizedPath
8082 return path . join ( os . tmpdir ( ) , tempFileName ) as NormalizedPath ;
8183} ;
8284
@@ -715,6 +717,7 @@ export let runBuildWatcherUsingValidBuildPath = (
715717
716718// parser helpers
717719export let pathToURI = ( file : NormalizedPath ) : FileURI => {
720+ // `pathToFileURL` ensures we can assume string is now FileURI
718721 return pathToFileURL ( file ) . toString ( ) as FileURI ;
719722} ;
720723let parseFileAndRange = ( fileAndRange : string ) => {
@@ -953,10 +956,9 @@ export let parseCompilerLogOutput = async (
953956 for ( const parsedDiagnostic of parsedDiagnostics ) {
954957 let [ fileAndRangeLine , ...diagnosticMessage ] = parsedDiagnostic . content ;
955958 let { file, range } = parseFileAndRange ( fileAndRangeLine ) ;
956- const fileUri = file as FileURI ;
957959
958- if ( result [ fileUri ] == null ) {
959- result [ fileUri ] = [ ] ;
960+ if ( result [ file ] == null ) {
961+ result [ file ] = [ ] ;
960962 }
961963
962964 // remove start and end whitespaces/newlines
@@ -982,7 +984,7 @@ export let parseCompilerLogOutput = async (
982984 range,
983985 } ) ;
984986
985- result [ fileUri ] . push ( diagnostic ) ;
987+ result [ file ] . push ( diagnostic ) ;
986988 }
987989 }
988990
0 commit comments