Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsx部分内容存在过时和错误 #168

Open
whinc opened this issue Mar 9, 2020 · 3 comments
Open

jsx部分内容存在过时和错误 #168

whinc opened this issue Mar 9, 2020 · 3 comments

Comments

@whinc
Copy link
Contributor

whinc commented Mar 9, 2020

译文:https://jkchao.github.io/typescript-book-chinese/jsx/nonReactJSX.html#jsxfactory

有两个问题:

  1. --jsxFactory 选项 tsc 已废弃(找不到该选项了),建议将该小标题添加废弃标识或说明。
  2. jsx 编译提示编译结果错误(原书也是错的),建议更正并添加说明
/** @jsx jsxFactory */
import { jsxFactory } from 'jsxFactory';

var div = <div>Hello JSX!</div>;

书中结果是:

'use strict';
var jsxFactory_1 = require('jsxFactory');
var div = jsxFactory_1.jsxFactory.createElement('div', null, 'Hello JSX!');

实际结果是(在 Typescript 3.8.3 编译器上运行),没有.createElement

"use strict";
/** @jsx jsxFactory */
var jsxFactory_1 = require("jsxFactory");
var div = jsxFactory_1.jsxFactory("div", null, "Hello JSX!");

重现链接:
Playground Link

@jkchao
Copy link
Owner

jkchao commented Mar 11, 2020

谢谢,我稍后验证一下,没问题就加上。

@jkchao
Copy link
Owner

jkchao commented Mar 11, 2020

  1. --jsxFactory 这个选项没有被废弃,https://www.typescriptlang.org/docs/handbook/compiler-options.html
  2. 建议直接在本地跑 tsc,Playgroud 上没有部分编译选项。

我这边试了下,是正常的。

@whinc
Copy link
Contributor Author

whinc commented Mar 11, 2020

  1. --jsxFactory 这个选项没有被废弃,https://www.typescriptlang.org/docs/handbook/compiler-options.html
  2. 建议直接在本地跑 tsc,Playgroud 上没有部分编译选项。

我这边试了下,是正常的。

本地 tsc 确实没有该选项,不过你发的这个文档链接确实有,可能是不推荐使用了吧

$ npx tsc --version
Version 3.8.3
$ npx tsc --help | grep 'jsx'
 --jsx KIND                                        

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants