typescript - How to declare a property as a subclass -


i have 3rd party lib returns baseclass.

i want add properties baseclass , use it. compile error.

var mysubclass : subclass = methodthatreturnsbaseclass();

compile error:type baseclass not assignable type subclass

interface subclass extends baseclass { title: string; } 

how should written?

how should written?

one possibility:

interface subclass extends baseclass {     title?: string; } 

another:

var mysubclass : subclass = <subclass>methodthatreturnsbaseclass(); 

i prefer method 1 more semantically correct


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -