Skip to content

Commit c5ef8de

Browse files
committed
fix(formatter): missing semicolon for declare function
1 parent 70c33a9 commit c5ef8de

File tree

3 files changed

+10
-28
lines changed

3 files changed

+10
-28
lines changed

crates/oxc_formatter/src/write/function.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ use crate::{
1717
},
1818
generated::ast_nodes::AstNode,
1919
write,
20-
write::arrow_function_expression::FormatMaybeCachedFunctionBody,
20+
write::{
21+
arrow_function_expression::FormatMaybeCachedFunctionBody, semicolon::OptionalSemicolon,
22+
},
2123
};
2224

2325
#[derive(Copy, Clone, Debug, Default)]
@@ -132,6 +134,10 @@ impl<'a> FormatWrite<'a> for FormatFunction<'a, '_> {
132134
)?;
133135
}
134136

137+
if self.is_ts_declare_function() {
138+
write!(f, [OptionalSemicolon])?;
139+
}
140+
135141
Ok(())
136142
}
137143
}

tasks/coverage/snapshots/formatter_typescript.snap

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ commit: 261630d6
22

33
formatter_typescript Summary:
44
AST Parsed : 8816/8816 (100.00%)
5-
Positive Passed: 8789/8816 (99.69%)
5+
Positive Passed: 8791/8816 (99.72%)
66
Mismatch: tasks/coverage/typescript/tests/cases/compiler/amdLikeInputDeclarationEmit.ts
77

88
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/arrayFromAsync.ts
@@ -25,8 +25,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/jsxNamespaceImplicitImp
2525

2626
Mismatch: tasks/coverage/typescript/tests/cases/compiler/propertyAccessExpressionInnerComments.ts
2727

28-
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/reverseMappedTypeInferenceSameSource1.ts
29-
An implementation cannot be declared in ambient contexts.
3028
Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapValidationClasses.ts
3129

3230
Mismatch: tasks/coverage/typescript/tests/cases/compiler/styledComponentsInstantiaionLimitNotReached.ts
@@ -39,8 +37,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/unionSignaturesWithThis
3937

4038
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/classes/propertyMemberDeclarations/staticPropertyNameConflicts.ts
4139
Classes may not have a static property named prototypeClasses may not have a static property named prototypeClasses may not have a static property named prototypeClasses may not have a static property named prototypeClasses may not have a static property named prototypeClasses may not have a static property named prototype
42-
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/controlFlow/controlFlowAssignmentPatternOrder.ts
43-
An implementation cannot be declared in ambient contexts.
4440
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/expressions/elementAccess/letIdentifierInElementAccess01.ts
4541
Unexpected token
4642
Mismatch: tasks/coverage/typescript/tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts

tasks/prettier_conformance/snapshots/prettier.ts.snap.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ts compatibility: 447/573 (78.01%)
1+
ts compatibility: 467/573 (81.50%)
22

33
# Failed
44

@@ -9,7 +9,6 @@ ts compatibility: 447/573 (78.01%)
99
| jsx/jsx/quotes.js | 💥💥💥💥 | 79.41% |
1010
| jsx/single-attribute-per-line/single-attribute-per-line.js | 💥✨ | 43.37% |
1111
| jsx/text-wrap/test.js | 💥 | 99.56% |
12-
| typescript/ambient/ambient.ts | 💥 | 94.12% |
1312
| typescript/angular-component-examples/15934-computed.component.ts | 💥💥 | 76.92% |
1413
| typescript/angular-component-examples/15934.component.ts | 💥💥 | 53.85% |
1514
| typescript/angular-component-examples/test.component.ts | 💥💥 | 41.18% |
@@ -30,7 +29,6 @@ ts compatibility: 447/573 (78.01%)
3029
| typescript/comments/16065.ts | 💥 | 63.64% |
3130
| typescript/comments/16207.ts | 💥 | 71.43% |
3231
| typescript/comments/16889.ts | 💥 | 62.61% |
33-
| typescript/comments/declare_function.ts | 💥 | 66.67% |
3432
| typescript/comments/location.ts | 💥 | 95.00% |
3533
| typescript/comments/mapped_types.ts | 💥 | 58.82% |
3634
| typescript/comments/method_types.ts | 💥 | 79.49% |
@@ -40,41 +38,28 @@ ts compatibility: 447/573 (78.01%)
4038
| typescript/compiler/anyIsAssignableToObject.ts | 💥 | 75.00% |
4139
| typescript/compiler/contextualSignatureInstantiation2.ts | 💥 | 88.89% |
4240
| typescript/compiler/indexSignatureWithInitializer.ts | 💥 | 75.00% |
43-
| typescript/compiler/privacyGloImport.ts | 💥 | 99.32% |
4441
| typescript/conditional-types/comments.ts | 💥💥 | 60.21% |
4542
| typescript/conditional-types/conditonal-types.ts | 💥💥 | 82.25% |
4643
| typescript/conditional-types/infer-type.ts | 💥💥 | 43.22% |
4744
| typescript/conditional-types/nested-in-condition.ts | 💥✨ | 15.79% |
4845
| typescript/conditional-types/new-ternary-spec.ts | 💥💥 | 52.64% |
4946
| typescript/conditional-types/parentheses.ts | 💥💥 | 60.24% |
50-
| typescript/conformance/ambient/ambientDeclarations.ts | 💥 | 61.54% |
51-
| typescript/conformance/classes/mixinAccessModifiers.ts | 💥 | 99.07% |
5247
| typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts | 💥 | 86.67% |
53-
| typescript/conformance/es6/Symbols/symbolProperty15.ts | 💥 | 73.33% |
54-
| typescript/conformance/types/ambient/ambientDeclarations.ts | 💥 | 90.00% |
55-
| typescript/conformance/types/functions/functionOverloadCompatibilityWithVoid01.ts | 💥 | 75.00% |
56-
| typescript/conformance/types/functions/functionOverloadCompatibilityWithVoid02.ts | 💥 | 75.00% |
57-
| typescript/conformance/types/functions/functionOverloadCompatibilityWithVoid03.ts | 💥 | 75.00% |
5848
| typescript/conformance/types/functions/functionOverloadErrorsSyntax.ts | 💥 | 0.00% |
5949
| typescript/conformance/types/namespaceExportDeclaration/exportAsNamespace.d.ts | 💥 | 75.00% |
60-
| typescript/conformance/types/tuple/wideningTuples1.ts | 💥 | 80.00% |
6150
| typescript/custom/abstract/abstractProperties.ts | 💥 | 75.00% |
6251
| typescript/custom/computedProperties/string.ts | 💥 | 73.33% |
63-
| typescript/custom/declare/declareModifier.d.ts | 💥 | 88.89% |
6452
| typescript/custom/modifiers/minustoken.ts | 💥 | 20.00% |
6553
| typescript/custom/modifiers/question.ts | 💥 | 0.00% |
6654
| typescript/custom/modifiers/readonly.ts | 💥 | 0.00% |
67-
| typescript/declare/declare_function.ts | 💥 | 44.44% |
68-
| typescript/declare/object-type-in-declare-function.ts | 💥 | 43.75% |
69-
| typescript/declare/trailing-comma/function-rest-trailing-comma.ts | 💥💥💥 | 50.00% |
55+
| typescript/declare/object-type-in-declare-function.ts | 💥 | 56.25% |
7056
| typescript/decorators/comments.ts | 💥 | 60.00% |
7157
| typescript/decorators/decorators-comments.ts | 💥 | 65.71% |
7258
| typescript/decorators-ts/angular.ts | 💥 | 87.50% |
7359
| typescript/decorators-ts/typeorm.ts | 💥 | 88.37% |
7460
| typescript/definite/definite.ts | 💥 | 57.14% |
7561
| typescript/definite/without-annotation.ts | 💥 | 25.00% |
7662
| typescript/enum/computed-members.ts | 💥 | 0.00% |
77-
| typescript/export/comment.ts | 💥 | 50.00% |
7863
| typescript/export/export.ts | 💥 | 85.71% |
7964
| typescript/function-type/consistent.ts | 💥 | 70.83% |
8065
| typescript/function-type/type-annotation.ts | 💥 | 0.00% |
@@ -92,9 +77,7 @@ ts compatibility: 447/573 (78.01%)
9277
| typescript/mapped-type/issue-11098.ts | 💥 | 60.00% |
9378
| typescript/mapped-type/break-mode/break-mode.ts | 💥 | 40.00% |
9479
| typescript/method/issue-10352-consistency.ts | 💥 | 63.64% |
95-
| typescript/method/semi.ts | 💥 | 42.86% |
9680
| typescript/module/global.ts | 💥 | 75.00% |
97-
| typescript/module/namespace_function.ts | 💥 | 66.67% |
9881
| typescript/multiparser-css/issue-6259.ts | 💥 | 57.14% |
9982
| typescript/non-null/optional-chain.ts | 💥 | 72.22% |
10083
| typescript/non-null/parens.ts | 💥 | 96.00% |
@@ -111,7 +94,6 @@ ts compatibility: 447/573 (78.01%)
11194
| typescript/rest-type/infer-type.ts | 💥 | 64.00% |
11295
| typescript/satisfies-operators/expression-statement.ts | 💥💥 | 78.38% |
11396
| typescript/satisfies-operators/lhs.ts | 💥✨ | 35.00% |
114-
| typescript/template-literal-types/template-literal-types.ts | 💥 | 93.33% |
11597
| typescript/tuple/dangling-comments.ts | 💥💥💥 | 21.28% |
11698
| typescript/tuple/trailing-comma-for-empty-tuples.ts | 💥💥💥 | 16.67% |
11799
| typescript/tuple/trailing-comma-trailing-rest.ts | 💥💥💥 | 0.00% |
@@ -122,8 +104,6 @@ ts compatibility: 447/573 (78.01%)
122104
| typescript/type-arguments-bit-shift-left-like/3.ts | 💥 | 0.00% |
123105
| typescript/type-arguments-bit-shift-left-like/5.tsx | 💥 | 0.00% |
124106
| typescript/typeof/typeof.ts | 💥 | 25.00% |
125-
| typescript/typeparams/const.ts | 💥 | 96.88% |
126-
| typescript/typeparams/line-breaking-after-extends-2.ts | 💥 | 93.94% |
127107
| typescript/typeparams/empty-parameters-with-arrow-function/issue-13817.ts | 💥 | 73.68% |
128108
| typescript/union/inlining.ts | 💥 | 79.70% |
129109
| typescript/union/union-parens.ts | 💥 | 92.59% |

0 commit comments

Comments
 (0)