MCPcopy
hub / github.com/arktypeio/arktype / applyReplacements

Function applyReplacements

ark/docs/components/playground/errorLens.ts:93–111  ·  view source on GitHub ↗
(message: string)

Source from the content-addressed store, hash-verified

91// extracting arktype errors for inline display based on:
92// https://github.com/usernamehw/vscode-error-lens/blob/019d29b010f85ebb6e25c5f7f8ffda83479bfda0/src/utils/extUtils.ts#L184
93const applyReplacements = (message: string): string => {
94 for (const transformation of errorLensReplacements) {
95 const matchResult = transformation.matcher.exec(message)
96 if (matchResult) {
97 message = transformation.message
98 // replace groups like $0 and $1 with groups from the match
99 for (let groupIndex = 0; groupIndex < matchResult.length; groupIndex++) {
100 message = message.replace(
101 new RegExp(`\\$${groupIndex}`, "gu"),
102 matchResult[Number(groupIndex)]
103 )
104 }
105
106 return message
107 }
108 }
109
110 return message
111}
112
113const getDiagnostics = async (
114 tsLanguageService: Monaco.languages.typescript.TypeScriptWorker,

Callers 1

updateDiagnosticsFunction · 0.85

Calls 1

execMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…