javascript - Operator '+' cannot be applied to types 'String' and 'String' in TypeScript -
i new typescript trying play it. face wired problem. when try concatenate 2 string
type using +
operator it's give error
operator '+' cannot applied types 'string' , 'string'
my code snap is
var firstname: string = 'foo'; var lastname: string = 'bar'; var name = firstname + lastname;
if use string
instead string
or add ''
it works fine. checked, within javascript can use +
on 2 string
object why it's show error in typescript ? bug or feature ? missing something. detail explanation appreciated.
string
not same string
. use string
unless really, know you're to.
the upper-case name string
refers boxed version of primitive string. these should avoided wherever possible -- don't behave normal string
s in subtle , unexpected ways (for example typeof new string('hello')
"object"
, not "string"
).
Comments
Post a Comment