提交 fe45a7d2 编写于 作者: M Matt Bierner

Fix remaining strict null errors in build scripts

上级 5862b416
......@@ -36,7 +36,7 @@ function createCompile(src, build, emitError) {
var opts = _.clone(getTypeScriptCompilerOptions(src));
opts.inlineSources = !!build;
opts.noFilesystemLookup = true;
var ts = tsb.create(opts, true, null, function (err) { return reporter(err.toString()); });
var ts = tsb.create(opts, true, undefined, function (err) { return reporter(err.toString()); });
return function (token) {
var utf8Filter = util.filter(function (data) { return /(\/|\\)test(\/|\\).*utf8/.test(data.path); });
var tsFilter = util.filter(function (data) { return /\.ts$/.test(data.path); });
......@@ -58,7 +58,7 @@ function createCompile(src, build, emitError) {
sourceRoot: opts.sourceRoot
}))
.pipe(tsFilter.restore)
.pipe(reporter.end(emitError));
.pipe(reporter.end(!!emitError));
return es.duplex(input, output);
};
}
......
......@@ -41,7 +41,7 @@ function createCompile(src: string, build: boolean, emitError?: boolean): (token
opts.inlineSources = !!build;
opts.noFilesystemLookup = true;
const ts = tsb.create(opts, true, null, err => reporter(err.toString()));
const ts = tsb.create(opts, true, undefined, err => reporter(err.toString()));
return function (token?: util.ICancellationToken) {
......@@ -66,7 +66,7 @@ function createCompile(src: string, build: boolean, emitError?: boolean): (token
sourceRoot: opts.sourceRoot
}))
.pipe(tsFilter.restore)
.pipe(reporter.end(emitError));
.pipe(reporter.end(!!emitError));
return es.duplex(input, output);
};
......
......@@ -11,6 +11,7 @@ const root = path.dirname(path.dirname(__dirname));
function getElectronVersion() {
const yarnrc = fs.readFileSync(path.join(root, '.yarnrc'), 'utf8');
// @ts-ignore
const target = /^target "(.*)"$/m.exec(yarnrc)[1];
return target;
......@@ -19,6 +20,7 @@ function getElectronVersion() {
module.exports.getElectronVersion = getElectronVersion;
// returns 0 if the right version of electron is in .build/electron
// @ts-ignore
if (require.main === module) {
const version = getElectronVersion();
const versionFile = path.join(root, '.build', 'electron', 'version');
......
......@@ -211,8 +211,8 @@ function sequence(streamProviders) {
pop();
return result;
}
function packageExtensionsStream(opts) {
opts = opts || {};
function packageExtensionsStream(optsIn) {
var opts = optsIn || {};
var localExtensionDescriptions = glob.sync('extensions/*/package.json')
.map(function (manifestPath) {
var extensionPath = path.dirname(path.join(root, manifestPath));
......
......@@ -34,7 +34,7 @@ function fromLocal(extensionPath: string, sourceMappingURLBase?: string): Stream
}
}
function fromLocalWebpack(extensionPath: string, sourceMappingURLBase: string): Stream {
function fromLocalWebpack(extensionPath: string, sourceMappingURLBase: string | undefined): Stream {
let result = es.through();
let packagedDependencies: string[] = [];
......@@ -249,7 +249,7 @@ function sequence(streamProviders: { (): Stream }[]): Stream {
if (streamProviders.length === 0) {
result.emit('end');
} else {
const fn = streamProviders.shift();
const fn = streamProviders.shift()!;
fn()
.on('end', function () { setTimeout(pop, 0); })
.pipe(result, { end: false });
......@@ -260,8 +260,8 @@ function sequence(streamProviders: { (): Stream }[]): Stream {
return result;
}
export function packageExtensionsStream(opts?: IPackageExtensionsOptions): NodeJS.ReadWriteStream {
opts = opts || {};
export function packageExtensionsStream(optsIn?: IPackageExtensionsOptions): NodeJS.ReadWriteStream {
const opts = optsIn || {};
const localExtensionDescriptions = (<string[]>glob.sync('extensions/*/package.json'))
.map(manifestPath => {
......
......@@ -124,7 +124,7 @@ function optimizeTask(opts) {
var resourcesStream = es.through(); // this stream will contain the resources
var bundleInfoStream = es.through(); // this stream will contain bundleInfo.json
bundle.bundle(entryPoints, loaderConfig, function (err, result) {
if (err) {
if (err || !result) {
return bundlesStream.emit('error', JSON.stringify(err));
}
toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream);
......@@ -163,7 +163,7 @@ function optimizeTask(opts) {
var result = es.merge(loader(src, bundledFileHeader, bundleLoader), bundlesStream, otherSourcesStream, resourcesStream, bundleInfoStream);
return result
.pipe(sourcemaps.write('./', {
sourceRoot: null,
sourceRoot: undefined,
addComment: true,
includeContent: true
}))
......@@ -219,13 +219,13 @@ function uglifyWithCopyrights() {
return es.duplex(input, output);
}
function minifyTask(src, sourceMapBaseUrl) {
var sourceMappingURL = sourceMapBaseUrl && (function (f) { return sourceMapBaseUrl + "/" + f.relative + ".map"; });
var sourceMappingURL = sourceMapBaseUrl ? (function (f) { return sourceMapBaseUrl + "/" + f.relative + ".map"; }) : undefined;
return function (cb) {
var jsFilter = filter('**/*.js', { restore: true });
var cssFilter = filter('**/*.css', { restore: true });
pump(gulp.src([src + '/**', '!' + src + '/**/*.map']), jsFilter, sourcemaps.init({ loadMaps: true }), uglifyWithCopyrights(), jsFilter.restore, cssFilter, minifyCSS({ reduceIdents: false }), cssFilter.restore, sourcemaps.write('./', {
sourceMappingURL: sourceMappingURL,
sourceRoot: null,
sourceRoot: undefined,
includeContent: true,
addComment: true
}), gulp.dest(src + '-min'), function (err) {
......
......@@ -188,7 +188,7 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
const bundleInfoStream = es.through(); // this stream will contain bundleInfo.json
bundle.bundle(entryPoints, loaderConfig, function (err, result) {
if (err) { return bundlesStream.emit('error', JSON.stringify(err)); }
if (err || !result) { return bundlesStream.emit('error', JSON.stringify(err)); }
toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream);
......@@ -237,7 +237,7 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
return result
.pipe(sourcemaps.write('./', {
sourceRoot: null,
sourceRoot: undefined,
addComment: true,
includeContent: true
}))
......@@ -302,7 +302,7 @@ function uglifyWithCopyrights(): NodeJS.ReadWriteStream {
}
export function minifyTask(src: string, sourceMapBaseUrl?: string): (cb: any) => void {
const sourceMappingURL = sourceMapBaseUrl && (f => `${sourceMapBaseUrl}/${f.relative}.map`);
const sourceMappingURL = sourceMapBaseUrl ? ((f: any) => `${sourceMapBaseUrl}/${f.relative}.map`) : undefined;
return cb => {
const jsFilter = filter('**/*.js', { restore: true });
......@@ -319,7 +319,7 @@ export function minifyTask(src: string, sourceMapBaseUrl?: string): (cb: any) =>
cssFilter.restore,
sourcemaps.write('./', {
sourceMappingURL,
sourceRoot: null,
sourceRoot: undefined,
includeContent: true,
addComment: true
}),
......
......@@ -45,6 +45,7 @@ function log() {
var messages = errors
.map(function (err) { return regex.exec(err); })
.filter(function (match) { return !!match; })
.map(function (x) { return x; })
.map(function (_a) {
var path = _a[1], line = _a[2], column = _a[3], message = _a[4];
return ({ path: path, line: parseInt(line), column: parseInt(column), message: message });
......
......@@ -55,6 +55,7 @@ function log(): void {
const messages = errors
.map(err => regex.exec(err))
.filter(match => !!match)
.map(x => x as string[])
.map(([, path, line, column, message]) => ({ path, line: parseInt(line), column: parseInt(column), message }));
try {
......
......@@ -448,7 +448,7 @@ function markNodes(languageService: ts.LanguageService, options: ITreeShakingOpt
}
if (options.shakeLevel === ShakeLevel.ClassMembers && (ts.isClassDeclaration(declaration) || ts.isInterfaceDeclaration(declaration))) {
enqueue_black(declaration.name);
enqueue_black(declaration.name!);
for (let j = 0; j < declaration.members.length; j++) {
const member = declaration.members[j];
......@@ -635,7 +635,7 @@ function generateResult(languageService: ts.LanguageService, shakeLevel: ShakeLe
/**
* Returns the node's symbol and the `import` node (if the symbol resolved from a different module)
*/
function getRealNodeSymbol(checker: ts.TypeChecker, node: ts.Node): [ts.Symbol, ts.Declaration] {
function getRealNodeSymbol(checker: ts.TypeChecker, node: ts.Node): [ts.Symbol | null, ts.Declaration | null] {
/**
* Returns the containing object literal property declaration given a possible name node, e.g. "a" in x = { "a": 1 }
*/
......
......@@ -18,7 +18,7 @@ declare module Lazy {
function on<T>(eventType: string): Sequence<T>;
function readFile(path: string): StringLikeSequence;
function makeHttpRequest(path: string): StringLikeSequence;
interface StrictLazy {
(value: string): StringLikeSequence;
<T>(value: T[]): ArrayLikeSequence<T>;
......@@ -87,7 +87,7 @@ declare module Lazy {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
interface Iterator<T> {
new (sequence: Sequence<T>): Iterator<T>;
new(sequence: Sequence<T>): Iterator<T>;
current(): T;
moveNext(): boolean;
}
......@@ -159,6 +159,9 @@ declare module Lazy {
map<U>(mapFn: MapCallback<T, U[]>): ArraySequence<U>;
map<U>(mapFn: MapCallback<T, U>): Sequence<U>;
// TODO: vscode addition to workaround strict null errors
flatten(): Sequence<any>;
max(valueFn?: NumberCallback<T>): T;
min(valueFn?: NumberCallback<T>): T;
none(valueFn?: TestCallback<T>): boolean;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册