File tree Expand file tree Collapse file tree
packages/babel-plugin-transform-typescript
test/fixtures/imports/elide-type-referenced-in-imports-equal-no Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,13 +13,19 @@ import transpileNamespace from "./namespace";
1313function isInType ( path : NodePath ) {
1414 switch ( path . parent . type ) {
1515 case "TSTypeReference" :
16- case "TSQualifiedName" :
1716 case "TSExpressionWithTypeArguments" :
1817 case "TSTypeQuery" :
1918 return true ;
19+ case "TSQualifiedName" :
20+ return (
21+ // `import foo = ns.bar` is transformed to `var foo = ns.bar` and should not be removed
22+ path . parentPath . findParent ( path => path . type !== "TSQualifiedName" )
23+ . type !== "TSImportEqualsDeclaration"
24+ ) ;
2025 case "ExportSpecifier" :
2126 return (
22- ( path . parentPath . parent as t . ExportNamedDeclaration ) . exportKind ===
27+ // @ts -expect-error: DeclareExportDeclaration does not have `exportKind`
28+ ( path . parentPath as NodePath < t . ExportSpecifier > ) . parent . exportKind ===
2329 "type"
2430 ) ;
2531 default :
Original file line number Diff line number Diff line change 1+ import nsa from "./module-a" ;
2+ import foo = nsa . bar ;
3+
4+ import nsb from "./module-b" ;
5+ import bar = nsb . foo . bar ;
Original file line number Diff line number Diff line change 1+ {
2+ "plugins" : [" transform-typescript" ]
3+ }
Original file line number Diff line number Diff line change 1+ import nsa from "./module-a" ;
2+ var foo = nsa . bar ;
3+ import nsb from "./module-b" ;
4+ var bar = nsb . foo . bar ;
You can’t perform that action at this time.
0 commit comments