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
{{ message }}
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
My question if how can i declare a class property in prototype based on this proposal?
What's more, i am ok with this proposal, but i am just worried about the already exist babel or TypeScript code may be broken if we allow declare a field without an initializer.
This proposal doesn't have any particular support for declaring (non-method) properties on prototypes. You can still do it through modifying the prototype manually, as before.
It's possible that existing Babel/TypeScript code will break, but for many other language features, we've lived through a change in semantics between earlier transpiler versions and fully compliant implementations.
Let's follow up in microsoft/TypeScript#27644 for the TypeScript compatibility issue. For Babel, the "spec" mode has been compliant in this sense for some time.
From the readme, i see we can declare a field without an initializer, eg:
But i am not sure whether if
bar
will be a instance property or just in prototype? eg:I am ask because there already have plenty differente behavior, eg:
ref: microsoft/TypeScript#2249
@babel/plugin-proposal-class-properties
with{ "loose": true }
: in instanceref: babel/babel#7391
The text was updated successfully, but these errors were encountered: