microsoft / microsoft/TypeScript
Translate JSX elements based on objects
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
When using a custom jsxFactory, it is currently only possible to use something that is a string or callable as the JSX element tag. I do not see a reason why there should be such limitation. In my use case I would like to use objects as "blueprints" for my jsx factory.
TypeScript Version: 3.5.1
Search Terms:
jsx jsxFactory object TS2604
Code
/*
* @jsx h
*/
function h (...args: any[]): string {
return 'something';
}
function FuncComponent() {
return '';
}
const StringComponent = 'test';
const ObjectComponent = { key: 'test '};
// works
const dom1 = <FuncComponent text="hello world" />;
// works
const dom3 = <StringComponent text="hello world" />;
// doesnt work
const dom4 = <ObjectComponent text="hello world" />;
Expected behavior:
JSX element <ObjectComponent text="hello world" /> should be translated to h(ObjectComponent, { text: "hello world" }).
Actual behavior:
Typescript throws an error: JSX element type 'ObjectComponent' does not have any construct or call signatures.
Related Issues:
N/A
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された TSX の再現コードと Playground リンクから始め、カスタム jsxFactory の処理における JSX 要素の型チェックの経路を追跡します。ObjectComponent のようなオブジェクト値の JSX タグが受け入れられ、例が construct-or-call-signatures エラーなしで h(ObjectComponent, { text: "hello world" }) に変換されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100