Commit Graph

11035 Commits

Author SHA1 Message Date
Alex Rickabaugh ed1db40322 fix(ivy): use 'typeof' and 'never' for type metadata (#24862)
Previously ngtsc would use a tuple of class types for listing metadata
in .d.ts files. For example, an @NgModule's declarations might be
represented with the type:

[NgIf, NgForOf, NgClass]

If the module had no declarations, an empty tuple [] would be produced.

This has two problems.

1. If the class type has generic type parameters, TypeScript will
complain that they're not provided.

2. The empty tuple type is not actually legal.

This commit addresses both problems.

1. Class types are now represented using the `typeof` operator, so the
above declarations would be represented as:

[typeof NgIf, typeof NgForOf, typeof NgClass].

Since typeof operates on a value, it doesn't require generic type
arguments.

2. Instead of an empty tuple, `never` is used to indicate no metadata.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh d3594fc1c5 fix(ivy): correctly export all *Def symbols as private (#24862)
Previously, some of the *Def symbols were not exported or were exported
as public API. This commit ensures every definition type is in the
private export namespace.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 9fd70c9715 refactor(ivy): run the compiler compliance tests against ngtsc (#24862)
This commit moves the compiler compliance tests into compiler-cli,
and uses ngtsc to run them instead of the custom compilation
pipeline used before. Testing against ngtsc allows for validation
of the real compiler output.

This commit also fixes a few small issues that prevented the tests
from passing.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh b7bbc82e3e fix(ivy): wrap non-statement assignment expressions in parentheses (#24862)
Previously, when translating an assignment expression (e.g. x = 3), the
translator would always print the statement as X = Y. However, if the
expression is included in a larger expression (X = (Y = Z)), the
translator would print "X = Y = Z" without regard for the outer
expression context.

Now, the translator understands when it's printing an expression
statement (X = Y;) vs an expression in a larger context (X = (Y = Z);)
and encapsulates the latter in parentheses.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 139f5b3672 fix(ivy): references track the identifier they were discovered under (#24862)
Previously, references had the concept of an identifier, but would not
properly detect whether the identifier should be used or not when
generating an expression. This change fixes that logic.

Additionally, now whenever an identifier resolves to a reference (even
one imported from another module) as part of resolving an expression,
the reference is updated to use that identifier. This ensures that for
a class Foo declared in foo.ts, but referenced in an expression in
bar.ts, the Reference returned includes the identifier from bar.ts,
meaning that writing an expression in bar.ts for the Reference will not
generate an import.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 6f8ec256ef fix(ivy): detect ngOnChanges as a non-static method (#24862)
Previously ngtsc had a bug where it would only detect the presence of
ngOnChanges as a static method. This commit flips the condition and only
recognizes ngOnChanges as a non-static method.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 5d7005eef5 feat(ivy): port the static resolver to use the ReflectionHost (#24862)
Previously, the static resolver did its own interpretation of statements
in the TypeScript AST, which only functioned on TypeScript code. ES5
code in particular would not work with the resolver as it had hard-coded
assumptions about AST structure.

This commit changes the resolver to use a ReflectionHost instead, which
abstracts away understanding of the structural side of the AST. It adds 3
new methods to the ReflectionHost in support of this functionality:

* getDeclarationOfIdentifier
* getExportsOfModule
* isClass

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 2e724ec68b feat(ivy): support host bindings in ngtsc (#24862)
This change adds support for host bindings to ngtsc, and parses them
both from decorators and from the metadata in the top-level annotation.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 76f8f78920 feat(ivy): compile queries in ngtsc (#24862)
This commit adds support for @ContentChild[ren] and @ViewChild[ren] in
ngtsc. Previously queries were ignored.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 6eb6ac7c12 fix(ivy): fix a couple issues with Input/Output compilation (#24862)
PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 9644873023 fix(ivy): ignore imports without ngInjectorDef in r3_injector (#24862)
ngInjectorDef.imports is generated from @NgModule.imports plus
@NgModule.exports. A problem arises as a result, because @NgModule
exports contain not only other modules (which will have ngInjectorDef
fields), but components, directives, and pipes as well. Because of
locality, it's difficult for the compiler to filter these out at
build time.

It's not impossible, but for now filtering them out at runtime will
allow testing of the compiler against complex applications.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh ae4563202c fix(ivy): export NgModuleFactory adapter (#24862)
PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 42d4287153 fix(ivy): ngInjectorDef should copy full imports/exports nodes (#24862)
@NgModule()s get compiled to two fields: ngModuleDef and ngInjectorDef.
Both fields contain imports, as both selector scopes and injectors have
the concept of composed units of configuration. Previously these fields
were generated by static resolution of imports and exports in metadata.

Support for ModuleWithProviders requires they be generated differently.
ngModuleDef's imports/exports are generated as resolved lists of types,
whereas ngInjectorDef's imports should reflect the raw expressions that
the developer wrote in the metadata.

This change modifies the NgModule handler and properly copies raw nodes
for the imports and exports into the ngInjectorDef.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh f9a6a175bf fix(ivy): properly inject all special token types (#24862)
Previously ngtsc had a few bugs handling special token types:

* Injector was not properly translated to INJECTOR
* ChangeDetectorRef was not injected via injectChangeDetectorRef()

This commit fixes these two bugs, and also adds a test to ensure
they continue to work correctly.

PR Close #24862
2018-07-20 11:48:36 -07:00
Alex Rickabaugh 53a16006d6 fix(ivy): export InheritDefinitionFeature (#24862)
PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh 8a986d4642 feat(ivy): statically resolve template expressions (#24862)
This commit adds support for template substitution expressions for
ngtsc static resolution.

PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh e346c3c2f2 refactor(ivy): fix an unnecessarily deep import (#24862)
PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh 60aeee7abf feat(ivy): selector side of ModuleWithProviders via type metadata (#24862)
Within an @NgModule it's common to include in the imports a call to
a ModuleWithProviders function, for example RouterModule.forRoot().
The old ngc compiler was able to handle this pattern because it had
global knowledge of metadata of not only the input compilation unit
but also all dependencies.

The ngtsc compiler for Ivy doesn't have this knowledge, so the
pattern of ModuleWithProviders functions is more difficult. ngtsc
must be able to determine which module is imported via the function
in order to expand the selector scope and properly tree-shake
directives and pipes.

This commit implements a solution to this problem, by adding a type
parameter to ModuleWithProviders through which the actual module
type can be passed between compilation units.

The provider side isn't a problem because the imports are always
copied directly to the ngInjectorDef.

PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh 1008bb6287 fix(ivy): unwrap parenthesized or cast expressions for metadata (#24862)
Metadata in Ivy must be literal. For example,

@NgModule({...})

is legal, whereas

const meta = {...};
@NgModule(meta)

is not.

However, some code contains additional superfluous parentheses:

@NgModule(({...}))

It is desirable that ngtsc accept this form of literal object.

PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh 8a5cd2200a fix(ivy): allow building router with ngtsc (#24862)
This commit adds the ivy-local tag to //packages/router. Since the
router depends on //packages/upgrade, it makes that package
compatible with ngtsc as well.

PR Close #24862
2018-07-20 11:48:35 -07:00
Alex Rickabaugh f58f3dc07a fix(ivy): handle ReadKeyExpr code generation (#24862)
This implements a missing expression type in ngtsc code generation:
that of bracket access to an object property.

PR Close #24862
2018-07-20 11:48:35 -07:00
Judy Bogart bb58138579 docs: fix bad link (#24825)
PR Close #24825
2018-07-20 11:34:38 -07:00
Xapuu b8f740b253 docs: remove closing parenthesis from provides guide (#24935)
PR Close #24935
2018-07-20 11:07:53 -07:00
Alex Eagle 23766b85e9
build: Fix windows tests (#24927)
closes #24927
2018-07-20 10:51:32 -07:00
George Kalpakas 3cd9645daa fix(docs-infra): fix table header layout in API pages (#24919)
PR Close #24919
2018-07-20 10:48:42 -07:00
George Kalpakas 2d38fa104b test(platform-webworker): avoid flakes due to existing `PlatformRef` (#24916)
PR Close #24916
2018-07-20 10:47:17 -07:00
Pawel Kozlowski 56b3f1703e fix(ivy): invoke lifecycle hooks of directives placed on ng-template (#24899)
PR Close #24899
2018-07-20 10:45:51 -07:00
Greg Magolan c438b5eeda build(bazel): turn on preserve-symlinks (#24881)
This change turns on preserve-symlinks in nodejs to verify hermeticity of the Angular build.

BREAKING CHANGE: Use of @angular/bazel rules now requires calling ng_setup_workspace() in your WORKSPACE file.

For example:

local_repository(
    name = "angular",
    path = "node_modules/@angular/bazel",
)

load("@angular//:index.bzl", "ng_setup_workspace")

ng_setup_workspace()

PR Close #24881
2018-07-20 10:37:30 -07:00
Marius Lichtblau 70b51a6255 docs: update i18n with requested changes (#24875)
use more general project name in code example

PR Close #24875
2018-07-20 10:36:13 -07:00
Marius Lichtblau 7ebd8e59a8 docs: update i18n doc regarding aot compilation (#24875)
Add missing lines to code example to allow using ng serve with custom i18n configurations.

PR Close #24875
2018-07-20 10:36:12 -07:00
George Kalpakas 1c533c913d build(docs-infra): add support for examples of type `elements` (#24840)
Examples using `@angular/elements` need to transpile to es2015 for
Custom Elements to work (on browsers that natively support them).

Alternatively, a polyfill would need to be loaded. For now, changing the
transpilation target to es2015 is the simplest solution.

PR Close #24840
2018-07-20 10:34:47 -07:00
Jan De Wilde ead3f926cb docs: add e2e tests for `elements` example (#24840)
PR Close #24840
2018-07-20 10:34:47 -07:00
Jan De Wilde 9be222f448 docs: fix `elements` example (#24840)
PR Close #24840
2018-07-20 10:34:47 -07:00
George Kalpakas b137f09345 docs: refactor `elements` example (#24840)
This makes the closing behavior more deterministic, which makes it
easier to be e2e-tested.

PR Close #24840
2018-07-20 10:34:47 -07:00
George Kalpakas 453693fd33 docs: clean up `elements` example (indentation, import order, etc) (#24840)
PR Close #24840
2018-07-20 10:34:47 -07:00
cexbrayat 270176bbe4 docs: more info on currency digits (#24661)
Adds an example of using the `currency` pipe with a currency that has no cents like CLP,
which will format the amount with no digits if `digitsInfo` is not provided:

    <!-- outputs CA$14.00 -->
    {{ 14 | currency:'CAD' }}
    <!-- outputs CLP14 -->
    {{ 14 | currency:'CLP' }}

Amends the docs, adds an example and fix an error with a current example.

PR Close #24661
2018-07-20 10:33:06 -07:00
Raphaël Jamet 5840a86f98 docs: Add notes on manual sanitization to security guide (#24176)
Some users have remarked that we don't explain how to manually call
sanitization, so add a few lines on that.

PR Close #24176
2018-07-20 10:27:12 -07:00
Victor Berchet 2aab1c9dd6 ci: remove Tina from pullaprove (#25006)
She has been removed as a collaborator to the project and pullaprove rejects
this config file which still lists her name.

PR Close #25006
2018-07-20 10:25:52 -07:00
Matias Niemelä f9669e50ff release: cut the v6.1.0-rc.3 release
Note that RC1 and RC2 glitched out midway during the npm release.
Therefore there is only one commit
2018-07-19 15:45:06 -07:00
Brandon Roberts 99a393e84f docs: add new Reactive Forms guide (#24578)
PR Close #24578
2018-07-19 13:46:30 -04:00
Martin Probst d76531d16e fix(animations): @internal must use JSDoc tags. (#24928)
This change fixes up several comments that accidentally used the JSDoc
tag @internal in regular block comments (`/*` instead of `/**`).

This prevents a problem with Closure Compiler that balks at `@` tags
occuring in regular block comments, because it assumes they were
intended to be tags for the compiler.

When occuring in `/**` JSDoc, tsickle escapes the tags, so they do not
cause problems.

PR Close #24928
2018-07-18 18:18:04 -04:00
Jamie Krug 23dc9a90b0 docs: fix typo in user input guide (#22630)
PR Close #22630
2018-07-18 14:04:09 -04:00
cexbrayat 0b28732d77 docs: typos in directives docs (#24665)
Fixes some typos introduced by #23902

PR Close #24665
2018-07-17 16:45:17 -04:00
Alex Eagle 06a33984af build: rename angular_devkit dependency to angular_cli (#24842)
PR Close #24842
2018-07-17 16:44:01 -04:00
Matias Niemelä ba3eb8b654 feat(ivy): properly apply class="", [class], [class.foo] and [attr.class] bindings (#24822)
PR Close #24822
2018-07-17 16:33:25 -04:00
Carlos Ortiz Garcia c8ad9657c9 fix(compiler): i18n_extractor now outputs the correct source file name (#24885)
for non-inline templates

- Non-inline templates used to ouput the path to the component TS file
instead of the path to the original HTML file.
- Inline templates keep the same behavior.

Fixes #24884

PR Close #24885
2018-07-16 16:09:01 -04:00
Matias Niemelä 9be8abd012 build: disable IE web worker tests (#24908)
Travis (saucelabs) has been super flaky when running IE
web worker tests lately. This patch temporarily disables
these tests on IE (not edge) until things get more stable.

PR Close #24908
2018-07-16 16:07:56 -04:00
Pete Bacon Darwin 74b250b146 feat(docs-infra): enable filtering by package on API list page (#24631)
PR Close #24631
2018-07-13 19:45:55 -04:00
Pete Bacon Darwin d8c828c9b1 build(docs-infra): implement the 'package' API template (#24631)
PR Close #24631
2018-07-13 19:45:54 -04:00
Alex Eagle 97277bc9fb build: update to Bazel 0.15 (#24841)
PR Close #24841
2018-07-13 15:05:16 -04:00