Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ts1206 decorators are not valid here, Angular 6 Tutorial Example

Tags:

angular

The "decorator" in question appears in the following block.

@NgModule({
  declarations: [
    AppComponent,
    MyNavComponent,
    FirstPageComponent,
    SecondPageComponent,
    ThirdPageComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    LayoutModule,
    MatToolbarModule,
    MatButtonModule,
    MatSidenavModule,
    RouterModule.forRoot(appRoutes),
    MatIconModule,
    MatListModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})

The example is my understanding of the way to import the RouterModule into the application described in the tutorial, Angular Material And Angular 6 – Material Design For Angular.

The messages generated by the trsnspiler, running in my local development server, follow.

Date: 2018-06-03T19:57:21.828Z - Hash: 46428b505e290e79e66d - Time: 632ms 4 unchanged chunks chunk {main} main.js, main.js.map (main) 15.3 kB [initial] [rendered] i 「wdm」: Compiled successfully. ERROR in src/app/app.module.ts(14,1): error TS1206: Decorators are not valid here.

I posted the whole application, minus the node_modules directory, is in StringMorph_20180603_151629.zip, on my OneDrive.

What nuance, obvious to all but me, did I overlook?

like image 930
David A. Gray Avatar asked Oct 16 '25 04:10

David A. Gray


1 Answers

This answer appears to be correct. The export class statement must immediately follow any decorator such as @Injectable, @NgModule, etc. The last two lines of your block above should be:

})
export class ModuleName { }
like image 65
J E Carter II Avatar answered Oct 17 '25 19:10

J E Carter II