Use "lib" in tsconfigs instead of "target". (#13968)

* Use "lib" in tsconfigs instead of "target".

Only add "dom" to libraries that need it. This is determined by a script, so many libraries that have "dom" maybe should not.

* Update new-package and readme

* Add back "target" where necessary
This commit is contained in:
Andy
2017-01-18 07:51:51 -08:00
committed by GitHub
parent c5506327ca
commit ae4fe7b6de
2896 changed files with 10548 additions and 3327 deletions

View File

@@ -1,4 +1,4 @@
// Usage: ts-node generate-tsconfigs
// Usage: ts-node generate-tsconfigs.ts
/// <reference types="node" />
@@ -11,17 +11,31 @@ function repeat(s: string, count: number) {
const home = path.join(__dirname, '..');
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))) {
for (const dirName of fs.readdirSync(home)) {
if (dirName.startsWith(".") || dirName === "node_modules" || dirName === "scripts") {
continue;
}
const dir = path.join(home, dirName);
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");
fixTsconfig(dir);
// Also do it for old versions
for (const subdir of fs.readdirSync(dir)) {
if (/^v\d+$/.test(subdir)) {
fixTsconfig(path.join(dir, subdir));
}
}
}
}
function fixTsconfig(dir: string): void {
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");
}
function fix(config: any): any {
const out: any = {};
for (const key in config) {
@@ -38,9 +52,7 @@ function fixCompilerOptions(config: any): any {
const out: any = {};
for (const key in config) {
out[key] = config[key];
if (key === "noImplicitAny") {
out.noImplicitThis = true;
}
// Do something interesting here
}
return out;
}

View File

@@ -79,7 +79,7 @@ function getTSConfig() {
return {
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,