From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= Newsgroups: gmane.emacs.bugs Subject: bug#59691: Html-like constructs fail in typescript Date: Wed, 30 Nov 2022 13:59:20 +0100 Message-ID: <0c7829a2-b5e0-ca19-e3be-2b568e203bc8@secure.kjonigsen.net> References: <1B6E5D5C-3EF3-4FDF-894D-B8577A030EF7@thornhill.no> <786DAB7F-F45D-405B-A4E5-4A60FD6CE7A7@secure.kjonigsen.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------IFFMtIMt6mVswTdeHkiUo2j0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23822"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 To: Theodor Thornhill , Yuan Fu , 59691@debbugs.gnu.org, Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 30 14:00:26 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0MhM-0005z2-HY for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 30 Nov 2022 14:00:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0Mh6-00031w-08; Wed, 30 Nov 2022 08:00:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0Mh2-00031P-1b for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2022 08:00:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0Mh1-0000RL-NX for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2022 08:00:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0Mh0-0004tb-Hy for bug-gnu-emacs@gnu.org; Wed, 30 Nov 2022 08:00:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Nov 2022 13:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59691 X-GNU-PR-Package: emacs Original-Received: via spool by 59691-submit@debbugs.gnu.org id=B59691.166981316918782 (code B ref 59691); Wed, 30 Nov 2022 13:00:02 +0000 Original-Received: (at 59691) by debbugs.gnu.org; 30 Nov 2022 12:59:29 +0000 Original-Received: from localhost ([127.0.0.1]:60831 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0MgS-0004ss-U0 for submit@debbugs.gnu.org; Wed, 30 Nov 2022 07:59:29 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:37887) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0MgR-0004sl-H2 for 59691@debbugs.gnu.org; Wed, 30 Nov 2022 07:59:28 -0500 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 6D8915C00A0; Wed, 30 Nov 2022 07:59:22 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 30 Nov 2022 07:59:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= secure.kjonigsen.net; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1669813162; x= 1669899562; bh=2s4ig7GC+lC/5HsZdOddSRxO9AzRRSijZKIqzo0uG6Q=; b=Z 76Y2LCFzwPfsxnQa7uM89xaqqnw1jInHp5ivW5fgo2F5znIYIqPUqFWCyceyX4YI HqzHnaCoJWsofUM1um3q2e2GYr6mjFNcg3RjfZB8wi5p5G5cSdzkCYx/S9PMV6SN mKljwdfry4VqaMb9MOjKTO1BzYGj/9C1yx5Lu8dATOOJlwgzIZTTd4opXaq1izWc MIc2n78/upx2tBqoAffvrBmqsEP41c8DxCXdF0EZLWRzH5FXXbDegJUjf1x5BSHz SU+Y/ylTqQFQHIbiv2j555VCpo3/hkYymfXObI8HVM0SPG7wD/ax05KTV2xJAusr qQ9uRth96vTGDionpakGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1669813162; x=1669899562; bh=2s4ig7GC+lC/5HsZdOddSRxO9AzR RSijZKIqzo0uG6Q=; b=qTOlV0/1z7elUhRmNNMa8h71q4bX9IGFsCFBFVwRjRBn OL5er9Xu8xt1YOMbi58+XoJVwD02myqi+aHrpBMZenHW8ZuJYIxH9CZI+RJGyg24 slx82x0LZNLD/pIQi2VU3zN91VMWpg4VKXYk3Ic+fVZzJs/n6vwo7a7L07Ogn3HT 2lSZd898XOmUmcZEksjL2Qs5MsxI/FbyPVzT1b/1yteit48reW/as/GaihpWXRSS l6EdPFMsLIi0aM9AlWDbCIPpiLkzsJhFE2ffXONUEHhyAxsI808Vyb7vTP0+O09T 4lBaRdS+9HBW5PtnuGs79quv0e+s5L45fIWOdEC+vg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrtdefgdeggecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpegtkfffgggfuffhvfhfjgesrgdtreertdefjeenucfhrhhomheplfhoshhtvghi nhcumfhjpphnihhgshgvnhcuoehjohhsthgvihhnsehsvggtuhhrvgdrkhhjohhnihhgsh gvnhdrnhgvtheqnecuggftrfgrthhtvghrnhephfekhfffgeelffelffektdetgefftdeu uefgtdeltdekudejtdegleduuddtlefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepjhhoshhtvghinhesshgvtghurhgvrdhkjhhonhhighhs vghnrdhnvght X-ME-Proxy: Feedback-ID: ib2f84088:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Nov 2022 07:59:21 -0500 (EST) Content-Language: nb-NO, en-GB In-Reply-To: <786DAB7F-F45D-405B-A4E5-4A60FD6CE7A7@secure.kjonigsen.net> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249488 Archived-At: This is a multi-part message in MIME format. --------------IFFMtIMt6mVswTdeHkiUo2j0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 29.11.2022 23:20, Jostein Kjønigsen wrote: > >> On 29 Nov 2022, at 22:48, Theodor Thornhill wrote: >> >>  >> >>> On 29 November 2022 22:37:25 CET, "Jostein Kjønigsen" 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. 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, * 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 = 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 --------------IFFMtIMt6mVswTdeHkiUo2j0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.

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,
  • 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
--------------IFFMtIMt6mVswTdeHkiUo2j0--