Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TS: Alternative Error Fix #2614

Merged
merged 16 commits into from
Jun 14, 2017
Merged

Update TS: Alternative Error Fix #2614

merged 16 commits into from
Jun 14, 2017

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented May 25, 2017

This is the same as #2606, but updates the custom error classes to use setPrototypeOf

Pros:

  • instanceof still works
  • fewer breaking changes
  • call stacks and other goodness preserved for Chrome DevTools

Cons:

  • IE10 users will need an Object.setPrototypeOf polyfill.
  • setPrototypeOf creates a "slow object" in V8... deoptimized as a hashtable, to my understanding.

Other things:

The Object.setPrototypeOf polyfill is trivial:

Object.setPrototypeOf || Object.setPrototypeOf = function(a, b) { a.__proto__ = b; return a; }

cc @trxcllnt

benlesh added 7 commits May 24, 2017 13:17
- adds `tslib` import to `Rx.ts`
- adds `--noEmitHelpers` to build output

closes #2605
BREAKING CHANGE: The following types no longer exist: `EmptyError`, `UnsubscriptionError`, `ArgumentOutOfRangeError`, `ObjectUnsubcribedError`, `TimeoutError`, `AjaxError`, `AjaxTimeoutError`. There are now utilities for creating and testing under `Rx.Util` for example:  `Rx.Util.createTimeoutError()` and `Rx.Util.isTimeoutError(err)` etc.

closes #2612
related #2582
BREAKING CHANGE: IE10 and lower will need to polyfill `Object.setPrototypeOf`
@rxjs-bot
Copy link

rxjs-bot commented May 25, 2017

Warnings
⚠️ commit message does not follows conventional change log (1)

(1) : RxJS uses conventional change log to generate changelog automatically. It seems some of commit messages are not following those, please check contributing guideline and update commit messages.

Generated by 🚫 dangerJS

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.003%) to 97.732% when pulling d242156 on benlesh:errorAlternative into da96b6a on ReactiveX:master.

benlesh and others added 3 commits May 25, 2017 09:53
- updates `responseType` in ajax observable area to be
`XMLHttpRequestResponseType`

BREAKING CHANGE: TypeScript 2.3 now required
BREAKING CHANGE: `AjaxRequest`'s `responseType` property is now
`XMLHttpRequestResponseType` rather than `string` to support TS 2.3
TypeScript now distributes typings via npm.
benlesh and others added 2 commits May 25, 2017 10:18
Fix buffer operator not emitting the last buffer when the source
completes. This is closer to rxjs v4* behaviour and matches the
behaviour of the other buffer operators. The _complete method is very
similar to thoses in bufferCount, bufferTime and bufferWhen.

*rxjs v4 will always emit the buffer if the source completes even if the
buffer is empty. This fix only emits if the buffer is non empty.

BREAKING CHANGE:

The `buffer()` operator now emits what's partially buffered when the
source completes. This is closer to rxjs v4* behaviour and matches the
v5 behaviour of the other buffer operators.
@@ -5,6 +5,7 @@ import { Observable } from '../../Observable';
import { Subscriber } from '../../Subscriber';
import { TeardownLogic } from '../../Subscription';
import { MapOperator } from '../../operator/map';
import 'tslib';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need this

@@ -1,4 +1,6 @@
/* tslint:disable:no-unused-variable */
import 'tslib';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need this either

@Widdershin
Copy link
Contributor

The failure from markdown-doctest appears to be a module issue.

It's failing when trying to import Rx from 'rxjs/Rx'.

This is the example from the README that's failing:

import Rx from 'rxjs/Rx';

Rx.Observable.of(1,2,3)

After being compiled by babel this is how it looks:

var _Rx = require('rxjs/Rx');

var _Rx2 = _interopRequireDefault(_Rx);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

_Rx2.default.Observable.of(1, 2, 3);

This started breaking with TypeScript 2.3 because now require('rxjs/Rx').__esModule is true so _interopRequireDefault goes down a different branch in the ternary.

This line now appears at the top of the compiled output:

Object.defineProperty(exports, "__esModule", { value: true });

Arguably this is reasonable behaviour, as import Rx from 'rxjs/rx'; is importing a default, and the module in question has no exported default.

I'm unsure why __esModule is now being set to true, seems like this must have changed in TypeScript 2.3 or is configured somewhere I can't see.

One possible fix is to change import Rx from 'rxjs/Rx' to import * as Rx from 'rxjs/Rx'.

Another would be to export a default, but that seems like it would be a lot of duplication.

I think this failure is indicative of a problem that could impact real users. I know TypeScript is strict about importing using that syntax from modules with no default. I think in the past babel allows you to use that syntax for commonjs modules, but maybe it's always been based on __esModule.

@benlesh
Copy link
Member Author

benlesh commented Jun 14, 2017

Thanks @Widdershin ... I think we can actually just make that change. It's only in two spots I believe.

- had to had new tslint rules specific for tests to disable no-unused-expression because it didn't like the chai assertions such as `expect(foo).to.be.true`, as it wanted `true` to be set or called as a function
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.003%) to 97.734% when pulling 5151d80 on benlesh:errorAlternative into 9bc0348 on ReactiveX:next.

@coveralls
Copy link

coveralls commented Jun 14, 2017

Coverage Status

Coverage decreased (-0.003%) to 97.734% when pulling 5151d80 on benlesh:errorAlternative into 9bc0348 on ReactiveX:next.

@benlesh benlesh merged commit 4515d30 into ReactiveX:next Jun 14, 2017
@benlesh benlesh deleted the errorAlternative branch June 14, 2017 21:20
hermanbanken added a commit to hermanbanken/RxJS that referenced this pull request Aug 7, 2017
Error.stack can potentially trigger expensive prepareStackTrace calls,
Observable.timeout would crate a TimeoutError on use, before the actual
error occurs. This eases tracing the location of the timeout, but with
the current implementation, slows down the application when using many
.timeout operators throughout the code.

Manual cherry-pick of ReactiveX#2614 commit d242156
hermanbanken added a commit to hermanbanken/RxJS that referenced this pull request Aug 7, 2017
Error.stack can potentially trigger expensive prepareStackTrace calls,
Observable.timeout would crate a TimeoutError on use, before the actual
error occurs. This eases tracing the location of the timeout, but with
the current implementation, slows down the application when using many
.timeout operators throughout the code.

Manual cherry-pick of ReactiveX#2614 commit d242156
hermanbanken added a commit to hermanbanken/RxJS that referenced this pull request Aug 7, 2017
Error.stack can potentially trigger expensive prepareStackTrace calls,
Observable.timeout would crate a TimeoutError on use, before the actual
error occurs. This eases tracing the location of the timeout, but with
the current implementation, slows down the application when using many
.timeout operators throughout the code.

Manual cherry-pick of ReactiveX#2614 commit d242156
@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants