-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
In code below constructing generic jsx element el1
works in 2.8.3, but breaks on 2.9.0-dev.20180512
. Constructing el2
in 2.9.0-dev.20180512
works fine - shouldn't these be completely equivalent?
TypeScript Version: 2.9.0-dev.20180512
Search Terms: jsx conditional
Code
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
class TestObject {
a: string = '';
b: number = 1;
c: () => void = () => { };
}
interface TestProps<T> {
model: T;
foo: FunctionPropertyNames<T>;
}
function Test<T>(props: TestProps<T>) { return <></>; }
const model = new TestObject();
const el1 = <Test model={model} foo="c" />;
const el2 = <Test<TestObject> model={model} foo="c" />;
Expected behavior:
Compilation passes without errors.
Actual behavior:
test.tsx:14:33 - error TS2326: Types of property 'foo' are incompatible.
Type 'string' is not assignable to type '"c"'.
14 const el1 = <Test model={model} foo="c" />;
~~~~~~~
Playground Link:
n/a since playground doesn't support jsx
Related Issues:
Possibly related to #23724
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue