Skip to content

Commit

Permalink
Convert some object types to interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed Apr 26, 2018
1 parent 0029f4d commit dc386e5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
20 changes: 13 additions & 7 deletions packages/typescript/fs-tree-utils/lib/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ import {Tree, TreeObject, FileContent} from './types'

export type NestedReadResult = Promise<Tree>

export type FlatReadResultFileContent = {[filename: string]: FileContent}
export interface FlatReadResultFileContent {
readonly [filename: string]: FileContent
}

interface WritableFlatReadResultFileContent {
[filename: string]: FileContent
}

export type FlatReadResultValue = {
fileContents: FlatReadResultFileContent,
directories: ReadonlyArray<string>,
files: ReadonlyArray<string>,
all: ReadonlyArray<string>
export interface FlatReadResultValue {
readonly fileContents: FlatReadResultFileContent
readonly directories: ReadonlyArray<string>
readonly files: ReadonlyArray<string>
readonly all: ReadonlyArray<string>
}

export type FlatReadResult = Promise<FlatReadResultValue>
Expand Down Expand Up @@ -56,7 +62,7 @@ export async function readFlat (name: string, deep?: DeepFunc): FlatReadResult {
)
)

let fileContents: FlatReadResultFileContent = {}
let fileContents: WritableFlatReadResultFileContent = {}
for (const [name, promise] of map) {
fileContents[name] = await promise
}
Expand Down
20 changes: 11 additions & 9 deletions packages/typescript/fs-tree-utils/lib/traverse.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import * as path from 'path'
import * as fsx from 'fs-extra'

export type TraversalDeepFuncParam = {
container: string,
item: string,
path: string,
stats: fsx.Stats,
level: number
export interface TraversalDeepFuncParam {
readonly container: string
readonly item: string
readonly path: string
readonly stats: fsx.Stats
readonly level: number
}
export type DeepFunc = (x: TraversalDeepFuncParam) => boolean
export type DepsDict = {
[packageName: string]: string

export interface DepsDict {
readonly [packageName: string]: string
}

export type DeepFunc = (x: TraversalDeepFuncParam) => boolean
export type TraversalResultItem = TraversalDeepFuncParam
export type TraversalResult = ReadonlyArray<TraversalResultItem>
export type AsyncTraversalResult = Promise<TraversalResult>
Expand Down
7 changes: 4 additions & 3 deletions packages/typescript/nested-workspace-helper/lib/mismatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export type Checker = (
type: DependencyType
) => PackageVersionRequirement

export type CheckerCollection = {
[name: string]: Checker
export interface CheckerCollection {
readonly [name: string]: Checker
}

export type CheckDependencyResult = Promise<MismatchedDependencyMap>
Expand Down Expand Up @@ -82,7 +82,8 @@ export namespace listMismatchedDependencies {
ANY_OR_EQUAL_MIN, ANY_OR_TILDA_MIN, ANY_OR_CARET_MIN
}

export type AllCheckerCollection = CheckerCollection & typeof prvAllCheckers
export type PrvCheckerCollection = Readonly<typeof prvAllCheckers>
export interface AllCheckerCollection extends CheckerCollection, PrvCheckerCollection {}

/** Collection of all checkers */
export const allCheckers: AllCheckerCollection = prvAllCheckers
Expand Down
5 changes: 4 additions & 1 deletion packages/typescript/path-env/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ export type PathDelimiter = ':' | ';'
export type PathElement = string
export type PathArray = ReadonlyArray<PathElement>
export type PathString = PathElement
export type Env = {[name: string]: string | undefined}

export interface Env {
readonly [name: string]: string | undefined
}

export type PathFactory = {
get: {
Expand Down

0 comments on commit dc386e5

Please sign in to comment.