Skip to content

Commit 48e58f4

Browse files
Handle unresolved baseType when trying to get completions for static member (microsoft#39731)
* Handle unresolved baseType when trying to get completions for static member Fixes microsoft#38067 * Update src/services/completions.ts Co-authored-by: Nathan Shively-Sanders <[email protected]> * correct the condition Co-authored-by: Nathan Shively-Sanders <[email protected]>
1 parent c5d21e7 commit 48e58f4

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/services/completions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,9 @@ namespace ts.Completions {
20122012
// List of property symbols of base type that are not private and already implemented
20132013
const baseSymbols = flatMap(getAllSuperTypeNodes(decl), baseTypeNode => {
20142014
const type = typeChecker.getTypeAtLocation(baseTypeNode);
2015-
return type && typeChecker.getPropertiesOfType(classElementModifierFlags & ModifierFlags.Static ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type);
2015+
return classElementModifierFlags & ModifierFlags.Static ?
2016+
type?.symbol && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) :
2017+
type && typeChecker.getPropertiesOfType(type);
20162018
});
20172019
symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags);
20182020
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @Filename: /node_modules/@types/react/index.d.ts
4+
//// export = React;
5+
//// export as namespace React;
6+
//// declare namespace React {
7+
//// function createElement(): any;
8+
//// interface Component<P = {}, S = {}, SS = any> { }
9+
//// class Component<P, S> {
10+
//// static contextType?: any;
11+
//// context: any;
12+
//// constructor(props: Readonly<P>);
13+
//// setState<K extends keyof S>(
14+
//// state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null),
15+
//// callback?: () => void
16+
//// ): void;
17+
//// }
18+
//// }
19+
20+
// @Filename: /a.ts
21+
//// import React from 'react'
22+
//// class Slider extends React.Component {
23+
//// static defau/**/ltProps = {
24+
//// onMouseDown: () => { },
25+
//// onMouseUp: () => { },
26+
//// unit: 'px',
27+
//// }
28+
//// handleChange = () => 10;
29+
//// }
30+
31+
verify.completions({
32+
marker: "",
33+
isNewIdentifierLocation: true,
34+
exact: completion.classElementKeywords,
35+
});

0 commit comments

Comments
 (0)