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
12 changes: 12 additions & 0 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,18 @@ bool tree_sitter_rescript_external_scanner_scan(
}
}
}
} else if (lexer->lookahead == 'w') {
advance(lexer);
if (lexer->lookahead == 'i') {
advance(lexer);
if (lexer->lookahead == 't') {
advance(lexer);
if (lexer->lookahead == 'h') {
// Ignore new lines before `with` keyword (module type constraints)
in_multiline_statement = true;
}
}
}
}

if (in_multiline_statement) {
Expand Down
60 changes: 60 additions & 0 deletions test/corpus/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,66 @@ module M = (Na: N, Nb: N): (
(type_identifier)))))
body: (block)))))

================================================================================
Module with type constraint
================================================================================

module LogResultDecoder: OnpingStdLib_PubSub.FromJSON
with type t = AlarmMixLogBatchTypes.batchResult = {
type t = AlarmMixLogBatchTypes.batchResult
let fromJSON = (json: JSON.t): result<t, string> => {
AlarmMixLogBatchTypes.decodeBatchResult(json)
}
}

--------------------------------------------------------------------------------

(source_file
(module_declaration
(module_binding
name: (module_identifier)
signature: (module_type_constraint
(module_identifier_path
(module_identifier)
(module_identifier))
(constrain_type
(type_identifier)
(type_identifier_path
(module_identifier)
(type_identifier))))
definition: (block
(type_declaration
(type_binding
name: (type_identifier)
(type_identifier_path
(module_identifier)
(type_identifier))))
(let_declaration
(let_binding
pattern: (value_identifier)
body: (function
parameters: (formal_parameters
(parameter
(value_identifier)
(type_annotation
(type_identifier_path
(module_identifier)
(type_identifier)))))
return_type: (type_annotation
(generic_type
(type_identifier)
(type_arguments
(type_identifier)
(type_identifier))))
body: (block
(expression_statement
(call_expression
function: (value_identifier_path
(module_identifier)
(value_identifier))
arguments: (arguments
(value_identifier))))))))))))

================================================================================
Dynamic imports
================================================================================
Expand Down