MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / removeConflictingGlobalDeclaration

Function removeConflictingGlobalDeclaration

scripts/prepare.ts:25–42  ·  view source on GitHub ↗

* Removes the conflicting global HTMLElementEventMap declaration from * @paulirish/trace_engine/models/trace/ModelImpl.d.ts to avoid TS2717 error * when both chrome-devtools-frontend and @paulirish/trace_engine declare * the same property.

()

Source from the content-addressed store, hash-verified

23 * the same property.
24 */
25function removeConflictingGlobalDeclaration(): void {
26 const filePath = resolve(
27 projectRoot,
28 'node_modules/@paulirish/trace_engine/models/trace/ModelImpl.d.ts',
29 );
30 console.log(
31 'Removing conflicting global declaration from @paulirish/trace_engine...',
32 );
33 const content = readFileSync(filePath, 'utf-8');
34 // Remove the declare global block using regex
35 // Matches: declare global { ... interface HTMLElementEventMap { ... } ... }
36 const newContent = content.replace(
37 /declare global\s*\{\s*interface HTMLElementEventMap\s*\{[^}]*\[ModelUpdateEvent\.eventName\]:\s*ModelUpdateEvent;\s*\}\s*\}/s,
38 '',
39 );
40 writeFileSync(filePath, newContent, 'utf-8');
41 console.log('Successfully removed conflicting global declaration.');
42}
43
44async function main() {
45 console.log('Running prepare script to clean up chrome-devtools-frontend...');

Callers 1

mainFunction · 0.85

Calls 2

resolveFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected