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

Poul K. Sørensen

C:\dev\OpenCMS\Website\Frontend\Scripts\libs\sinnovations>tsc sinnovations.listv iewbase.ts --module amd C:/dev/OpenCMS/Website/Frontend/Scripts/libs/sinnovations/sinnovations.listviewb ase.ts(11,5): error TS2025: Public property 'columns' of exported class has or i s using private type 'KnockoutObservableArray'.

/// <reference path="../../typings/knockout/knockout.d.ts" />
import ko = require('knockout');

interface Column {
    label: string;
}

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;

I understand the error, but dont know how else to get the effect of above. Anyone have a solution to export some interfaces along a class that is exported as export = class?

basarat

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;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Typescript error : Property defined as private on type Class is defined as public on type Interface

From Dev

Typescript error : Property defined as private on type Class is defined as public on type Interface

From Dev

Exported variable has or is using private type TypeScript error

From Dev

Understanding "public" / "private" in typescript class

From Dev

Typescript: Difference between declaring class variables using private, public and nothing

From Dev

Typescript: Type of exported AMD class not found

From Dev

Typescript error: A private property is missing?

From Dev

Private class as return type from public method

From Dev

Why does my private array give me an inconsistent accessibility error using a public property to get it

From Dev

TypeScript dynamic property type on class

From Dev

Type mismatch error : passing class public get property as argument to sub procedure

From Dev

Modify class private outside class without using public method

From Dev

Public constructor of a private class

From Dev

Class (private and public)

From Dev

class declaration - Property does not exist on type in TypeScript

From Dev

Cast JSON array as type for Typescript class property

From Dev

Inheritance TypeScript with exported class and modules

From Dev

Reasons using combination of public, private, protected and class / variable?

From Dev

Private property / public getter - javascript

From Dev

readonly public, readwrite private property

From Dev

Private property / public getter - javascript

From Dev

Public to private using reflection

From Dev

Public vs Private in Typescript Constructors

From Dev

Typescript Error: Property 'mapType' is missing in type '{}'

From Dev

Inconsistent accessibility: property type - How to solve it if both class and list was public

From Dev

Private property in class implementation

From Dev

How to match exported OpenPGP public and private key pairs?

From Dev

Public members in package private class

From Dev

Is a class by default public, private or internal

Related Related

  1. 1

    Typescript error : Property defined as private on type Class is defined as public on type Interface

  2. 2

    Typescript error : Property defined as private on type Class is defined as public on type Interface

  3. 3

    Exported variable has or is using private type TypeScript error

  4. 4

    Understanding "public" / "private" in typescript class

  5. 5

    Typescript: Difference between declaring class variables using private, public and nothing

  6. 6

    Typescript: Type of exported AMD class not found

  7. 7

    Typescript error: A private property is missing?

  8. 8

    Private class as return type from public method

  9. 9

    Why does my private array give me an inconsistent accessibility error using a public property to get it

  10. 10

    TypeScript dynamic property type on class

  11. 11

    Type mismatch error : passing class public get property as argument to sub procedure

  12. 12

    Modify class private outside class without using public method

  13. 13

    Public constructor of a private class

  14. 14

    Class (private and public)

  15. 15

    class declaration - Property does not exist on type in TypeScript

  16. 16

    Cast JSON array as type for Typescript class property

  17. 17

    Inheritance TypeScript with exported class and modules

  18. 18

    Reasons using combination of public, private, protected and class / variable?

  19. 19

    Private property / public getter - javascript

  20. 20

    readonly public, readwrite private property

  21. 21

    Private property / public getter - javascript

  22. 22

    Public to private using reflection

  23. 23

    Public vs Private in Typescript Constructors

  24. 24

    Typescript Error: Property 'mapType' is missing in type '{}'

  25. 25

    Inconsistent accessibility: property type - How to solve it if both class and list was public

  26. 26

    Private property in class implementation

  27. 27

    How to match exported OpenPGP public and private key pairs?

  28. 28

    Public members in package private class

  29. 29

    Is a class by default public, private or internal

HotTag

Archive