@@ -65,20 +65,14 @@ def post_process_typescript_declarations(schema_dir: Path) -> None:
6565 index_signature_unknown_pattern = re .compile (r"\[k:\s*string\]:\s*unknown;?" )
6666 index_signature_any_pattern = re .compile (r"\[k:\s*string\]:\s*any;?" )
6767 import_statement = "import type { JSONObject } from '@llamaindex/ui';\n "
68- import_regex = re .compile (
69- r"import\s+type\s+\{\s*JSONObject\s*\}\s+from\s+'@llamaindex/ui';"
70- )
68+ import_regex = re .compile (r"import\s+type\s+\{\s*JSONObject\s*\}\s+from\s+'@llamaindex/ui';" )
7169
7270 for dts_path in schema_dir .glob ("*.d.ts" ):
7371 content = dts_path .read_text (encoding = "utf-8" )
7472
7573 # Replace index signature value types
76- new_content = index_signature_unknown_pattern .sub (
77- "[k: string]: JSONObject;" , content
78- )
79- new_content = index_signature_any_pattern .sub (
80- "[k: string]: JSONObject;" , new_content
81- )
74+ new_content = index_signature_unknown_pattern .sub ("[k: string]: JSONObject;" , content )
75+ new_content = index_signature_any_pattern .sub ("[k: string]: JSONObject;" , new_content )
8276
8377 # Insert import if JSONObject is used and import not present
8478 if "JSONObject" in new_content and not import_regex .search (new_content ):
@@ -88,14 +82,8 @@ def post_process_typescript_declarations(schema_dir: Path) -> None:
8882 if banner_end != - 1 :
8983 # Move to the next newline after banner
9084 next_newline = new_content .find ("\n " , banner_end + 2 )
91- insertion_index = (
92- next_newline + 1 if next_newline != - 1 else banner_end + 2
93- )
94- new_content = (
95- new_content [:insertion_index ]
96- + import_statement
97- + new_content [insertion_index :]
98- )
85+ insertion_index = next_newline + 1 if next_newline != - 1 else banner_end + 2
86+ new_content = new_content [:insertion_index ] + import_statement + new_content [insertion_index :]
9987
10088 if new_content != content :
10189 dts_path .write_text (new_content , encoding = "utf-8" )
0 commit comments