Align empty module declaration with TS (#19568)
This commit is contained in:
1 parent
a4e6f7a026
commit
6394c73209
7 files changed
+38
-14
No files matched your search
@@ -0,0 +1,14 @@
|
|||||||
|
#### Stop enforcing empty module declaration to break (#19568 by @fisker)
|
||||||
|
|
||||||
|
<!-- prettier-ignore -->
|
||||||
|
```flow
|
||||||
|
// Input
|
||||||
|
declare module "foo" {}
|
||||||
|
|
||||||
|
// Prettier stable
|
||||||
|
declare module "foo" {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prettier main
|
||||||
|
declare module "foo" {}
|
||||||
|
```
|
||||||
@@ -48,6 +48,7 @@ function printBlock(path, options, print) {
|
|||||||
parent.type === "ModuleExpression" ||
|
parent.type === "ModuleExpression" ||
|
||||||
(parent.type === "CatchClause" && !parentParent.finalizer) ||
|
(parent.type === "CatchClause" && !parentParent.finalizer) ||
|
||||||
parent.type === "TSModuleDeclaration" ||
|
parent.type === "TSModuleDeclaration" ||
|
||||||
|
parent.type === "DeclareModule" ||
|
||||||
parent.type === "MatchStatementCase" ||
|
parent.type === "MatchStatementCase" ||
|
||||||
node.type === "StaticBlock"
|
node.type === "StaticBlock"
|
||||||
)) {
|
)) {
|
||||||
|
|||||||
@@ -22,11 +22,9 @@ declare module bar {
|
|||||||
// that we implicitly assume in type-at-pos and coverage implementations. In
|
// that we implicitly assume in type-at-pos and coverage implementations. In
|
||||||
// particular, when unchecked it causes a crash with coverage --color.
|
// particular, when unchecked it causes a crash with coverage --color.
|
||||||
|
|
||||||
declare module foo {
|
declare module foo {}
|
||||||
}
|
|
||||||
|
|
||||||
declare module bar {
|
declare module bar {}
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
@@ -46,8 +44,7 @@ declare module foo {
|
|||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
// check coverage of declare module
|
// check coverage of declare module
|
||||||
|
|
||||||
declare module foo {
|
declare module foo {}
|
||||||
}
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
`;
|
`;
|
||||||
@@ -92,11 +89,9 @@ declare class qux {
|
|||||||
// that we implicitly assume in type-at-pos and coverage implementations. In
|
// that we implicitly assume in type-at-pos and coverage implementations. In
|
||||||
// particular, when unchecked it causes non-termination with coverage --color.
|
// particular, when unchecked it causes non-termination with coverage --color.
|
||||||
|
|
||||||
declare module foo {
|
declare module foo {}
|
||||||
}
|
|
||||||
|
|
||||||
declare module bar {
|
declare module bar {}
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ declare module "foo" {
|
|||||||
declare var bar: string
|
declare var bar: string
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module baz {
|
declare module baz {}
|
||||||
}
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
`;
|
`;
|
||||||
@@ -66,8 +65,7 @@ declare module "foo" {
|
|||||||
declare var bar: string;
|
declare var bar: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module baz {
|
declare module baz {}
|
||||||
}
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
`;
|
`;
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||||
|
|
||||||
|
exports[`empty.ts format 1`] = `
|
||||||
|
====================================options=====================================
|
||||||
|
parsers: ["typescript", "flow"]
|
||||||
|
printWidth: 80 (default) |
|
||||||
|
=====================================input======================================
|
||||||
|
declare module "foo" {}
|
||||||
|
|
||||||
|
=====================================output=====================================
|
||||||
|
declare module "foo" {}
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
`;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
declare module "foo" {}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
runFormatTest(import.meta, ["typescript", "flow"]);
|
||||||
Reference in new issue
Block a user