{"action":"created","issue":{"url":"https://api.github.com/repos/keplersj/gatsby-theme-early-bird/issues/150","repository_url":"https://api.github.com/repos/keplersj/gatsby-theme-early-bird","labels_url":"https://api.github.com/repos/keplersj/gatsby-theme-early-bird/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/keplersj/gatsby-theme-early-bird/issues/150/comments","events_url":"https://api.github.com/repos/keplersj/gatsby-theme-early-bird/issues/150/events","html_url":"https://github.com/keplersj/gatsby-theme-early-bird/issues/150","id":526646490,"node_id":"MDU6SXNzdWU1MjY2NDY0OTA=","number":150,"title":"Consider type inference over type assertions ","user":{"login":"Eyas","id":554424,"node_id":"MDQ6VXNlcjU1NDQyNA==","avatar_url":"https://avatars2.githubusercontent.com/u/554424?v=4","gravatar_id":"","url":"https://api.github.com/users/Eyas","html_url":"https://github.com/Eyas","followers_url":"https://api.github.com/users/Eyas/followers","following_url":"https://api.github.com/users/Eyas/following{/other_user}","gists_url":"https://api.github.com/users/Eyas/gists{/gist_id}","starred_url":"https://api.github.com/users/Eyas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eyas/subscriptions","organizations_url":"https://api.github.com/users/Eyas/orgs","repos_url":"https://api.github.com/users/Eyas/repos","events_url":"https://api.github.com/users/Eyas/events{/privacy}","received_events_url":"https://api.github.com/users/Eyas/received_events","type":"User","site_admin":false},"labels":[{"id":1690198267,"node_id":"MDU6TGFiZWwxNjkwMTk4MjY3","url":"https://api.github.com/repos/keplersj/gatsby-theme-early-bird/labels/feature_request","name":"feature_request","color":"ededed","default":false,"description":null}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2019-11-21T14:56:05Z","updated_at":"2019-11-22T21:03:04Z","closed_at":null,"author_association":"NONE","body":"See https://basarat.gitbooks.io/typescript/docs/types/type-assertion.html#assertion-considered-harmful\r\n\r\nI was looking at https://github.com/keplersj/gatsby-theme-early-bird/blob/master/gatsby-theme-early-bird/src/components/BlogPostItem/index.tsx#L40-L52\r\n\r\nthe `as BlogPosting` means that we're not getting the full power of TypeScript's type checking there. In general, something like:\r\n\r\n```ts\r\nconst posting: BlogPosting = { ... };  // Better\r\nconst posting = { ... } as BlogPosting;  // Worse\r\n```\r\n\r\nas the latter *asserts* the type (kind of similar to \"downcasting\", in that it casts to more specific types --like in the links-- but not totally irrelevant types).\r\n\r\nThe fix, here and elsewhere, is to either assign to a temporary, or use something like (shameless plug) [react-schemaorg](https://www.npmjs.com/package/react-schemaorg) which does exactly the same thing you're doing, but forces type checking."},"comment":{"url":"https://api.github.com/repos/keplersj/gatsby-theme-early-bird/issues/comments/557693289","html_url":"https://github.com/keplersj/gatsby-theme-early-bird/issues/150#issuecomment-557693289","issue_url":"https://api.github.com/repos/keplersj/gatsby-theme-early-bird/issues/150","id":557693289,"node_id":"MDEyOklzc3VlQ29tbWVudDU1NzY5MzI4OQ==","user":{"login":"keplersj","id":594124,"node_id":"MDQ6VXNlcjU5NDEyNA==","avatar_url":"https://avatars1.githubusercontent.com/u/594124?v=4","gravatar_id":"","url":"https://api.github.com/users/keplersj","html_url":"https://github.com/keplersj","followers_url":"https://api.github.com/users/keplersj/followers","following_url":"https://api.github.com/users/keplersj/following{/other_user}","gists_url":"https://api.github.com/users/keplersj/gists{/gist_id}","starred_url":"https://api.github.com/users/keplersj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keplersj/subscriptions","organizations_url":"https://api.github.com/users/keplersj/orgs","repos_url":"https://api.github.com/users/keplersj/repos","events_url":"https://api.github.com/users/keplersj/events{/privacy}","received_events_url":"https://api.github.com/users/keplersj/received_events","type":"User","site_admin":false},"created_at":"2019-11-22T21:03:04Z","updated_at":"2019-11-22T21:03:04Z","author_association":"OWNER","body":"Thank you for commenting on that! Really informative and helpful. I implemented your tips in one of my [other Gatsby themes](https://github.com/keplersj/gatsby-theme-atom-service/commit/6b1082daca72a51c0a9ecda2db4fa10ad81f5c4d) and it worked really well. This then lead me to [fix a bug](https://github.com/keplersj/jest-serializer-json-ld-script/commit/b565405c099f23e9c90335e7cdc212491d927ef8) in the package I use to serialize LD+JSON data in Jest snapshots. Thank you!"}}
{"actor":{"display_login":"keplersj"}}