Skip to content

Commit 09fd77e

Browse files
Fix type errors
1 parent 28c1ef9 commit 09fd77e

3 files changed

Lines changed: 30 additions & 21 deletions

File tree

libs/parsing/index/src/lib/global-index.class.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class GlobalIndex {
5656
/**
5757
* Tokens categorized by type to reduce number of checks for global conflicts
5858
*/
59-
globalTokensByTypeByName: GlobalTokensByTypeByName = {};
59+
globalTokensByTypeByName!: GlobalTokensByTypeByName;
6060

6161
/**
6262
* Constructor which initializes properties in our constants so that they
@@ -111,7 +111,7 @@ export class GlobalIndex {
111111
const byNameForType = this.globalTokensByTypeByName[types[i]];
112112
const names = Object.keys(byNameForType);
113113
for (let j = 0; j < names.length; j++) {
114-
exported[types[i]].push(byNameForType[names[j]][0]);
114+
exported[types[i]].push(byNameForType[names[j]][0] as any);
115115
}
116116
}
117117
return exported;
@@ -332,7 +332,9 @@ export class GlobalIndex {
332332
break;
333333
case byName.length === 1:
334334
// remove display name
335-
delete IDL_DISPLAY_NAMES[tokens[i].type][tokens[i].name];
335+
delete (IDL_DISPLAY_NAMES[tokens[i].type] || {})[
336+
tokens[i].name
337+
];
336338

337339
// remove structure/type names
338340
if (tokens[i].type === GLOBAL_TOKEN_TYPES.STRUCTURE) {
@@ -355,7 +357,7 @@ export class GlobalIndex {
355357

356358
// mark as changed if we had problems
357359
if (file in this.globalSyntaxProblemsByFile) {
358-
this.changedFiles[file] = undefined;
360+
this.changedFiles[file] = false;
359361
}
360362

361363
// reset problems for our file as well
@@ -456,9 +458,11 @@ export class GlobalIndex {
456458

457459
// save by type
458460
if (token.name in this.globalTokensByTypeByName[token.type]) {
459-
this.globalTokensByTypeByName[token.type][token.name].push(token);
461+
this.globalTokensByTypeByName[token.type][token.name].push(
462+
token as any,
463+
);
460464
} else {
461-
this.globalTokensByTypeByName[token.type][token.name] = [token];
465+
this.globalTokensByTypeByName[token.type][token.name] = [token as any];
462466
}
463467
}
464468
}
@@ -558,8 +562,8 @@ export class GlobalIndex {
558562

559563
// check all files that we need to process
560564
const files = this.globalTokensByTypeByName[token.type][token.name]
561-
.filter((item) => item.file !== undefined)
562-
.map((item) => item.file);
565+
.map((item) => item.file)
566+
.filter((item) => item !== undefined);
563567

564568
// process each file
565569
for (let z = 0; z < files.length; z++) {
@@ -577,6 +581,11 @@ export class GlobalIndex {
577581
// extract the problem
578582
const problem = problems[j];
579583

584+
// skip if no file
585+
if (!problem.file) {
586+
continue;
587+
}
588+
580589
// check if our file matches
581590
if (
582591
(problem.file === token.file || clear) &&

libs/parsing/index/src/lib/global-index.interface.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export type GlobalIndexedToken = IGlobalIndexedToken<GlobalTokenType>;
2222
* Lookup with all tokens by type. We store an array of the token types
2323
* which we can manually search through to find.
2424
*/
25-
export interface GlobalTokensByTypeByName {
26-
[key: string]: { [key: string]: GlobalIndexedToken[] };
27-
}
25+
export type GlobalTokensByTypeByName = {
26+
[key in GlobalTokenType]: { [name: string]: IGlobalIndexedToken<key>[] };
27+
};
2828

2929
/**
3030
* Lookup with tokens by type for easier access when we export
@@ -33,14 +33,14 @@ export type ExportedGlobalTokensByType = {
3333
[key in GlobalTokenType]: IGlobalIndexedToken<key>[];
3434
};
3535

36-
/**
37-
* For each file we index tokens for, track which types of tokens they
38-
* contribute to filter the locations we need to clean up tokens from so
39-
* we don't need to process all tokens.
40-
*/
41-
export interface ITokenTypesByFile {
42-
[file: string]: { [key: string]: GlobalIndexedToken[] };
43-
}
36+
// /**
37+
// * For each file we index tokens for, track which types of tokens they
38+
// * contribute to filter the locations we need to clean up tokens from so
39+
// * we don't need to process all tokens.
40+
// */
41+
// export type ITokenTypesByFile = {
42+
// [file: string]: { [key in GlobalTokenType]: GlobalIndexedToken[] };
43+
// };
4444

4545
/**
4646
* Maps our token types to problem codes

libs/types/idl-data-types/src/lib/global-types.interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ interface IGlobalTokenTypeLookup {
4848
/**
4949
* Names for all global tokens
5050
*/
51-
export const GLOBAL_TOKEN_TYPES: IGlobalTokenTypeLookup = {
51+
export const GLOBAL_TOKEN_TYPES = {
5252
FUNCTION: 'f',
5353
PROCEDURE: 'p',
5454
FUNCTION_METHOD: 'fm',
5555
PROCEDURE_METHOD: 'pm',
5656
STRUCTURE: 's',
5757
SYSTEM_VARIABLE: 'sv',
5858
COMMON: 'c',
59-
};
59+
} as const satisfies IGlobalTokenTypeLookup;
6060

6161
/** Native code */
6262
type InternalTokenSource = 'internal';

0 commit comments

Comments
 (0)