@@ -25,14 +25,19 @@ pub enum JsDeclarationKind {
2525 /// Declares both a type and a value.
2626 Enum ,
2727
28+ /// A `function` declaration or a `declare function` overload signature.
29+ ///
30+ /// Declares only a value, and is hoisted to the function scope.
31+ Function ,
32+
2833 /// A generic type parameter, declared in angle brackets.
2934 ///
3035 /// For example: `<T>`.
3136 ///
3237 /// Declares only a type.
3338 Generic ,
3439
35- /// A `function` or ` var` declaration.
40+ /// A `var` declaration.
3641 ///
3742 /// Declares only a value, and is hoisted to the function scope.
3843 HoistedValue ,
@@ -110,6 +115,7 @@ impl JsDeclarationKind {
110115 self ,
111116 Self :: Class
112117 | Self :: Enum
118+ | Self :: Function
113119 | Self :: HoistedValue
114120 | Self :: Import
115121 | Self :: Namespace
@@ -129,14 +135,14 @@ impl JsDeclarationKind {
129135 if let Some ( declaration) = AnyJsDeclaration :: cast_ref ( & ancestor) {
130136 return match declaration {
131137 AnyJsDeclaration :: JsClassDeclaration ( _) => Self :: Class ,
132- AnyJsDeclaration :: JsFunctionDeclaration ( _) => Self :: HoistedValue ,
138+ AnyJsDeclaration :: JsFunctionDeclaration ( _) => Self :: Function ,
133139 AnyJsDeclaration :: JsVariableDeclaration ( decl) => match decl. variable_kind ( ) {
134140 Ok ( JsVariableKind :: Const | JsVariableKind :: Let ) => Self :: Value ,
135141 Ok ( JsVariableKind :: Using ) => Self :: Using ,
136142 Ok ( JsVariableKind :: Var ) => Self :: HoistedValue ,
137143 Err ( _) => Self :: Unknown ,
138144 } ,
139- AnyJsDeclaration :: TsDeclareFunctionDeclaration ( _) => Self :: HoistedValue ,
145+ AnyJsDeclaration :: TsDeclareFunctionDeclaration ( _) => Self :: Function ,
140146 AnyJsDeclaration :: TsEnumDeclaration ( _) => Self :: Enum ,
141147 AnyJsDeclaration :: TsExternalModuleDeclaration ( _) => Self :: Module ,
142148 AnyJsDeclaration :: TsInterfaceDeclaration ( _) => Self :: Interface ,
@@ -246,7 +252,8 @@ impl TsBindingReference {
246252 match self {
247253 Self :: ValueType ( binding_id)
248254 | Self :: TypeAndValueType ( binding_id)
249- | Self :: NamespaceAndValueType ( binding_id) => binding_id,
255+ | Self :: NamespaceAndValueType ( binding_id)
256+ | Self :: Type ( binding_id) => binding_id,
250257 Self :: Merged {
251258 ty,
252259 value_ty,
@@ -255,14 +262,15 @@ impl TsBindingReference {
255262 . or ( namespace_ty)
256263 . or ( ty)
257264 . expect ( "a merged reference must have at least two fields set to `Some`" ) ,
258- Self :: Type ( binding_id) => binding_id,
259265 }
260266 }
261267
262268 /// Creates a union from this binding reference with another.
263269 ///
264270 /// If both bindings refer to the same kind of type, the binding ID(s) from
265- /// `other` takes precedence.
271+ /// `other` take precedence. Same-name function overloads are tracked
272+ /// separately in the scope's overload map, so here two functions simply
273+ /// merge last-wins like any other pair of values.
266274 pub fn union_with ( self , other : Self ) -> Self {
267275 match ( self , other) {
268276 ( Self :: Type ( own_binding_id) , Self :: ValueType ( other_binding_id) ) => {
0 commit comments