Table of contents
Overview
Retrieve the configuration for a typescript file.
Installation
$ npm install @structured-types/typescript-config --save-dev
Getting started
import { getTypescriptConfig } from '@structured-types/typescript-config';
import * as ts from 'typescript';
const config = getTypescriptConfig('./tsfile.ts', {
compilerOptions: {
jsx: ts.JsxEmit.ReactJSX,
}
});
API
TSConfigFS
type
defined in @structured-types/typescript-config/misc/typescript-config/src/index.ts
properties
Name | Type |
---|---|
fileExists* |
function (filePath *: string ) => Promise <boolean > |
readFile* |
function (filePath *: string ) => Promise <(string , null )> |
TSConfigOptions
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 |
getTypescriptConfig
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 |