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

type-check with typescript 1.9 #1697

Closed
alexeagle opened this issue May 10, 2016 · 8 comments
Closed

type-check with typescript 1.9 #1697

alexeagle opened this issue May 10, 2016 · 8 comments

Comments

@alexeagle
Copy link
Contributor

TypeScript 1.9 (@next) has been out for a while and will be the 2.0 beta in a couple weeks.
Newer TypeScript has many features which are useful in build tooling. Would be nice to be able to use these features while compiling rxjs.

$ npm install typescript@next
$ npm run build_es6

> @reactivex/rxjs@5.0.0-beta.7 compile_dist_es6 /Users/alexeagle/Projects/RxJS
> 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


130   const { callbackFunc, args, scheduler } = source;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

dist/es6/src/observable/BoundCallbackObservable.ts(130,9): error TS2341: Property 'args' is private and only accessible within class 'BoundCallbackObservable<T>'.


130   const { callbackFunc, args, scheduler } = source;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

dist/es6/src/observable/BoundCallbackObservable.ts(130,9): error TS2341: Property 'callbackFunc' is private and only accessible within class 'BoundCallbackObservable<T>'.


130   const { callbackFunc, args, scheduler } = source;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

dist/es6/src/observable/BoundNodeCallbackObservable.ts(130,9): error TS2341: Property 'args' is private and only accessible within class 'BoundNodeCallbackObservable<T>'.


130   const { callbackFunc, args, scheduler } = source;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

dist/es6/src/observable/BoundNodeCallbackObservable.ts(130,9): error TS2341: Property 'callbackFunc' is private and only accessible within class 'BoundNodeCallbackObservable<T>'.


102       unsubscribe = () => sourceObj.removeEventListener(eventName, <EventListener>handler);
                                        ~~~~~~~~~~~~~~~~~~~

dist/es6/src/observable/FromEventObservable.ts(102,37): error TS2339: Property 'removeEventListener' does not exist on type 'EventTarget | { addListener: (eventName: string, handler: Function) => void; removeListener: (eve...'.


105       unsubscribe = () => sourceObj.off(eventName, handler);
                                        ~~~

dist/es6/src/observable/FromEventObservable.ts(105,37): error TS2339: Property 'off' does not exist on type 'EventTarget | { addListener: (eventName: string, handler: Function) => void; removeListener: (eve...'.


108       unsubscribe = () => sourceObj.removeListener(eventName, handler);
                                        ~~~~~~~~~~~~~~

dist/es6/src/observable/FromEventObservable.ts(108,37): error TS2339: Property 'removeListener' does not exist on type 'EventTarget | { addListener: (eventName: string, handler: Function) => void; removeListener: (eve...'.


242     return i < this.length ? { value: array[i], done: false } : { done: true };
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

dist/es6/src/operator/zip.ts(242,12): error TS2322: Type '{ value: T; done: boolean; } | { done: boolean; }' is not assignable to type 'IteratorResult<T>'.
  Type '{ done: boolean; }' is not assignable to type 'IteratorResult<T>'.
    Property 'value' is missing in type '{ done: boolean; }'.


280       return { done: true };
                 ~~~~~~~~~~~~~~

dist/es6/src/operator/zip.ts(280,14): error TS2322: Type '{ done: boolean; }' is not assignable to type 'IteratorResult<T>'.
  Property 'value' is missing in type '{ done: boolean; }'.
@david-driscoll
Copy link
Member

src/observable/BoundCallbackObservable.ts

The problems in appear to be legitimate, interestingly I don't know why they are erroring now. Looking at the code it should have always been an error.

src/observable/FromEventObservable.ts

The issues in FromEventObservable appear to be a bug in the compiler. It appears the type guard is not working inside the closure. I only say that because it was working, and I know some additional work has been done in the compiler to support Type Guards on objects ( eg isEventTarget(this.souce) ).

if (isEventTarget(sourceObj)) {
    // sourceObj is "EventTarget"
    sourceObj.addEventListener(eventName, <EventListener>handler);
    // sourceObj is no longer "EventTarget"
    unsubscribe = () => sourceObj.removeEventListener(eventName, <EventListener>handler);
}
src/operator/zip.ts

Appears to be legitimate errors, my best guess is that IteratorResult<T> changed to imply that there must always be a next value.

src/observable/BoundCallbackObservable.ts and src/operator/zip.ts can be fixed fairly quickly. I strongly feel that src/observable/FromEventObservable.ts is a compiler error.

@david-driscoll
Copy link
Member

Going to open an issue on the TS repo for FromEventObservable

Looking at the following:
image

image

@david-driscoll
Copy link
Member

Actually appears to be a breaking change for TypeScript 2.0.

See microsoft/TypeScript#7662.

Update the PR as well.

@alexeagle
Copy link
Contributor Author

cc @rkirov

@kwonoj
Copy link
Member

kwonoj commented Jun 4, 2016

@david-driscoll I assume this can be closed for now by your latest PR #1700, is my understanding correct?

@zackarychapple
Copy link

@Blesh this can get closed duplicate of #1700

@benlesh
Copy link
Member

benlesh commented Jun 7, 2016

Thanks @zackarychapple!

@benlesh benlesh closed this as completed Jun 7, 2016
@lock
Copy link

lock bot commented Jun 7, 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 7, 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

No branches or pull requests

5 participants