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

error TS1122: A tuple type element list cannot be empty. #28667

Closed
BitRuby opened this issue Nov 25, 2018 · 0 comments
Closed

error TS1122: A tuple type element list cannot be empty. #28667

BitRuby opened this issue Nov 25, 2018 · 0 comments

Comments

@BitRuby
Copy link

BitRuby commented Nov 25, 2018

TypeScript Version: 3.01

Search Terms:
#16636

Code
mycomponent.ts

import { Component, OnInit, AfterViewInit,} from '@angular/core';
import { MatTableDataSource } from '@angular/material';
import { Data } from 'src/app/core/data/data.model';
import { DataService } from 'src/app/core/data/data.service';

@Component({
  selector: 'app-mycomponent,
  templateUrl: './mycomponent.html',
  styleUrls: ['./mycomponent.css']
})
export class MyComponent implements OnInit, AfterViewInit {

  dataSource = new Array<MatTableDataSource<Data['Column']>>();

  constructor(private ds: DataService) {
  }
  ngOnInit() {
  }
  ngAfterViewInit(): void {
    this.loadData();
  }
  loadData(): void {
    this.ds.getData().subscribe(data=> {
      if (data=== null) { return; }
      this.dataSource[0] = new MatTableDataSource(data as []);
    });
}

Expected behavior:
Should not throwing ERROR in console
Actual behavior:
First compile after build doesn't work and throwing error TS1122: A tuple type element list cannot be empty. in line with this.dataSource[0] = new MatTableDataSource(data as []). After enter some changes in code to trigger recompilation my application works, but still throwing error.

Related Issues:
#7520

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

1 participant