@mnrendra/obtain-tsconfig-paths
v1.2.0
Published
Obtain a valid baseUrl and paths from the compilerOptions in the tsconfig.json file
Downloads
140
Maintainers
Readme
@mnrendra/obtain-tsconfig-paths
Obtain a valid baseUrl
and paths
from the compilerOptions
in the tsconfig.json
file so you don't need to import and validate the tsconfig.json
file manually.
Install
npm i @mnrendra/obtain-tsconfig-paths
Usage
Using CommonJS
:
const { obtainTSConfigPaths, obtainTSConfigPathsSync } = require('@mnrendra/obtain-tsconfig-paths')
// Asynchronously
obtainTSConfigPaths()
.then(({ baseUrl, paths }) => {
console.log('asynchronously:', baseUrl, paths)
})
// Synchronously
const { baseUrl, paths } = obtainTSConfigPathsSync()
console.log('synchronously:', baseUrl, paths)
Using ES Module
:
import { obtainTSConfigPaths, obtainTSConfigPathsSync } from '@mnrendra/obtain-tsconfig-paths'
// Asynchronously
obtainTSConfigPaths()
.then(({ baseUrl, paths }) => {
console.log('asynchronously:', baseUrl, paths)
})
// Synchronously
const { baseUrl, paths } = obtainTSConfigPathsSync()
console.log('synchronously:', baseUrl, paths)
Options
• baseUrl
type: BaseURL|null|undefined
default: undefined
tsconfig.json
's compilerOptons.baseUrl
.
• paths
type: Paths|null|undefined
default: undefined
tsconfig.json
's compilerOptons.paths
.
Types
import type {
// @mnrendra/types-tsconfig
TSConfig,
CompilerOptions,
BaseURL,
Paths,
// @mnrendra/obtain-tsconfig-paths
TSConfigPaths
} from '@mnrendra/obtain-tsconfig-paths'