diff --git a/crates/oxc_ast/src/serialize.rs b/crates/oxc_ast/src/serialize.rs index 8dcee041ec310..efdc7ac605388 100644 --- a/crates/oxc_ast/src/serialize.rs +++ b/crates/oxc_ast/src/serialize.rs @@ -109,7 +109,8 @@ impl ESTree for ProgramConverter<'_, '_> { } else if let Some(first_stmt) = program.body.first() { first_stmt.span().start } else { - program.span.start + // If program contains no statements or directives, span start = span end + program.span.end } } else { program.span.start diff --git a/tasks/coverage/snapshots/estree_typescript.snap b/tasks/coverage/snapshots/estree_typescript.snap index 5dc6eee5df75d..41cb9ba4bf184 100644 --- a/tasks/coverage/snapshots/estree_typescript.snap +++ b/tasks/coverage/snapshots/estree_typescript.snap @@ -2,7 +2,7 @@ commit: 15392346 estree_typescript Summary: AST Parsed : 10619/10725 (99.01%) -Positive Passed: 8832/10725 (82.35%) +Positive Passed: 8851/10725 (82.53%) Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts A class member cannot have the 'const' keyword. Mismatch: tasks/coverage/typescript/tests/cases/compiler/abstractPropertyInConstructor.ts @@ -74,7 +74,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/awaitedTypeStrictNull.t Mismatch: tasks/coverage/typescript/tests/cases/compiler/baseCheck.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/bigintWithLib.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/bigintWithoutLib.ts -Mismatch: tasks/coverage/typescript/tests/cases/compiler/bind2.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/bluebirdStaticThis.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/bom-utf8.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/capturedLetConstInLoop12.ts @@ -299,7 +298,6 @@ Unexpected estree file content error: 2 != 3 Mismatch: tasks/coverage/typescript/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration1.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/duplicateIdentifierBindingElementInParameterDeclaration2.ts -Mismatch: tasks/coverage/typescript/tests/cases/compiler/duplicateIdentifierShouldNotShortCircuitBaseTypeBinding.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/duplicateLocalVariable1.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/duplicateLocalVariable2.ts tasks/coverage/typescript/tests/cases/compiler/elidedJSImport1.ts @@ -314,7 +312,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitBOM.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitBundleWithPrologueDirectives1.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts -Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitCommentsOnlyFile.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitHelpersWithLocalCollisions.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitMemberAccessExpression.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts @@ -384,7 +381,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/exportEqualsProperty.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/exportImportAndClodule.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/exportImportCanSubstituteConstEnumForValue.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/exportObjectRest.ts -Mismatch: tasks/coverage/typescript/tests/cases/compiler/exportStarFromEmptyModule.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/expressionWithJSDocTypeArguments.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts tasks/coverage/typescript/tests/cases/compiler/extendsUntypedModule.ts @@ -529,7 +525,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/isolatedDeclarationsAdd tasks/coverage/typescript/tests/cases/compiler/isolatedDeclarationsAllowJs.ts Unexpected estree file content error: 1 != 2 -Mismatch: tasks/coverage/typescript/tests/cases/compiler/isolatedModulesReExportAlias.ts tasks/coverage/typescript/tests/cases/compiler/jsDeclarationEmitExportedClassWithExtends.ts Unexpected estree file content error: 3 != 4 @@ -661,9 +656,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/letDeclarations- Expected a semicolon or an implicit semicolon after a statement, but found none Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/letDeclarations-validContexts.ts Expected a semicolon or an implicit semicolon after a statement, but found none -Mismatch: tasks/coverage/typescript/tests/cases/compiler/libCompileChecks.ts -Mismatch: tasks/coverage/typescript/tests/cases/compiler/libTypeScriptSubfileResolving.ts -Mismatch: tasks/coverage/typescript/tests/cases/compiler/libTypeScriptSubfileResolvingConfig.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/lift.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/literals-negative.ts Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/literalsInComputedProperties1.ts @@ -745,7 +737,6 @@ Unexpected estree file content error: 3 != 5 tasks/coverage/typescript/tests/cases/compiler/moduleResolutionWithSuffixes_one_jsModule.ts Unexpected estree file content error: 1 != 3 -Mismatch: tasks/coverage/typescript/tests/cases/compiler/moduleResolutionWithSymlinks_referenceTypes.ts tasks/coverage/typescript/tests/cases/compiler/moduleResolution_classicPrefersTs.ts Unexpected estree file content error: 2 != 3 @@ -944,10 +935,8 @@ Unexpected estree file content error: 1 != 3 Mismatch: tasks/coverage/typescript/tests/cases/compiler/signatureCombiningRestParameters3.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/signatureCombiningRestParameters4.ts -Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMap-Comment1.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMap-Comments.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMap-FileWithComments.ts -Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMap-SingleSpace1.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapForFunctionWithCommentPrecedingStatement01.ts Mismatch: tasks/coverage/typescript/tests/cases/compiler/sourceMapSample.ts @@ -1207,7 +1196,6 @@ Expected `,` but found `is` Mismatch: tasks/coverage/typescript/tests/cases/conformance/controlFlow/controlFlowAliasing.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/controlFlow/controlFlowAssignmentPatternOrder.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/declarationEmit/declarationEmitWorkWithInlineComments.ts -Mismatch: tasks/coverage/typescript/tests/cases/conformance/declarationEmit/typeReferenceRelatedFiles.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor2.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor3.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor4.ts @@ -1880,8 +1868,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/conformance/externalModules/type tasks/coverage/typescript/tests/cases/conformance/externalModules/typeOnly/importSpecifiers_js.ts Unexpected estree file content error: 1 != 2 -Mismatch: tasks/coverage/typescript/tests/cases/conformance/externalModules/typeOnly/importsNotUsedAsValues_error.ts -Mismatch: tasks/coverage/typescript/tests/cases/conformance/externalModules/verbatimModuleSyntaxNoElisionCJS.ts Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/functions/functionOverloadErrorsSyntax.ts A rest parameter must be last in a parameter list Mismatch: tasks/coverage/typescript/tests/cases/conformance/functions/functionParameterObjectRestAndInitializers.ts @@ -1895,7 +1881,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/conformance/internalModules/Decl Mismatch: tasks/coverage/typescript/tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.ts -Mismatch: tasks/coverage/typescript/tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStringIndexerAndExportedFunctionWithTypeIncompatibleWithIndexer.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleWithSameNameAndCommonRoot.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleWithSameNameAndCommonRootES6.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/internalModules/DeclarationMerging/EnumAndModuleWithSameNameAndCommonRoot.ts @@ -2462,7 +2447,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/p Mismatch: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/parserRealSource6.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/parserRealSource8.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/parserS7.2_A1.5_T2.ts -Mismatch: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/parserS7.6.1.1_A1.10.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/parserS7.6_A4.2_T1.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/parserSyntaxWalker.generated.ts Mismatch: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript5/parserUnicode2.ts @@ -2480,9 +2464,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement22.ts The left-hand side of a `for...of` statement may not be `async` Mismatch: tasks/coverage/typescript/tests/cases/conformance/pedantic/noUncheckedIndexedAccessDestructuring.ts -Mismatch: tasks/coverage/typescript/tests/cases/conformance/references/library-reference-4.ts -Mismatch: tasks/coverage/typescript/tests/cases/conformance/references/library-reference-5.ts -Mismatch: tasks/coverage/typescript/tests/cases/conformance/references/library-reference-scoped-packages.ts tasks/coverage/typescript/tests/cases/conformance/salsa/chainedPrototypeAssignment.ts Unexpected estree file content error: 1 != 3