Add "noImplicitThis" to all tsconfig.json (#13446)

* Add "noImplicitThis" to all tsconfig.json

* Use `"noImplicitThis": false` on packages with broken tests.
This commit is contained in:
Andy
2016-12-19 14:11:46 -08:00
committed by GitHub
parent 5ad6479868
commit a4bd9fa3c1
2688 changed files with 3646 additions and 975 deletions

View File

@@ -1,3 +1,5 @@
// Usage: ts-node generate-tsconfigs
/// <reference types="node" />
import * as fs from 'fs';
@@ -7,27 +9,38 @@ function repeat(s: string, count: number) {
return Array(count + 1).join(s);
}
function checkDir(home: string, count: number) {
fs.readdir(home, (err, dirs) => {
if (err) throw err;
const home = path.join(__dirname, '..');
for (const dir of dirs.map(d => path.join(home, d))) {
fs.lstat(dir, (err, stats) => {
if (err) throw err;
if (stats.isDirectory()) {
checkDir(dir, count + 1);
const target = path.join(dir, 'tsconfig.json');
fs.exists(target, exists => {
if (exists) {
const old = JSON.parse(fs.readFileSync(target, 'utf-8'));
old['compilerOptions']['typesRoot'] = repeat('../', count);
fs.writeFileSync(target, JSON.stringify(old, undefined, 4));
}
});
}
});
}
});
const dirs = fs.readdirSync(home).filter(d => !(d.startsWith(".") || d === "node_modules" || d === "scripts"));
for (const dir of dirs.map(d => path.join(home, d))) {
const stats = fs.lstatSync(dir);
if (stats.isDirectory()) {
const target = path.join(dir, 'tsconfig.json');
let json = JSON.parse(fs.readFileSync(target, 'utf-8'));
json = fix(json);
fs.writeFileSync(target, JSON.stringify(json, undefined, 4), "utf-8");
}
}
checkDir(path.join(__dirname, '..'), 1);
function fix(config: any): any {
const out: any = {};
for (const key in config) {
let value = config[key];
if (key === "compilerOptions") {
value = fixCompilerOptions(value);
}
out[key] = value;
}
return out;
}
function fixCompilerOptions(config: any): any {
const out: any = {};
for (const key in config) {
out[key] = config[key];
if (key === "noImplicitAny") {
out.noImplicitThis = true;
}
}
return out;
}