Skip to content

Commit 0298db2

Browse files
style: 💄 use interface for types
1 parent d45ef48 commit 0298db2

File tree

15 files changed

+88
-58
lines changed

15 files changed

+88
-58
lines changed

‎biome.json‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222
"linter": {
2323
"rules": {
2424
"style": {
25+
"noInferrableTypes": "error",
2526
"noParameterAssign": "error",
27+
"noUnusedTemplateLiteral": "error",
28+
"noUselessElse": "error",
2629
"useAsConstAssertion": "error",
30+
"useConsistentTypeDefinitions": "error",
2731
"useDefaultParameterLast": "error",
2832
"useEnumInitializers": "error",
29-
"useSelfClosingElements": "error",
30-
"useSingleVarDeclarator": "error",
31-
"noUnusedTemplateLiteral": "error",
3233
"useNumberNamespace": "error",
33-
"noInferrableTypes": "error",
34-
"noUselessElse": "error"
34+
"useSelfClosingElements": "error",
35+
"useSingleVarDeclarator": "error"
3536
}
3637
}
3738
}

‎packages/bloom-filter/src/bloom-filter.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class BloomFilter<T extends { toString(): string }> {
5555
}
5656
}
5757

58-
export type SerialisedBloomFilter = {
58+
export interface SerialisedBloomFilter {
5959
readonly size: number
6060
readonly hashes: number
6161
readonly seed: number

‎packages/bloom-filter/src/counting-bloom-filter.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class CountingBloomFilter<T extends { toString(): string }> {
6363
}
6464
}
6565

66-
export type SerialisedCountingBloomFilter = {
66+
export interface SerialisedCountingBloomFilter {
6767
readonly size: number
6868
readonly hashes: number
6969
readonly seed: number

‎packages/bloom-search/src/index.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { range, unique, windowed } from '@pacote/array'
22
import { BloomFilter, optimal } from '@pacote/bloom-filter'
33
import { memoize } from '@pacote/memoize'
44
import type { U64 } from '@pacote/u64'
5-
import { type XXHash, xxh64 } from '@pacote/xxhash'
5+
import { xxh64, type XXHash } from '@pacote/xxhash'
66
import { findLast } from './array'
77
import { entries, keys, pick } from './object'
8-
import { EXCLUDE, PHRASE, REQUIRE, queryTerms } from './query'
8+
import { EXCLUDE, PHRASE, queryTerms, REQUIRE } from './query'
99
import { countIdf } from './tf-idf'
1010

1111
export type PreprocessFunction<Document, Field extends keyof Document> = (
@@ -23,7 +23,10 @@ export type TokenizerFunction = (token: string, language?: string) => string[]
2323
* @template Document The type of document being indexed.
2424
* @template SummaryField The document keys that can be returned in search results.
2525
*/
26-
export type IndexedDocument<Document, SummaryField extends keyof Document> = {
26+
export interface IndexedDocument<
27+
Document,
28+
SummaryField extends keyof Document,
29+
> {
2730
/**
2831
* Summary fields for the document. These are preserved as-is.
2932
*/
@@ -35,7 +38,7 @@ export type IndexedDocument<Document, SummaryField extends keyof Document> = {
3538
readonly signatures: Record<number, BloomFilter<string>>
3639
}
3740

38-
export type Index<Document, SummaryField extends keyof Document> = {
41+
export interface Index<Document, SummaryField extends keyof Document> {
3942
version: number
4043
documents: Record<string, IndexedDocument<Document, SummaryField>>
4144
}
@@ -47,11 +50,11 @@ export type Index<Document, SummaryField extends keyof Document> = {
4750
* @template SummaryField The document keys that can be returned in search results.
4851
* @template IndexField The document keys to be indexed for searching.
4952
*/
50-
export type Options<
53+
export interface Options<
5154
Document extends Record<string, unknown>,
5255
SummaryField extends keyof Document = keyof Document,
5356
IndexField extends keyof Document = keyof Document,
54-
> = {
57+
> {
5558
/**
5659
* The fields to index, provided as an array or as a record of field keys and
5760
* weight values.
@@ -117,13 +120,13 @@ export type Options<
117120
tokenizer?: TokenizerFunction
118121
}
119122

120-
type SearchTokens = {
123+
interface SearchTokens {
121124
required: string[]
122125
included: string[]
123126
excluded: string[]
124127
}
125128

126-
type Result<Document, SummaryField extends keyof Document> = {
129+
interface Result<Document, SummaryField extends keyof Document> {
127130
readonly summary: Pick<Document, SummaryField>
128131
readonly score: number
129132
}

‎packages/emitter/src/index.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
interface Events {
2-
[name: string]: (...args: unknown[]) => void
2+
// Allow event maps with specific parameter lists to satisfy the constraint.
3+
// biome-ignore lint/suspicious/noExplicitAny: any argument
4+
[name: string]: (...args: any[]) => void
35
}
46

57
interface Emitter<E extends Events> {

‎packages/emitter/test/index.spec.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** biome-ignore-all lint/style/useConsistentTypeDefinitions: tests require type */
2+
13
import { expect, test, vi } from 'vitest'
24
import { createEmitter } from '../src'
35

‎packages/ffetch/src/index.ts‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
import { pipe } from 'fp-ts/function'
2-
import {
3-
type TaskEither,
4-
chain,
5-
chainW,
6-
left,
7-
tryCatch,
8-
} from 'fp-ts/lib/TaskEither'
9-
import {
10-
type FetchError,
11-
NetworkError,
12-
ParserError,
13-
StatusError,
14-
} from './errors'
2+
import { chain, chainW, left, type TaskEither, tryCatch } from 'fp-ts/lib/TaskEither'
3+
import { type FetchError, NetworkError, ParserError, StatusError } from './errors'
154

165
type Fetch<E, T> = (
176
input: Request | string,

‎packages/immutable/test/immutable.spec.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import type { Immutable } from '../src/index'
44
describe('Immutable', () => {
55
it('marks nested object properties as readonly', () => {
66
type Actual = Immutable<{ foo: { bar: string } }>
7-
type Expected = { readonly foo: { readonly bar: string } }
7+
interface Expected {
8+
readonly foo: { readonly bar: string }
9+
}
810
expectTypeOf<Actual>().toEqualTypeOf<Expected>()
911
})
1012

‎packages/jest-either/src/toMatchRight.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
isAsymmetricMatcher,
77
matchObject,
88
matchString,
9-
rightPredicate
9+
rightPredicate,
1010
} from './shared/predicates'
1111
import { printReceivedRight } from './shared/print'
1212
import type { MatcherResult } from './shared/types'

‎packages/linked-list/src/core.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { None, type Option, Some } from '@pacote/option'
22

3-
type Empty = undefined
4-
type Cons<T> = readonly [value: T, next: Cons<T> | Empty]
3+
export type Empty = undefined
4+
export type Cons<T> = readonly [value: T, next: Cons<T> | Empty]
55
export type LinkedList<T> = Cons<T> | Empty
66

7-
type CallbackArgs<T> = [value: T, index: number, collection: LinkedList<T>]
8-
type MapCallback<T, R> = (...args: CallbackArgs<T>) => R
9-
type ReduceCallback<T, R> = (acc: R, ...args: CallbackArgs<T>) => R
7+
export type CallbackArgs<T> = [
8+
value: T,
9+
index: number,
10+
collection: LinkedList<T>,
11+
]
12+
export type MapCallback<T, R> = (...args: CallbackArgs<T>) => R
13+
export type ReduceCallback<T, R> = (acc: R, ...args: CallbackArgs<T>) => R
1014
export type PredicateFunction<T> = MapCallback<T, boolean>
1115

1216
export function car<T>(cons: Cons<T>): T {

0 commit comments

Comments
 (0)