Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code comments containing "#bun" causes Bun to not parse TypeScript #15884

Closed
dtinth opened this issue Dec 19, 2024 · 2 comments · Fixed by #15888 or #15912
Closed

Code comments containing "#bun" causes Bun to not parse TypeScript #15884

dtinth opened this issue Dec 19, 2024 · 2 comments · Fixed by #15888 or #15912
Assignees
Labels
bug Something isn't working confirmed bug We can reproduce this issue transpiler parser || printer

Comments

@dtinth
Copy link
Contributor

dtinth commented Dec 19, 2024

What version of Bun is running?

1.1.40+b5b51004e

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

Run this:

// https://bun.sh/docs/api/http#bun-serve
const a: string = "hello";
console.log(a);

What is the expected behavior?

Output should be:

hello

What do you see instead?

SyntaxError is thrown:

1 | // https://bun.sh/docs/api/http#bun-serve
2 | const a: string = "hello";
    ^
SyntaxError: Unexpected token ':'. const declared variable 'a' must have an initializer.
      at <parse> (/Users/dtinth/Projects/elysia-by-example/hello.ts:2:1)
      at native:11:43
note: missing sourcemaps for /Users/dtinth/Projects/elysia-by-example/hello.ts
note: consider bundling with '--sourcemap' to get unminified traces

Bun v1.1.40 (macOS arm64)

Additional information

The repro case can be reduced to:

// #bun
const a: string = "hello";
console.log(a);

Without the comment, it works:

const a: string = "hello";
console.log(a);

With the comment not containing #bun, it works:

// https://bun.sh/docs/api/http#fetch-request-handler
const a: string = "hello";
console.log(a);

With the comment containing #bun immediately followed by an alphanumeric character, it works:

// #bunlai
const a: string = "hello";
console.log(a);
@dtinth dtinth added bug Something isn't working needs triage labels Dec 19, 2024
@Electroid Electroid added transpiler parser || printer and removed needs triage labels Dec 19, 2024
@DonIsaac DonIsaac self-assigned this Dec 20, 2024
@DonIsaac DonIsaac added the confirmed bug We can reproduce this issue label Dec 20, 2024
@DonIsaac DonIsaac linked a pull request Dec 20, 2024 that will close this issue
2 tasks
@dtinth
Copy link
Contributor Author

dtinth commented Dec 20, 2024

Thanks for a speedy fix! 🙏

@Jarred-Sumner Jarred-Sumner reopened this Dec 20, 2024
@Jarred-Sumner
Copy link
Collaborator

We had to revert it due to a regression it caused, but we'll likely get it into the following release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed bug We can reproduce this issue transpiler parser || printer
Projects
None yet
4 participants