最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Unable to resolve signature of class decorator when called as an expression at @Injectable Angular - Stack Overflow

programmeradmin4浏览0评论

Full Error Message
Unable to resolve signature of class decorator when called as an expression. Argument of type 'ClassDecoratorContext' is not assignable to parameter of type 'string | symbol | undefined'.

I created a book Module under App Module. Inside that Module I created Service File for Work. When I create a file I got this Error..?

This is My Service File

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/mon/http'

@Injectable({
  providedIn:"root"
})
export class BookService {

  constructor(private _http: HttpClient){ }
}

File Structure

This is My book.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/mon';

import { BookRoutingModule } from './book-routing.module';
import { HomeComponent } from './home/homeponent';
import { bookReducer } from './store/reducer/book.reducer';
import { StoreModule } from '@ngrx/store';


@NgModule({
  declarations: [
    HomeComponent
  ],
  imports: [
    CommonModule,
    BookRoutingModule,
    StoreModule.forFeature('bookReducer',bookReducer)
  ]
})
export class BookModule { }

Full Error Message
Unable to resolve signature of class decorator when called as an expression. Argument of type 'ClassDecoratorContext' is not assignable to parameter of type 'string | symbol | undefined'.

I created a book Module under App Module. Inside that Module I created Service File for Work. When I create a file I got this Error..?

This is My Service File

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/mon/http'

@Injectable({
  providedIn:"root"
})
export class BookService {

  constructor(private _http: HttpClient){ }
}

File Structure

This is My book.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/mon';

import { BookRoutingModule } from './book-routing.module';
import { HomeComponent } from './home/home.ponent';
import { bookReducer } from './store/reducer/book.reducer';
import { StoreModule } from '@ngrx/store';


@NgModule({
  declarations: [
    HomeComponent
  ],
  imports: [
    CommonModule,
    BookRoutingModule,
    StoreModule.forFeature('bookReducer',bookReducer)
  ]
})
export class BookModule { }

Share Improve this question edited Apr 26, 2023 at 11:35 Sakthivel asked Apr 26, 2023 at 11:33 SakthivelSakthivel 631 silver badge7 bronze badges 1
  • This is hard to "debug" do you have a reproduction? – timdeschryver Commented Apr 26, 2023 at 18:09
Add a ment  | 

2 Answers 2

Reset to default 15

If are using VSCode, try to restart your TypeScript Server.

Ctrl+Shift+P > TypeScript: Restart TS Server

It fixed it for me

In my case the reason was in wrong file name: MyClassts => MyClass.ts

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论