1+ #!/usr/bin/env python3
2+
3+ # Read the file
4+ with open ('src/compiler/checker.ts' , 'r' , encoding = 'utf-8' ) as f :
5+ lines = f .readlines ()
6+
7+ # Find the line to replace (should be around line 22489)
8+ target_line = " reportError(message, generalizedSourceType, targetType);\n "
9+ replacement = """ // Check if both types are long and format differently for better readability
10+ if (message === Diagnostics.Type_0_is_not_assignable_to_type_1 &&
11+ generalizedSourceType.length > 30 && targetType.length > 30) {
12+ // Remove quotes from type strings and format with newlines
13+ const sourceTypeUnquoted = generalizedSourceType.replace(/^'|'$/g, "");
14+ const targetTypeUnquoted = targetType.replace(/^'|'$/g, "");
15+ const customMessage = {
16+ ...message,
17+ message: `Type: \\ n${sourceTypeUnquoted}\\ n\\ nis not assignable to type:\\ n${targetTypeUnquoted}`
18+ };
19+ reportError(customMessage);
20+ } else {
21+ reportError(message, generalizedSourceType, targetType);
22+ }
23+ """
24+
25+ # Replace the line
26+ for i , line in enumerate (lines ):
27+ if line == target_line :
28+ lines [i ] = replacement + "\n "
29+ print (f"Replaced line { i + 1 } " )
30+ break
31+ else :
32+ print ("Target line not found" )
33+
34+ # Write the file back
35+ with open ('src/compiler/checker.ts' , 'w' , encoding = 'utf-8' ) as f :
36+ f .writelines (lines )
37+
38+ print ("File modified successfully" )
0 commit comments