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

Typeahead checks if falsy but tries to get .length of potentially null value and that throws an error #2530

Closed
matjazonline opened this issue Jul 18, 2018 · 1 comment

Comments

@matjazonline
Copy link

Bug description:

The issue is at 'const count = results.length;' typeahead.ts:360 when 'results' value is null.
The workaround is to pass empty array to items observable, but at the top of this method null is expected: 'if (!results || results.length === 0) {'

Console error:

global-error-handler.ts:37 client error: TypeError: Cannot read property 'length' of null
at SafeSubscriber._next (typeahead.js:238)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:195)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:133)
at ...

@pkozlowski-opensource
Copy link
Member

Here is a reproduction scenario: https://stackblitz.com/edit/angular-metn4u?file=app/typeahead-basic.ts

We do assume that empty results should be denoted by [] but maybe we should protect against null / undefined / not an array...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants