Subject: Re: bug#77369: typescript-ts-mode's defun definition is wrong

From: Yuan Fu <[email-masked]>
Date: Thu, 3 Apr 2025 00:46:04 -0700

> On Apr 3, 2025, at 12:30 AM, Eli Zaretskii <[email-masked]> wrote:
> 
>> From: Daniel Colascione <[email-masked]>
>> Date: Sat, 29 Mar 2025 14:17:15 -0400
>> 
>> Not sure whether this is a bug or just surprising design, but in this
>> code:
>> 
>>    function Blah(foo) {
>>      const foo = 1;
>>      const bar = 2;
>>    }
>> 
>> with point on "const foo", I do not expect end-of-defun to go to "const
>> bar".  I expect it to go to the closing curly brace.
> 
> Juri and Yuan, any comments or suggestions?

I pushed a fix for it. Maybe my message got lost? Though now that I think of it, I should’ve pushed the fix to emacs-30 instead of master...

Below is my last message:
> 
> Yeah, that’s because const foo = 1; is a “lexical_declaration”, which is considered a defunct in typescript-ts-mode, because in js you can have arrow functions like
> 
> const Blah = (foo) => {
>  return true;
> };
> 
> Which is also a “lexical_declaration”. I guess we can refine the pattern matching to check if it’s an arrow function and only then consider it a defun.
> 
> I did that, now on latest master, end-of-defun should move to the end of the function in your example.
> 
Yuan