By ensuring that legacy i18n message ids are rendered into the templates
of components for packages processed by ngcc, we ensure that these packages
can be used in an application that may provide translations in a legacy
format.
Fixes#34056
PR Close#34135
Placing this configuration in to the bundle avoids having to pass the
value around through lots of function calls, but also could enable
support for different behaviour per bundle in the future.
PR Close#34135
Now that `@angular/localize` can interpret multiple legacy message ids in the
metablock of a `$localize` tagged template string, this commit adds those
ids to each i18n message extracted from component templates, but only if
the `enableI18nLegacyMessageIdFormat` is not `false`.
PR Close#34135
This change will enable the Angular compiler to provide these legacy
message ids by default, which will solve problems with ngcc not knowing
whether to generate legacy ids or not.
PR Close#34135
When first written there was no way to specify the raw text when
programmatically creating a template tagged literal AST node.
This is now fixed in TS and so the hack is no longer needed.
PR Close#34135
We should only generate the `providedIn` property in injectable
defs if it has a non-null value. `null` does not communicate
any information to the runtime that isn't communicated already
by the absence of the property.
This should give us some modest code size savings.
PR Close#34116
With this change we fix the logic to detect if a package is installed, removing a package and add a package by using the CLI schematic helpers.
Also we save `@angular/bazel` package directly as a `devDependency` when doing `ng-add`.
Closes#34164
PR Close#34181
For injectables, we currently generate a factory function in the
injectable def (prov) that delegates to the factory function in
the factory def (fac). It looks something like this:
```
factory: function(t) { return Svc.fac(t); }
```
The extra wrapper function is unnecessary since the args for
the factory functions are the same. This commit changes the
compiler to generate this instead:
```
factory: Svc.fac
```
Because we are generating less code for each injectable, we
should see some modest code size savings. AIO's main bundle
is about 1 KB smaller.
PR Close#34076
The ViewEngine translation extractor does not convert `-` to `_` for
placeholders that represent custom elements. For example `<app-component>`
gets converted to placeholders like `START_TAG_APP-COMPONENT`.
In `$localize` placeholders are expected to be snake-case, not kebab-case.
So we must normalize them when parsing a translation file that might have
been created via the View Engine translation extractor.
The `$localize` extraction code will normalize these placeholders when
creating translation files in the first place.
Fixes#34151
PR Close#34155
Various targets have their template type-checking disabled in the past.
There is no reason for this any more.
The only target that was tricky was packages/examples/core:core_examples
which was quite broken and I had to fix it up.
Template typechecking is still disabled under blaze, see FW-1753 for more
info.
PR Close#34144
due to an unfortunate condition in 168abc6d6f/packages/compiler-cli/src/ngtsc/program.ts (L430-L434) the typechecking has been disabled when running under bazel + ivy.
As far as I can tell the ivyTemplateTypeCheck flag is now obsolete, so removing this
code from ng_module.bzl is desirable. I'll send a separate PR to remove the flag completely.
PR Close#34144
The missing-injectable migration has been updated to handle a breaking change that is
unrelated to missing ´@Injectable` decorators. Though, the breaking change will be handled
as part of this migration since we did not want to create another migration (with all the boilerplate etc.)
The guide has been already updated to reflect the new pattern the migration handles, but we
should also rename the title of the guide to something that also mentions the other pattern.
Not renaming the guide URL since it is referenced in past releases and it's safer to keep the old
URL. The important thing is to change the actual rendered title.
PR Close#34125
If a Component or Directive is not part of any NgModule, the language
service currently produces an error message. This should not be an
error. Instead, it should be a suggestion.
This PR removes `ng.DiagnosticKind`, and instead reuses
`ts.DiagnosticCategory`.
PR closes https://github.com/angular/vscode-ng-language-service/issues/458
PR Close#34115
The language service incorrectly reports an error if it fails to find
NgModule metadata for a particular Component / Directive. In many cases,
the use case is legit, particularly in test.
This commit removes such diagnostic message and cleans up the interface
for `TypeScriptHost.getTemplateAst()`.
PR closes https://github.com/angular/vscode-ng-language-service/issues/463
PR Close#34113
To quicken migration for our own developers away from using compile=aot
for setting ivy, we actually fail the build process if the compile
build variable is used with a message to use our config flags instead.
PR Close#34109
To inform downstream users to switch to using angular_ivy_enabled as the build
variable for setting Ivy, a deprecation message is printed instructing the user
to migrate away from building with compile=*
PR Close#34109
Currently, variables of an unknown type in an `*ngFor` expression are
refined to have the type of the iterable binding of the `*ngFor`
expression. Unfortunately, this is a bug for variables aliasing
[values exported by
`*ngFor`](https://angular.io/api/common/NgForOf#local-variables),
including `index` and `first`, because they are also given the type of
the binding expression, but they are not of the binding type. For
example, in
```typescript
@Component({
selector: 'test',
template: `
<div *ngFor="let hero of heroes; let i = index; let isFirst = first">
{{ hero }}
</div>
`
})
export class TestComponent {
heroes: Hero[];
}
```
The local variables `i` and `isFirst` are determined to have a type of
`Hero`, when actually their types are `number` and `boolean`,
respectively.
This commit fixes this bug by checking if the value of a variable in an
`*ngFor` expression is known to be an export and assigning the variable
the type of that export value. Only if the variable does not alias an
export is it typed with the binding value of the `*ngFor` expression.
Closes https://github.com/angular/vscode-ng-language-service/issues/460
PR Close#34089
* This brings in a fix to the `@npm//foo:foo_files` targets for https://github.com/angular/angular/pull/33927 so the a rules_nodejs patch can be removed.
* It also brings a protractor_web_test fix that resolves the need for a work-around in /modules/playground/e2e_test/sourcemap/BUILD.bazel.
PR Close#34073
Previously, some RxJS-related examples (which are not proper Angular apps) were not
tested on CI as part of the `example-e2e` npm script. This meant that the examples
could get out-of-date or contain compile errors without as noticing.
This commit ensures that the `example-e2e` script picks up these examples and checks
that they compile successfully.
Partly addresses #28017.
PR Close#34063
This allows us to update the version of the package in a single place for all tests.
Notable exemption of this is aio which currently doesn't depend on anything installed in the root.
PR Close#34002
Previously, the Angular AOT compiler would always add a
`ɵprov` to injectables. But in ngcc this resulted in duplicate `ɵprov`
properties since published libraries already have this property.
Now in ngtsc, trying to add a duplicate `ɵprov` property is an error,
while in ngcc the additional property is silently not added.
// FW-1750
PR Close#34085
Prior to this commit, the unknown element can happen twice for AOT-compiled components: once during compilation and once again at runtime. Due to the fact that `schemas` information is not present on Component and NgModule defs after AOT compilation, the second check (at runtime) may fail, even though the same check was successful at compile time. This commit updates the code to avoid the second check for AOT-compiled components by checking whether `schemas` information is present in a logic that executes the unknown element check.
PR Close#34024