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# - SharpDX Toolkit models rendering inside out -

c# - ajax - How to receive data both html and json from server? -