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

tsc error with typescript@2.1 #4208

Closed
afc163 opened this issue Dec 11, 2016 · 19 comments
Closed

tsc error with typescript@2.1 #4208

afc163 opened this issue Dec 11, 2016 · 19 comments

Comments

@afc163
Copy link
Member

afc163 commented Dec 11, 2016

antd-tools run compile
components/modal/confirm.tsx(92,7): error TS2531: Object is possibly 'null'.
components/tooltip/index.tsx(127,40): error TS2345: Argument of type 'ReactElement<any> | (undefined & ReactElement<any>) | (null & undefined) | (null & ReactElement<a...' is not assignable to parameter of type '{}'.
  Type 'undefined' is not assignable to type '{}'.
components/tooltip/index.tsx(128,24): error TS2532: Object is possibly 'undefined'.
components/tooltip/index.tsx(128,30): error TS2339: Property 'props' does not exist on type 'ReactElement<any> | (undefined & ReactElement<any>) | (null & ReactElement<any>) | (string & unde...'.
  Property 'props' does not exist on type 'string & undefined'.
components/tooltip/index.tsx(143,33): error TS2345: Argument of type 'ReactElement<any> | (undefined & ReactElement<any>) | (null & undefined) | (null & ReactElement<a...' is not assignable to parameter of type 'ReactElement<any>'.
  Type 'undefined' is not assignable to type 'ReactElement<any>'.
[14:08:49] TypeScript: 5 semantic errors
[14:08:49] TypeScript: emit succeeded (with errors)

And travis is ok.

$ tsc -v
2.0.10
@yesmeck
Copy link
Member

yesmeck commented Dec 11, 2016

$ tsc -v
Version 2.1.4

这个是没问题。

@afc163
Copy link
Member Author

afc163 commented Dec 13, 2016

发现是 https://github.com/lozinsky/typescript-babel-jest 依赖了 typescript@2.1。然后使用 tnpm 安装时,antd-tools 优先使用了 2.1 版本导致报错。

我们需要优先适配下 2.1.4?

@afc163 afc163 changed the title tsc error in local development tsc error with typescript@2.1 Dec 13, 2016
@yesmeck
Copy link
Member

yesmeck commented Dec 13, 2016

这个 typescript-babel-jest 最好换成 ts-jest,现在用 typescript-babel-jest 统计出来的 coverage 是错误的,不过现在 ts-jest 有个问题 kulshekhar/ts-jest#63 ,不知道我们现在配置 "jsx": "preserve" 目的是什么?

@BANG88
Copy link
Member

BANG88 commented Dec 14, 2016

配置jsxpreserve可以不经过TypeScript处理React. 编译出来的 js 跟我们写es6一样.

@benjycui
Copy link
Contributor

@yiminghe 这个问题我也想不通。

不知道我们现在配置 "jsx": "preserve" 目的是什么?

@warmhug
Copy link
Contributor

warmhug commented Dec 15, 2016

配置 preserve ,估计是保留给 babel-presets-react 来处理

@yesmeck
Copy link
Member

yesmeck commented Dec 15, 2016

@BANG88 @warmhug 你们说的都是 preserve 的作用,但是让 babel 去处理的目的是什么?

@BANG88
Copy link
Member

BANG88 commented Dec 15, 2016

使用babel的各种plugins,如果typescript直接编译出来的话就不需要babel了。

@benjycui
Copy link
Contributor

但是就算提前把 <div /> 编译成 React.createElement('div') 也不会影响其他 babel-plugin 的行为吧。

@benjycui
Copy link
Contributor

2.1.x 正式发布了 https://github.com/Microsoft/TypeScript/releases/tag/v2.1.4

其实搞不懂 TypeScript 的版本号规则。。

@BANG88
Copy link
Member

BANG88 commented Dec 19, 2016

😭

@infeng
Copy link
Contributor

infeng commented Dec 19, 2016

好像beta的时候版本也会递增,跟webpack一样

@benjycui
Copy link
Contributor

antd 依赖的 TypeScript 升级到 2.1.x 了。

@yesmeck typescript-babel-jest 的问题,有必要的话,另起一个 issue 记录。

@yesmeck
Copy link
Member

yesmeck commented Dec 19, 2016

splitObject 可以去掉了。

@warmhug
Copy link
Contributor

warmhug commented Dec 19, 2016

antd-mobile 谁来帮忙升级下

@benjycui
Copy link
Contributor

splitObject 可以去掉了。

已去。

@benjycui
Copy link
Contributor

@warmhug antd-mobile 升级 antd-tools 的话,还要处理 tslint 的问题吧。。

@warmhug
Copy link
Contributor

warmhug commented Dec 19, 2016

lint 规则先忽略掉

@lock
Copy link

lock bot commented May 2, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants