AYUDA error TS2511: Cannot create an instance of an abstract class
Publicado por Paloma (1 intervención) el 21/03/2021 22:55:12
Soy nueva en Javascript.... podeis ayudarme... creo que tengo que incluir un método pero no se como...
tengo este código en un Archivo persona.ts
Y en este archivo main1.ts
me da el siguiente error:
error TS2511: Cannot create an instance of an abstract class
Soy nueva en Javascript.... podeis ayudarme... creo que tengo que incluir un método pero no se como...
tengo este código en un Archivo persona.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
export abstract class Persona {
private _nombre: string;
private _apellidos: string;
private _edad: number;
private _dni: number;
private _cumpleaños: number;
private _colorfavorito: string;
private _sexo: string;
private _direcciones: string;
private _mails: string;
private _telefonos: number;
private _notas: string;
constructor(a: string, b: string, c:number, d:number, e:number, f:string, g:string, h:string, i:string, j:number, k:string) {
this._nombre = a;
this._apellidos = b;
this._edad = c;
this._dni = d;
this._cumpleaños = e;
this._colorfavorito = f;
this._sexo = g;
this._direcciones = h;
this._mails = i;
this._telefonos = j;
this._notas = k;
}
public get nombre(): string {
return this._nombre;
}
public set nombre(value: string) {
this._nombre=value;
}
public get apellidos(): string {
return this._apellidos;
}
public set apellidos(value: string) {
this._apellidos=value;
}
public get edad(): number {
return this._edad;
}
public set edad(value: number) {
this._edad=value;
}
public get dni(): number {
return this._dni;
}
public set dni(value: number) {
this._dni=value;
}
public get cumpleaños(): number {
return this._cumpleaños;
}
public set cumpleaños(value: number) {
this._cumpleaños=value;
}
public get colorfavorito(): string {
return this._colorfavorito;
}
public set colorfavorito(value: string) {
this._colorfavorito=value;
}
public get sexo(): string {
return this._sexo;
}
public set sexo(value: string) {
this._sexo=value;
}
public get direcciones(): string {
return this._direcciones;
}
public set direcciones(value: string) {
this._direcciones=value;
}
public get mails(): string {
return this._mails;
}
public set mails(value: string) {
this._mails=value;
}
public get telefonos(): number {
return this._telefonos;
}
public set telefonos(value: number) {
this._telefonos=value;
}
public get notas(): number {
return this._telefonos;
}
public set notas(value: number) {
this._telefonos=value;
}
abstract Persona():void;
}
Y en este archivo main1.ts
1
2
3
4
5
6
7
8
import {Persona} from "./Persona";
console.log ('------------- Iniciamos ejecución del programa -------------------');
let Pers1 = new Persona("Paloma");
console.log('El nombre es:', Pers1.nombre);
console.log ('----------- Finalizamos ejecución del programa --------------------')
me da el siguiente error:
error TS2511: Cannot create an instance of an abstract class
Soy nueva en Javascript.... podeis ayudarme... creo que tengo que incluir un método pero no se como...
Valora esta pregunta


-1