Typescript 导入的函数给出一个TypeError:。。。这不是一个函数
我有一个在很多文件中使用的函数。这项工作:Typescript 导入的函数给出一个TypeError:。。。这不是一个函数,typescript,Typescript,我有一个在很多文件中使用的函数。这项工作: import moment from 'moment'; let monthAsString = (month: number): string => { return moment().locale('de').month(month - 1).format("MMMM"); } configuration2005.push( { worksheetName: monthAsString(10), } ) 在额外文件中
import moment from 'moment';
let monthAsString = (month: number): string => {
return moment().locale('de').month(month - 1).format("MMMM");
}
configuration2005.push(
{
worksheetName: monthAsString(10),
}
)
在额外文件中分离函数时,我得到一个类型错误:
export function monthAsString(month: number): string {
return moment().locale('de').month(month - 1).format("MMMM");
}
错误:
TypeError: configurations_1.monthAsString is not a function
at Object.<anonymous> (/Users/mles/project/src/configuration-2005.ts:12:22)
...
TypeError:configurations\u 1.monthastring不是函数
反对。(/Users/mles/project/src/configuration-2005.ts:12:22)
...
我错过了什么?VSCode未显示任何错误。对我正常工作:对我正常工作:
TypeError: configurations_1.monthAsString is not a function
at Object.<anonymous> (/Users/mles/project/src/configuration-2005.ts:12:22)
...