我有一个量角器项目,我想将另一个项目中的多个类导出到我的测试类中。 Helper
的第一类可以导入,但其余的我得到一个错误:has no exported member - People, Groups
app.ts
export { Helper } from './src/helpers/helper';
export { People } from './src/helpers/people';
export { Groups } from './src/helpers/groups';
package.json
{
...
"name": "sub-project",
"main": "app.ts",
...
}
helper.ts
import { HttpClient } from './http-client';
export class Helper {
private httpClient = new HttpClient();
public async myFunction(): { }
}
people.ts
import { HttpClient } from './http-client';
export class People {
private httpClient = new HttpClient();
public async myFunction(): { }
}
test.ts
import { Helper, People, Groups} from 'sub-project'; // error, has no exported member - People, Groups, (Helper - ok)
tsconfig
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": ".",
"target": "es5",
"module": "commonjs",
"types": [
"chai",
"chai-as-promised",
"mocha"
],
}
}
答案 0 :(得分:2)
立即转口是一项新功能,可能有问题。
避免
const pubData = res.data();
Object.keys(pubData).forEach(function(key) {
// key is 1892872, pubData[key] is the associated object
console.log(key, pubData[key]);
});
,并改用以下内容:
export { Helper } from './src/helpers/helper';
export { People } from './src/helpers/people';
export { Groups } from './src/helpers/groups';