@@ -38,10 +38,7 @@ function main(): void {
3838        } 
3939    } 
4040
41-     const  outputFilesDir  =  path . dirname ( inputFilePath ) ; 
42-     const  thisFilePathRel  =  path . relative ( process . cwd ( ) ,  outputFilesDir ) ; 
43- 
44-     const  infoFileOutput  =  buildInfoFileOutput ( diagnosticMessages ,  `./${ path . basename ( inputFilePath ) }  ` ,  thisFilePathRel ) ; 
41+     const  infoFileOutput  =  buildInfoFileOutput ( diagnosticMessages ,  inputFilePath ) ; 
4542    checkForUniqueCodes ( diagnosticMessages ) ; 
4643    writeFile ( "diagnosticInformationMap.generated.ts" ,  infoFileOutput ) ; 
4744
@@ -59,28 +56,32 @@ function checkForUniqueCodes(diagnosticTable: InputDiagnosticMessageTable) {
5956    } ) ; 
6057} 
6158
62- function  buildInfoFileOutput ( messageTable : InputDiagnosticMessageTable ,  inputFilePathRel : string ,  thisFilePathRel : string ) : string  { 
63-     let  result  = 
64-         "// <auto-generated />\r\n"  + 
65-         "// generated from '"  +  inputFilePathRel  +  "' in '"  +  thisFilePathRel . replace ( / \\ / g,  "/" )  +  "'\r\n"  + 
66-         "/* @internal */\r\n"  + 
67-         "namespace ts {\r\n"  + 
68-         "    function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}, elidedInCompatabilityPyramid?: boolean, reportsDeprecated?: {}): DiagnosticMessage {\r\n"  + 
69-         "        return { code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid, reportsDeprecated };\r\n"  + 
70-         "    }\r\n"  + 
71-         "    export const Diagnostics = {\r\n" ; 
59+ function  buildInfoFileOutput ( messageTable : InputDiagnosticMessageTable ,  inputFilePathRel : string ) : string  { 
60+     const  result  =  [ 
61+         "// <auto-generated />" , 
62+         `// generated from '${ inputFilePathRel }  '` , 
63+         "" , 
64+         "import { DiagnosticCategory, DiagnosticMessage } from \"./types\";" , 
65+         "" , 
66+         "function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}, elidedInCompatabilityPyramid?: boolean, reportsDeprecated?: {}): DiagnosticMessage {" , 
67+         "    return { code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid, reportsDeprecated };" , 
68+         "}" , 
69+         "" , 
70+         "/* @internal */" , 
71+         "export const Diagnostics = {" , 
72+     ] ; 
7273    messageTable . forEach ( ( {  code,  category,  reportsUnnecessary,  elidedInCompatabilityPyramid,  reportsDeprecated } ,  name )  =>  { 
7374        const  propName  =  convertPropertyName ( name ) ; 
7475        const  argReportsUnnecessary  =  reportsUnnecessary  ? `, /*reportsUnnecessary*/ ${ reportsUnnecessary }  `  : "" ; 
7576        const  argElidedInCompatabilityPyramid  =  elidedInCompatabilityPyramid  ? `${ ! reportsUnnecessary  ? ", /*reportsUnnecessary*/ undefined"  : "" }  , /*elidedInCompatabilityPyramid*/ ${ elidedInCompatabilityPyramid }  `  : "" ; 
7677        const  argReportsDeprecated  =  reportsDeprecated  ? `${ ! argElidedInCompatabilityPyramid  ? ", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined"  : "" }  , /*reportsDeprecated*/ ${ reportsDeprecated }  `  : "" ; 
7778
78-         result   +=   `         ${ propName }  : diag(${ code }  , DiagnosticCategory.${ category }  , "${ createKey ( propName ,  code ) }  ", ${ JSON . stringify ( name ) } ${ argReportsUnnecessary } ${ argElidedInCompatabilityPyramid } ${ argReportsDeprecated }  ),\r\n`  ; 
79+         result . push ( `    ${ propName }  : diag(${ code }  , DiagnosticCategory.${ category }  , "${ createKey ( propName ,  code ) }  ", ${ JSON . stringify ( name ) } ${ argReportsUnnecessary } ${ argElidedInCompatabilityPyramid } ${ argReportsDeprecated }  ),`  ) ; 
7980    } ) ; 
8081
81-     result   +=   "    };\r\n}" ; 
82+     result . push ( "};" ) ; 
8283
83-     return  result ; 
84+     return  result . join ( "\r\n" ) ; 
8485} 
8586
8687function  buildDiagnosticMessageOutput ( messageTable : InputDiagnosticMessageTable ) : string  { 
0 commit comments