mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
feat: add support for strict null checks (#5094)
This commit is contained in:
committed by
Jeremy Elbourn
parent
49dfe60387
commit
2bf7024527
@@ -5,6 +5,7 @@
|
||||
"moduleResolution": "node",
|
||||
"noEmitOnError": true,
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"sourceMap": true,
|
||||
"target": "es5",
|
||||
"baseUrl": "",
|
||||
|
||||
@@ -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']) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../../dist/tools/gulp",
|
||||
"strictNullChecks": true,
|
||||
"noEmitOnError": true,
|
||||
"noImplicitAny": true,
|
||||
"target": "es5",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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))) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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": "",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"declaration": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"strictNullChecks": true,
|
||||
"lib": ["es6", "dom"],
|
||||
"mapRoot": "./",
|
||||
"module": "es6",
|
||||
|
||||
Reference in New Issue
Block a user