@@ -2403,7 +2403,7 @@ func GetImpliedNodeFormatForFile(path string, packageJsonType string) core.Modul
2403
2403
impliedNodeFormat = core .ResolutionModeESM
2404
2404
} else if tspath .FileExtensionIsOneOf (path , []string {tspath .ExtensionDcts , tspath .ExtensionCts , tspath .ExtensionCjs }) {
2405
2405
impliedNodeFormat = core .ResolutionModeCommonJS
2406
- } else if packageJsonType != "" && tspath .FileExtensionIsOneOf (path , []string {tspath .ExtensionDts , tspath .ExtensionTs , tspath .ExtensionTsx , tspath .ExtensionJs , tspath .ExtensionJsx }) {
2406
+ } else if tspath .FileExtensionIsOneOf (path , []string {tspath .ExtensionDts , tspath .ExtensionTs , tspath .ExtensionTsx , tspath .ExtensionJs , tspath .ExtensionJsx }) {
2407
2407
impliedNodeFormat = core .IfElse (packageJsonType == "module" , core .ResolutionModeESM , core .ResolutionModeCommonJS )
2408
2408
}
2409
2409
@@ -2739,6 +2739,22 @@ func IsTypeOnlyImportOrExportDeclaration(node *Node) bool {
2739
2739
return IsTypeOnlyImportDeclaration (node ) || isTypeOnlyExportDeclaration (node )
2740
2740
}
2741
2741
2742
+ func IsExclusivelyTypeOnlyImportOrExport (node * Node ) bool {
2743
+ switch node .Kind {
2744
+ case KindExportDeclaration :
2745
+ return node .AsExportDeclaration ().IsTypeOnly
2746
+ case KindImportDeclaration , KindJSImportDeclaration :
2747
+ if importClause := node .AsImportDeclaration ().ImportClause ; importClause != nil {
2748
+ return importClause .AsImportClause ().IsTypeOnly
2749
+ }
2750
+ case KindJSDocImportTag :
2751
+ if importClause := node .AsJSDocImportTag ().ImportClause ; importClause != nil {
2752
+ return importClause .AsImportClause ().IsTypeOnly
2753
+ }
2754
+ }
2755
+ return false
2756
+ }
2757
+
2742
2758
func GetClassLikeDeclarationOfSymbol (symbol * Symbol ) * Node {
2743
2759
return core .Find (symbol .Declarations , IsClassLike )
2744
2760
}
@@ -2941,6 +2957,59 @@ func GetPropertyNameForPropertyNameNode(name *Node) string {
2941
2957
panic ("Unhandled case in getPropertyNameForPropertyNameNode" )
2942
2958
}
2943
2959
2960
+ func IsPartOfTypeOnlyImportOrExportDeclaration (node * Node ) bool {
2961
+ return FindAncestor (node , IsTypeOnlyImportOrExportDeclaration ) != nil
2962
+ }
2963
+
2964
+ func IsPartOfExclusivelyTypeOnlyImportOrExportDeclaration (node * Node ) bool {
2965
+ return FindAncestor (node , IsExclusivelyTypeOnlyImportOrExport ) != nil
2966
+ }
2967
+
2968
+ func IsEmittableImport (node * Node ) bool {
2969
+ switch node .Kind {
2970
+ case KindImportDeclaration :
2971
+ return node .AsImportDeclaration ().ImportClause == nil || ! node .AsImportDeclaration ().ImportClause .IsTypeOnly ()
2972
+ case KindExportDeclaration :
2973
+ return ! node .AsExportDeclaration ().IsTypeOnly
2974
+ case KindImportEqualsDeclaration :
2975
+ return ! node .AsImportEqualsDeclaration ().IsTypeOnly
2976
+ case KindCallExpression :
2977
+ return IsImportCall (node )
2978
+ }
2979
+ return false
2980
+ }
2981
+
2982
+ func IsResolutionModeOverrideHost (node * Node ) bool {
2983
+ if node == nil {
2984
+ return false
2985
+ }
2986
+ switch node .Kind {
2987
+ case KindImportType , KindExportDeclaration , KindImportDeclaration , KindJSImportDeclaration :
2988
+ return true
2989
+ }
2990
+ return false
2991
+ }
2992
+
2993
+ func HasResolutionModeOverride (node * Node ) bool {
2994
+ if node == nil {
2995
+ return false
2996
+ }
2997
+ var attributes * ImportAttributesNode
2998
+ switch node .Kind {
2999
+ case KindImportType :
3000
+ attributes = node .AsImportTypeNode ().Attributes
3001
+ case KindImportDeclaration , KindJSImportDeclaration :
3002
+ attributes = node .AsImportDeclaration ().Attributes
3003
+ case KindExportDeclaration :
3004
+ attributes = node .AsExportDeclaration ().Attributes
3005
+ }
3006
+ if attributes != nil {
3007
+ _ , ok := attributes .GetResolutionModeOverride ()
3008
+ return ok
3009
+ }
3010
+ return false
3011
+ }
3012
+
2944
3013
func IsStringTextContainingNode (node * Node ) bool {
2945
3014
return node .Kind == KindStringLiteral || IsTemplateLiteralKind (node .Kind )
2946
3015
}
0 commit comments