Skip to content

AST change proposal: Improve TSModuleDeclaration #6440

@fisker

Description

@fisker

Before You File a Proposal Please Confirm You Have Done The Following...

Relevant Package

ast-spec

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Description

Currently

module a.b {}
^^^^^^^^^^^^^ TSModuleDeclaration(a)
       ^      TSModuleDeclaration(a).id
         ^^^^ TSModuleDeclaration(b)
         ^    TSModuleDeclaration(b).id
           ^^ TSModuleBlock

Can we change it to

module a.b {}
^^^^^^^^^^^^^ TSModuleDeclaration
       ^^^    TSModuleDeclaration.id
           ^^ TSModuleBlock

?

Another problem is we parse the following code as the same ast

namespace a {}
module a {}

Prettier can't distinguish them without the original code. Failure detection

Maybe add TSNamespaceDeclaration or TSModuleDeclaration.namespace?

Fail

N/a

Pass

N/a

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy