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

esbuild compile typescript error #3111

Closed
wszgrcy opened this issue May 10, 2023 · 1 comment
Closed

esbuild compile typescript error #3111

wszgrcy opened this issue May 10, 2023 · 1 comment

Comments

@wszgrcy
Copy link

wszgrcy commented May 10, 2023

let tag = { start: 0, end: 0 };
  let endColumnIndex = 0;
  console.log(tag.start! < endColumnIndex, tag.end! >= endColumnIndex);

output

{
  warnings: [],
  code: 'let tag = { start: 0, end: 0 };\n' +
    'let endColumnIndex = 0;\n' +
    'console.log(tag.start = endColumnIndex);\n',
  map: '',
  mangleCache: undefined,
  legalComments: undefined
}

code

  let a =await transform(
    `  let tag = { start: 0, end: 0 };
  let endColumnIndex = 0;
  console.log(tag.start! < endColumnIndex, tag.end! >= endColumnIndex);`,
    { loader: 'ts' }
  );
  console.log(a);

version:0.17.18

@hyrious
Copy link

hyrious commented May 10, 2023

This is interesting: https://www.typescriptlang.org/play?#code/FAMw9mAEA8kIwBpICZID5IAoBGBDATgJTBA

foo < 1, 2 >= (bar)
// js: foo < 1, 2 >= (bar)

foo < 1, 2 > (bar)
// js: foo(bar)

Babel seems to handle foo < 1, 2 > bar and for < 1, 2 > (bar) well, but fails at >= too:

foo < 1, 2 >= bar
// Invalid left-hand side in assignment expression.

Sucrase produces the same result as esbuild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants