You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AssemblyScript seems to recognize this syntax and compiles fine:
classX{doSomething(): this {returnthis;}}
However, in AssemblyScript, it always is treated as the class where this is used - which is not necessarily the type of the instance when the object is extended.
classYextendsX{doSomethingElse(): string{return"You made it!";}}
ERROR TS2339: Property 'doSomethingElse' does not exist on type 'assembly/index/X'.
:
12 │ console.log(new Y().doSomething().doSomethingElse());
│ ~~~~~~~~~~~~~~~
└─ in assembly/index.ts(12,35)
Essentially, y.doSomething() is returning a type X where it should return a type Y.
TypeScript tooling believes the value should be Y, but AssemblyScript thinks it's X.
Casting the value using <Y> or as Y works, but the point is that one may have full awareness of the original type when making the call.
AssemblyScript version
v0.27.32
The text was updated successfully, but these errors were encountered:
Bug description
Found via StackOverflow: https://stackoverflow.com/q/79232050/634824
TypeScript allows the
this
keyword to be used as a type.AssemblyScript seems to recognize this syntax and compiles fine:
However, in AssemblyScript, it always is treated as the class where
this
is used - which is not necessarily the type of the instance when the object is extended.Steps to reproduce
With the above code,
fails to compile. The error is:
Essentially,
y.doSomething()
is returning a typeX
where it should return a typeY
.TypeScript tooling believes the value should be
Y
, but AssemblyScript thinks it'sX
.Casting the value using
<Y>
oras Y
works, but the point is that one may have full awareness of the original type when making the call.AssemblyScript version
v0.27.32
The text was updated successfully, but these errors were encountered: