{"id":18423449,"url":"https://github.com/thejoin95/proposal-nullcheck-object-destructuring","last_synced_at":"2026-03-19T04:18:48.762Z","repository":{"id":151847809,"uuid":"624881957","full_name":"TheJoin95/proposal-nullcheck-object-destructuring","owner":"TheJoin95","description":"Null check in object destructuring","archived":false,"fork":false,"pushed_at":"2023-04-07T16:56:20.000Z","size":6,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-23T05:03:09.936Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.mikilombardi.com/proposal-nullcheck-object-destructuring/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheJoin95.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-07T13:47:31.000Z","updated_at":"2023-04-07T16:56:52.000Z","dependencies_parsed_at":"2023-05-12T15:00:32.106Z","dependency_job_id":null,"html_url":"https://github.com/TheJoin95/proposal-nullcheck-object-destructuring","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"tc39/template-for-proposals","purl":"pkg:github/TheJoin95/proposal-nullcheck-object-destructuring","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheJoin95%2Fproposal-nullcheck-object-destructuring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheJoin95%2Fproposal-nullcheck-object-destructuring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheJoin95%2Fproposal-nullcheck-object-destructuring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheJoin95%2Fproposal-nullcheck-object-destructuring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheJoin95","download_url":"https://codeload.github.com/TheJoin95/proposal-nullcheck-object-destructuring/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheJoin95%2Fproposal-nullcheck-object-destructuring/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271745472,"owners_count":24813499,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T04:37:19.261Z","updated_at":"2026-03-19T04:18:48.728Z","avatar_url":"https://github.com/TheJoin95.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Proposal of null check object destructuring\n\nProposal to add the null check in objct destructuring syntax\n\n## Status\n\nState: -1\n\nAuthor: @thejoin95 ([@thejoin95](https://twitter.com/thejoin95))\n\nChampion: need one\n\n## Motivation\n\nObject destructuring is well use by the javascript developers. The default value in case of an undefined prop is useful and I think it could be even better if we are going to implement it as well with the null check, especially for a nested object in order to avoid null check errors.\n\n## Use cases \u0026 description\n\nImagine to have an object with n depth level, e.g. a react state/context with differents properties containing n-depth objects.\nIn some scenario you want to destructure few properties at the first level and in other case also some more specific in-depth props.\n\n```\nconst state = {\n  navbar: {\n    profileMenu: {\n      username: 'jhondoe',\n      ...\n    }\n  },\n  footer: {\n    brand: {\n      title: 'brand one',\n      ...\n    }\n  },\n  ...\n}\n\nconst {\n  navbar: {\n    profileMenu: {\n      username: ProfileMenuUsername\n    }\n  }\n} = state;\n\n```\n\nLet's say that, the properties are going to be valorised but some of them would have a `null` value:\n\n```\n{\n  navbar: {\n    profileMenu: null,\n  },\n  footer: {\n    brand: {\n      title: 'brand one',\n      ...\n    }\n  },\n  ...\n}\n\nconst {\n  navbar: {\n    profileMenu: {\n      username: ProfileMenuUsername\n    }\n  }\n} = state; // this will break because there is no valid username prop in null\n\n```\n\nWhen a nested property is undefined, we could assign the default value, defined in the object destructuring syntax:\n\n```\nconst {\n  navbar: {\n    profileMenu: {\n      username: ProfileMenuUsername\n    } = { username: null }\n  } = { profileMenu: { username: null } }\n} = state;\n\n```\n\nIt would be great to have a syntax to indicate whenever a property could be nullable by adding a short circuit instead of throwing an error by reusing the `.?`, such like:\n\n```\nconst {\n  navbar: {\n    profileMenu?: {\n      username: ProfileMenuUsername\n    } = { username: null }\n  } = { profileMenu: { username: null } }\n} = state;\n\n```\n\n## Comparison\n\nThese npm modules do something like the proposal:\n- [lodash.get](https://lodash.com/docs/#get)\n\nEven though is a different approach, would say old style, and I believe it should implemented directly on the destructure syntax.\n\n## Q\u0026A\n\nIn progress","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthejoin95%2Fproposal-nullcheck-object-destructuring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthejoin95%2Fproposal-nullcheck-object-destructuring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthejoin95%2Fproposal-nullcheck-object-destructuring/lists"}