How to use the @tslab/typescript-for-tslab.getDefaultTypeRoots function in @tslab/typescript-for-tslab

To help you get started, we’ve selected a few @tslab/typescript-for-tslab 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 yunabe / tslab / src / converter.ts View on Github external
function getTypeRoots(): string[] {
    // If @types/node does not exist in the default type roots,
    // use @types under tslab/node_modules (bug#10).
    // TODO: Integration-test for this behavior.
    const typeRoots =
      ts.getDefaultTypeRoots(cwd, {
        directoryExists: sys.directoryExists
      }) || [];
    for (const root of typeRoots) {
      if (ts.sys.fileExists(pathlib.join(root, "node", "package.json"))) {
        return typeRoots;
      }
    }
    typeRoots.push(pathlib.join(__dirname, "..", "node_modules", "@types"));
    return typeRoots;
  }