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
classWSPacketEvent{publicstaticname="WSPacketEvent";constructor(publictarget:WS,publicpacket:InPacket){}}functionaddListeners(ws:WS){ws.on(WSPacketEvent.name,this.onPacket);//Runtime error. //TypeError: Cannot assign to read only property 'name' //of function WSPacketEvent(target, packet) }
classWSPacketEvent{//public static name = "WSPacketEvent";constructor(publictarget:WS,publicpacket:InPacket){}}functionaddListeners(ws:WS){ws.on(WSPacketEvent.name,this.onPacket);//Compile error. //Error:(18, 29) TS2339: Property 'name' does not exist on type 'typeof WSPacketEvent'.}
Expected behavior:
Show warning when try to write to class static property named "name"
Do not show error if try to read from class static property named "name", which was not explicitly declared in TS code
TypeScript Version:
1.8.9 --target ES7
The text was updated successfully, but these errors were encountered:
terbooter
changed the title
Should show warning if use "name" as static class property
Show warning if use "name" as static class property
Apr 7, 2016
Actual behavior:
This is because of function's property "name" is read only in ES6
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
If remove assignment
Expected behavior:
TypeScript Version:
1.8.9 --target ES7
The text was updated successfully, but these errors were encountered: