TypeScript Version: 2.9.0-dev.20180428
Search Terms: jsx, jsxfactory
Code
Over at preact we are currently trying out the new feature of locally scoped JSX namespaces.
// tsconfig.json
{
"compilerOptions": {
"jsx": "react",
"jsxFactory": "h",
}
}
// This is how most of our users use preact with TS
import { h, Component } from "preact";
export class Foo extends Component {
render() {
// <div> has type `any`
return <div>hey</div>;
}
}
Slightly rewriting our example we can get this to work:
// tsconfig.json
{
"compilerOptions": {
"jsx": "react",
"jsxFactory": "preact.h",
}
}
import * as preact from "preact";
export class Foo extends preact.Component {
render() {
// <div> now has correct type
return <div>hey</div>;
}
}
But that does seem unnecessary.
Expected behavior:
Type of <div> is inferred from the JSX namespace when using jsxFactory: h and import { h } from "preact"
Actual behavior:
<div> is typed as any.
Playground Link:
N/A
Related Issues:
TypeScript Version: 2.9.0-dev.20180428
Search Terms: jsx, jsxfactory
Code
Over at preact we are currently trying out the new feature of locally scoped JSX namespaces.
Slightly rewriting our example we can get this to work:
But that does seem unnecessary.
Expected behavior:
Type of
<div>is inferred from theJSXnamespace when usingjsxFactory: handimport { h } from "preact"Actual behavior:
<div>is typed asany.Playground Link:
N/A
Related Issues: