Skip to content

fix(eslint): off no-undef #199

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

Closed
wants to merge 1 commit into from
Closed

fix(eslint): off no-undef #199

wants to merge 1 commit into from

Conversation

sufuwang
Copy link
Collaborator

在 ts 或者 tsx 有如下 eslint 报错

'JSX' is not defined.eslint[no-undef]

@sufuwang
Copy link
Collaborator Author

@all-contributors please add @sufuwang for

@allcontributors
Copy link
Contributor

@sufuwang

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

@sufuwang
Copy link
Collaborator Author

@all-contributors please add @sufuwang for code

@allcontributors
Copy link
Contributor

@sufuwang

I've put up a pull request to add @sufuwang! 🎉

@sufuwang sufuwang requested review from ElsaOOo and kagol February 16, 2022 13:29
@kagol
Copy link
Member

kagol commented Feb 17, 2022

在 ts 或者 tsx 有如下 eslint 报错

'JSX' is not defined.eslint[no-undef]

no-undef 这个规则表示不允许使用未声明的变量,看起来是有用的,为什么要关闭这个规则呢?
@sufuwang

@sufuwang
Copy link
Collaborator Author

sufuwang commented Feb 17, 2022

在 ts 或者 tsx 有如下 eslint 报错

'JSX' is not defined.eslint[no-undef]

no-undef 这个规则表示不允许使用未声明的变量,看起来是有用的,为什么要关闭这个规则呢? @sufuwang

@kagol 这个规则在 ts 中使用时,eslint 会错误地认为全局类型为未定义,如 JSX ,并且 ts 会判断某个正在使用的变量是否已经被定义,所以建议关掉这个规则,在 ts 和 tsx 文件中

@kagol
Copy link
Member

kagol commented Feb 19, 2022

@sufuwang 这个错误是怎么报出来的呢?

'JSX' is not defined.eslint[no-undef]

@sufuwang
Copy link
Collaborator Author

image

@kagol
Copy link
Member

kagol commented Feb 20, 2022

image

为什么要用JSX.Element的写法呢?直接在xxx.tsx的文件中写JSX的语法就行,这个no-undef的规则不应该因为这个JSX.Element的写法报错而移除。

@sufuwang
Copy link
Collaborator Author

@kagol 如果项目有一个 d.ts 文件,在 ts 或 tsx 文件中使用其中的类型,则 eslint 会报此错误,devui 中不会存在 d.ts 的声明文件吗?

@sufuwang sufuwang closed this Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants