我对错误TS2709感到有些困惑:无法将名称空间“ ListTaskPair”用作类型?

时间:2019-05-21 21:01:55

标签: angular typescript

一段时间以来,我一直在努力解决这个问题。不是如何消除错误,而是为什么要这样做:

import { List, ListTaskPair, ListType, Task, TaskLite } from '../../../../api';

无法解决以下问题:“ api / index.ts”具有:

export { AWSItem } from 'awsItem';
export { Backup } from 'backup';
export { FakeDropList } from 'fakedroplist';
export { FormError } from 'error';
export { Label } from 'label';
export { List, ListType } from 'list';
export { ListTaskPair } from 'listTaskPair';
export { Sublist } from 'subList';
export { Task } from 'task';
export { TrackerFile } from 'trackerFile';
export { TaskLite } from 'taskLite';
export * from 'githubItem';
export { ListLabel } from 'trackerLabel';
export { User, Role } from 'user';
export { SharingUser } from 'sharingUser';
export { nullObjectId } from 'mongodbObjectId';
export { Mapper } from 'mapper';
export { DerivedLabel } from 'derivedLabel';
export { LabelType } from 'list';
export { Type, Unit } from 'task';
export { Comment, GithubUser, GithubItem, GithubLabel } from 'issue';
export { ObjectId } from 'bson';

但是我必须做类似的事情:

import { List } from '../../../../api/list';
import { TaskLite } from '../../../../api/taskLite';
import { ListTaskPair } from '../../../../api/listTaskPair';
import { Task } from '../../../../api/task';

停止TS2709问题。

因此,除了能够将我的对象分组到一个index.ts中,然后再大量导入它们之外,我不得不将它们分解成单独的导入,这很痛苦。无论如何,是否可以说服打字稿更自由地导入?过去似乎有些宽容。

您的见解将非常有帮助。

就我的环境而言:

Angular CLI: 7.3.9
Node: 12.2.0
OS: linux x64
Angular: 7.2.15
... common, compiler, compiler-cli, core, elements, forms, http
... platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.9
@angular-devkit/build-angular     0.13.9
@angular-devkit/build-optimizer   0.13.9
@angular-devkit/core              7.3.9
@angular-devkit/schematics        7.3.9
@angular/cli                      7.3.9
@schematics/angular               7.3.9
@schematics/update                0.13.9
rxjs                              6.5.2
typescript                        3.2.2
webpack                           4.31.0

0 个答案:

没有答案