Skip to content

Commit b3b4bf4

Browse files
committed
fix: TypeScript compilation errors
- Fix symbol index type errors with type assertions - Remove unused getDefaultFormatting function - Add null check for match[1] in detectIndent - Remove unused contentWithoutImport variable
1 parent ffad1d4 commit b3b4bf4

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/utils/config.mts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,7 @@ export function updateConfigValue<Key extends keyof LocalConfig>(
395395
// Now update with new values.
396396
editor.update(configToSave)
397397
// Use the editor's internal stringify which preserves formatting.
398-
// We need to extract the content without symbols and then stringify
399-
// with the formatting metadata.
400-
const { getEditableJsonClass: _, ...contentWithoutImport } = editor.content as any
398+
// Extract the formatting symbols from the content.
401399
const INDENT_SYMBOL = Symbol.for('indent')
402400
const NEWLINE_SYMBOL = Symbol.for('newline')
403401
const indent = (editor.content as any)[INDENT_SYMBOL] ?? 2

src/utils/editable-json.mts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interface EditableJsonSaveOptions {
4242
*/
4343
function detectIndent(json: string): string | number {
4444
const match = json.match(/^[{[][\r\n]+(\s+)/m)
45-
if (!match) {
45+
if (!match || !match[1]) {
4646
return 2
4747
}
4848
const indent = match[1]
@@ -61,15 +61,6 @@ function detectNewline(json: string): string {
6161
return match ? match[0] : '\n'
6262
}
6363

64-
/**
65-
* Get default formatting for JSON files.
66-
*/
67-
function getDefaultFormatting(): JsonFormatting {
68-
return {
69-
indent: 2,
70-
newline: '\n',
71-
}
72-
}
7364

7465
/**
7566
* Sort object keys alphabetically.
@@ -289,8 +280,9 @@ export class EditableJson<T = Record<string, unknown>> {
289280
const parsed = parseJson(data)
290281
const indent = detectIndent(data)
291282
const newline = detectNewline(data)
292-
parsed[INDENT_SYMBOL] = indent
293-
parsed[NEWLINE_SYMBOL] = newline
283+
// Use type assertion to allow symbol indexing.
284+
;(parsed as any)[INDENT_SYMBOL] = indent
285+
;(parsed as any)[NEWLINE_SYMBOL] = newline
294286
this._content = parsed as Record<string | symbol, unknown>
295287
return this
296288
}

0 commit comments

Comments
 (0)