René's URL Explorer Experiment


Title: Ivy compiler incorrectly allows undefined to be passed to any component input even without explicit undefined in input type when strictNullChecks is on · Issue #32690 · angular/angular · GitHub

Open Graph Title: Ivy compiler incorrectly allows undefined to be passed to any component input even without explicit undefined in input type when strictNullChecks is on · Issue #32690 · angular/angular

X Title: Ivy compiler incorrectly allows undefined to be passed to any component input even without explicit undefined in input type when strictNullChecks is on · Issue #32690 · angular/angular

Description: 🐞 bug report Affected Package Not exactly sure, but probably: @angular/compiler @angular/compiler-cli Is this a regression? No, from my experience, the old compiler didn't enforce strictNullChecks in templates at all, so this is new to I...

Open Graph Description: 🐞 bug report Affected Package Not exactly sure, but probably: @angular/compiler @angular/compiler-cli Is this a regression? No, from my experience, the old compiler didn't enforce strictNullChecks ...

X Description: 🐞 bug report Affected Package Not exactly sure, but probably: @angular/compiler @angular/compiler-cli Is this a regression? No, from my experience, the old compiler didn't enforce strictNullChe...

Opengraph URL: https://github.com/angular/angular/issues/32690

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Ivy compiler incorrectly allows undefined to be passed to any component input even without explicit undefined in input type when strictNullChecks is on","articleBody":"\u003c!--🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅\r\n\r\nOh hi there! 😄\r\n\r\nTo expedite issue processing please search open and closed issues before submitting a new one.\r\nExisting issues often contain information about workarounds, resolution, or progress updates.\r\n\r\n🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅🔅-->\r\n\r\n\r\n# 🐞 bug report\r\n\r\n### Affected Package\r\n\u003c!-- Can you pin-point one or more @angular/* packages as the source of the bug? -->\r\n\r\nNot exactly sure, but probably:\r\n@angular/compiler\r\n@angular/compiler-cli\r\n\r\n### Is this a regression?\r\n\r\n\u003c!-- Did this behavior use to work in the previous version? --> \r\n\r\nNo, from my experience, the old compiler didn't enforce strictNullChecks in templates at all, so this is new to Ivy.\r\n\r\n### Description\r\n\r\nWith `strictNullChecks` turned _on_, if you have a component input with a certain type that does _not_ explicitly include `undefined`, the Ivy compiler _does not complain_ if you pass `undefined` to that input from another component. This defeats a lot of the purpose of using `strictNullChecks`. (Note that it does complain about passing `null` if `null` isn't explicitly in the type, so I know `strictNullChecks` is enabled properly.)\r\n\r\nI believe this is due to the use of `Partial\u003cPick\u003c...>>` in the type check block for the template as described here: https://blog.angularindepth.com/type-checking-templates-in-angular-viewengine-and-ivy-77f8536359f5\r\n\r\n`Partial\u003c...>` causes each property to be made optional, which in effect adds `undefined` to the type of each property as well, as described in the TypeScript docs: `Optional parameters and properties automatically have undefined added to their types, even when their type annotations don’t specifically include undefined.`. (https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#optional-parameters-and-properties)\r\n\r\nSo, what seems to be happening is the Ivy compiler is adding `undefined` to the type of every input when considering the bindings, which means it will never complain about passing `undefined` to the input of any component. That really makes `strictNullChecks` a lot less useful.\r\n\r\nPlease understand that although nobody in practice would probably pass a hardcoded `undefined` to a component input, this is an actual problem any time you use `undefined` to represent the absence of a value being passed to a component. In my case, I have a store I subscribe to using the `async` pipe, and then some of the state gets passed into child components from there. Various properties on my state have types like `SomeModel | undefined`. `undefined` could mean the model is not yet loaded, for example. Although some people may use `null` instead, there seems to be a significant group that prefers to use `undefined` in all cases. Wherever you fall on that debate, my point is that this definitely comes into play in real projects, and in fact I'm having the issue after switching to Ivy in my own project. I can't have a lot of confidence in what I'm passing to my components' inputs if `undefined` is always allowed by the compiler regardless of the actual type of the inputs.\r\n\r\n## 🔬 Minimal Reproduction\r\n\u003c!--\r\nPlease create and share minimal reproduction of the issue starting with this template: https://stackblitz.com/fork/angular-issue-repro2\r\n-->\r\n\r\n\u003c!--\r\nIf StackBlitz is not suitable for reproduction of your issue, please create a minimal GitHub repository with the reproduction of the issue.\r\nA good way to make a minimal reproduction is to create a new app via `ng new repro-app` and add the minimum possible code to show the problem. \r\nShare the link to the repo below along with step-by-step instructions to reproduce the problem, as well as expected and actual behavior.\r\n\r\nIssues that don't have enough info and can't be reproduced will be closed.\r\n\r\nYou can read more about issue submission guidelines here: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-submitting-an-issue\r\n-->\r\n\r\nhttps://github.com/compeek/angular-ivy-input-undefined-issue\r\n\r\nIf you compile this project, you should only see a compiler error about `null` and not about `undefined` as well. See `index.html` for some more explanation of the example.\r\n\r\nYou can reproduce this easily in any project with `strictNullChecks` turned on and the Ivy compiler enabled with these two components (from my minimal reproduction project):\r\n\r\n```\r\n@Component({\r\n  selector: 'app-root',\r\n  template: `\u003capp-child [stringOnlyInput1]=\"thisPropertyIsUndefined\" [stringOnlyInput2]=\"thisPropertyIsNull\">\u003c/app-child>`\r\n})\r\nexport class AppComponent {\r\n  thisPropertyIsUndefined: undefined = undefined;\r\n  thisPropertyIsNull: null = null;\r\n}\r\n\r\n@Component({\r\n  selector: 'app-child',\r\n  template: `\r\n    {{ 'stringOnlyInput1: ' + stringOnlyInput1 }}\r\n    \u003cbr>\r\n    {{ 'stringOnlyInput2: ' + stringOnlyInput2 }}\r\n  `\r\n})\r\nexport class ChildComponent {\r\n  @Input() stringOnlyInput1: string = '';\r\n  @Input() stringOnlyInput2: string = '';\r\n}\r\n```\r\n\r\nThe compiler should complain about the values passed to both inputs, but in fact it only complains about the `null` value and not `undefined`.\r\n\r\n## 🔥 Exception or Error\r\n\r\nI would expect an error like:\r\n`Type 'undefined' is not assignable to type 'string'.`\r\n\r\nBut none is thrown.\r\n\r\nAnd in fact if you do it with `null`, the error looks like this:\r\n`Type 'null' is not assignable to type 'string | undefined'.`\r\n\r\nNotice how it says it's not assignable to `string | undefined` even though the input type is just `string`.\r\n\r\n## 🌍  Your Environment\r\n\r\n**Angular Version:**\r\n\u003cpre>\u003ccode>\r\n\u003c!-- run `ng version` and paste output below -->\r\nAngular CLI: 9.0.0-next.4\r\nNode: 10.16.3\r\nOS: win32 x64\r\nAngular: 9.0.0-next.6\r\n... animations, common, compiler, compiler-cli, core\r\n... language-service, platform-browser, platform-browser-dynamic\r\n... router\r\n\r\nPackage                           Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect         0.900.0-next.4\r\n@angular-devkit/build-angular     0.900.0-next.4\r\n@angular-devkit/build-optimizer   0.900.0-next.4\r\n@angular-devkit/build-webpack     0.900.0-next.4\r\n@angular-devkit/core              9.0.0-next.4\r\n@angular-devkit/schematics        9.0.0-next.4\r\n@angular/cli                      9.0.0-next.4\r\n@ngtools/webpack                  9.0.0-next.4\r\n@schematics/angular               9.0.0-next.4\r\n@schematics/update                0.900.0-next.4\r\nrxjs                              6.5.3\r\ntypescript                        3.5.3\r\nwebpack                           4.39.3\r\n\u003c/code>\u003c/pre>\r\n\r\n**Anything else relevant?**\r\n\u003c!-- ✍️Is this a browser specific issue? If so, please specify the browser and version. -->\r\n\r\n\u003c!-- ✍️Do any of these matter: operating system, IDE, package manager, HTTP server, ...? If so, please mention it below. -->\r\n","author":{"url":"https://github.com/compeek","@type":"Person","name":"compeek"},"datePublished":"2019-09-16T04:31:47Z","url":"https://github.com/angular/angular/issues/32690"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f2f52d38-8a8f-97ca-a1d4-a970d17a3d68
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC5B2:60A6D:27AB6D:34BFBB:6B018CEA
html-safe-nonce2ff1bc5aba85417d8a7e0c80c4d88555a034b13b14f406700d12be0173fe1810
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNUIyOjYwQTZEOjI3QUI2RDozNEJGQkI6NkIwMThDRUEiLCJ2aXNpdG9yX2lkIjoiNjAwNDEyMjkzNDUwNTk5OTU5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac5e49dab67180ea4597beeeba5f3ab643135ee39e42bcb3219b203e77bc16a41d
hovercard-subject-tagissue:493841472
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/32690/issue_layout
twitter:imagehttps://opengraph.githubassets.com/62e203a20e98b9cf7da3df77692def007dc53cd8752b5f6e46384adb50055e59/angular/angular/issues/32690
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/62e203a20e98b9cf7da3df77692def007dc53cd8752b5f6e46384adb50055e59/angular/angular/issues/32690
og:image:alt🐞 bug report Affected Package Not exactly sure, but probably: @angular/compiler @angular/compiler-cli Is this a regression? No, from my experience, the old compiler didn't enforce strictNullChecks ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecompeek
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/32690#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F32690
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F32690
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/32690
Reloadhttps://github.com/angular/angular/issues/32690
Reloadhttps://github.com/angular/angular/issues/32690
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues837 (837)https://github.com/angular/angular/issues
Pull requests143 (143)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/32690
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/32690
Ivy compiler incorrectly allows undefined to be passed to any component input even without explicit undefined in input type when strictNullChecks is onhttps://github.com/angular/angular/issues/32690#top
area: compilerIssues related to `ngc`, Angular's template compilerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20compiler%22
needsTriagehttps://github.com/angular/angular/milestone/83
https://github.com/compeek
compeekhttps://github.com/compeek
on Sep 16, 2019https://github.com/angular/angular/issues/32690#issue-493841472
https://blog.angularindepth.com/type-checking-templates-in-angular-viewengine-and-ivy-77f8536359f5https://blog.angularindepth.com/type-checking-templates-in-angular-viewengine-and-ivy-77f8536359f5
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#optional-parameters-and-propertieshttps://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#optional-parameters-and-properties
https://github.com/compeek/angular-ivy-input-undefined-issuehttps://github.com/compeek/angular-ivy-input-undefined-issue
compeekhttps://github.com/compeek
on Sep 16, 2019https://github.com/angular/angular/issues/32690#event-2635159041
compeekhttps://github.com/compeek
on Sep 16, 2019https://github.com/angular/angular/issues/32690#event-2635159215
compeekhttps://github.com/compeek
on Sep 16, 2019https://github.com/angular/angular/issues/32690#event-2635159870
AndrewKushnirhttps://github.com/AndrewKushnir
area: compilerIssues related to `ngc`, Angular's template compilerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20compiler%22
comp: ivyhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22comp%3A%20ivy%22
on Sep 16, 2019https://github.com/angular/angular/issues/32690#event-2637133249
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
on Sep 16, 2019https://github.com/angular/angular/issues/32690#event-2637133291
https://github.com/alxhub
alxhubhttps://github.com/alxhub
on Oct 8, 2019https://github.com/angular/angular/issues/32690#issuecomment-539727824
https://angular-team.atlassian.net/browse/FW-1606https://angular-team.atlassian.net/browse/FW-1606
@JoostKhttps://github.com/JoostK
https://github.com/compeek
compeekhttps://github.com/compeek
on Oct 9, 2019https://github.com/angular/angular/issues/32690#issuecomment-539786497
https://angular-team.atlassian.net/browse/FW-1606https://angular-team.atlassian.net/browse/FW-1606
compeekhttps://github.com/compeek
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 9, 2019https://github.com/angular/angular/issues/32690#event-2697411584
compeekhttps://github.com/compeek
on Oct 9, 2019https://github.com/angular/angular/issues/32690#event-2697411676
https://github.com/JoostK
JoostKhttps://github.com/JoostK
on Oct 9, 2019https://github.com/angular/angular/issues/32690#issuecomment-539816063
@compeekhttps://github.com/compeek
https://github.com/compeek
compeekhttps://github.com/compeek
on Oct 9, 2019https://github.com/angular/angular/issues/32690#issuecomment-539820977
@JoostKhttps://github.com/JoostK
https://github.com/JoostK
JoostKhttps://github.com/JoostK
on Oct 9, 2019https://github.com/angular/angular/issues/32690#issuecomment-539823829
https://github.com/compeek
compeekhttps://github.com/compeek
on Oct 9, 2019https://github.com/angular/angular/issues/32690#issuecomment-539824674
mheveryhttps://github.com/mhevery
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
50bf17ahttps://github.com/angular/angular/commit/50bf17aca03727fae6389d90df4ff8f6b68d2f82
on Oct 14, 2019https://github.com/angular/angular/issues/32690#event-2711712082
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Nov 14, 2019https://github.com/angular/angular/issues/32690#issuecomment-553957996
automatic conversation locking policyhttps://github.com/angular/angular/blob/67d80f/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Nov 14, 2019https://github.com/angular/angular/issues/32690#event-2799655014
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/32690
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/32690
area: compilerIssues related to `ngc`, Angular's template compilerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20compiler%22
needsTriageNo due datehttps://github.com/angular/angular/milestone/83
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.