我们有一个SDK monorepo,我们尝试将其移至打字稿2.9.2
不幸的是,当我们尝试构建它时,ts产生了Cannot find module '../../../another-sdk-name/module/address
显然,在优化地址的同时,打字稿决定使用相对地址代替初始的绝对地址,这直接导致我们尝试通过不存在的地址导入文件。
最奇怪的部分是,有些进口货已经得到妥善解决,而有些进口货却没有,但是它们之间没有直接关联:
DomainEvent.d.ts
// This is being resolved correctly
import { DomainEvent, DomainEventMeta } from '@monorepo/monorepo-eventkit';
export declare const DomainEventMandatory: {
type: "entity-created" | "entity-updated";
payload: {
entityId: string
};
// This is throwing an error
meta: import("../../../../../../monorepo-eventkit/dist/src/emittable/EmittableMeta").EmittableMeta;
};
相应导入文件的内容:
DomainEventMeta.d.ts
import { EmittableMeta } from '../emittable/EmittableMeta';
export declare type DomainEventMeta = EmittableMeta;
DomainEvent.d.ts
import { Emittable } from '../emittable/Emittable';
export declare type DomainEvent = Emittable;
此文件未正确导入:
EmittableMeta.d.ts
export declare type SourceType = 'partner' | 'internal';
export declare type SourceId = string;
export declare type UserId = string;
export declare type UserRole = string;
export declare type EmittableMeta = {
correlation: {
[key: string]: any;
};
creationDate: Date;
sourceType: SourceType;
sourceId: SourceId;
userRole?: UserRole;
userId?: UserId;
version: string;
};