Public property of exported class is using private type error in TypeScript

前端 未结 1 927
小鲜肉
小鲜肉 2021-01-17 20:16

C:\\dev\\OpenCMS\\Website\\Frontend\\Scripts\\libs\\sinnovations>tsc sinnovations.listv iewbase.ts --module amd C:/dev/OpenCMS/Website/Frontend/Scripts/li

相关标签:
1条回答
  • 2021-01-17 20:56

    I am afraid you need to define the interface in another file. e.g.

    a.ts:

    interface Column {
        label: string;
    }
    

    and your code :

    /// <reference path="../../typings/knockout/knockout.d.ts" />
    /// <reference path="./a.ts" />
    import ko = require('knockout');
    
    
    var _templateBase = '/Frontend/Templates/ListView/';
    class ListViewBase<T> {
    
        columns: KnockoutObservableArray<Column> = ko.observableArray([]);
        rows: KnockoutObservableArray<T> = ko.observableArray([]); 
    
        constructor(public templateHeaderRow = _templateBase+'DefaultTableHeaderTemplate', public templateBodyRow = _templateBase + 'DefaultTableRowTemplate') {
    
        }
    
        addColumn(column: Column) {
            this.columns.push(column);
        }
    
        addRow(row: T) {
            this.rows.push(row);
        }
    
        static configure(templateBase) {
            _templateBase = templateBase;   
        }
    }
    
    export = ListViewBase;
    
    0 讨论(0)
提交回复
热议问题