Skip to content

Commit

Permalink
chore: set up typeRoots for package tsconfig (#2286)
Browse files Browse the repository at this point in the history
  • Loading branch information
malept authored May 23, 2021
1 parent 9f2bc41 commit d378b20
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tools/link-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import * as path from 'path';
const BASE_DIR = path.resolve(__dirname, '..');
const PACKAGES_DIR = path.resolve(BASE_DIR, 'packages');

async function copyTSConfig(packageDir: string): Promise<void> {
const relativeBaseDir = path.relative(packageDir, BASE_DIR);
const tsconfig = await fs.readJson(path.resolve(BASE_DIR, 'tsconfig.json'));
tsconfig.compilerOptions.typeRoots = [
path.join(relativeBaseDir, 'node_modules', '@types'),
path.join(relativeBaseDir, 'typings'),
];
await fs.writeJson(path.resolve(packageDir, 'tsconfig.json'), tsconfig, { spaces: 2 });
}

(async () => {
const dirsToLink = [];

Expand All @@ -14,7 +24,7 @@ const PACKAGES_DIR = path.resolve(BASE_DIR, 'packages');
}

for (const dir of dirsToLink) {
await fs.copy(path.resolve(BASE_DIR, 'tsconfig.json'), path.resolve(dir, 'tsconfig.json'));
await copyTSConfig(dir);
await fs.copy(path.resolve(BASE_DIR, '.npmignore'), path.resolve(dir, '.npmignore'));
const pj = await fs.readJson(path.resolve(dir, 'package.json'));
if (pj.main) {
Expand Down

0 comments on commit d378b20

Please sign in to comment.