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 -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -