Skip to content

Commit 62ad72b

Browse files
committed
fix: build error due to types
1 parent af64fa5 commit 62ad72b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/utils/schema.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,16 @@ export function loadSchema(
1818
schemaPath: string,
1919
context: RuleContext,
2020
): null | SchemaObject {
21-
return loadJsonInternal(schemaPath, context, (schema) => {
22-
migrateToDraft7(schema as SchemaObject);
21+
return loadJsonInternal(schemaPath, context, (schema_) => {
22+
const schema = schema_ as SchemaObject;
23+
migrateToDraft7(schema);
2324
return schema;
2425
});
2526
}
2627
/**
2728
* Load json data
2829
*/
29-
export function loadJson<
30-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore
31-
T = any,
32-
>(jsonPath: string, context: RuleContext): null | T {
30+
export function loadJson<T>(jsonPath: string, context: RuleContext): null | T {
3331
return loadJsonInternal(jsonPath, context);
3432
}
3533

@@ -39,7 +37,7 @@ export function loadJson<
3937
function loadJsonInternal<T>(
4038
jsonPath: string,
4139
context: RuleContext,
42-
edit?: (json: unknown) => unknown,
40+
edit?: (json: unknown) => T,
4341
): null | T {
4442
if (jsonPath.startsWith("http://") || jsonPath.startsWith("https://")) {
4543
return loadJsonFromURL(jsonPath, context, edit);
@@ -52,7 +50,7 @@ function loadJsonInternal<T>(
5250
url = `${url}.json`;
5351
}
5452
return loadJsonFromURL(url, context, (orig) => {
55-
const result = edit?.(orig) ?? orig;
53+
const result = edit?.(orig) ?? (orig as T);
5654
if (jsonPath === "vscode://schemas/settings/machine") {
5755
// Adjust `vscode://schemas/settings/machine` resource to avoid bugs.
5856
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- ignore
@@ -111,7 +109,7 @@ function removeEmptyEnum(
111109
function loadJsonFromURL<T>(
112110
jsonPath: string,
113111
context: RuleContext,
114-
edit?: (json: unknown) => unknown,
112+
edit?: (json: unknown) => T,
115113
): null | T {
116114
let jsonFileName = jsonPath.replace(/^https?:\/\//u, "");
117115
if (!jsonFileName.endsWith(".json")) {
@@ -180,9 +178,9 @@ function postProcess<T>(
180178
jsonFilePath: string,
181179
json: string,
182180
context: RuleContext,
183-
edit: ((json: unknown) => unknown) | undefined,
181+
edit: ((json: unknown) => T) | undefined,
184182
): T | null {
185-
let data;
183+
let data: T;
186184
try {
187185
data = JSON.parse(json);
188186
} catch {

0 commit comments

Comments
 (0)