Thanks to visit codestin.com
Credit goes to github.com

Skip to content

未指定类型和指定为any的不太一样 #74

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

Conversation

wangchengcheer
Copy link

如果未指定类型

let something;

something = 'seven';
something = 7;

something.setName('Tom');//错误,提示Property 'setName' does not exist on type 'number'.ts(2339)

如果指定了类型为any

let something :any;

something = 'seven';
something = 7;

something.setName('Tom');//正确

@xcatliu
Copy link
Owner

xcatliu commented Sep 2, 2019

你是不是配置了 noImplicitAny?我是按照没有配置这个参数约定的

@xcatliu xcatliu closed this Sep 2, 2019
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

Successfully merging this pull request may close these issues.

2 participants