microsoft / microsoft/TypeScript
Compiler generates jsxFactory call with incorrect namespace
オープン
まだ誰も着手していません。
Domain: Error Messages
Needs Proposal
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 3.2.2, 3.3.0-dev.20190111
Search Terms:
jsx, jsxFactory
Code
Full solution: test.zip
namespace Templates {
export function compile(_: string, __: { [key: string]: any }, ...___: Array<any>) {
return {};
}
}
// this template generated properly as call to Templates.compile
namespace SomeNS.Templates.OtherNS {
export const Boolean = (props: {
id: string;
name: string;
}) => {
return (
<input type="checkbox" id={props.id} name={props.name} />
);
}
}
// this template generated as call to non-existing SomeNS.Templates.compile
namespace SomeNS.templates {
export const text = (value: string) => <span>{value}</span>;
}
{
"compileOnSave": false,
"files": [
"root.ts"
],
"compilerOptions": {
"noEmitOnError": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
"target": "es5",
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
"noErrorTruncation": true,
"allowJs": true,
"lib": [
"dom",
"es5"
],
"stripInternal": true,
"declaration": false,
"jsx": "react",
"jsxFactory": "Templates.compile"
}
}
Expected behavior:
Proper call to jsxFactory method generated
Actual behavior:
Generated code contains call of non-existing method (SomeNS.Templates.compile instead of Templates.compile):
"use strict";
var Templates;
(function (Templates) {
function compile(_, __) {
var ___ = [];
for (var _i = 2; _i < arguments.length; _i++) {
___[_i - 2] = arguments[_i];
}
return {};
}
Templates.compile = compile;
})(Templates || (Templates = {}));
var SomeNS;
(function (SomeNS) {
var templates;
(function (templates) {
// unknown SomeNS.Templates.compile method called
templates.text = function (value) { return SomeNS.Templates.compile("span", null, value); };
})(templates = SomeNS.templates || (SomeNS.templates = {}));
})(SomeNS || (SomeNS = {}));
var SomeNS;
(function (SomeNS) {
var TestClass = (function () {
function TestClass() {
}
TestClass.prototype.test = function () {
return SomeNS.Templates.OtherNS.Boolean({
id: 'id',
name: 'name'
});
};
return TestClass;
}());
SomeNS.TestClass = TestClass;
})(SomeNS || (SomeNS = {}));
var SomeNS;
(function (SomeNS) {
var Templates;
(function (Templates) {
var OtherNS;
(function (OtherNS) {
OtherNS.Boolean = function (props) {
// proper Templates.compile method called
return (Templates.compile("input", { type: "checkbox", id: props.id, name: props.name }));
};
})(OtherNS = Templates.OtherNS || (Templates.OtherNS = {}));
})(Templates = SomeNS.Templates || (SomeNS.Templates = {}));
})(SomeNS || (SomeNS = {}));
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
root.ts の再現例と issue に示されているコンパイラオプションから始めるか、test.zip を展開してください。入れ子になった namespace 内に JSX がある場合の JSX factory の出力を追跡し、生成された出力を期待される Templates.compile の呼び出しと比較してください。コンパイラが設定された factory を包含する namespace で修飾しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100