My code file is getting too long with both declarations and other code mixed together. Below is a snippet from my ./src/index.ts
file:
// --> I want to move this to a separate file
export interface Client extends Options {
transactionsCounter: number;
requestCallbacks: any;
socket: any;
}
// <-- I want to move this to a separate file
export class Client {
constructor(options: Options) {
const defaultOptions = {
host: 'ws://127.0.0.1',
port: 8080,
logger: function() {
const prefix = "LOG:";
console.log.call(null, prefix, ...Array.from(arguments))
},
maxTime: 30000,
startFromTransactionId: 1
};
Object.assign(this, { ...defaultOptions, ...options });
this.transactionsCounter = 0;
this.requestCallbacks = {};
this.socket = null;
}
}
I am looking for a solution to move the TypeScript declarations to a separate file. How can I achieve this effectively?
Should I simply create a new file and import it for each declaration, or is there a method that will allow me to move the declarations to another file while still maintaining them in the namespace of my existing code?