Closed anatolyaliev closed 5 months ago
The following piece of code is valid but it is parsed incorrectly:
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm" @Entity() export class User { @PrimaryGeneratedColumn() @Column() id: number; @Column() firstName: string; @Column() lastName: string; @Column() isActive: boolean; }
Here's a link to the TypeScript Playground showing that the snippet above is valid JavaScript or TypeScript:
https://www.typescriptlang.org/play?ssl=1&ssc=1&pln=17&pc=2#code/JYWwDg9gTgLgBAbzgUQHY2DAngGjgBSlAEMosBxAU1UqmJkoBMBhCAGwFcRU9XPu4AXzgAzKBBBwARNjCVoIKQCglAATQZsACgCUSygA9IsOAGM2xAM6W4AVUu1ESuC7irCJMlRp0GLdlyous6uqnyBwa5wwIwAXHCoXABGtADcKlFhAdyRriLAUJYwAHLEIJTxRUSoAObpIS5Z-EF6URZFpeWVMNV1GaHhOa2uwJYAgqYYAG4VcEkQ7JTEqOmCSkA
The output of tree-sitter parse is the following:
tree-sitter parse
[program](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [18, 0] [import_statement](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [0, 64] [import_clause](https://tree-sitter.github.io/tree-sitter/playground#) [0, 7] - [0, 49] [named_imports](https://tree-sitter.github.io/tree-sitter/playground#) [0, 7] - [0, 49] [import_specifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 9] - [0, 15] name: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 9] - [0, 15] [import_specifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 17] - [0, 39] name: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 17] - [0, 39] [import_specifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 41] - [0, 47] name: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 41] - [0, 47] source: [string](https://tree-sitter.github.io/tree-sitter/playground#) [0, 55] - [0, 64] [string_fragment](https://tree-sitter.github.io/tree-sitter/playground#) [0, 56] - [0, 63] [export_statement](https://tree-sitter.github.io/tree-sitter/playground#) [2, 0] - [16, 1] decorator: [decorator](https://tree-sitter.github.io/tree-sitter/playground#) [2, 0] - [2, 9] [call_expression](https://tree-sitter.github.io/tree-sitter/playground#) [2, 1] - [2, 9] function: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [2, 1] - [2, 7] arguments: [arguments](https://tree-sitter.github.io/tree-sitter/playground#) [2, 7] - [2, 9] declaration: [class_declaration](https://tree-sitter.github.io/tree-sitter/playground#) [3, 7] - [16, 1] name: [type_identifier](https://tree-sitter.github.io/tree-sitter/playground#) [3, 13] - [3, 17] body: [class_body](https://tree-sitter.github.io/tree-sitter/playground#) [3, 18] - [16, 1] [decorator](https://tree-sitter.github.io/tree-sitter/playground#) [4, 4] - [4, 29] [call_expression](https://tree-sitter.github.io/tree-sitter/playground#) [4, 5] - [4, 29] function: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [4, 5] - [4, 27] arguments: [arguments](https://tree-sitter.github.io/tree-sitter/playground#) [4, 27] - [4, 29] [decorator](https://tree-sitter.github.io/tree-sitter/playground#) [5, 4] - [5, 13] [call_expression](https://tree-sitter.github.io/tree-sitter/playground#) [5, 5] - [5, 13] function: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [5, 5] - [5, 11] arguments: [arguments](https://tree-sitter.github.io/tree-sitter/playground#) [5, 11] - [5, 13] [public_field_definition](https://tree-sitter.github.io/tree-sitter/playground#) [6, 4] - [6, 14] name: [property_identifier](https://tree-sitter.github.io/tree-sitter/playground#) [6, 4] - [6, 6] type: [type_annotation](https://tree-sitter.github.io/tree-sitter/playground#) [6, 6] - [6, 14] [predefined_type](https://tree-sitter.github.io/tree-sitter/playground#) [6, 8] - [6, 14] [decorator](https://tree-sitter.github.io/tree-sitter/playground#) [8, 4] - [8, 13] [call_expression](https://tree-sitter.github.io/tree-sitter/playground#) [8, 5] - [8, 13] function: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [8, 5] - [8, 11] arguments: [arguments](https://tree-sitter.github.io/tree-sitter/playground#) [8, 11] - [8, 13] [public_field_definition](https://tree-sitter.github.io/tree-sitter/playground#) [9, 4] - [9, 21] name: [property_identifier](https://tree-sitter.github.io/tree-sitter/playground#) [9, 4] - [9, 13] type: [type_annotation](https://tree-sitter.github.io/tree-sitter/playground#) [9, 13] - [9, 21] [predefined_type](https://tree-sitter.github.io/tree-sitter/playground#) [9, 15] - [9, 21] [decorator](https://tree-sitter.github.io/tree-sitter/playground#) [11, 4] - [11, 13] [call_expression](https://tree-sitter.github.io/tree-sitter/playground#) [11, 5] - [11, 13] function: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [11, 5] - [11, 11] arguments: [arguments](https://tree-sitter.github.io/tree-sitter/playground#) [11, 11] - [11, 13] [public_field_definition](https://tree-sitter.github.io/tree-sitter/playground#) [12, 4] - [12, 20] name: [property_identifier](https://tree-sitter.github.io/tree-sitter/playground#) [12, 4] - [12, 12] type: [type_annotation](https://tree-sitter.github.io/tree-sitter/playground#) [12, 12] - [12, 20] [predefined_type](https://tree-sitter.github.io/tree-sitter/playground#) [12, 14] - [12, 20] [decorator](https://tree-sitter.github.io/tree-sitter/playground#) [14, 4] - [14, 13] [call_expression](https://tree-sitter.github.io/tree-sitter/playground#) [14, 5] - [14, 13] function: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [14, 5] - [14, 11] arguments: [arguments](https://tree-sitter.github.io/tree-sitter/playground#) [14, 11] - [14, 13] [public_field_definition](https://tree-sitter.github.io/tree-sitter/playground#) [15, 4] - [15, 21] name: [property_identifier](https://tree-sitter.github.io/tree-sitter/playground#) [15, 4] - [15, 12] type: [type_annotation](https://tree-sitter.github.io/tree-sitter/playground#) [15, 12] - [15, 21] [predefined_type](https://tree-sitter.github.io/tree-sitter/playground#) [15, 14] - [15, 21]
The expected behavior is to have decorators under public_field_definition hierarchy
The following piece of code is valid but it is parsed incorrectly:
Here's a link to the TypeScript Playground showing that the snippet above is valid JavaScript or TypeScript:
https://www.typescriptlang.org/play?ssl=1&ssc=1&pln=17&pc=2#code/JYWwDg9gTgLgBAbzgUQHY2DAngGjgBSlAEMosBxAU1UqmJkoBMBhCAGwFcRU9XPu4AXzgAzKBBBwARNjCVoIKQCglAATQZsACgCUSygA9IsOAGM2xAM6W4AVUu1ESuC7irCJMlRp0GLdlyous6uqnyBwa5wwIwAXHCoXABGtADcKlFhAdyRriLAUJYwAHLEIJTxRUSoAObpIS5Z-EF6URZFpeWVMNV1GaHhOa2uwJYAgqYYAG4VcEkQ7JTEqOmCSkA
The output of
tree-sitter parse
is the following:The expected behavior is to have decorators under public_field_definition hierarchy