我想创建一个“实用模块”:tnt.module.ts:
import {NgModule} from '@angular/core';
import {toUpperCase} from "./tnt.utils";
@NgModule({
declarations: [
toUpperCase
],
exports: [
toUpperCase
]
})
export default class TntModule {}
这是一个 util 函数示例:tnt.utils.ts
export const toUpperCase= function (str:String) {
return str.toUpperCase()
}
我收到一个错误:
ERROR in [default] /data/2016/le-tube/src/app/shared/tnt/tnt.module.ts:5:10
Argument of type '{ imports: undefined[]; declarations: ((str: String) => string)[]; exports: ((str: String) => str...' is not assignable to parameter of type 'NgModule'.
Types of property 'declarations' are incompatible.
Type '((str: String) => string)[]' is not assignable to type '(any[] | Type<any>)[]'.
Type '(str: String) => string' is not assignable to type 'any[] | Type<any>'.
Type '(str: String) => string' is not assignable to type 'Type<any>'.
Type '(str: String) => string' provides no match for the signature 'new (...args: any[]): any'
我错过了什么?为什么我不能创建具有简单功能的模块?我想我只是错过了一个简单的细节,但我无法弄清楚......