microsoft / microsoft/TypeScript
Compiler generates jsxFactory call with incorrect namespace
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.3k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 132
Mô tả
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 = {}));
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với bản tái hiện trong root.ts và các tùy chọn trình biên dịch được hiển thị trong issue, hoặc giải nén test.zip. Theo dõi việc phát sinh JSX factory khi JSX xuất hiện bên trong các namespace lồng nhau và so sánh đầu ra được tạo với lời gọi Templates.compile mong đợi. Công việc hoàn tất khi trình biên dịch không còn định danh factory đã cấu hình kèm theo namespace bao quanh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- compilers
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100