Fix non-selfclosing JSX tag contextual types (#27251)

This commit is contained in:
Wesley Wigham
2018-09-24 10:38:39 -07:00
committed by GitHub
parent 03af107672
commit b7fc092404
8 changed files with 280 additions and 87 deletions

View File

@@ -16827,6 +16827,12 @@ namespace ts {
}
function getContextualJsxElementAttributesType(node: JsxOpeningLikeElement) {
if (isJsxOpeningElement(node) && node.parent.contextualType) {
// Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit
// _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type
// (as below) instead!
return node.parent.contextualType;
}
if (isJsxIntrinsicIdentifier(node.tagName)) {
return getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
}