-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_strings.py
More file actions
29 lines (24 loc) · 979 Bytes
/
fix_strings.py
File metadata and controls
29 lines (24 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
def r(f, old, new):
if not os.path.exists(f): return
with open(f, 'r') as file:
c = file.read()
c = c.replace(old, new)
with open(f, 'w') as file:
file.write(c)
type_str = "string | number | boolean | object | undefined | null"
for root, _, files in os.walk('src'):
for file in files:
if file.endswith('.ts'):
path = os.path.join(root, file)
r(path, "type: 'unknown'", f"type: '{type_str}'")
r(path, ": 'unknown'", f": '{type_str}'")
r(path, "return 'unknown';", f"return '{type_str}';")
for root, _, files in os.walk('tests'):
for file in files:
if file.endswith('.ts'):
path = os.path.join(root, file)
r(path, "type: 'unknown'", f"type: '{type_str}'")
r(path, ": 'unknown'", f": '{type_str}'")
r(path, "return 'unknown';", f"return '{type_str}';")
r(path, "toBe('unknown')", f"toBe('{type_str}')")