Skip to content

[TS] do not change module into namespace and break/hug them correctly #5533

@ikatyang

Description

@ikatyang

Originally reported by @xcatliu in prettier/tslint-config-prettier#234

Prettier 1.15.2
Playground link

--parser typescript

Input:

module X {}

module X {
  const x = 1;
}

module X {
  module X {}
}

module X {
  module X {
    const x = 1;
  }
}

namespace X {}

namespace X {
  const x = 1;
}

namespace X {
  namespace X {}
}

namespace X {
  namespace X {
    const x = 1;
  }
}

Output:

namespace X {

}

namespace X {
  const x = 1;
}

namespace X {
  namespace X {  }
}

namespace X {
  namespace X { const x = 1; }
}

namespace X {

}

namespace X {
  const x = 1;
}

namespace X {
  namespace X {  }
}

namespace X {
  namespace X { const x = 1; }
}

Expected behavior:
Same as input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions