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

Parse error in class method with return type and < #1590

Closed
unlessgames opened this issue Nov 10, 2024 · 1 comment · Fixed by #1591
Closed

Parse error in class method with return type and < #1590

unlessgames opened this issue Nov 10, 2024 · 1 comment · Fixed by #1591
Assignees
Labels
bug Something isn't working typescript TypeScript compatibility or extensions

Comments

@unlessgames
Copy link

unlessgames commented Nov 10, 2024

Trying to upgrade to newer civet version (from 0.6.x), I get some errors in my code, like this won't parse anymore

class A
  fn(i: number): string
    if i < 10
      "a"
    else # <--- parse error here 
      "b"

The same thing parses fine outside of a class

fn := (i: number) : string =>
    if i < 10
      "a"
    else 
      "b"

or using do

class A
  fn(i: number) : string do
    if i < 10
      "a"
    else 
      "b"
@bbrk24
Copy link
Contributor

bbrk24 commented Nov 10, 2024

The same thing parses fine outside of a class

fn := (i: number) : string =>
    if i < 10
      "a"
    else 
      "b"

The reason this works is because it's an arrow. Using a function instead also doesn't parse:

function fn(i: number): string
    if i < 10
      "a"
    else 
      "b"

@edemaine edemaine added bug Something isn't working typescript TypeScript compatibility or extensions labels Nov 10, 2024
@edemaine edemaine self-assigned this Nov 10, 2024
edemaine added a commit that referenced this issue Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typescript TypeScript compatibility or extensions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants