Skip to content

Error in a case without type annotation. #3666

@lacolaco

Description

@lacolaco

Playground

interface PolymerElement {
  properties?: { [propName: string]: StringConstructor|PolymerElementProperty };
}

interface PolymerElementProperty {
  type: StringConstructor;
}

// Why is this incorrectly implements?
class WithoutTypeAnnotation implements PolymerElement {
    properties = {
        prop1: String,
        prop2: {
            type: String
        }
    };
}

class WithTypeAnnotation implements PolymerElement {
    properties:{ [propName: string]: StringConstructor|PolymerElementProperty } = {
        prop1: String,
        prop2: {
            type: String
        }
    };
}

Both properties are same object, but tsc occurs error in a case without type annotation. Why?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions