Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print declare and export keywords for nested namespace #15249

Merged
merged 5 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions changelog_unreleased/typescript/15249.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#### Print `declare` and `export` keywords for nested namespace (#15249 by @sosukesuzuki)

<!-- prettier-ignore -->
```tsx
// Input
declare namespace abc1.def {}
export namespace abc2.def {}

// Prettier stable
namespace abc1.def {}
namespace abc2.def {}

// Prettier main
declare namespace abc1.def {}
export namespace abc2.def {}
```
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"@iarna/toml": "2.2.5",
"@prettier/is-es5-identifier-name": "0.2.0",
"@prettier/parse-srcset": "3.1.0",
"@typescript-eslint/typescript-estree": "6.3.0",
"@typescript-eslint/visitor-keys": "6.3.0",
"@typescript-eslint/typescript-estree": "6.4.0",
"@typescript-eslint/visitor-keys": "6.4.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you upgrade @typescript-eslint/eslint-plugin too? So the dependencies doesn't get duplicated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 5cdb8a6

"acorn": "8.10.0",
"acorn-jsx": "5.3.2",
"angular-estree-parser": "7.0.0",
Expand Down
42 changes: 42 additions & 0 deletions tests/format/typescript/module/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,45 @@ namespace X {

================================================================================
`;

exports[`namespace_nested.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
declare namespace abc1.def {}

export declare namespace abc2.def {}

export namespace abc3.def {}

namespace abc4.def {}

declare namespace abc5.def.ghi {}

export declare namespace abc2.def.ghi {}

export namespace abc3.def.ghi {}

namespace abc4.def.ghi {}

=====================================output=====================================
declare namespace abc1.def {}

export declare namespace abc2.def {}

export namespace abc3.def {}

namespace abc4.def {}

declare namespace abc5.def.ghi {}

export declare namespace abc2.def.ghi {}

export namespace abc3.def.ghi {}

namespace abc4.def.ghi {}

================================================================================
`;
15 changes: 15 additions & 0 deletions tests/format/typescript/module/namespace_nested.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
declare namespace abc1.def {}

export declare namespace abc2.def {}

export namespace abc3.def {}

namespace abc4.def {}

declare namespace abc5.def.ghi {}

export declare namespace abc2.def.ghi {}

export namespace abc3.def.ghi {}

namespace abc4.def.ghi {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also replace namespace with module keyword, and test them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 4c60892

39 changes: 37 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,13 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/types@npm:6.4.0":
version: 6.4.0
resolution: "@typescript-eslint/types@npm:6.4.0"
checksum: 85b293ad1559dbf8103b2c4cfd0db11c3d9c970d502e2c13d4b1d35e420567042d7077a716d2b4e5113286314d5260f378f242a6dd22ad4b94b4aa69c5f79223
languageName: node
linkType: hard

"@typescript-eslint/typescript-estree@npm:5.61.0":
version: 5.61.0
resolution: "@typescript-eslint/typescript-estree@npm:5.61.0"
Expand Down Expand Up @@ -1913,6 +1920,24 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/typescript-estree@npm:6.4.0":
version: 6.4.0
resolution: "@typescript-eslint/typescript-estree@npm:6.4.0"
dependencies:
"@typescript-eslint/types": 6.4.0
"@typescript-eslint/visitor-keys": 6.4.0
debug: ^4.3.4
globby: ^11.1.0
is-glob: ^4.0.3
semver: ^7.5.4
ts-api-utils: ^1.0.1
peerDependenciesMeta:
typescript:
optional: true
checksum: a8db3896550515d0adf140ee115527b409916c4a14ac1f45b5623d130a27ae2d08a1ac906ceda440b01167c88846e2b91ca2025f3d718bff389948f66990c1e7
languageName: node
linkType: hard

"@typescript-eslint/utils@npm:6.3.0":
version: 6.3.0
resolution: "@typescript-eslint/utils@npm:6.3.0"
Expand Down Expand Up @@ -1968,6 +1993,16 @@ __metadata:
languageName: node
linkType: hard

"@typescript-eslint/visitor-keys@npm:6.4.0":
version: 6.4.0
resolution: "@typescript-eslint/visitor-keys@npm:6.4.0"
dependencies:
"@typescript-eslint/types": 6.4.0
eslint-visitor-keys: ^3.4.1
checksum: 42eb614b9c0a49b6929e093757d772fd27fe5dda9c75f4c7820d1710012c8257eea9bd4f1c4173e2265a8a9ad86cefc1a21869893e7304f3b29b94fa1f987554
languageName: node
linkType: hard

"abbrev@npm:^1.0.0":
version: 1.1.1
resolution: "abbrev@npm:1.1.1"
Expand Down Expand Up @@ -7019,8 +7054,8 @@ __metadata:
"@types/find-cache-dir": 3.2.1
"@types/jest": 29.5.3
"@typescript-eslint/eslint-plugin": 6.3.0
"@typescript-eslint/typescript-estree": 6.3.0
"@typescript-eslint/visitor-keys": 6.3.0
"@typescript-eslint/typescript-estree": 6.4.0
"@typescript-eslint/visitor-keys": 6.4.0
acorn: 8.10.0
acorn-jsx: 5.3.2
angular-estree-parser: 7.0.0
Expand Down