{"action":"opened","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/15271","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/15271/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/15271/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/15271/events","html_url":"https://github.com/Microsoft/TypeScript/issues/15271","id":222810206,"number":15271,"title":"Inconsistent String Literal Type Propagation","user":{"login":"mattnedrich","id":4796480,"avatar_url":"https://avatars1.githubusercontent.com/u/4796480?v=3","gravatar_id":"","url":"https://api.github.com/users/mattnedrich","html_url":"https://github.com/mattnedrich","followers_url":"https://api.github.com/users/mattnedrich/followers","following_url":"https://api.github.com/users/mattnedrich/following{/other_user}","gists_url":"https://api.github.com/users/mattnedrich/gists{/gist_id}","starred_url":"https://api.github.com/users/mattnedrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattnedrich/subscriptions","organizations_url":"https://api.github.com/users/mattnedrich/orgs","repos_url":"https://api.github.com/users/mattnedrich/repos","events_url":"https://api.github.com/users/mattnedrich/events{/privacy}","received_events_url":"https://api.github.com/users/mattnedrich/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-04-19T17:21:26Z","updated_at":"2017-04-19T17:21:26Z","closed_at":null,"body":"**TypeScript Version:**  2.3.0 RC\r\n\r\n I'm observing some strange type behavior. Consider the following snippet.\r\n\r\n```ts\r\ntype myType = \"MY_TYPE\";\r\nconst myType: myType = \"MY_TYPE\";\r\n\r\nconst foo = myType;\r\nconst bar = {\r\n  baz: foo\r\n};\r\n```\r\n\r\nThe type of `foo` and `baz` are both `\"MY_TYPE\"` as expected.\r\n\r\nHowever using this `strEnum` function as described [here](https://github.com/basarat/typescript-book/blob/master/docs/types/literal-types.md) which, based on my understanding, should be doing the same thing as the above code, results in something different:\r\n\r\n```ts\r\nfunction strEnum<T extends string>(o: Array<T>): {[K in T]: K} {\r\n  return o.reduce((res, key) => {\r\n    res[key] = key;\r\n    return res;\r\n  }, Object.create(null));\r\n}\r\n\r\nconst myTypeEnum = strEnum([\"MY_TYPE\"])\r\n\r\nconst foo = myTypeEnum.MY_TYPE;\r\nconst bar = {\r\n  baz: foo\r\n};\r\n```\r\nHere, foo is detected to be type `\"MY_TYPE\"`, but `baz` is recognized as type `string` \r\n\r\nAm I doing something wrong? Is this expected behavior?"}}
{"actor":{"display_login":"mattnedrich"}}