{"action":"opened","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4787","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4787/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4787/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4787/events","html_url":"https://github.com/Microsoft/TypeScript/issues/4787","id":106422530,"number":4787,"title":"Option idea: NoImplicityCastAny","user":{"login":"jargv","id":551187,"avatar_url":"https://avatars.githubusercontent.com/u/551187?v=3","gravatar_id":"","url":"https://api.github.com/users/jargv","html_url":"https://github.com/jargv","followers_url":"https://api.github.com/users/jargv/followers","following_url":"https://api.github.com/users/jargv/following{/other_user}","gists_url":"https://api.github.com/users/jargv/gists{/gist_id}","starred_url":"https://api.github.com/users/jargv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jargv/subscriptions","organizations_url":"https://api.github.com/users/jargv/orgs","repos_url":"https://api.github.com/users/jargv/repos","events_url":"https://api.github.com/users/jargv/events{/privacy}","received_events_url":"https://api.github.com/users/jargv/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-14T20:35:25Z","updated_at":"2015-09-14T20:35:25Z","closed_at":null,"body":"Here's a use case I have in mind for typescript, at which it failed:\r\n\r\nI'm coding along, enjoying optional types and cranking out my feature. After a while I decide that my interfaces are well-understood and I create a `DefinedThing` interface. So I change my function from `foo(thing : any) : void {...}` to `foo(thing : DefinedThing) : void {...}`. The problem is that none of my other code which uses `foo` uses types yet, so Typescript will happily convert `any` into `DefinedThing` in calling `foo`. Adding the type has given me no benefit at all.\r\n\r\nWhat I would have liked to happen in this case is that typescript would give me errors anywhere that I'm trying to use an `any` in place of a `DefinedThing`. Following these errors would lead me to be much more explicit throughout my code, but only in the places where I have nailed down my interfaces. All of the rest of my code would continue to be untyped. This is different from NoImplicitAny in that it would not require types on everything. Further it would be a stronger guarantee than NoImplicitAny for the code that has types; use of *explicit* `any` defeats many guarantees of the typesystem.\r\n\r\nIn Other words, I'm proposing that that an `any` only be allowed to substitute for other types with a cast: `let f : DefinedThing = <DefinedThing>anyVar;` when a flag is given, such as `NoImplicitCastAny`.\r\n\r\nIn the language of C and C++, this is like saying I would like `any` to behave like C++'s void* rather than like C's void*. "}}