Skip to content

Commit

Permalink
chore(typings): enable 'noImplicitReturns' to all build (#1821)
Browse files Browse the repository at this point in the history
- enhancement to #1740, enables option to npm script as well
  • Loading branch information
kwonoj authored and benlesh committed Jul 11, 2016
1 parent ffcb9fc commit c76a14d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@
"copy_src_cjs": "mkdirp ./dist/cjs/src && shx cp -r ./src/* ./dist/cjs/src",
"copy_src_es6": "mkdirp ./dist/es6/src && shx cp -r ./src/* ./dist/es6/src",
"commit": "git-cz",
"compile_dist_amd": "tsc typings/globals/es6-shim/index.d.ts ./dist/amd/src/Rx.ts ./dist/amd/src/add/observable/of.ts -m amd --sourceMap --outDir ./dist/amd --target ES5 --diagnostics --pretty --noImplicitAny --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_cjs": "tsc typings/globals/es6-shim/index.d.ts ./dist/cjs/src/Rx.ts ./dist/cjs/src/add/observable/of.ts -m commonjs --sourceMap --outDir ./dist/cjs --target ES5 -d --diagnostics --pretty --noImplicitAny --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_es6": "tsc ./dist/es6/src/Rx.ts ./dist/es6/src/add/observable/of.ts -m es2015 --sourceMap --outDir ./dist/es6 --target ES6 -d --diagnostics --pretty --noImplicitAny --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_es6_for_docs": "tsc ./dist/es6/src/Rx.ts ./dist/es6/src/add/observable/of.ts ./dist/es6/src/MiscJSDoc.ts -m es2015 --sourceMap --outDir ./dist/es6 --target ES6 -d --diagnostics --pretty --noImplicitAny --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_amd": "tsc typings/globals/es6-shim/index.d.ts ./dist/amd/src/Rx.ts ./dist/amd/src/add/observable/of.ts -m amd --sourceMap --outDir ./dist/amd --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_cjs": "tsc typings/globals/es6-shim/index.d.ts ./dist/cjs/src/Rx.ts ./dist/cjs/src/add/observable/of.ts -m commonjs --sourceMap --outDir ./dist/cjs --target ES5 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_es6": "tsc ./dist/es6/src/Rx.ts ./dist/es6/src/add/observable/of.ts -m es2015 --sourceMap --outDir ./dist/es6 --target ES6 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_es6_for_docs": "tsc ./dist/es6/src/Rx.ts ./dist/es6/src/add/observable/of.ts ./dist/es6/src/MiscJSDoc.ts -m es2015 --sourceMap --outDir ./dist/es6 --target ES6 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --suppressImplicitAnyIndexErrors --moduleResolution node",
"cover": "shx rm -rf dist/cjs && tsc typings/globals/es6-shim/index.d.ts src/Rx.ts src/add/observable/of.ts -m commonjs --outDir dist/cjs --sourceMap --target ES5 -d && nyc --reporter=lcov --reporter=html --exclude=spec/support/**/* --exclude=spec-js/**/* mocha --opts spec/support/default.opts spec-js",
"decision_tree_widget": "cd doc/decision-tree-widget && npm run build && cd ../..",
"doctoc": "doctoc CONTRIBUTING.md",
Expand Down
5 changes: 5 additions & 0 deletions spec/Notification-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ describe('Notification', () => {
expect(Notification).to.be.a('function');
});

it('should not allow convert to observable if given kind is unknown', () => {
const n = new Notification('x');
expect(() => n.toObservable()).to.throw();
});

describe('createNext', () => {
it('should return a Notification', () => {
const n = Notification.createNext('test');
Expand Down
1 change: 1 addition & 0 deletions src/Notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class Notification<T> {
case 'C':
return Observable.empty<T>();
}
throw new Error('Unexpected notification kind value');
}

private static completeNotification: Notification<any> = new Notification('C');
Expand Down
4 changes: 3 additions & 1 deletion src/observable/dom/AjaxObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class AjaxSubscriber<T> extends Subscriber<Event> {

if (result === errorObject) {
this.error(errorObject.e);
return;
return null;
}

// timeout and responseType can be set once the XHR is open
Expand All @@ -269,6 +269,8 @@ export class AjaxSubscriber<T> extends Subscriber<Event> {
xhr.send();
}
}

return xhr;
}

private serializeBody(body: any, contentType?: string) {
Expand Down
5 changes: 3 additions & 2 deletions src/util/subscribeToResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export function subscribeToResult<T>(outerSubscriber: OuterSubscriber<any, any>,
let destination: Subscriber<any> = new InnerSubscriber(outerSubscriber, outerValue, outerIndex);

if (destination.isUnsubscribed) {
return;
return null;
}

if (result instanceof Observable) {
if (result._isScalar) {
destination.next((<any>result).value);
destination.complete();
return;
return null;
} else {
return result.subscribe(destination);
}
Expand Down Expand Up @@ -76,4 +76,5 @@ export function subscribeToResult<T>(outerSubscriber: OuterSubscriber<any, any>,
} else {
destination.error(new TypeError('unknown type returned'));
}
return null;
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"noImplicitAny": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"moduleResolution": "node",
"target": "es6",
"outDir": "dist/es6"
},
Expand Down

0 comments on commit c76a14d

Please sign in to comment.