unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "Jostein Kjønigsen" <jostein@secure.kjonigsen.net>,
	"Yuan Fu" <casouri@gmail.com>,
	59691@debbugs.gnu.org, "Eli Zaretskii" <eliz@gnu.org>
Subject: bug#59691: Html-like constructs fail in typescript
Date: Wed, 30 Nov 2022 14:16:14 +0100	[thread overview]
Message-ID: <5332D6E2-B0C8-423F-B88B-9A9BB4D5D6BF@thornhill.no> (raw)
In-Reply-To: <0c7829a2-b5e0-ca19-e3be-2b568e203bc8@secure.kjonigsen.net>



On 30 November 2022 13:59:20 CET, "Jostein Kjønigsen" <jostein@secure.kjonigsen.net> wrote:
>On 29.11.2022 23:20, Jostein Kjønigsen wrote:
>> 
>>> On 29 Nov 2022, at 22:48, Theodor Thornhill<theo@thornhill.no>  wrote:
>>> 
>>> 
>>> 
>>>> On 29 November 2022 22:37:25 CET, "Jostein Kjønigsen"<jostein@secure.kjonigsen.net>  wrote:
>>>> Nice!
>>>> 
>>>> Should we until further notice assume that js-ts-mode suffers from the same issues, and that a jsx-ts-mode might be needed too? To me it at least sounds plausible.
>>> No, because there are no ambiguities in the grammar with types and jsx.
>>> 
>> Note this behaviour was triggered even when a HTML-tag was contained inside a plain string.
>> 
>> Even without hard typescript casts, there are places where I suspect the same issues can bleed into js-ts-mode.
>> 
>> I’ll try to do more testing tomorrow.
>
>First of all - good news!
>
>Contrary to my expectations, I've tested and I cannot reproduce this issue in js-ts-mode.
>

Yeah, that's what I've seen as well.

>Even more good news:
>
>Looking deeper into this using treesit-explorer-mode (an extremely helpful tool, Yuan!), I found I may have misinterpreted the state of the parse-tree in previous report.
>
>Based on that, I would like to revise this bug report:
>
> * HTML-like constructs inside strings are --/not/-- treated at
>   jsx_opening_elements,

That's correct!

> * only angle-bracket "hard" casts (which isn't present in Javascript)
>   is causing issues for fontification.
>
>Also, reading up, from what I can tell "hard casts" using angle-brackets are no longer encouraged as the default way to cast:
>
>    const service = <IService>object;
>
>This is because the above code will cause a compiler error if used in TSX-files (as opposed to TS-files). Instead "as" expressions are preferred, because they work equally well for both TS & TSX-files:
>
>    const service = object as IService;
>
>That means that writing idiomatic TypeScript with typescrip-ts-mode should produce the expected behaviour, while one may encounter issues with older code.
>
>I'm not sure introducing a new major-mode for this 1 aspect of TypeScript development is worth it?
>
>Does anyone else have an opinion on this?
>
>--
>Jostein

I think that because this is an actual feature it makes sense to have two modes. But defaulting to tsx as the language of choice until now is ok too.

Theo





  reply	other threads:[~2022-11-30 13:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29 20:02 bug#59691: 29.0.60; typescript-ts-mode: any HTML-like elements causes fontification to become invalid and remaining parse-tree to become jsx-expression Jostein Kjønigsen
2022-11-29 21:01 ` bug#59691: Html-like constructs fail in typescript Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-29 21:37   ` Jostein Kjønigsen
2022-11-29 21:47     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]       ` <786DAB7F-F45D-405B-A4E5-4A60FD6CE7A7@secure.kjonigsen.net>
2022-11-30 12:59         ` Jostein Kjønigsen
2022-11-30 13:16           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-11-30 12:35   ` Eli Zaretskii
2022-11-30 13:00     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-30 14:25       ` Eli Zaretskii
2022-11-30 14:47         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-30 10:22 ` bug#59691: 29.0.60; typescript-ts-mode: any HTML-like elements causes fontification to become invalid and remaining parse-tree to become jsx-expression Yuan Fu
2022-11-30 14:09   ` Eli Zaretskii
2022-11-30 15:21     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-30 16:05       ` Eli Zaretskii
2022-11-30 18:10         ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-30 18:19           ` Eli Zaretskii
2022-11-30 18:20             ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-30 18:21             ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-01  6:01               ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-01  7:44                 ` Eli Zaretskii
2022-12-01  8:12                   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-01 10:05                     ` Eli Zaretskii
2022-12-01 10:52                       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-01 12:10                         ` Eli Zaretskii
2022-12-02  4:44                           ` Yuan Fu
2022-12-02 20:29                             ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-02 21:28                               ` Jostein Kjønigsen
2022-12-02 22:54                                 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-03  6:38                                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5332D6E2-B0C8-423F-B88B-9A9BB4D5D6BF@thornhill.no \
    --to=bug-gnu-emacs@gnu.org \
    --cc=59691@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=jostein@secure.kjonigsen.net \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).