Skip to content

Disable automatic colon insertion before function body #95

@mjambon

Description

@mjambon

This is something I noticed while testing the fix for #93.

The following code is parsed correctly by tree-sitter-javascript parser but incorrectly by tree-sitter-typescript:

function f()
{}

tree-sitter-typescript sees a function_signature followed by a statement_block:

(program [0, 0] - [2, 0]
  (function_signature [0, 0] - [0, 12]
    name: (identifier [0, 9] - [0, 10])
    parameters: (formal_parameters [0, 10] - [0, 12]))
  (statement_block [1, 0] - [1, 2]))

However, the tree-sitter-javascript implementation works fine and gives us a single function_declaration:

(program [0, 0] - [2, 0]
  (function_declaration [0, 0] - [1, 2]
    name: (identifier [0, 9] - [0, 10])
    parameters: (formal_parameters [0, 10] - [0, 12])
    body: (statement_block [1, 0] - [1, 2])))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions