Retrieve the configuration for a typescript file
npm install @structured-types/typescript-config- Overview
- Installation
- Getting started
- API
- TSConfigFS
- TSConfigOptions
- getTypescriptConfig
Retrieve the configuration for a typescript file.
``bash`
$ npm install @structured-types/typescript-config --save-dev
import { getTypescriptConfig } from '@structured-types/typescript-config';
import * as ts from 'typescript';
const config = getTypescriptConfig('./tsfile.ts', {
compilerOptions: {
jsx: ts.JsxEmit.ReactJSX,
}
});
type
_defined in @structured-types/typescript-config/misc/typescript-config/src/index.ts_
properties
| Name | Type |
| ------------- | ------------------------------------------------------------------------------------- |
| fileExists | function (filePath\: stringPromise
) => <boolean> |readFile
| | function (filePath\: stringPromise
) => <(string, null)> |
type
Config parsing options
_defined in @structured-types/typescript-config/misc/typescript-config/src/index.ts_
properties
| Name | Type | Description |
| ------ | --------------- | ----------------------------------------------- |
| json | boolean | keep json format of ts config |host
| | ts.CompilerHost | optional compiler host to use instead of ts.sys |
function
Reads any typescript configuration files for a given file, including the extends references
_defined in @structured-types/typescript-config/misc/typescript-config/src/index.ts_
parameters
| Name | Type | Description |
| --------------- | ------------------------------------- | ---------------------------------------------------------------------------------------- |
| filePath* | string | the full file path to the file |defaultConfig
| | ts.CompilerOptions | optional default configuration |options
| | TSConfigOptions | Config parsing options |returns
| | ts.CompilerOptions \| undefined` | the typescript configuration for the file, or undefined if this is not a typescript file |