How to use the tsconfig.loadSync function in tsconfig

To help you get started, we’ve selected a few tsconfig examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dividab / tsconfig-paths / example / api / main.ts View on Github external
import { createMatchPath } from "../../src";
import * as Tsconfig from "tsconfig";
import * as path from "path";

// Load tsconfig
const loadResult = Tsconfig.loadSync(process.cwd(), undefined);

// Create function that will match paths
const matchPath = createMatchPath(
  path.join(
    path.dirname(loadResult.path),
    loadResult.config.compilerOptions.baseUrl
  ),
  loadResult.config.compilerOptions.paths
);

// Match a path and log result
const result = matchPath("foo/mylib");
console.log(result);
github dividab / tsconfig-paths / example / perf / main.ts View on Github external
import { createMatchPath } from "../../src";
import * as Tsconfig from "tsconfig";
import * as path from "path";

// Load tsconfig
const loadResult = Tsconfig.loadSync(process.cwd());

// Create function that will match paths
const matchPath = createMatchPath(
  path.join(
    path.dirname(loadResult.path),
    loadResult.config.compilerOptions.baseUrl
  ),
  loadResult.config.compilerOptions.paths
);

const iterations = 100000;

console.time(`Matching path ${iterations} times`);
for (let i = 0; i < iterations; i++) {
  const result = matchPath("foo/mylib", undefined, undefined, [
    ".ts",
github fossasia / susper.com / node_modules / ts-node / dist / index.js View on Github external
function readConfig(compilerOptions, project, cwd, ts) {
    var result = tsconfig_1.loadSync(cwd, typeof project === 'string' ? project : undefined);
    result.config.compilerOptions = Object.assign({}, result.config.compilerOptions, compilerOptions, {
        sourceMap: true,
        inlineSourceMap: false,
        inlineSources: true,
        declaration: false,
        noEmit: false,
        outDir: '$$ts-node$$'
    });
    var configPath = result.path && normalizeSlashes(result.path);
    var basePath = configPath ? path_1.dirname(configPath) : normalizeSlashes(cwd);
    if (typeof ts.parseConfigFile === 'function') {
        return fixConfig(ts.parseConfigFile(result.config, ts.sys, basePath), ts);
    }
    if (typeof ts.parseJsonConfigFileContent === 'function') {
        return fixConfig(ts.parseJsonConfigFileContent(result.config, ts.sys, basePath, undefined, configPath), ts);
    }
github bfwg / angular-spring-starter / frontend / node_modules / ts-node / dist / index.js View on Github external
function readConfig(compilerOptions, project, cwd, ts) {
    var result = tsconfig_1.loadSync(cwd, typeof project === 'string' ? project : undefined);
    result.config.compilerOptions = Object.assign({}, result.config.compilerOptions, compilerOptions, {
        sourceMap: true,
        inlineSourceMap: false,
        inlineSources: true,
        declaration: false,
        noEmit: false,
        outDir: '$$ts-node$$'
    });
    var configPath = result.path && normalizeSlashes(result.path);
    var basePath = configPath ? path_1.dirname(configPath) : normalizeSlashes(cwd);
    if (typeof ts.parseConfigFile === 'function') {
        return fixConfig(ts.parseConfigFile(result.config, ts.sys, basePath), ts);
    }
    if (typeof ts.parseJsonConfigFileContent === 'function') {
        return fixConfig(ts.parseJsonConfigFileContent(result.config, ts.sys, basePath, undefined, configPath), ts);
    }
github vuejs / vue-jest / lib / load-typescript-config.js View on Github external
const find = () => {
    const { path, config } = tsconfig.loadSync(process.cwd())

    if (!path) {
      logger.info(
        'no tsconfig.json found, defaulting to default typescript options'
      )
    }

    return path ? config : defaultTypescriptConfig
  }
  const cachedConfig = cache.get('typescript-config')
github sider / TyScan / src / typescript / misc.ts View on Github external
export function configureCompilerOptions(path: string) {
  const json = tsconfig.loadSync(path).config.compilerOptions;
  compilerOptions = ts.convertCompilerOptionsFromJson(json, process.cwd()).options;
}
github valor-software / ngm-cli / src / utils / submodules-resolution.ts View on Github external
      .map(dir => ({dir, tsconfig: tsconfig.loadSync(dir)}))
      .map(opt => resolveOptions(project, opt)))
github sider / TyScan / src / typescript / program.ts View on Github external
private getCompilerOptions() {
    if (this.compilerOptions === undefined) {
      const json = tsconfig.loadSync(this.tsconfigPath).config.compilerOptions;
      this.compilerOptions = ts.convertCompilerOptionsFromJson(json, process.cwd()).options;
    }
    return this.compilerOptions!;
  }
}
github sider / TyScan / dist / compiler.js View on Github external
const program = ts.createProgram([path], OPTIONS);
    return new Result(program, program.getSourceFile(path));
}
exports.compileFile = compileFile;
class Result {
    constructor(program, srcFile) {
        this.program = program;
        this.srcFile = srcFile;
    }
    isSuccessful() {
        return this.program.getSyntacticDiagnostics(this.srcFile).length === 0;
    }
}
exports.Result = Result;
const TEST_FILE_NAME = '__tyscan_test__.ts';
const OPTIONS = ts.convertCompilerOptionsFromJson(tsconfig.loadSync('.').config.compilerOptions, process.cwd()).options;
//# sourceMappingURL=compiler.js.map

tsconfig

Resole and parse `tsconfig.json`, replicating to TypeScript's behaviour

MIT
Latest version published 7 years ago

Package Health Score

71 / 100
Full package analysis