Skip to content

Commit 2129f69

Browse files
committed
fix: always display react components completions for React.FC & in more cases, hotfix for pixi
1 parent 526766c commit 2129f69

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

typescript/src/completions/filterJsxComponents.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,16 @@ export default (entries: ts.CompletionEntry[], node: ts.Node, position: number,
6666
const { symbol } = entry
6767
// tsFull.isCheckJsEnabledForFile(sourceFile, compilerOptions)
6868
if (!symbol) return true
69+
if (entry.name.startsWith('pixi')) return true
6970
// performance: symbol coming from lib cannot be JSX element, so let's skip checking them
70-
// todo other decl
71+
// todo test might help
72+
// const symbolLinkType = symbol.links?.type
73+
// if (symbolLinkType) {
74+
// const symbolLinkTypeString = typeChecker.typeToString(symbolLinkType)
75+
// if (symbolLinkTypeString.includes('ReactElement') || symbolLinkTypeString.includes('ReactNode')) return true
76+
// }
77+
78+
// todo other decl?
7179
const firstDeclaration = symbol.declarations?.[0]
7280
if (!firstDeclaration) return
7381
// todo-low
@@ -158,6 +166,9 @@ const isJsxElement = (typeChecker: ts.TypeChecker, signatures: readonly ts.Signa
158166
}
159167

160168
const getIsJsxComponentSignature = (typeChecker: ts.TypeChecker, signature: ts.Signature) => {
169+
const signatureString = typeChecker.signatureToString(signature)
170+
if (signatureString.includes('ReactNode')) return true
171+
161172
let returnType: ts.Type | undefined = signature.getReturnType()
162173
if (!returnType) return
163174
// todo setting to allow any

0 commit comments

Comments
 (0)