How to use the @tslab/typescript-for-tslab.sys 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
export function createConverter(options?: ConverterOptions): Converter {
  const cwd = ts.sys.getCurrentDirectory();
  const srcFilename = pathlib.join(
    cwd,
    options?.isJS ? "__tslab__.js" : "__tslab__.ts"
  );
  const declFilename = pathlib.join(cwd, "__prev__.d.ts");

  const outDir = "outDir";
  const dstFilename = pathlib.join(outDir, "__tslab__.js");
  const dstDeclFilename = pathlib.join(outDir, "__tslab__.d.ts");

  // c.f.
  // https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping
  // https://github.com/microsoft/TypeScript/issues/22306#issuecomment-412266626
  const traspileTarget =
    semver.major(process.version) >= 12
      ? ts.ScriptTarget.ES2019
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;
  }
github yunabe / tslab / src / converter.ts View on Github external
sys.fileExists = function(path: string): boolean {
    return ts.sys.fileExists(forwardTslabPath(cwd, path));
  };
  sys.readDirectory = function(