diff --git a/src/format/formatDiagnosticMessage.ts b/src/format/formatDiagnosticMessage.ts index ade69ff..e69d68a 100644 --- a/src/format/formatDiagnosticMessage.ts +++ b/src/format/formatDiagnosticMessage.ts @@ -28,7 +28,7 @@ export const formatDiagnosticMessage = ( message // format declare module snippet .replaceAll( - /'(declare module )'(.*)';'/g, + /['“](declare module )['”](.*)['“];['”]/g, (_: string, p1: string, p2: string) => formatTypeScriptBlock(_, `${p1} "${p2}"`) ) @@ -44,7 +44,7 @@ export const formatDiagnosticMessage = ( ) // Format type pairs .replaceAll( - /(types) '(.*?)' and '(.*?)'[\.]?/gi, + /(types) ['“](.*?)['”] and ['“](.*?)['”][\.]?/gi, (_: string, p1: string, p2: string, p3: string) => `${formatTypeBlock(p1, p2, format)} and ${formatTypeBlock( "", @@ -54,7 +54,7 @@ export const formatDiagnosticMessage = ( ) // Format type annotation options .replaceAll( - /type annotation must be '(.*?)' or '(.*?)'[\.]?/gi, + /type annotation must be ['“](.*?)['”] or ['“](.*?)['”][\.]?/gi, (_: string, p1: string, p2: string, p3: string) => `${formatTypeBlock(p1, p2, format)} or ${formatTypeBlock( "", @@ -63,40 +63,40 @@ export const formatDiagnosticMessage = ( )}` ) .replaceAll( - /(Overload \d of \d), '(.*?)', /gi, + /(Overload \d of \d), ['“](.*?)['”], /gi, (_, p1: string, p2: string) => `${p1}${formatTypeBlock("", p2, format)}` ) // format simple strings - .replaceAll(/^'"[^"]*"'$/g, formatTypeScriptBlock) + .replaceAll(/^['“]"[^"]*"['”]$/g, formatTypeScriptBlock) // Format types .replaceAll( - /(type|type alias|interface|module|file|file name|method's|subtype of constraint) '(.*?)'(?=[\s(.|,)])/gi, + /(type|type alias|interface|module|file|file name|method's|subtype of constraint) ['“](.*?)['“](?=[\s(.|,)])/gi, (_, p1: string, p2: string) => formatTypeOrModuleBlock(_, p1, p2, format) ) // Format reversed types .replaceAll( - /(.*)'([^>]*)' (type|interface|return type|file|module)/gi, + /(.*)['“]([^>]*)['”] (type|interface|return type|file|module)/gi, (_: string, p1: string, p2: string, p3: string) => `${p1}${formatTypeOrModuleBlock(_, "", p2, format)} ${p3}` ) // Format simple types that didn't captured before .replaceAll( - /'((void|null|undefined|any|boolean|string|number|bigint|symbol)(\[\])?)'/g, + /['“]((void|null|undefined|any|boolean|string|number|bigint|symbol)(\[\])?)['”]/g, formatSimpleTypeBlock ) // Format some typescript key words .replaceAll( - /'(import|export|require|in|continue|break|let|false|true|const|new|throw|await|for await|[0-9]+)( ?.*?)'/g, + /['“](import|export|require|in|continue|break|let|false|true|const|new|throw|await|for await|[0-9]+)( ?.*?)['”]/g, (_: string, p1: string, p2: string) => formatTypeScriptBlock(_, `${p1}${p2}`) ) // Format return values .replaceAll( - /(return|operator) '(.*?)'/gi, + /(return|operator) ['“](.*?)['”]/gi, (_, p1: string, p2: string) => `${p1} ${formatTypeScriptBlock("", p2)}` ) // Format regular code blocks .replaceAll( - /'((?:(?!:\s*}).)*?)' (?!\s*:)/g, + /['“]((?:(?!:\s*}).)*?)['“] (?!\s*:)/g, (_: string, p1: string) => `${unStyledCodeBlock(p1)} ` );