TypeScript: public/private class constructor argument does not transpile default parameter #8692
Labels
area: typescript
Has PR
i: bug
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
Bug Report
Current Behavior
The
public
/private
keywords in a class constructor's argument prevents the default parameter from being transpiled.Input Code
The typescript preset doesn't seem to work in the REPL, just add the
@babel/plugin-transform-typescript
to check the results.Expected behavior/code
I've enabled the env preset, configured to target ie11, so the default parameter should be transpiled to something ie11 can work with.
The transpiled code looks like this:
Babel Configuration (.babelrc, package.json, cli command)
Environment
Possible Solution
Removing the
public
/private
keywords does generate good code:You can also check how TS transpiles this piece of code: https://www.typescriptlang.org/play/#src=export%20default%20class%20Example%20%7B%0D%0A%20%20constructor(public%20arg1%20%3D%20null)%20%7B%20%7D%0D%0A%7D
Additional context/Screenshots
this.arg1 = arg1;
is also missing from the constructor, as you can see from the TS transpilation result above. This is already addressed there: #7074 #8669 #8682The text was updated successfully, but these errors were encountered: