I’m having a little strage issue.
I’ve create an class called Classe.
import { diceENUM } from '../diceENUM'; import { classeENUM } from './classesEnum';
export class Classe { private classe: classeENUM; private nivel: number; private dadoDeVida: diceENUM;
constructor($classe: classeENUM, $nivel: number, $dadoDeVida: diceENUM) { this.classe = $classe; this.nivel = $nivel; this.dadoDeVida = $dadoDeVida; } public get $nome(): string { switch (this.classe) { case 0: return 'Clerigo'; case 1: return 'Homem de Armas'; case 2: return 'Mago'; case 3: return 'Ladino'; } } public get $classe(): classeENUM { return this.classe; } public set $classe(classe : classeENUM){ this.classe = classe; } public get $nivel(): number { return this.nivel; } public set $nivel(nivel : number){ this.nivel = nivel; } public get $dadoDeVida(): diceENUM { return this.dadoDeVida; } public set $dadoDeVida(dadoDeVida : diceENUM){ this.dadoDeVida = dadoDeVida; } }
Ok, nothing wrong about it.
Then I created an class called Mago that extends Classe.
import { Classe } from './classe'; import { BonusDeClasse } from '../constantesClass'; import { AcessoMagia } from '../constantesClass'; import { ConstantesClass } from '../constantesClass';
export class Mago extends Classe{ constructor(nivel: number){ super(2, nivel, 4) } public get $bonus() : BonusDeClasse { if (this.$nivel <= 0) { return null; } else { let bonus = ConstantesClass.MAGO_BONUS; for (var index = 0; index < bonus.length; index++) { if (this.$nivel === bonus[index].nivel) { return bonus[index]; } } return null; } } public get $magia() : AcessoMagia { if (this.$nivel <= 0) { return null; } else { let bonus = ConstantesClass.MAGO_MAGIA; for (var index = 0; index < bonus.length; index++) { if (this.$nivel === bonus[index].nivel && bonus[index].acessoMagia.length === 9 ) { return bonus[index]; } } return null; } } }
Ok, nothing wrong about it neither…
But, I’ve created another class called HomemDeArmas that extends Classe.
And type ionic serve.
And on transpiling it return this error:
typescript: D:/Estudos/example/src/classes/homemdearmas.ts, line: 5 Type 'any' is not a constructor function type.
Follow the code of HomemDeArmas bellow:
import { Classe } from './classe'; import { BonusDeClasse } from '../constantesClass'; import { ConstantesClass } from '../constantesClass';
export class HomemDeArmas extends Classe{
constructor(nivel: number){ super(1, nivel, 10) }
public get $bonus() : BonusDeClasse { if (this.$nivel <= 0) { return null; } else { let bonus = ConstantesClass.MAN_AT_ARMS_BONUS; for (var index = 0; index < bonus.length; index++) { if (this.$nivel === bonus[index].nivel) { return bonus[index]; } } return null; } }
}
I Just can’t find any logic about this error.
Maybe it’s just a simple thing to correct
ionic info:
Cordova CLI: 6.5.0 Ionic Framework Version: 2.0.1 Ionic CLI Version: 2.2.1 Ionic App Lib Version: 2.2.0 Ionic App Scripts Version: 1.1.0 ios-deploy version: Not installed ios-sim version: Not installed OS: Windows 7 Node Version: v7.4.0 Xcode version: Not installed