I have a project https://github.com/theADAMJR/2PG and https://github.com/theADAMJR/2PG-Dashboard and I keep having to copy and paste types between both projects.
export class AutoModModule extends Module {
ignoredRoles: string[] = [];
autoDeleteMessages = true;
filters: MessageFilter[] = [];
banWords: string[] = [];
banLinks: string[] = [];
filterThreshold = 5;
autoWarnUsers = true;
}
export enum EventType {
Ban = "BAN",
ConfigUpdate = "CONFIG_UPDATE",
LevelUp = "LEVEL_UP",
MessageDeleted = "MESSAGE_DELETED",
MemberJoin = "MEMBER_JOIN",
MemberLeave = "MEMBER_LEAVE",
Unban = "UNBAN",
Warn ="WARN"
}
Is there a conventional way to share types between TypeScript projects?
TypeScript does have support for sharing code between projects. However, that does not cater to you if you've got the projects split across multiple repositories:
https://www.typescriptlang.org/docs/handbook/project-references.html
If you need to split your project into different repositories, I would suggest publishing npm packages to a private package repository:
https://docs.npmjs.com/creating-and-publishing-private-packages
If you are the only developer and mostly using your own machine, then you could use locally installed packages:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.