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

Fix from stream initialvalue type #251

Merged
merged 2 commits into from May 16, 2020
Merged

Conversation

NaridaL
Copy link
Collaborator

@NaridaL NaridaL commented May 15, 2020

@KEIII You're right, the initial value wasn't typed correctly. I changed your PR a bit, as it isn't necessary to add a second type parameter to type it properly. Could you check this resolves problems with your use case?

@coveralls
Copy link

coveralls commented May 15, 2020

Coverage Status

Coverage decreased (-0.3%) to 93.212% when pulling 47321e7 on fix-from-stream-initialvalue-type into 643c44a on master.

I enabled strict mode to resolve all the null errors in observable-stream.ts and test/observable-stream.ts
@NaridaL NaridaL force-pushed the fix-from-stream-initialvalue-type branch from c5d3f89 to 47321e7 Compare May 15, 2020 16:10
@KEIII
Copy link
Contributor

KEIII commented May 15, 2020

Thanks a lot for your review. Here is some code to describe type problem:

const num$ = timer(1000).pipe(map(() => 42)); // we got 42 after 1000 ms after subscribe
const listener: IStreamListener<number> = fromStream(num$); // no initial value, no warnings
listener.current.toFixed(); // Runtime Error: TypeError: Cannot read property 'toFixed' of undefined

TypeScript say no type errors to this code. But real think is what listener.current is undefined (cause initialValue is undefined) before stream emits value.

@NaridaL
Copy link
Collaborator Author

NaridaL commented May 15, 2020

@KEIII , OK, that should give the proper warning now, as the 1-arg fromSream is defined as:

export function fromStream<T>(observable: IObservableStream<T>): IStreamListener<T | undefined>

@NaridaL
Copy link
Collaborator Author

NaridaL commented May 16, 2020

@mweststrate Can you publish a 5.6.0? Thanks!

@NaridaL NaridaL deleted the fix-from-stream-initialvalue-type branch May 16, 2020 10:32
@KEIII
Copy link
Contributor

KEIII commented May 17, 2020

@NaridaL Nope, it's still no warning. The only way I was able to describe it properly was second type for initial value like #247
I got it. It works for strict mode. Thanks.

@NaridaL NaridaL mentioned this pull request May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants