Skip to content

Commit 897993b

Browse files
committed
fix: resolve readonly array includes TS errors from main merge
EVERY_SYMBOL_KIND and CORE_SYMBOL_KINDS are readonly-typed after kinds.js was converted to kinds.ts in #553. Array.prototype.includes on a readonly T[] rejects a wider argument type — cast to readonly string[] at call sites where the argument is string/AnyNodeKind. Also spread CORE_SYMBOL_KINDS where a mutable string[] is expected.
1 parent 65dcb2a commit 897993b

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/db/repository/in-memory-repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export class InMemoryRepository extends Repository {
286286
}
287287

288288
findNodesForTriage(opts: TriageQueryOpts = {}): NodeRow[] {
289-
if (opts.kind && !EVERY_SYMBOL_KIND.includes(opts.kind)) {
289+
if (opts.kind && !(EVERY_SYMBOL_KIND as readonly string[]).includes(opts.kind)) {
290290
throw new ConfigError(
291291
`Invalid kind: ${opts.kind} (expected one of ${EVERY_SYMBOL_KIND.join(', ')})`,
292292
);
@@ -563,7 +563,7 @@ export class InMemoryRepository extends Repository {
563563

564564
getCallableNodes(): CallableNodeRow[] {
565565
return [...this.#nodes.values()]
566-
.filter((n) => CORE_SYMBOL_KINDS.includes(n.kind))
566+
.filter((n) => (CORE_SYMBOL_KINDS as readonly string[]).includes(n.kind))
567567
.map((n) => ({ id: n.id, name: n.name, kind: n.kind, file: n.file }));
568568
}
569569

src/db/repository/nodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function findNodesForTriage(
4646
db: BetterSqlite3Database,
4747
opts: TriageQueryOpts = {},
4848
): NodeRow[] {
49-
if (opts.kind && !EVERY_SYMBOL_KIND.includes(opts.kind)) {
49+
if (opts.kind && !(EVERY_SYMBOL_KIND as readonly string[]).includes(opts.kind)) {
5050
throw new ConfigError(
5151
`Invalid kind: ${opts.kind} (expected one of ${EVERY_SYMBOL_KIND.join(', ')})`,
5252
);

src/domain/analysis/implementations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function implementationsData(
2727
noTests,
2828
file: opts.file,
2929
kind: opts.kind,
30-
kinds: opts.kind ? undefined : CORE_SYMBOL_KINDS,
30+
kinds: opts.kind ? undefined : [...CORE_SYMBOL_KINDS],
3131
});
3232
if (nodes.length === 0) {
3333
return { name, results: [] };
@@ -78,7 +78,7 @@ export function interfacesData(
7878
noTests,
7979
file: opts.file,
8080
kind: opts.kind,
81-
kinds: opts.kind ? undefined : CORE_SYMBOL_KINDS,
81+
kinds: opts.kind ? undefined : [...CORE_SYMBOL_KINDS],
8282
});
8383
if (nodes.length === 0) {
8484
return { name, results: [] };

0 commit comments

Comments
 (0)