Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions common/corpus/declarations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,15 @@ export async function readFile(filename: string): Promise<Buffer>

(program
(export_statement
(function
(function_declaration
(identifier)
(formal_parameters
(required_parameter (identifier) (type_annotation (predefined_type)))
(required_parameter (identifier) (type_annotation (predefined_type))))
(statement_block
(return_statement (object (shorthand_property_identifier) (shorthand_property_identifier))))))
(comment)
(export_statement (class (type_identifier) (class_body)))
(export_statement (class_declaration (type_identifier) (class_body)))
(export_statement (function_signature
(identifier)
(formal_parameters (required_parameter (identifier) (type_annotation (predefined_type))))
Expand Down Expand Up @@ -858,3 +858,22 @@ let a!: b;
(identifier)
(type_annotation
(type_identifier)))))

====================================
Top-level exports
====================================

export default abstract class C { }
export default class C { }
export class C { }
export default interface I { }
export interface I { }

---

(program
(export_statement (abstract_class_declaration (type_identifier) (class_body)))
(export_statement (class_declaration (type_identifier) (class_body)))
(export_statement (class_declaration (type_identifier) (class_body)))
(export_statement (interface_declaration (type_identifier) (object_type)))
(export_statement (interface_declaration (type_identifier) (object_type))))
3 changes: 1 addition & 2 deletions common/define-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ module.exports = function defineGrammar(dialect) {
previous,
seq('export', 'type', $.export_clause),
seq('export', '=', $.identifier, $._semicolon),
seq('export', 'as', 'namespace', $.identifier, $._semicolon),
seq('export', 'default', $.function_signature)
seq('export', 'as', 'namespace', $.identifier, $._semicolon)
),

non_null_expression: $ => prec.left('unary', seq(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"main": "./bindings/node",
"devDependencies": {
"tree-sitter-cli": "^0.19.1",
"tree-sitter-javascript": "github:tree-sitter/tree-sitter-javascript#v0.19.0"
"tree-sitter-javascript": "github:tree-sitter/tree-sitter-javascript#40a1427"
},
"scripts": {
"build": "npm run build-typescript && npm run build-tsx",
Expand Down
55 changes: 28 additions & 27 deletions tsx/src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,34 @@
"value": "default"
},
{
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL",
"name": "expression"
}
},
{
"type": "SYMBOL",
"name": "_semicolon"
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "declaration",
"content": {
"type": "SYMBOL",
"name": "declaration"
}
},
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL",
"name": "expression"
}
},
{
"type": "SYMBOL",
"name": "_semicolon"
}
]
}
]
}
]
}
Expand Down Expand Up @@ -215,23 +233,6 @@
"name": "_semicolon"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "export"
},
{
"type": "STRING",
"value": "default"
},
{
"type": "SYMBOL",
"name": "function_signature"
}
]
}
]
},
Expand Down
4 changes: 0 additions & 4 deletions tsx/src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -1969,10 +1969,6 @@
"type": "export_clause",
"named": true
},
{
"type": "function_signature",
"named": true
},
{
"type": "identifier",
"named": true
Expand Down
Loading