Skip to content

Commit 06fc07c

Browse files
fix(ast/estree): Fix TSImportType (#10200)
Skips the `isTypeOf` field for the Estree serialiser on the `TSImportType` node. Part of our broader work to align our AST's ESTree output with that of TS-ESLint's. Relates to #9705
1 parent 9ffb613 commit 06fc07c

File tree

6 files changed

+2
-20
lines changed

6 files changed

+2
-20
lines changed

crates/oxc_ast/src/ast/ts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,7 @@ pub struct TSImportType<'a> {
13021302
pub qualifier: Option<TSTypeName<'a>>,
13031303
pub type_arguments: Option<Box<'a, TSTypeParameterInstantiation<'a>>>,
13041304
/// `true` for `typeof import("foo")`
1305+
#[estree(skip)]
13051306
pub is_type_of: bool,
13061307
}
13071308

crates/oxc_ast/src/generated/derive_estree.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3117,7 +3117,6 @@ impl ESTree for TSImportType<'_> {
31173117
state.serialize_field("options", &self.options);
31183118
state.serialize_field("qualifier", &self.qualifier);
31193119
state.serialize_field("typeArguments", &self.type_arguments);
3120-
state.serialize_field("isTypeOf", &self.is_type_of);
31213120
state.end();
31223121
}
31233122
}

napi/parser/deserialize-js.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1810,7 +1810,6 @@ function deserializeTSImportType(pos) {
18101810
options: deserializeOptionBoxObjectExpression(pos + 24),
18111811
qualifier: deserializeOptionTSTypeName(pos + 32),
18121812
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
1813-
isTypeOf: deserializeBool(pos + 56),
18141813
};
18151814
}
18161815

napi/parser/deserialize-ts.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,6 @@ function deserializeTSImportType(pos) {
18851885
options: deserializeOptionBoxObjectExpression(pos + 24),
18861886
qualifier: deserializeOptionTSTypeName(pos + 32),
18871887
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
1888-
isTypeOf: deserializeBool(pos + 56),
18891888
};
18901889
}
18911890

npm/oxc-types/types.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,6 @@ export interface TSImportType extends Span {
13211321
options: ObjectExpression | null;
13221322
qualifier: TSTypeName | null;
13231323
typeArguments: TSTypeParameterInstantiation | null;
1324-
isTypeOf: boolean;
13251324
}
13261325

13271326
export interface TSFunctionType extends Span {

tasks/coverage/snapshots/estree_typescript.snap

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

33
estree_typescript Summary:
44
AST Parsed : 10618/10725 (99.00%)
5-
Positive Passed: 7072/10725 (65.94%)
5+
Positive Passed: 7087/10725 (66.08%)
66
Mismatch: tasks/coverage/typescript/tests/cases/compiler/APISample_compile.ts
77
Mismatch: tasks/coverage/typescript/tests/cases/compiler/APISample_linter.ts
88
Mismatch: tasks/coverage/typescript/tests/cases/compiler/APISample_parseConfig.ts
@@ -548,7 +548,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitStringEn
548548
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitSymlinkPaths.ts
549549
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitTopLevelNodeFromCrossFile2.ts
550550
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitTransitiveImportOfHtmlDeclarationItem.ts
551-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitTripleSlashReferenceAmbientModule.ts
552551
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts
553552
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters1.ts
554553
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters2.ts
@@ -567,18 +566,15 @@ Unexpected estree file content error: 2 != 3
567566
tasks/coverage/typescript/tests/cases/compiler/declarationEmitUsingAlternativeContainingModules2.ts
568567
Unexpected estree file content error: 2 != 3
569568
570-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitUsingTypeAlias1.ts
571569
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitUsingTypeAlias2.ts
572570
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitVarInElidedBlock.ts
573571
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationEmitWithInvalidPackageJsonTypings.ts
574572
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationFileNoCrashOnExtraExportModifier.ts
575-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationImportTypeAliasInferredAndEmittable.ts
576573
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationMaps.ts
577574
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationMapsWithoutDeclaration.ts
578575
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationNoDanglingGenerics.ts
579576
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationQuotedMembers.ts
580577
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationTypecheckNoUseBeforeReferenceCheck.ts
581-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationsForInferredTypeFromOtherFile.ts
582578
Mismatch: tasks/coverage/typescript/tests/cases/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.ts
583579
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/declareAlreadySeen.ts
584580
declare' modifier already seen.
@@ -1122,7 +1118,6 @@ Unexpected estree file content error: 1 != 2
11221118
11231119
Mismatch: tasks/coverage/typescript/tests/cases/compiler/importTypeTypeofClassStaticLookup.ts
11241120
Mismatch: tasks/coverage/typescript/tests/cases/compiler/importTypeWithUnparenthesizedGenericFunctionParsed.ts
1125-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/importUsedAsTypeWithErrors.ts
11261121
Mismatch: tasks/coverage/typescript/tests/cases/compiler/importUsedInGenericImportResolves.ts
11271122
Mismatch: tasks/coverage/typescript/tests/cases/compiler/importWithTrailingSlash_noResolve.ts
11281123
Mismatch: tasks/coverage/typescript/tests/cases/compiler/importedAliasesInTypePositions.ts
@@ -1659,7 +1654,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/narrowingRestGenericCal
16591654
Mismatch: tasks/coverage/typescript/tests/cases/compiler/narrowingUnionToUnion.ts
16601655
Mismatch: tasks/coverage/typescript/tests/cases/compiler/narrowingUnionWithBang.ts
16611656
Mismatch: tasks/coverage/typescript/tests/cases/compiler/nestedExcessPropertyChecking.ts
1662-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/nestedGenericConditionalTypeWithGenericImportType.ts
16631657
Mismatch: tasks/coverage/typescript/tests/cases/compiler/nestedHomomorphicMappedTypesWithArrayConstraint1.ts
16641658
Mismatch: tasks/coverage/typescript/tests/cases/compiler/nestedLoops.ts
16651659
Mismatch: tasks/coverage/typescript/tests/cases/compiler/nestedObjectRest.ts
@@ -2221,7 +2215,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/compiler/unionWithIndexSignature
22212215
Mismatch: tasks/coverage/typescript/tests/cases/compiler/uniqueSymbolAllowsIndexInObjectWithIndexSignature.ts
22222216
Mismatch: tasks/coverage/typescript/tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts
22232217
Mismatch: tasks/coverage/typescript/tests/cases/compiler/uniqueSymbolPropertyDeclarationEmit.ts
2224-
Mismatch: tasks/coverage/typescript/tests/cases/compiler/unmetTypeConstraintInImportCall.ts
22252218
Mismatch: tasks/coverage/typescript/tests/cases/compiler/unreachableDeclarations.ts
22262219
Mismatch: tasks/coverage/typescript/tests/cases/compiler/unresolvableSelfReferencingAwaitedUnion.ts
22272220
Mismatch: tasks/coverage/typescript/tests/cases/compiler/unspecializedConstraints.ts
@@ -2392,7 +2385,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/members/priv
23922385
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodAssignment.ts
23932386
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/members/privateNames/privateNameStaticMethodCallExpression.ts
23942387
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/members/privateNames/privateNameUnused.ts
2395-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/members/privateNames/privateNamesUnique-2.ts
23962388
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/members/privateNames/privateWriteOnlyAccessorRead.ts
23972389
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/mixinClassesAnnotated.ts
23982390
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/mixinClassesAnonymous.ts
@@ -3325,7 +3317,6 @@ Cannot use `await` as an identifier in an async context
33253317
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/externalModules/topLevelAwaitNonModule.ts
33263318
`await` is only allowed within async functions and at the top levels of modules
33273319
Mismatch: tasks/coverage/typescript/tests/cases/conformance/externalModules/topLevelFileModule.ts
3328-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/externalModules/typeOnly/allowsImportingTsExtension.ts
33293320
Mismatch: tasks/coverage/typescript/tests/cases/conformance/externalModules/typeOnly/enums.ts
33303321
tasks/coverage/typescript/tests/cases/conformance/externalModules/typeOnly/grammarErrors.ts
33313322
Unexpected estree file content error: 3 != 4
@@ -3615,7 +3606,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/tsxUnionElementT
36153606
Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/tsxUnionElementType4.tsx
36163607
Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/tsxUnionElementType5.tsx
36173608
Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/tsxUnionElementType6.tsx
3618-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/moduleResolution/allowImportingTypesDtsExtension.ts
36193609
tasks/coverage/typescript/tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts
36203610
Unexpected estree file content error: 3 != 5
36213611

@@ -3788,7 +3778,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/conformance/node/nodeModulesImpo
37883778
tasks/coverage/typescript/tests/cases/conformance/node/nodeModulesImportAttributes.ts
37893779
Unexpected estree file content error: 1 != 2
37903780

3791-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/node/nodeModulesImportAttributesTypeModeDeclarationEmit.ts
37923781
Mismatch: tasks/coverage/typescript/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts
37933782
Mismatch: tasks/coverage/typescript/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts
37943783
Mismatch: tasks/coverage/typescript/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts
@@ -4225,17 +4214,13 @@ Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/contextualType
42254214
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes01.tsx
42264215
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/contextualTypes/jsxAttributes/contextuallyTypedStringLiteralsInJsxAttributes02.tsx
42274216
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/import/importTypeAmbient.ts
4228-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/import/importTypeAmbientMissing.ts
42294217
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/import/importTypeAmdBundleRewrite.ts
4230-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/import/importTypeGeneric.ts
42314218
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/import/importTypeGenericTypes.ts
42324219
tasks/coverage/typescript/tests/cases/conformance/types/import/importTypeInJSDoc.ts
42334220
Unexpected estree file content error: 1 != 2
42344221
42354222
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/import/importTypeLocal.ts
42364223
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/import/importTypeLocalMissing.ts
4237-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/import/importTypeNested.ts
4238-
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/import/importTypeNestedNoRef.ts
42394224
Mismatch: tasks/coverage/typescript/tests/cases/conformance/types/import/importTypeNonString.ts
42404225
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/types/import/importWithTypeArguments.ts
42414226
Expected `from` but found `<`

0 commit comments

Comments
 (0)