Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make types of File and Folder more explicit #1118

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/files/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { FileType } from './fileType'
import { type INode, Node } from './node'
import { Node } from './node'

export class File extends Node {

get type(): FileType {
get type(): FileType.File {
return FileType.File
}

Expand All @@ -23,6 +23,4 @@ export class File extends Node {
/**
* Interface of the File class
*/
export interface IFile extends INode {
readonly type: FileType.File
}
export type IFile = Pick<File, keyof File>
18 changes: 7 additions & 11 deletions lib/files/folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { NodeData } from './nodeData'
import { FileType } from './fileType'
import { type INode, Node } from './node'
import { type NodeData } from './nodeData'
import { Node } from './node'

export class Folder extends Node {

Expand All @@ -16,22 +16,22 @@ export class Folder extends Node {
})
}

get type(): FileType {
get type(): FileType.Folder {
return FileType.Folder
}

get extension(): string|null {
get extension(): null {
return null
}

get mime(): string {
get mime(): 'httpd/unix-directory' {
return 'httpd/unix-directory'
}

/**
* Returns a clone of the folder
*/
clone(): Node {
clone(): Folder {
return new Folder(this.data)
}

Expand All @@ -40,8 +40,4 @@ export class Folder extends Node {
/**
* Interface of the folder class
*/
export interface IFolder extends INode {
readonly type: FileType.Folder
readonly extension: null
readonly mime: 'httpd/unix-directory'
}
export type IFolder = Pick<Folder, keyof Folder>
Loading