Skip to content

Commit

Permalink
feat(interfaces): LoadTsconfigOptions
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Feb 4, 2023
1 parent 8eea639 commit c9cdf33
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* @module tsconfig-utils
*/

export {}
export * from './interfaces'
26 changes: 26 additions & 0 deletions src/interfaces/__tests__/options-load-tsconfig.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @file Type Tests - LoadTsconfigOptions
* @module tsconfig-utils/interfaces/tests/unit-d/LoadTsconfigOptions
*/

import type { Fn, KeysRequired } from '@flex-development/tutils'
import type { URL } from 'node:url'
import type TestSubject from '../options-load-tsconfig'

describe('unit-d:interfaces/LoadTsconfigOptions', () => {
it('should allow empty object', () => {
expectTypeOf<KeysRequired<TestSubject>>().toBeNever()
})

it('should match [file?: Fn<[URL | string], boolean>]', () => {
expectTypeOf<TestSubject>()
.toHaveProperty('file')
.toEqualTypeOf<Fn<[URL | string], boolean> | undefined>()
})

it('should match [read?: Fn<[URL | string], string>]', () => {
expectTypeOf<TestSubject>()
.toHaveProperty('read')
.toEqualTypeOf<Fn<[URL | string], string> | undefined>()
})
})
6 changes: 6 additions & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @file Entry Point - Interfaces
* @module tsconfig-utils/interfaces
*/

export type { default as LoadTsconfigOptions } from './options-load-tsconfig'
34 changes: 34 additions & 0 deletions src/interfaces/options-load-tsconfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @file Interfaces - LoadTsconfigOptions
* @module tsconfig-utils/interfaces/LoadTsconfigOptions
*/

import type { Fn } from '@flex-development/tutils'
import type { URL } from 'node:url'

/**
* Options for loading tsconfig files.
*/
interface LoadTsconfigOptions {
/**
* Checks if a file exists at the given module `id`.
*
* @default internal.isFile
*
* @param {URL | string} id - Module id to evaluate
* @return {boolean} `true` if file exists at `id`, `false` otherwise
*/
file?: Fn<[URL | string], boolean> | undefined

/**
* Reads the file at the given module `id`.
*
* @default internal.readFile
*
* @param {URL | string} id - Module id to evaluate
* @return {string} File content at `id`
*/
read?: Fn<[URL | string], string> | undefined
}

export type { LoadTsconfigOptions as default }

0 comments on commit c9cdf33

Please sign in to comment.