mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Fixed an issue with quickInfo crashing on a function property returned from generic function (#49049)
This commit is contained in:
parent
ec9f6a428b
commit
3da4886c76
@ -11340,7 +11340,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
|
||||
// The outer type parameters are those defined by enclosing generic classes, methods, or functions.
|
||||
function getOuterTypeParametersOfClassOrInterface(symbol: Symbol): TypeParameter[] | undefined {
|
||||
const declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration)!;
|
||||
const declaration = (symbol.flags & SymbolFlags.Class || symbol.flags & SymbolFlags.Function)
|
||||
? symbol.valueDeclaration
|
||||
: symbol.declarations?.find(decl => {
|
||||
if (decl.kind === SyntaxKind.InterfaceDeclaration) {
|
||||
return true;
|
||||
}
|
||||
if (decl.kind !== SyntaxKind.VariableDeclaration) {
|
||||
return false;
|
||||
}
|
||||
const initializer = (decl as VariableDeclaration).initializer;
|
||||
return !!initializer && (initializer.kind === SyntaxKind.FunctionExpression || initializer.kind === SyntaxKind.ArrowFunction);
|
||||
})!;
|
||||
Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
|
||||
return getOuterTypeParameters(declaration);
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// function createProps<T>(t: T) {
|
||||
//// function getProps() {}
|
||||
//// function createVariants() {}
|
||||
////
|
||||
//// getProps.createVariants = createVariants;
|
||||
//// return getProps;
|
||||
//// }
|
||||
////
|
||||
//// createProps({})./**/createVariants();
|
||||
|
||||
verify.quickInfoAt("", "(property) getProps<{}>.createVariants: () => void");
|
||||
@ -0,0 +1,13 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// function createProps<T>(t: T) {
|
||||
//// const getProps = function() {}
|
||||
//// const createVariants = function() {}
|
||||
////
|
||||
//// getProps.createVariants = createVariants;
|
||||
//// return getProps;
|
||||
//// }
|
||||
////
|
||||
//// createProps({})./**/createVariants();
|
||||
|
||||
verify.quickInfoAt("", "(property) getProps<{}>.createVariants: () => void");
|
||||
@ -0,0 +1,13 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// function createProps<T>(t: T) {
|
||||
//// const getProps = () => {}
|
||||
//// const createVariants = () => {}
|
||||
////
|
||||
//// getProps.createVariants = createVariants;
|
||||
//// return getProps;
|
||||
//// }
|
||||
////
|
||||
//// createProps({})./**/createVariants();
|
||||
|
||||
verify.quickInfoAt("", "(property) getProps<{}>.createVariants: () => void");
|
||||
Loading…
x
Reference in New Issue
Block a user