feat: add support for strict null checks (#5094)

This commit is contained in:
Kristiyan Kostadinov
2017-06-21 19:13:52 +02:00
committed by Jeremy Elbourn
parent 49dfe60387
commit 2bf7024527
122 changed files with 763 additions and 661 deletions
+1
View File
@@ -5,6 +5,7 @@
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"strictNullChecks": true,
"sourceMap": true,
"target": "es5",
"baseUrl": "",
+7 -2
View File
@@ -31,7 +31,7 @@ task(':publish:whoami', execTask('npm', ['whoami'], {
task(':publish:logout', execTask('npm', ['logout']));
function _execNpmPublish(label: string, packageName: string): Promise<{}> {
function _execNpmPublish(label: string, packageName: string): Promise<{}> | undefined {
const packageDir = join(buildConfig.outputDir, 'releases', packageName);
if (!statSync(packageDir).isDirectory()) {
@@ -50,7 +50,12 @@ function _execNpmPublish(label: string, packageName: string): Promise<{}> {
console.log(green(`Publishing ${packageName}...`));
const command = 'npm';
const args = ['publish', '--access', 'public', label ? `--tag` : undefined, label || undefined];
const args = ['publish', '--access', 'public'];
if (label) {
args.push('--tag', label);
}
return new Promise((resolve, reject) => {
console.log(grey(`Executing: ${command} ${args.join(' ')}`));
if (argv['dry']) {
+1 -3
View File
@@ -82,9 +82,7 @@ function getScreenshotFiles(database: firebase.database.Database) {
let binaryData = new Buffer(childSnapshot.val(), 'base64').toString('binary');
writeFileSync(`${LOCAL_GOLDENS}/${key}.screenshot.png`, binaryData, 'binary');
counter++;
if (counter == snapshot.numChildren()) {
return true;
}
return counter == snapshot.numChildren();
});
}).catch((error: any) => console.log(error));
}
+1
View File
@@ -6,6 +6,7 @@
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../../dist/tools/gulp",
"strictNullChecks": true,
"noEmitOnError": true,
"noImplicitAny": true,
"target": "es5",
+2 -2
View File
@@ -89,7 +89,7 @@ export function execNodeTask(packageName: string, executable: string | string[],
options: ExecTaskOptions = {}) {
if (!args) {
args = <string[]>executable;
executable = undefined;
executable = '';
}
return (done: (err: any) => void) => {
@@ -100,7 +100,7 @@ export function execNodeTask(packageName: string, executable: string | string[],
// Execute the node binary within a new child process using spawn.
// The binary needs to be `node` because on Windows the shell cannot determine the correct
// interpreter from the shebang.
execTask('node', [binPath].concat(args), options)(done);
execTask('node', [binPath].concat(args!), options)(done);
}
});
};
+1 -1
View File
@@ -5,7 +5,7 @@ import {existsSync} from 'fs';
const BUILD_CONFIG_FILENAME = 'build-config.js';
/** Method that searches for a build config file that will be used for packaging. */
export function findBuildConfig(): string {
export function findBuildConfig(): string | null {
let currentDir = process.cwd();
while (!existsSync(resolve(currentDir, BUILD_CONFIG_FILENAME))) {
+2 -2
View File
@@ -11,7 +11,7 @@ export function inlineMetadataResources(metadata: any, componentResources: Map<s
// Convert `templateUrl` to `template`
if (metadata.templateUrl) {
const fullResourcePath = componentResources.get(basename(metadata.templateUrl));
metadata.template = readFileSync(fullResourcePath, 'utf-8');
metadata.template = readFileSync(fullResourcePath!, 'utf-8');
delete metadata.templateUrl;
}
@@ -20,7 +20,7 @@ export function inlineMetadataResources(metadata: any, componentResources: Map<s
metadata.styles = [];
for (const styleUrl of metadata.styleUrls) {
const fullResourcePath = componentResources.get(basename(styleUrl));
metadata.styles.push(readFileSync(fullResourcePath, 'utf-8'));
metadata.styles.push(readFileSync(fullResourcePath!, 'utf-8'));
}
delete metadata.styleUrls;
}
+4 -2
View File
@@ -8,7 +8,9 @@ export function transpileFile(inputPath: string, outputPath: string, options: ts
const inputFile = fs.readFileSync(inputPath, 'utf-8');
const transpiled = ts.transpileModule(inputFile, { compilerOptions: options });
reportDiagnostics(transpiled.diagnostics);
if (transpiled.diagnostics) {
reportDiagnostics(transpiled.diagnostics);
}
fs.writeFileSync(outputPath, transpiled.outputText);
@@ -18,7 +20,7 @@ export function transpileFile(inputPath: string, outputPath: string, options: ts
}
/** Formats the TypeScript diagnostics into a error string. */
function formatDiagnostics(diagnostics: ts.Diagnostic[], baseDir: string): string {
function formatDiagnostics(diagnostics: ts.Diagnostic[], baseDir = ''): string {
return diagnostics.map(diagnostic => {
let res = `• ${chalk.red(`TS${diagnostic.code}`)} - `;
@@ -5,6 +5,7 @@
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"strictNullChecks": true,
"sourceMap": true,
"target": "es5",
"baseUrl": "",
+1
View File
@@ -4,6 +4,7 @@
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"strictNullChecks": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",