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

[combineLatest] can not identify type of its params #7208

Open
lhbvita opened this issue Mar 8, 2023 · 1 comment
Open

[combineLatest] can not identify type of its params #7208

lhbvita opened this issue Mar 8, 2023 · 1 comment

Comments

@lhbvita
Copy link

lhbvita commented Mar 8, 2023

Describe the bug

here, this.__linkServ.links is type of Observable and this.__userServ.getUserInfo() is type of ReplaySubject, but folow code get error.
combineLatest([this.__linkServ.links, this.__userServ.getUserInfo()]) .pipe(takeUntil(this.__destroy$)) .subscribe(([links, userInfo]) => { const link = links?.tms_predefinedTag_common || ''; const hasAuth = !userInfo?.roles?.includes('op_gated_tms'); const predefinedTag = this.operators?.items?.[0]!; predefinedTag.hide = !(link && hasAuth); predefinedTag.link.href = link; });

image

if i specify the types manully like:
combineLatest([this.__linkServ.links, this.__userServ.getUserInfo()] as [Observable<any>,Observable<any>]) .pipe(takeUntil(this.__destroy$)) .subscribe(([links, userInfo]) => { const link = links?.tms_predefinedTag_common || ''; const hasAuth = !userInfo?.roles?.includes('op_gated_tms'); const predefinedTag = this.operators?.items?.[0]!; predefinedTag.hide = !(link && hasAuth); predefinedTag.link.href = link; });
it is ok.

Another thing is, the former code combineLatest refers to
image
but the later refers to
image

Expected behavior

no error

Reproduction code

No response

Reproduction URL

No response

Version

7.4.0

Environment

No response

Additional context

No response

@voliva
Copy link
Contributor

voliva commented Mar 8, 2023

Can you please provide a playground with something that can be reproduced? Codesandbox or Stackblitz.

I tried a simple example

const links: Observable<unknown> = null as any;
const userInfo: ReplaySubject<unknown> = null as any;

combineLatest([links, userInfo]).subscribe(([links, userInfo]) => {
  // Works correctly
})

My env is rxjs@7.5.7

If you manage to create a sandbox for it, it will be simpler to find out what's the issue

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

No branches or pull requests

2 participants