@@ -137,17 +137,26 @@ class ImportDeclaration extends Stmt, Import, @import_declaration {
137137 is instanceof ImportNamespaceSpecifier and
138138 count ( this .getASpecifier ( ) ) = 1
139139 or
140- // For compatibility with the non-standard implementation of default imports,
141- // treat default imports as namespace imports in cases where it can't cause ambiguity
142- // between named exports and the properties of a default-exported object.
143- not this .getImportedModule ( ) .( ES2015Module ) .hasBothNamedAndDefaultExports ( ) and
144- is .getImportedName ( ) = "default"
140+ result = this .getAmbiguousDefaultImportNode ( )
145141 )
146142 or
147143 // `import { createServer } from 'http'`
148144 result = DataFlow:: destructuredModuleImportNode ( this )
149145 }
150146
147+ /**
148+ * Gets the data flow node corresponding to the `foo` in `import foo from "somewhere"`.
149+ *
150+ * This refers to the default import, but some non-standard compilers will treat it as a namespace
151+ * import. In order to support both interpretations, it is considered an "ambiguous default import".
152+ *
153+ * Note that renamed default imports, such as `import { default as foo } from "somewhere"`,
154+ * are not considered ambiguous, and will not be reported by this predicate.
155+ */
156+ DataFlow:: Node getAmbiguousDefaultImportNode ( ) {
157+ result = DataFlow:: valueNode ( this .getASpecifier ( ) .( ImportDefaultSpecifier ) )
158+ }
159+
151160 /** Holds if this is declared with the `type` keyword, so it only imports types. */
152161 predicate isTypeOnly ( ) { has_type_keyword ( this ) }
153162
0 commit comments