类型“从不”必须具有返回迭代器的“ [Symbol.iterator]()”方法。打字稿

时间:2019-12-30 23:20:45

标签: angular typescript

我有此代码

authComplete$.subscribe(([user, loggedIn]) => {

显然,这只是错误所在行的代码段不完整。错误

Type 'never' must have a '[Symbol.iterator]()' method that returns an iterator.

我不知道该如何解决。或者这甚至意味着什么

这是到目前为止的完整代码和我的研究

private handleAuthCallback() {
    // Call when app reloads after user logs in with Auth0
    const params = window.location.search;
    if (params.includes('code=') && params.includes('state=')) {
      let targetRoute: string; // Path to redirect to after login processsed
      const authComplete$ = this.handleRedirectCallback$.pipe(
        // Have client, now call method to handle auth callback redirect
        tap(cbRes => {
          // Get and set target redirect route from callback results
          targetRoute = cbRes.appState && cbRes.appState.target ? cbRes.appState.target : '/';
        }),
        concatMap(() => {
          // Redirect callback complete; get user and login status
          return combineLatest([
            this.getUser$(),
            this.isAuthenticated$
          ]);
        })
      );
      // Subscribe to authentication completion observable
      // Response will be an array of user and login status
      authComplete$.subscribe(([user, loggedIn]) => {     // <-- line error is on
        // Redirect to target route after callback processing
        this.router.navigate([targetRoute]);
      });
    }
  }

这是在处理auth0角度积分示例,该示例可以在此处找到 https://auth0.com/docs/quickstart/spa/angular2

到目前为止,我对这个网站的研究是

https://www.geekabyte.io/2019/06/typing-iterables-and-iterators-with.html

但是老实说,读了几次后我更加困惑了。

我确实发现可能需要更改我在tsconfig.json文件中所做的角度应用程序中的某些设置

"lib": [
      "es2018",
      "dom",
      "es5", "es6", "dom.iterable"
    ]

我们将不胜感激

1 个答案:

答案 0 :(得分:0)

所以我不确定这是否是解决方案,但是我删除了用户并登录

SFrame

现在是:

import csv

def fetch(name_string, data):
    x = 0
    location = 0
    output = []

    if name_string == "ONE":
        location = 0
    elif name_string == "TWO":
        location = 1
    else:
        return print("An unknown error occurred")

    for line in data:
        if x > 0:
            output.append(float(line[location]))              
        x += 1

    return output


with open("test_file.csv", "r") as f:
    reader = csv.reader(f)
    data = list(reader)

col1 = fetch("ONE", data)
col2 = fetch("TWO", data)

print(col1)
print(col2)

我必须继续设置我的身份验证方案,以查看代码是否有效。得到答案后,我将进一步详细说明该答案。

但是就代码编译而言,删除数组确实有效。