JsModule { bom_token: missing (optional), interpreter_token: missing (optional), directives: JsDirectiveList [], items: JsModuleItemList [ JsBogusStatement { items: [ DECLARE_KW@0..8 "declare" [] [Whitespace(" ")], JsBogusStatement { items: [ FUNCTION_KW@8..17 "function" [] [Whitespace(" ")], JsIdentifierBinding { name_token: IDENT@17..21 "test" [] [], }, TsTypeParameters { l_angle_token: L_ANGLE@21..22 "<" [] [], items: TsTypeParameterList [ TsTypeParameter { modifiers: TsTypeParameterModifierList [], name: TsTypeParameterName { ident_token: IDENT@22..23 "A" [] [], }, constraint: missing (optional), default: missing (optional), }, ], r_angle_token: R_ANGLE@23..24 ">" [] [], }, JsParameters { l_paren_token: L_PAREN@24..25 "(" [] [], items: JsParameterList [ JsFormalParameter { decorators: JsDecoratorList [], binding: JsIdentifierBinding { name_token: IDENT@25..26 "a" [] [], }, question_mark_token: missing (optional), type_annotation: TsTypeAnnotation { colon_token: COLON@26..28 ":" [] [Whitespace(" ")], ty: TsReferenceType { name: JsReferenceIdentifier { value_token: IDENT@28..29 "A" [] [], }, type_arguments: missing (optional), }, }, initializer: missing (optional), }, ], r_paren_token: R_PAREN@29..30 ")" [] [], }, TsReturnTypeAnnotation { colon_token: COLON@30..32 ":" [] [Whitespace(" ")], ty: TsStringType { string_token: STRING_KW@32..39 "string" [] [Whitespace(" ")], }, }, JsFunctionBody { l_curly_token: L_CURLY@39..41 "{" [] [Whitespace(" ")], directives: JsDirectiveList [], statements: JsStatementList [ JsReturnStatement { return_token: RETURN_KW@41..48 "return" [] [Whitespace(" ")], argument: JsStringLiteralExpression { value_token: JS_STRING_LITERAL@48..78 "\"ambient function with a body\"" [] [], }, semicolon_token: SEMICOLON@78..80 ";" [] [Whitespace(" ")], }, ], r_curly_token: R_CURLY@80..81 "}" [] [], }, ], }, ], }, ], eof_token: EOF@81..82 "" [Newline("\n")] [], } 0: JS_MODULE@0..82 0: (empty) 1: (empty) 2: JS_DIRECTIVE_LIST@0..0 3: JS_MODULE_ITEM_LIST@0..81 0: JS_BOGUS_STATEMENT@0..81 0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")] 1: JS_BOGUS_STATEMENT@8..81 0: FUNCTION_KW@8..17 "function" [] [Whitespace(" ")] 1: JS_IDENTIFIER_BINDING@17..21 0: IDENT@17..21 "test" [] [] 2: TS_TYPE_PARAMETERS@21..24 0: L_ANGLE@21..22 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@22..23 0: TS_TYPE_PARAMETER@22..23 0: TS_TYPE_PARAMETER_MODIFIER_LIST@22..22 1: TS_TYPE_PARAMETER_NAME@22..23 0: IDENT@22..23 "A" [] [] 2: (empty) 3: (empty) 2: R_ANGLE@23..24 ">" [] [] 3: JS_PARAMETERS@24..30 0: L_PAREN@24..25 "(" [] [] 1: JS_PARAMETER_LIST@25..29 0: JS_FORMAL_PARAMETER@25..29 0: JS_DECORATOR_LIST@25..25 1: JS_IDENTIFIER_BINDING@25..26 0: IDENT@25..26 "a" [] [] 2: (empty) 3: TS_TYPE_ANNOTATION@26..29 0: COLON@26..28 ":" [] [Whitespace(" ")] 1: TS_REFERENCE_TYPE@28..29 0: JS_REFERENCE_IDENTIFIER@28..29 0: IDENT@28..29 "A" [] [] 1: (empty) 4: (empty) 2: R_PAREN@29..30 ")" [] [] 4: TS_RETURN_TYPE_ANNOTATION@30..39 0: COLON@30..32 ":" [] [Whitespace(" ")] 1: TS_STRING_TYPE@32..39 0: STRING_KW@32..39 "string" [] [Whitespace(" ")] 5: JS_FUNCTION_BODY@39..81 0: L_CURLY@39..41 "{" [] [Whitespace(" ")] 1: JS_DIRECTIVE_LIST@41..41 2: JS_STATEMENT_LIST@41..80 0: JS_RETURN_STATEMENT@41..80 0: RETURN_KW@41..48 "return" [] [Whitespace(" ")] 1: JS_STRING_LITERAL_EXPRESSION@48..78 0: JS_STRING_LITERAL@48..78 "\"ambient function with a body\"" [] [] 2: SEMICOLON@78..80 ";" [] [Whitespace(" ")] 3: R_CURLY@80..81 "}" [] [] 4: EOF@81..82 "" [Newline("\n")] [] -- ts_declare_function_with_body.ts:1:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × A 'declare' function cannot have a function body > 1 │ declare function test(a: A): string { return "ambient function with a body"; } │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 │ i remove this body -- declare function test(a: A): string { return "ambient function with a body"; }