2017-04-03 7 views
5

मुझे इन इकाइयों को बनाने का प्रयास करते समय निम्न त्रुटि मिल रही है।टाइपरर: क्लास अपरिभाषित मान को फ़ंक्शन या शून्य नहीं है

TypeError: Class extends value undefined is not a function or null

मैं इस परिपत्र निर्भरता के साथ कुछ है यह सोचते हैं रहा हूँ, लेकिन कैसे यह है कि जब तालिका विरासत और कई रिश्तों को एक का उपयोग कर से बचा जाना माना जाता है?

यह BaseComic_1.BaseComic पर निम्नलिखित जावास्क्रिप्ट के बारे में शिकायत कर रहा है।

let Variant = class Variant extends BaseComic_1.BaseComic {

यहाँ पूरी फाइल है।

"use strict"; 
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 
    return c > 3 && r && Object.defineProperty(target, key, r), r; 
}; 
var __metadata = (this && this.__metadata) || function (k, v) { 
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 
}; 
Object.defineProperty(exports, "__esModule", { value: true }); 
const typeorm_1 = require("typeorm"); 
const Comic_1 = require("./Comic"); 
const BaseComic_1 = require("./BaseComic"); 
let Variant = class Variant extends BaseComic_1.BaseComic { 
}; 
__decorate([ 
    typeorm_1.ManyToOne(type => Comic_1.Comic, comic => comic.variants), 
    __metadata("design:type", Comic_1.Comic) 
], Variant.prototype, "comic", void 0); 
Variant = __decorate([ 
    typeorm_1.ClassEntityChild() 
], Variant); 
exports.Variant = Variant; 
//# sourceMappingURL=Variant.js.map 

import {Entity, Column, PrimaryGeneratedColumn, OneToMany} from "typeorm"; 
import {Comic} from "./Comic"; 

@Entity() 
export class Series { 

    @PrimaryGeneratedColumn() 
    public id: number; 

    @Column("text", { 
     length: 30 
    }) 
    public copyright: string; 

    @Column("text", { 
     length: 100 
    }) 
    public attributionText: string; 

    @Column("text", { 
     length: 150 
    }) 
    public attributionHTML: string; 

    @Column("text", { 
     length: 50 
    }) 
    public etag: string; 

    @Column("text", { 
     length: 200 
    }) 
    public title: string; 

    @Column("text") 
    public description: string; 

    @Column("number", { 
     length: 4 
    }) 
    public startYear: number; 

    @Column("number", { 
     length: 4 
    }) 
    public endYear: number; 

    @Column("text", { 
     length: 20 
    }) 
    public rating: string; 

    @Column("text", { 
     length: 20 
    }) 
    public type: string; 

    @Column("text") 
    public thumbnail: string; 

    @OneToMany(type => Comic, comic => comic.series) 
    public comics: Array<Comic>; 
} 

import {Entity, TableInheritance, PrimaryGeneratedColumn, Column, ManyToOne, DiscriminatorColumn} from "typeorm"; 
import {Series} from "./Series"; 

@Entity() 
@TableInheritance("class-table") 
@DiscriminatorColumn({ name: "type", type: "string"}) 
export class BaseComic { 

    @PrimaryGeneratedColumn() 
    public id: number; 

    @Column("text", { 
     length: 30 
    }) 
    public copyright: string; 

    @Column("text", { 
     length: 100 
    }) 
    public attributionText: string; 

    @Column("text", { 
     length: 150 
    }) 
    public attributionHTML: string; 

    @Column("text", { 
     length: 50 
    }) 
    public etag: string; 

    @Column("text", { 
     length: 200 
    }) 
    public title: string; 

    @Column("int") 
    public issue: number; 

    @Column("text") 
    public variantDescription: string; 

    @Column("boolean") 
    public variant: boolean; 

    @Column("text") 
    public description: string; 

    @Column("int") 
    public pageCount: number; 

    @Column("date") 
    public onSaleDate: Date; 

    @Column("date") 
    public unlimitedDate: Date; 

    @Column("text") 
    public thumbnail: string; 

    @ManyToOne(type => Series, series => series.comics) 
    public series: Series; 
} 

import {OneToMany, ClassEntityChild} from "typeorm"; 
import {Variant} from "./Variant"; 
import {BaseComic} from "./BaseComic"; 

@ClassEntityChild() 
export class Comic extends BaseComic { 

    @OneToMany(type => Variant, variant => variant.comic) 
    public variants: Variant[]; 
} 

import {ManyToOne, ClassEntityChild} from "typeorm"; 
import {Comic} from "./Comic"; 
import {BaseComic} from "./BaseComic"; 

@ClassEntityChild() 
export class Variant extends BaseComic { 

    @ManyToOne(type => Comic, comic => comic.variants) 
    public comic: Comic; 
} 

उत्तर

11

मैं एक ही मुद्दा रहा था। यह पता चला कि मैं सर्कुलर रूप से कक्षाओं का आयात कर रहा था, जो स्पष्ट रूप से एक सीमा है।

this अन्य उत्तर

+1

मेरे पास ब्राउज़र के साथ एक परिपत्र आयात समस्या थी। यह असंगत और अजीब था - फ़ाइल को संशोधित करना या टिप्पणी करना और चीजों को हटाने और पुन: प्रयास करना कभी-कभी इसे दूर कर देगा। मुश्किल। – user1978019

+1

ध्यान दें कि ऐसा लगता है कि परिपत्र संदर्भ * फाइल * के बीच है, न कि * प्रकार *। तो यहां तक ​​कि जब आपके प्रकार के संदर्भ परिपत्र नहीं होते हैं, तब भी आपके पास इस प्रकार की समस्याएं हो सकती हैं जो आपके प्रकारों में मौजूद हैं। –

संबंधित मुद्दे