Skip to content

Commit 467618d

Browse files
committed
refactor(column): use interfaces rather than instances
Similar to what we did with View, Node, File, and Folder. As we cannot validate class instances anyways we can just use interfaces, allowing more flexible code. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 6a3a582 commit 467618d

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

lib/navigation/column.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { IView } from './view.ts'
88

99
import { checkOptionalProperty } from '../utils/objectValidation.ts'
1010

11-
interface ColumnData {
11+
export interface IColumn {
1212
/** Unique column ID */
1313
id: string
1414
/** Translated column title */
@@ -24,11 +24,11 @@ interface ColumnData {
2424
summary?: (node: INode[], view: IView) => string
2525
}
2626

27-
export class Column implements ColumnData {
27+
export class Column implements IColumn {
2828

29-
private _column: ColumnData
29+
private _column: IColumn
3030

31-
constructor(column: ColumnData) {
31+
constructor(column: IColumn) {
3232
validateColumn(column)
3333
this._column = column
3434
}
@@ -61,7 +61,7 @@ export class Column implements ColumnData {
6161
* @param column - the column to check
6262
* @throws {Error} if the column is not valid
6363
*/
64-
export function validateColumn(column: ColumnData): void {
64+
export function validateColumn(column: IColumn): void {
6565
if (typeof column !== 'object' || column === null) {
6666
throw new Error('View column must be an object')
6767
}

lib/navigation/view.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
*/
55

66
import type { IFolder, INode } from '../node/index.ts'
7+
import type { IColumn } from './column.ts'
78

89
import isSvg from 'is-svg'
9-
import { Column, validateColumn } from './column.ts'
10+
import { validateColumn } from './column.ts'
1011
import { checkOptionalProperty } from '../utils/objectValidation.ts'
1112

1213
export type ContentsWithRoot = {
@@ -82,7 +83,7 @@ export interface IView {
8283
* This view column(s). Name and actions are
8384
* by default always included
8485
*/
85-
columns?: Column[]
86+
columns?: IColumn[]
8687

8788
/** The parent unique ID */
8889
parent?: string

0 commit comments

Comments
 (0)