TS1146: Declaration expected .. why?

Viewed 4864

I'm with a small problem.

I probably because I'm tired, sorry, I could not found the solution. Somebody can help me?

I have this file: src/app/app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgClass } from '@angular/common';
import { AppComponent } from './app.component';
import { ServerComponent } from './server/server.component';
@NgModule({
    declarations: [
        AppComponent,
        ServerComponent
    ],
    imports: [
        BrowserModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }

Than inside of this component I create a new component, as sample of course.

src/app/server/server.component.ts

import { Component } from '@angular/core';
@Component({
 selector: 'app-server',
 templateUrl: ''
});
export class ServerComponent {
};

src/app/server/serve.component.html

<p>
 Start simple
</p>

Super simple, right? I agree. But when I try to run, I get this error:

70% building modules 3/3 modules 0 active ERROR in src/app/server/server.component.ts(6,3): error TS1146: Declaration expected.

The system can not find the file (server.component.ts), but I did put the path correctly here (src/app/app.module.ts), I did declaration, I did import { Component } from '@angular/core'; , so .. what is missing? I cant understand.

Thanks all.

2 Answers

you shouldn't put semicolon before export

import { Component } from '@angular/core';
@Component({
 selector: 'app-server',
 templateUrl: ''
 })
 export class ServerComponent {
 };

Sometimes extra curly brackets throw such error. angular

Related