We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new constructor.prototype.constructor
import { VuexClassModuleFactory, ModuleOptions, IVuexModule } from "./module-factory"; import { VuexModule } from "./VuexModule"; type VuexModuleClass = new (...args: any[]) => VuexModule; export function Module<T extends VuexModuleClass>(target: T): T; export function Module(options?: ModuleOptions): ClassDecorator; export function Module<T extends VuexModuleClass>(arg?: ModuleOptions | T): ClassDecorator | T { if (typeof arg === "function") { return moduleDecoratorFactory()(arg) as T; } else { return moduleDecoratorFactory(arg); } } function moduleDecoratorFactory(moduleOptions?: ModuleOptions) { return <TFunction extends Function>(constructor: TFunction): TFunction => { const accessor: any = function(...args: any[]) { const instance = new constructor.prototype.constructor(...args) as IVuexModule; Object.setPrototypeOf(instance, accessor.prototype); const factory = new VuexClassModuleFactory(constructor, instance, moduleOptions || {}); factory.registerVuexModule(); return factory.buildAccessor(); }; accessor.prototype = Object.create(constructor.prototype); accessor.prototype.constructor = accessor; return accessor; }; }
what is the reason for using new constructor.prototype.constructor to create instance but not new constructor? i am a beginner, a little confused.
new constructor
The text was updated successfully, but these errors were encountered:
No branches or pull requests
what is the reason for using
new constructor.prototype.constructor
to create instance but notnew constructor
?i am a beginner, a little confused.
The text was updated successfully, but these errors were encountered: