diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index 6e51e418ee433..ec036341774b0 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -10128,10 +10128,9 @@ namespace ts {
const correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text);
correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol);
if (isUnhyphenatedJsxName(node.name.text)) {
- // Maybe there's a string indexer?
- const indexerType = getIndexTypeOfType(elementAttributesType, IndexKind.String);
- if (indexerType) {
- correspondingPropType = indexerType;
+ const attributeType = getTypeOfPropertyOfType(elementAttributesType, getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, IndexKind.String);
+ if (attributeType) {
+ correspondingPropType = attributeType;
}
else {
// If there's no corresponding property with this name, error
diff --git a/tests/baselines/reference/tsxAttributeResolution14.errors.txt b/tests/baselines/reference/tsxAttributeResolution14.errors.txt
new file mode 100644
index 0000000000000..81d42e49059f6
--- /dev/null
+++ b/tests/baselines/reference/tsxAttributeResolution14.errors.txt
@@ -0,0 +1,38 @@
+tests/cases/conformance/jsx/file.tsx(14,28): error TS2322: Type 'number' is not assignable to type 'string'.
+tests/cases/conformance/jsx/file.tsx(16,28): error TS2322: Type 'boolean' is not assignable to type 'string | number'.
+
+
+==== tests/cases/conformance/jsx/react.d.ts (0 errors) ====
+
+ declare module JSX {
+ interface Element { }
+ interface IntrinsicElements {
+ div: any;
+ }
+ interface ElementAttributesProperty { prop: any }
+ }
+
+==== tests/cases/conformance/jsx/file.tsx (2 errors) ====
+
+ interface IProps {
+ primaryText: string,
+ [propName: string]: string | number
+ }
+
+ function VerticalNavMenuItem(prop: IProps) {
+ return
props.primaryText
+ }
+
+ function VerticalNav() {
+ return (
+
+ // error
+ ~~~~~~~~~~~~~~~
+!!! error TS2322: Type 'number' is not assignable to type 'string'.
+ // ok
+ // error
+ ~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'.
+
+ )
+ }
\ No newline at end of file
diff --git a/tests/baselines/reference/tsxAttributeResolution14.js b/tests/baselines/reference/tsxAttributeResolution14.js
new file mode 100644
index 0000000000000..d920179458cc0
--- /dev/null
+++ b/tests/baselines/reference/tsxAttributeResolution14.js
@@ -0,0 +1,47 @@
+//// [tests/cases/conformance/jsx/tsxAttributeResolution14.tsx] ////
+
+//// [react.d.ts]
+
+declare module JSX {
+ interface Element { }
+ interface IntrinsicElements {
+ div: any;
+ }
+ interface ElementAttributesProperty { prop: any }
+}
+
+//// [file.tsx]
+
+interface IProps {
+ primaryText: string,
+ [propName: string]: string | number
+}
+
+function VerticalNavMenuItem(prop: IProps) {
+ return props.primaryText
+}
+
+function VerticalNav() {
+ return (
+
+ // error
+ // ok
+ // error
+
+ )
+}
+
+//// [file.jsx]
+function VerticalNavMenuItem(prop) {
+ return props.primaryText
;
+}
+function VerticalNav() {
+ return (
+ // error
+ // error
+ // ok
+ // ok
+ // error
+ // error
+
);
+}
diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx
new file mode 100644
index 0000000000000..1e4418e7fba37
--- /dev/null
+++ b/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx
@@ -0,0 +1,32 @@
+//@jsx: preserve
+//@module: amd
+
+//@filename: react.d.ts
+declare module JSX {
+ interface Element { }
+ interface IntrinsicElements {
+ div: any;
+ }
+ interface ElementAttributesProperty { prop: any }
+}
+
+//@filename: file.tsx
+
+interface IProps {
+ primaryText: string,
+ [propName: string]: string | number
+}
+
+function VerticalNavMenuItem(prop: IProps) {
+ return props.primaryText
+}
+
+function VerticalNav() {
+ return (
+
+ // error
+ // ok
+ // error
+
+ )
+}
\ No newline at end of file