请问大佬ArkTS语法中的联合类型是被弃用了吗,
我这边用联合类型一直报错
let varing: string | number = 'a'
可以正常运行,但我把值改成数字类型就报错
let varing: string | number = 'a'
varing = 100
console。log(varing)
报错提示:
[Compile Result] Argument of type 'number' is not assignable to parameter of type 'string'.
也试过
let varing: string | number = 100
报错提示:
[Compile Result] Argument of type 'number' is not assignable to parameter of type 'string'.