angular-cn/packages
Alex Rickabaugh 1eba57eb00 fix(language-service): show suggestion when type inference is suboptimal (#41072)
The Ivy Language Service uses the compiler's template type-checking engine,
which honors the configuration in the user's tsconfig.json. We recommend
that users upgrade to `strictTemplates` mode in their projects to take
advantage of the best possible type inference, and thus to have the best
experience in Language Service.

If a project is not using `strictTemplates`, then the compiler will not
leverage certain type inference options it has. One case where this is very
noticeable is the inference of let- variables for structural directives that
provide a template context guard (such as NgFor). Without `strictTemplates`,
these guards will not be applied and such variables will be inferred as
'any', degrading the user experience within Language Service.

This is working as designed, since the Language Service _should_ reflect
types exactly as the compiler sees them. However, the View Engine Language
Service used its own type system that _would_ infer these types even when
the compiler did not. As a result, it's confusing to some users why the
Ivy Language Service has "worse" type inference.

To address this confusion, this commit implements a suggestion diagnostic
which is shown in the Language Service for variables which could have been
narrowed via a context guard, but the type checking configuration didn't
allow it. This should make the reason why variables receive the 'any' type
as well as the action needed to improve the typings much more obvious,
improving the Language Service experience.

Fixes angular/vscode-ng-language-service#1155
Closes #41042

PR Close #41072
2021-03-23 09:39:19 -07:00
..
animations feat(core): support TypeScript 4.2 (#41158) 2021-03-17 09:10:25 -07:00
bazel feat(core): drop support for TypeScript 4.0 and 4.1 (#41158) 2021-03-17 09:10:25 -07:00
benchpress fix(dev-infra): update type castings for JSON.parse usage (#40710) 2021-02-09 10:48:43 -08:00
common feat(core): support TypeScript 4.2 (#41158) 2021-03-17 09:10:25 -07:00
compiler refactor(compiler): use `ɵɵInjectorDeclaration` rather than `ɵɵInjectorDef` in compiled output (#41119) 2021-03-22 08:57:18 -07:00
compiler-cli fix(language-service): show suggestion when type inference is suboptimal (#41072) 2021-03-23 09:39:19 -07:00
core refactor(compiler): use `ɵɵInjectorDeclaration` rather than `ɵɵInjectorDef` in compiled output (#41119) 2021-03-22 08:57:18 -07:00
docs docs(di): fix typo in advanced di doc (#36634) 2020-05-01 09:50:28 -07:00
elements feat(core): support TypeScript 4.2 (#41158) 2021-03-17 09:10:25 -07:00
examples docs: improve description, examples of DecimalPipe's digitsInfo parameter (#40714) 2021-02-26 15:42:29 -08:00
forms feat(core): support TypeScript 4.2 (#41158) 2021-03-17 09:10:25 -07:00
language-service fix(language-service): show suggestion when type inference is suboptimal (#41072) 2021-03-23 09:39:19 -07:00
localize docs(localize): expose documentation for the `@angular/localize` package (#40317) 2021-03-19 12:36:10 -07:00
misc/angular-in-memory-web-api docs: remove duplicated the (#40434) 2021-01-14 11:33:57 -08:00
platform-browser fix(animations): cleanup DOM elements when the root view is removed (#41059) 2021-03-22 12:58:11 -07:00
platform-browser-dynamic feat(core): support TypeScript 4.2 (#41158) 2021-03-17 09:10:25 -07:00
platform-server feat(core): support TypeScript 4.2 (#41158) 2021-03-17 09:10:25 -07:00
private/testing build: update .bazelversion (#40579) 2021-01-26 11:35:54 -08:00
router fix(router): fragment can be null (#37336) 2021-03-22 10:02:39 -07:00
service-worker feat(core): support TypeScript 4.2 (#41158) 2021-03-17 09:10:25 -07:00
upgrade feat(core): support TypeScript 4.2 (#41158) 2021-03-17 09:10:25 -07:00
zone.js feat(core): support TypeScript 4.2 (#41158) 2021-03-17 09:10:25 -07:00
BUILD.bazel build: replace @types/trusted-types dep with minimal type defs (#39211) 2020-10-15 09:08:00 -07:00
README.md docs: add doc reference to npm package readme (#33911) 2019-11-20 14:46:23 -08:00
circular-deps-test.conf.js fix(platform-webworker): remove platform-webworker and platform-webworker-dynamic (#38846) 2020-09-30 09:13:59 -04:00
empty.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
goog.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
license-banner.txt docs: update year (#40925) 2021-02-22 12:37:40 -08:00
system.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
tsconfig-build-no-strict.json refactor(core): ensure compatibility with typescript strict flag (#30993) 2019-07-18 14:21:25 -07:00
tsconfig-build.json refactor(core): ensure compatibility with typescript strict flag (#30993) 2019-07-18 14:21:25 -07:00
tsconfig-test.json refactor: fix typescript strict flag failures in all tests (#30993) 2019-07-18 14:21:26 -07:00
tsconfig.json fix(platform-webworker): remove platform-webworker and platform-webworker-dynamic (#38846) 2020-09-30 09:13:59 -04:00
types.d.ts build: replace @types/trusted-types dep with minimal type defs (#39211) 2020-10-15 09:08:00 -07:00

README.md

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

Usage information and reference details can be found in Angular documentation.

License: MIT