* Check if a property with the given name is known anywhere in the given type. In an object type, a property * is considered known if * 1. the object type is empty and the check is for assignability, or * 2. if the object type has index signatures, or * 3. if the
(targetType, name, isComparingJsxAttributes)
| 74267 | * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType |
| 74268 | */ |
| 74269 | function isKnownProperty(targetType, name, isComparingJsxAttributes) { |
| 74270 | if (targetType.flags & 524288 /* TypeFlags.Object */) { |
| 74271 | // For backwards compatibility a symbol-named property is satisfied by a string index signature. This |
| 74272 | // is incorrect and inconsistent with element access expressions, where it is an error, so eventually |
| 74273 | // we should remove this exception. |
| 74274 | if (getPropertyOfObjectType(targetType, name) || |
| 74275 | getApplicableIndexInfoForName(targetType, name) || |
| 74276 | isLateBoundName(name) && getIndexInfoOfType(targetType, stringType) || |
| 74277 | isComparingJsxAttributes && isHyphenatedJsxName(name)) { |
| 74278 | // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. |
| 74279 | return true; |
| 74280 | } |
| 74281 | } |
| 74282 | else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { |
| 74283 | for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { |
| 74284 | var t = _a[_i]; |
| 74285 | if (isKnownProperty(t, name, isComparingJsxAttributes)) { |
| 74286 | return true; |
| 74287 | } |
| 74288 | } |
| 74289 | } |
| 74290 | return false; |
| 74291 | } |
| 74292 | function isExcessPropertyCheckTarget(type) { |
| 74293 | return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) || |
| 74294 | type.flags & 67108864 /* TypeFlags.NonPrimitive */ || |
no test coverage detected