从导出问题导入Typescript ES6

时间:2019-11-07 19:33:29

标签: typescript ecmascript-6

我正在将节点代码转换为打字稿,并在导出和导入方面遇到问题/困惑。

文件:lookup.ts

const SecurityTypeSchema = new GraphQLObjectType({});
const EmailTypeSchema = new GraphQLObjectType({});
const PhoneTypeSchema = new GraphQLObjectType({});
const AddressTypeSchema = new GraphQLObjectType({});
const CountrySchema = new GraphQLObjectType({});

export default {
    SecurityTypeSchema,
    EmailTypeSchema,
    PhoneTypeSchema,
    AddressTypeSchema,
    CountrySchema
}

文件:account.ts

作品:

import * as SecurityTypeSchema from './lookup';
import * as EmailTypeSchema from './lookup';
import * as PhoneTypeSchema from './lookup';
import * as CountrySchema from './lookup'; 

错误:

import {
    SecurityTypeSchema
    EmailTypeSchema,
    PhoneTypeSchema,
    CountrySchema
} from './lookup';  

错误:

import * as Lookup from './lookup';
const {
    SecurityTypeSchema
    EmailTypeSchema,
    PhoneTypeSchema,
    CountrySchema
} = Lookup;

我喜欢最后两个选项,因为我喜欢将它们分组。我正在查看以下linkhere,但仍然出现错误。

如果有人可以给我任何提示,我将不胜感激。

谢谢

0 个答案:

没有答案