Skip to content

Commit

Permalink
feat(interfaces): ResolvePathsOptions
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 7, 2023
1 parent 2e839e5 commit 08ace44
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/interfaces/__tests__/options-resolve-paths.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @file Type Tests - ResolvePathsOptions
* @module tsconfig-utils/interfaces/tests/unit-d/ResolvePathsOptions
*/

import type mlly from '@flex-development/mlly'
import type LoadTsconfigOptions from '../options-load-tsconfig'
import type TestSubject from '../options-resolve-paths'

describe('unit-d:interfaces/ResolvePathsOptions', () => {
it('should extend LoadTsconfigOptions', () => {
expectTypeOf<TestSubject>().toMatchTypeOf<LoadTsconfigOptions>()
})

it('should extend Omit<mlly.ResolveAliasOptions, "aliases" | "cwd">', () => {
expectTypeOf<TestSubject>().toMatchTypeOf<
Omit<mlly.ResolveAliasOptions, 'aliases' | 'cwd'>
>()
})

it('should match [parent: mlly.ModuleId]', () => {
expectTypeOf<TestSubject>()
.toHaveProperty('parent')
.toEqualTypeOf<mlly.ModuleId>()
})

it('should match [tsconfig?: mlly.ModuleId]', () => {
expectTypeOf<TestSubject>()
.toHaveProperty('tsconfig')
.toEqualTypeOf<mlly.ModuleId | undefined>()
})
})
1 change: 1 addition & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*/

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

import type mlly from '@flex-development/mlly'
import type LoadTsconfigOptions from './options-load-tsconfig'

/**
* Options for resolving path aliases in `export`, `import`, and `require`
* statements.
*
* @see {@linkcode LoadTsconfigOptions}
* @see {@linkcode mlly.ResolveAliasOptions}
*
* @extends {LoadTsconfigOptions}
* @extends {Omit<mlly.ResolveAliasOptions,'aliases'|'cwd'>}
*/
interface ResolvePathsOptions
extends LoadTsconfigOptions,
Omit<mlly.ResolveAliasOptions, 'aliases' | 'cwd'> {
/**
* Return resolved module URLs as absolute specifiers ([`file:` URLs][1]).
*
* If `false`, return resolved module URLs as bare or relative specifiers.
*
* [1]: https://nodejs.org/api/esm.html#file-urls
*
* @see https://nodejs.org/api/esm.html#terminology
*
* @default false
*/
absolute?: boolean | undefined

/**
* Id of module to resolve from.
*/
parent: mlly.ModuleId

/**
* Module id of [tsconfig][1] file.
*
* [1]: https://www.typescriptlang.org/tsconfig
*
* @default mlly.toURL('tsconfig.json')
*/
tsconfig?: mlly.ModuleId | undefined
}

export type { ResolvePathsOptions as default }

0 comments on commit 08ace44

Please sign in to comment.