mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add intra expression inference sites based on JSX attributes (#52837)
This commit is contained in:
@@ -30230,7 +30230,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
*/
|
||||
function createJsxAttributesTypeFromAttributesProperty(openingLikeElement: JsxOpeningLikeElement, checkMode: CheckMode | undefined) {
|
||||
const attributes = openingLikeElement.attributes;
|
||||
const attributesType = getContextualType(attributes, ContextFlags.None);
|
||||
const contextualType = getContextualType(attributes, ContextFlags.None);
|
||||
const allAttributesTable = strictNullChecks ? createSymbolTable() : undefined;
|
||||
let attributesTable = createSymbolTable();
|
||||
let spread: Type = emptyJsxObjectType;
|
||||
@@ -30259,12 +30259,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
|
||||
explicitlySpecifyChildrenAttribute = true;
|
||||
}
|
||||
if (attributesType) {
|
||||
const prop = getPropertyOfType(attributesType, member.escapedName);
|
||||
if (contextualType) {
|
||||
const prop = getPropertyOfType(contextualType, member.escapedName);
|
||||
if (prop && prop.declarations && isDeprecatedSymbol(prop)) {
|
||||
addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText as string);
|
||||
}
|
||||
}
|
||||
if (contextualType && checkMode && checkMode & CheckMode.Inferential && !(checkMode & CheckMode.SkipContextSensitive) && isContextSensitive(attributeDecl)) {
|
||||
const inferenceContext = getInferenceContext(attributes);
|
||||
Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
|
||||
const inferenceNode = (attributeDecl.initializer as JsxExpression).expression!;
|
||||
addIntraExpressionInferenceSite(inferenceContext, inferenceNode, exprType);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Debug.assert(attributeDecl.kind === SyntaxKind.JsxSpreadAttribute);
|
||||
|
||||
Reference in New Issue
Block a user