Deliver web apps with confidence 🚀
Find a file
JoostK 2a2744721b fix(compiler-cli): ensure literal types are retained when strictNullInputTypes is disabled (#38305)
Consider the `NgModel` directive which has the `ngModelOptions` input:

```ts
class NgModel {
  @Input() ngModelOptions: { updateOn: 'blur'|'change'|'submit' };
}
```

In a template this may be set using an object literal as follows:

```html
<input ngModel [ngModelOptions]="{updateOn: 'blur'}">
```

This assignment should be accepted, as the object's type aligns with the
`ngModelOptions` input in `NgModel`. However, if the `strictNullInputTypes`
option is disabled this assignment would inadvertently produce an error:

```
Type '{ updateOn: string; }' is not assignable to type '{ updateOn: "blur"|"change"|"submit"; }'.
  Types of property 'updateOn' are incompatible.
    Type 'string' is not assignable to type '"blur"|"change"|"submit"'
```

This is due to the `'blur'` value being inferred to be of type `string`
instead of retaining its literal type. The non-null assertion operator
that is automatically inserted for input binding assignments when
`strictNullInputTypes` is disabled inhibits TypeScript from inferring
the string value as its literal type.

This commit fixes the issue by omitting the insertion of the non-null
operator for object literals and array literals.

PR Close #38305
2021-11-09 18:01:24 +00:00
.circleci ci: do not capture nested bazel integration test workspace within Bazel (#44061) 2021-11-05 16:22:17 +00:00
.devcontainer ci: update default circle ci image to cimg/node:14.17.6 (#43810) 2021-10-12 17:43:15 +00:00
.github build: update angular (#44024) 2021-11-03 15:06:36 -07:00
.husky build: remove unnecessary husky gitignore file (#42870) 2021-07-19 17:31:55 -07:00
.ng-dev build: update to the latest version of @angular/dev-infra-private (#43541) 2021-10-04 10:51:01 -07:00
.vscode docs: added commas to sentences in .vscode/README.md (#43684) 2021-10-21 18:39:58 +00:00
.yarn build: update to yarn v1.22.10 (#40562) 2021-01-26 10:52:27 -08:00
aio docs: update getting started tutorial to use StackBlitz web-containers (#44085) 2021-11-08 18:12:16 +00:00
docs docs: clarify meaning of ellipsis in bazel command (#43890) 2021-10-20 20:14:48 +00:00
goldens refactor(forms): update minlength/maxlength to inherit abstractValidator (#43998) 2021-11-05 20:09:53 +00:00
integration test: re-enable bazel integration test with APF v13 (#44061) 2021-11-05 16:22:17 +00:00
modules build: remove "ivy-only" bazel tag (#43862) 2021-10-19 10:06:55 -07:00
packages fix(compiler-cli): ensure literal types are retained when strictNullInputTypes is disabled (#38305) 2021-11-09 18:01:24 +00:00
scripts build: use the latest version of Chrome (v93) in non-bazel tests (#43880) 2021-10-29 13:10:25 -07:00
third_party build: rename shims_for_IE.js -> shims_for_internal_tests.js (#43002) 2021-08-02 10:38:42 -07:00
tools ci: remove saucelabs view engine tests (#43862) 2021-10-19 10:06:55 -07:00
.bazelignore test: delete integration test for language service plugin (#41740) 2021-04-23 11:00:40 -07:00
.bazelrc ci: do not capture nested bazel integration test workspace within Bazel (#44061) 2021-11-05 16:22:17 +00:00
.bazelversion build: remove outdated note when updating bazel version (#42760) 2021-07-09 14:50:14 -07:00
.clang-format feat(tooling): Add a .clang-format for automated JavaScript formatting. 2015-04-02 08:44:34 -07:00
.editorconfig build: use https link to editorconfig.org in .editorconfig (#27664) 2018-12-18 09:30:09 -08:00
.gitattributes build: remove ts-api-guardian from repository (#42735) 2021-07-26 12:02:14 -07:00
.gitignore build: Turn tsec checks into bazel tests. (#43108) 2021-09-13 14:45:57 -07:00
.gitmessage build: remove dev-infra directory and migrate to relying on @angular/dev-infra-private-builds (#43061) 2021-08-16 10:44:27 -07:00
.mailmap build: add a Git .mailmap with my new name (#19550) 2017-10-09 14:35:30 -07:00
.npmrc build: rely on engines to prevent using npm for dependency install (#41477) 2021-04-07 12:05:01 -07:00
.nvmrc ci: update default circle ci image to cimg/node:14.17.6 (#43810) 2021-10-12 17:43:15 +00:00
.prettierrc ci: use prettier to format yml files (#42136) 2021-05-19 11:20:20 -07:00
.pullapprove.yml docs: improve consuming partial-Ivy code outside the Angular CLI (#44027) 2021-11-04 18:55:52 +00:00
.yarnrc build: update to yarn v1.22.10 (#40562) 2021-01-26 10:52:27 -08:00
browser-providers.conf.js ci: update mobile browsers tested via browser stack to correctly test supported browsers (#43858) 2021-11-05 19:56:03 +00:00
BUILD.bazel build: rename shims_for_IE.js -> shims_for_internal_tests.js (#43002) 2021-08-02 10:38:42 -07:00
CHANGELOG.md docs: fix typo in the CHANGELOG (#44058) 2021-11-05 16:32:08 +00:00
CODE_OF_CONDUCT.md docs: add Discord as an official communication channel (#39149) 2020-10-14 10:23:15 -07:00
CONTRIBUTING.md docs: fixed minor grammar mistakes in CONTRIBUTING (#43684) 2021-10-21 18:39:58 +00:00
gulpfile.js build: convert CLDR locale extraction from Gulp to Bazel tool (#42230) 2021-07-16 12:44:59 -07:00
karma-js.conf.js ci: remove browserstack configuration (#43881) 2021-10-18 15:00:22 -07:00
LICENSE docs: update the copyright notice date (#40707) 2021-02-16 10:04:23 -08:00
package.json build: update dependency vlq to v2 (#43901) 2021-11-08 17:00:56 +00:00
README.md docs: improve documentation (#44031) 2021-11-05 16:23:50 +00:00
renovate.json build: add angular v12 packages to renovate ignore list (#44054) 2021-11-05 16:22:53 +00:00
test-events.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test-main.js build: remove unnecessary polyfills from tests (#42567) 2021-06-14 14:14:41 -07:00
tsconfig-tslint.json build: remove dev-infra directory and migrate to relying on @angular/dev-infra-private-builds (#43061) 2021-08-16 10:44:27 -07:00
tslint.json build: enable esModuleInterop in TypeScript compilations (#43431) 2021-10-01 18:28:45 +00:00
WORKSPACE build: update all non-major dependencies (#43838) 2021-10-15 10:45:02 -07:00
yarn.lock build: update dependency vlq to v2 (#43901) 2021-11-08 17:00:56 +00:00
yarn.lock.readme.md build: remove travisci leftovers (#27979) 2019-01-09 10:41:16 -08:00

Angular - The modern web developer's platform.

angular-logo
Angular is a development platform for building mobile and desktop web applications
using Typescript/JavaScript and other languages.

www.angular.io

Contributing Guidelines · Submit an Issue · Blog

CI status   Angular on npm   Discord conversation


Documentation

Get started with Angular, learn the fundamentals and explore advanced topics on our documentation website.

Advanced

Development Setup

Prerequisites

Setting Up a Project

Install the Angular CLI globally:

npm install -g @angular/cli

Create workspace:

ng new [PROJECT NAME]

Run the application:

cd [PROJECT NAME]
ng serve

Angular is cross-platform, fast, scalable, has incredible tooling, and is loved by millions.

Quickstart

Get started in 5 minutes.

Ecosystem

angular ecosystem logos

Changelog

Learn about the latest improvements.

Upgrading

Check out our upgrade guide to find out the best way to upgrade your project.

Contributing

Contributing Guidelines

Read through our contributing guidelines to learn about our submission process, coding rules and more.

Want to Help?

Want to report a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues labeled as help wanted or good first issue.

Code of Conduct

Help us keep Angular open and inclusive. Please read and follow our Code of Conduct.

Community

Join the conversation and help the community.

Love Angular badge

Love Angular? Give our repo a star ⬆️.