Reputation: 2738
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?
Upvotes: 1
Views: 1270
Reputation: 6791
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:
Installing a local module using npm?
Upvotes: 2