Skip to content

Commit efa490e

Browse files
committed
Detect weak type errors with primitive sources
1 parent 40dd8ba commit efa490e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9427,7 +9427,7 @@ namespace ts {
94279427
function hasCommonProperties(source: Type, target: Type) {
94289428
const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes);
94299429
for (const prop of getPropertiesOfType(source)) {
9430-
if (isKnownProperty(target, prop.name, isComparingJsxAttributes)) {
9430+
if (isKnownProperty(target, prop.name, isComparingJsxAttributes, /*skipGlobalObject*/ true)) {
94319431
return true;
94329432
}
94339433
}
@@ -14221,12 +14221,12 @@ namespace ts {
1422114221
* @param name a property name to search
1422214222
* @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType
1422314223
*/
14224-
function isKnownProperty(targetType: Type, name: string, isComparingJsxAttributes: boolean): boolean {
14224+
function isKnownProperty(targetType: Type, name: string, isComparingJsxAttributes: boolean, skipGlobalObject?: boolean): boolean {
1422514225
if (targetType.flags & TypeFlags.Object) {
1422614226
const resolved = resolveStructuredTypeMembers(<ObjectType>targetType);
1422714227
if (resolved.stringIndexInfo ||
1422814228
resolved.numberIndexInfo && isNumericLiteralName(name) ||
14229-
getPropertyOfType(targetType, name) ||
14229+
(skipGlobalObject ? getPropertyOfObjectType(targetType, name) : getPropertyOfType(targetType, name)) ||
1423014230
isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) {
1423114231
// For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known.
1423214232
return true;

0 commit comments

Comments
 (0)