Comments (3)
The shorthand also sets that variable in the class so you need to emit an assignment.
"use strict";
class Hello {
constructor(hello) {
this.hello = hello;
}
toString() {
return this.hello;
}
}
from bun.
I see the problem.
The code does track this:
But I forgot about the transform afterwards.
from bun.
Fixed in Jarred-Sumner/bun@d91e897
Currently, it follows the semantics of useDefineForClassFields
which TypeScript enables by default when targeting ESNext or ES2022.
The following code:
class Testing {
constructor(private hello: string) {}
toString() {
return this.hello;
}
}
Now transpiles to:
class Testing {
hello;
constructor(hello) {
this.hello = hello;
}
toString() {
return this.hello;
}
}
Note that there is a semantic difference when useDefineForClassFields
is disabled with tsc
. In that case, tsc
removes the property from the class body. When useDefineForClassFields
is disabled, tsc
transpiles to:
class Testing {
constructor(hello) {
this.hello = hello;
}
toString() {
return this.hello;
}
}
Removing unitialized properties can cause a runtime performance problem when instantiating many objects of the same class due to polymorphism. However, for compatibility, it would be best if bun supports that anyway. The original issue was the build error due to private
being used inside of function arguments though.
from bun.
Related Issues (20)
- Executable built with bun build --compile does not work on QEMU Virtual CPU HOT 5
- Type error using prisma
- Memory leak with streaming downloads from azure blob storage HOT 2
- JWS verification error HOT 1
- `bun install` installs optional dependency with optional=false in bunfig.toml
- bun test: "Can't find variable: React" when using key and object spread on JSX element HOT 1
- Version 1.0.14 stills not resolve node_modules with .ts and .js files
- bun update -E doesn't work but --exact works HOT 1
- swipe between "dependencies" and "devDependencies" HOT 1
- Bun.file() crashes with no message given on WSL HOT 1
- Support cloudflare wrangler HOT 2
- [plugin] get import attributes/assertions in plugin
- Help dependabot team to support bun HOT 2
- `bun create elysia myapp` takes a long time and then returns `connection refused` HOT 1
- Bundle 'minify' with 'identifiers' enabled breaks AlpineJS when certain other bundles are present HOT 2
- bun:test expect extra spaces are not highlighted
- bun build can cause unexpected name collisions when minify=false
- Npm package aliases do not write to yarn lock file correctly with --yarn HOT 1
- Can't remove globally installed packages HOT 3
- `%s` in Mocha tests? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bun.