{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3523","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3523/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3523/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3523/events","html_url":"https://github.com/Microsoft/TypeScript/issues/3523","id":88804249,"number":3523,"title":"Question: is there a way to detect an unsound assignment via public compiler API?","user":{"login":"aleksey-bykov","id":937933,"avatar_url":"https://avatars.githubusercontent.com/u/937933?v=3","gravatar_id":"","url":"https://api.github.com/users/aleksey-bykov","html_url":"https://github.com/aleksey-bykov","followers_url":"https://api.github.com/users/aleksey-bykov/followers","following_url":"https://api.github.com/users/aleksey-bykov/following{/other_user}","gists_url":"https://api.github.com/users/aleksey-bykov/gists{/gist_id}","starred_url":"https://api.github.com/users/aleksey-bykov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aleksey-bykov/subscriptions","organizations_url":"https://api.github.com/users/aleksey-bykov/orgs","repos_url":"https://api.github.com/users/aleksey-bykov/repos","events_url":"https://api.github.com/users/aleksey-bykov/events{/privacy}","received_events_url":"https://api.github.com/users/aleksey-bykov/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/API","name":"API","color":"bfe5bf"},{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Question","name":"Question","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-16T18:33:01Z","updated_at":"2015-06-18T19:15:23Z","closed_at":null,"body":"My situation (#3067):\r\n```typescript\r\ninterface A {\r\n    x: string;\r\n}\r\n\r\ninterface B {\r\n    x: string;\r\n    y: string;\r\n}\r\n\r\nfunction copyB(value: B): B {\r\n    return undefined;\r\n}\r\n\r\nvar values: A[] = [];\r\nvalues.map(copyB); // <-- unsound assigment\r\n```\r\nI've managed to get an AST and a type checker. I am holding a reference to the argument (copyB from above) object.\r\n\r\nCan anyone outline the steps that need to be taken to determine that the assignment from the example is unsound using the public compiler API?"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/113263123","html_url":"https://github.com/Microsoft/TypeScript/issues/3523#issuecomment-113263123","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/3523","id":113263123,"user":{"login":"JsonFreeman","id":8052525,"avatar_url":"https://avatars.githubusercontent.com/u/8052525?v=3","gravatar_id":"","url":"https://api.github.com/users/JsonFreeman","html_url":"https://github.com/JsonFreeman","followers_url":"https://api.github.com/users/JsonFreeman/followers","following_url":"https://api.github.com/users/JsonFreeman/following{/other_user}","gists_url":"https://api.github.com/users/JsonFreeman/gists{/gist_id}","starred_url":"https://api.github.com/users/JsonFreeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JsonFreeman/subscriptions","organizations_url":"https://api.github.com/users/JsonFreeman/orgs","repos_url":"https://api.github.com/users/JsonFreeman/repos","events_url":"https://api.github.com/users/JsonFreeman/events{/privacy}","received_events_url":"https://api.github.com/users/JsonFreeman/received_events","type":"User","site_admin":false},"created_at":"2015-06-18T19:15:23Z","updated_at":"2015-06-18T19:15:23Z","body":"You'd have to do a couple of things:\r\n\r\n1. Augment checkTypeAssignableTo to take a flag indicating that you only want to allow sound assignments.\r\n2. Add the checks that you want to fail on, guarded by this flag.\r\n3. Add a relation cache that stores results for sound checks, so it doesn't mix with the existing cache.\r\n4. Expose this function on the type checker interface."}}