You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+9-17Lines changed: 9 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -7600,7 +7600,7 @@ namespace ts {
7600
7600
return true;
7601
7601
}
7602
7602
else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) {
7603
-
// For JSXAttributes, if the attribute has hyphenated name considered the attribute to be known
7603
+
// For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known.
7604
7604
return true;
7605
7605
}
7606
7606
}
@@ -11281,27 +11281,19 @@ namespace ts {
11281
11281
11282
11282
function getContextualTypeForJsxAttribute(attribute: JsxAttribute | JsxSpreadAttribute) {
11283
11283
// When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give JSXAttributes a contextual type
11284
-
// which is a type of the parameter of the signature we are trying out. This is not the case if it is a statefull Jsx (i.e ReactComponenet class)
11284
+
// which is a type of the parameter of the signature we are trying out. This is not the case if it is a stateful JSX (i.e ReactComponenet class)
11285
11285
// So if that is the case, just return the type of the JsxAttribute in such contextual type with out going into resolving of the JsxOpeningLikeElement again
11286
-
if ((<JsxAttributes>attribute.parent).contextualType) {
Copy file name to clipboardExpand all lines: tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(28,24): error TS2322: Type '{ extra: true; onClick: (k: any) => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
1
+
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(28,24): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
2
2
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
3
3
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,24): error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
4
4
Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'.
5
5
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(30,24): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
6
6
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
7
7
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(31,24): error TS2322: Type '{ goTo: "home"; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
8
8
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
9
-
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(34,25): error TS2322: Type '{ extra: true; onClick: (k: any) => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
9
+
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(34,25): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
10
10
Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
11
11
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(37,25): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
12
12
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
Copy file name to clipboardExpand all lines: tests/baselines/reference/tsxStatelessFunctionComponentOverload5.errors.txt
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ tests/cases/conformance/jsx/file.tsx(50,24): error TS2322: Type '{ to: string; o
4
4
Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
5
5
tests/cases/conformance/jsx/file.tsx(51,24): error TS2322: Type '{ onClick: () => void; to: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
6
6
Property 'onClick' does not exist on type 'IntrinsicAttributes & HyphenProps'.
7
-
tests/cases/conformance/jsx/file.tsx(52,24): error TS2322: Type '{ onClick: (k: any) => void; to: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
7
+
tests/cases/conformance/jsx/file.tsx(52,24): error TS2322: Type '{ onClick: (k: MouseEvent<any>) => void; to: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
8
8
Property 'onClick' does not exist on type 'IntrinsicAttributes & HyphenProps'.
9
9
tests/cases/conformance/jsx/file.tsx(54,24): error TS2322: Type '{ to: string; onClick(e: any): void; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
10
10
Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
@@ -81,7 +81,7 @@ tests/cases/conformance/jsx/file.tsx(57,24): error TS2322: Type '{ data-format:
81
81
!!! error TS2322: Property 'onClick' does not exist on type 'IntrinsicAttributes & HyphenProps'.
!!! error TS2322: Type '{ onClick: (k: any) => void; to: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
84
+
!!! error TS2322: Type '{ onClick: (k: MouseEvent<any>) => void; to: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
85
85
!!! error TS2322: Property 'onClick' does not exist on type 'IntrinsicAttributes & HyphenProps'.
86
86
const b4 = <MainButton {...obj3} to />; // Should error because Incorrect type; but attributes are any so everything is allowed
87
87
const b5 = <MainButton {...{ onClick(e: any) { } }} {...obj0} />; // Spread retain method declaration (see GitHub #13365), so now there is an extra attributes
0 commit comments