[英]Cannot import functions from another file in Typescript
In my typescript file, I have these functions:在我的 typescript 文件中,我有以下功能:
export {convertToArray, getColumn}
function convertToArray(fileName: string): StringTable {
...
}
function getColumn(columnName: string, table: StringTable): string[] {
...
}
And I'm trying to import them in another Typescript file:我正在尝试将它们导入另一个 Typescript 文件:
import {convertToArray, getColumn} from './csv-reader'
But now it's telling me that my functions are declared locally but never exported.但现在它告诉我我的函数是在本地声明的,但从未导出。
That's because you exported them before defining them.那是因为您在定义它们之前导出了它们。 Try with:尝试:
export function convertToArray(fileName: string): StringTable {
...
}
export function getColumn(columnName: string, table: StringTable): string[] {
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.