Typescript - Code fails to build from error TS1128: Declaration or Statement expected, but runs as expected when I serve the code

In my case was just necessary to compile again the project


You have commented

//inputData };

I think the curly brace should be on the next line...

//inputData
};

Edit

Your ngOnInit function should not contain other functions:

import { Component, OnInit} from '@angular/core';

import { submitService } from './Common-functions/submit.service';

@Component({
selector: 'my-app',
template: `htmlCode`

})
export class AppComponent implements OnInit{ 
  hideTable = true;
  lengthOfRecords = 0;
  lowerLimit = 0;
  upperLimit = 5;
  prevButtonDisabled = true;
  nextButtonDisabled = false;

  //User inputs

constructor(private sService:submitService) { }

ngOnInit() {
    // Add any initialization code here
}

submitToJSON() {

     //SumbitJSON Object
        var submitJSON = {
            //inputData 
                 };

        this.sService.POST(submitJSON);
 }


returnDetails() {

this.listOfIDs = {//ListData};

        this.hideTable = false;
    var keys = Object.keys(this.listOfIDs);
        var len = keys.length;
        this.lengthOfRecords = len;
    }

prev() {
        if(this.lowerLimit <= 0) {
            ;
            }
        else {
            this.lowerLimit = this.lowerLimit - 6;
            this.upperLimit = this.upperLimit - 5;
            this.nextButtonDisabled = false;
            if(this.lowerLimit <= 0) {
                this.prevButtonDisabled = true;
                }
            }
        }
next() {
        if(this.upperLimit >= this.lengthOfRecords) {
            ;
            }
        else {
            this.lowerLimit = this.lowerLimit + 6;
            this.upperLimit = this.upperLimit + 5;
            this.prevButtonDisabled = false;
            if(this.upperLimit >= this.lengthOfRecords) {
                this.nextButtonDisabled = true;
                }
            }
        }

 getEntries(obj, from, to) {
    if(obj!=null) {
        var entries = [];
        for(var key in obj) {
            // extract index after `app`
            var index = key.substring(3);
            if(index >= from && index <= to) {
                entries.push( obj[key]);
            }
        }
        return entries;
        }



}

Just had the same error and it went away after closing IntelliJ and reopening. I had been modifying the file with the error. It is like it was looking at an old version somehow.

Tags:

Npm

Angular