javascript - Error with Inheritance and TypeScript: X is not a constructor function type -
i working on small webapp , using typescript, node.js, express, , mongodb.
i have super class want 2 other classes inherit from. classes listed below. when compile, 2 classes trying inherit complain superclass (the give same error): "[class file path (in case a)] not constructor function type"
a.ts
export class { //private fields... constructor(username: string, password: string, firstname: string, lastname: string, accounttype: string) { // initialisation } } b.ts
import = require('./a); export class b extends { constructor(username: string, password: string, firstname: string, lastname: string, accounttype: string) { super(username, password, firstname, lastname, accounttype); } } c.ts
import = require('./a ); export class c extends { constructor(username: string, password: string, firstname: string, lastname: string, accounttype: string) { super(username, password, firstname, lastname, accounttype); } } this pretty simple, , yet class c , b cannot compile. examples have seen online not have other syntax writing these classes/ constructor. trying follow convention, can't seem work.
any appreciated! reading.
replace
import = require('./a'); with
import { } './a'; or
import modulea = require('./a'); export class b extends modulea.a { // ... }
Comments
Post a Comment