Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented May 7, 2020

This is a big PR with lots of commits. But most are in the compiler or are just tweaks to tests. So hopefully it will not be too arduous to review. It will be easier to go commit by commit when reviewing.

@googlebot

This comment has been minimized.

crisbeto added a commit to crisbeto/material2 that referenced this pull request May 8, 2020
The Framework team is in the process of updating to TS 3.9 (see angular/angular#36989) which means that soon we'll have to switch to it as well. These changes update us to the latest RC and resolve all of the build issues so that we can quickly switch to the final version once it's available.
jelbourn pushed a commit to angular/components that referenced this pull request May 8, 2020
The Framework team is in the process of updating to TS 3.9 (see angular/angular#36989) which means that soon we'll have to switch to it as well. These changes update us to the latest RC and resolve all of the build issues so that we can quickly switch to the final version once it's available.
trik pushed a commit to gnucoop/ajf that referenced this pull request May 11, 2020
The Angular team is in the process of updating to TS 3.9 (see angular/angular#36989) which means that soon we'll have to switch to it as well. These changes update us to the latest RC and resolve all of the build issues so that we can quickly switch to the final version once it's available.
@petebacondarwin petebacondarwin added area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime comp: ngcc labels May 11, 2020
@ngbot ngbot bot modified the milestone: needsTriage May 11, 2020
@petebacondarwin petebacondarwin added the refactoring Issue that involves refactoring or code-cleanup label May 11, 2020
trik pushed a commit to gnucoop/gngt that referenced this pull request May 11, 2020
The Angular team is in the process of updating to TS 3.9 (see angular/angular#36989) which means that soon we'll have to switch to it as well. These changes update us to the latest RC and resolve all of the build issues so that we can quickly switch to the final version once it's available.
@petebacondarwin petebacondarwin force-pushed the ts3-9 branch 3 times, most recently from 7322661 to 822bd51 Compare May 12, 2020 07:23
@alan-agius4 alan-agius4 force-pushed the ts3-9 branch 2 times, most recently from 845573e to 904c60f Compare May 12, 2020 13:15
@alan-agius4

This comment has been minimized.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 14, 2020
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
Version 7.7.12 generates aliases for objects named the same as global symbols which breaks ts-api-guardian since it doesn't support aliases.

See: microsoft/rushstack#1830

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…gular#36989)

In TypeScript 3.9, type nodes need to exist in the context of a statement.
This commit ensures that the synthetic type node has such a parent.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…e program (angular#36989)

In TypeScript 3.9, the compiler is able to re-use (i.e. not invalidate)
the previous program if only external templates (i.e. no TS files) have
changed.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
- Fix several compilation errors
- Update @microsoft/api-extractor to be compatible with TypeScript 3.9

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…gular#36989)

A number of overloads were added to `detectKnownDeclaration()` to
allow it to support `null` being passed through. In practice this could
easily be avoided, which allows the overloads to be removed and the
method signature and implementations to be simplified.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…t.isClass()` (angular#36989)

The comment in this function confused me, so I updated it to clarify that
`isClass()` is not true for un-named classes.

Also, I took the opportunity to use a helper method to simplify the function
itself.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…ression()` (angular#36989)

The previous implementations of `hasBaseClass()` are almost
identical to the implementation of `getBaseClassExpression()`.
There is little benefit in duplicating this code so this refactoring
changes `hasBaseClass()` to just call `getBaseClassExpression()`.
This allows the various hosts that implement this to be simplified.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
The `Import` import from `src/ngtsc/reflection` is not being used.
This commit simply removes this import from the code.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…ngular#36989)

Previously the path to the unlocker process was being resolved by the
current file-system. In the case that this was a `MockFileSystemWindows`
on a non-Windows operating system, this resulted in an incorrect path
to the entry-point.

Now the path to the entry-point is hand-crafted to avoid being broken by
whatever FileSystem is in use.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…sses (angular#36989)

In TS 3.9, ES2015 output can contain ES classes that are wrapped in an
IIFE. So now ES2015 class declarations can look like one of:

```
class OuterClass1 {}
```

```
let OuterClass = class InnerClass {};
```

```
var AliasClass;
let OuterClass = AliasClass = class InnerClass {};
```

```
let OuterClass = (() => class InnerClass {}};
```

```
var AliasClass;
let OuterClass = AliasClass = (() => class InnerClass {})();
```

```
let OuterClass = (() => {
  let AdjacentClass = class InnerClass {};
  // ... static properties or decorators attached to `AdjacentClass`
  return AdjacentClass;
})();
```

```
var AliasClass;
let OuterClass = AliasClass = (() => {
  let AdjacentClass = class InnerClass {};
  // ... static properties or decorators attached to `AdjacentClass`
  return AdjacentClass;
})();
```

The `Esm5ReflectionHost` already handles slightly different IIFE wrappers
around function-based classes. This can be substantially reused when
fixing `Esm2015ReflectionHost`, since there is a lot of commonality
between the two.

This commit moves code from the `Esm5ReflectionHost` into the `Esm2015ReflectionHost`
and looks to share as much as possible between the two hosts.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…angular#36989)

After the refactoring of the reflection hosts to accommodate
ES2015 classes wrapped in IIFEs. The same treatment needs to
be applied to the rendering formatters.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
The recent tests for Enum handling were added to the
incorrect describe block. This commit moves them back
to the correct block.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
In TypeScript 3.9 the emitted JS code has some differences.
This commit updates the tests to be resilient to these changes.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
Using backtick multiline strings leads to confusing layout
that does not fit with the surrounding indentation. Also it
can lead to test fragility due to automated code formatting.

This commit changes just one set of subject code to use
a more resilient string concatenation approach.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…ent` (angular#36989)

The term `ReexportStatement` is too general for this particular concept.
Here the re-export actually refers to a wildcard where all the module
exports are being re-exported.

When we introduce other re-export statement types later this will be
confusing.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
This file had a few small typos and other issues that have
now been fixed in this commit.............................

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
)

In the CommonJS and UMD reflection hosts, the logic for computing the
`viaModule` property of `Declaration` objects was not correct for some
cases when getting the exports of modules.

In these cases it was setting `viaModule` to the path of the local module
rather than `null`.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…ngular#36989)

In TypeScript 3.9 some re-export syntaxes have changed to be getter
functions (created by calls to `Object.defineProperty()`) rather than
simple property accessors.

This commit adds support into the CommonJS and UMD reflection hosts
for this style of re-export syntax.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…6989)

Here are the significant changes found in
`dist/main.js` for AIO...

```
t.\u0275prov = r.Kb({token: t, factory: t.\u0275fac}),
```
to
```
t.\u0275prov = r.Jb({
  token: t,
  factory: function(e) {
    return t.\u0275fac(e)
  }
}),
```

```
function hs(t){const e=ms();
```

to

```
  function fs(t){if(!(t=String(t).trim()))return'';
  const e=t.match(ds);
  return e&&Un(e[1])===e[1]||t.match(hs)&&function(t){let e=!0,n=!0;
  for(let s=0;
  s<t.length;
  s++){const r=t.charAt(s);
  '\''===r&&n?e=!e:'"'===r&&e&&(n=!n)}return e&&n}(t)?t:(Hn()&&console.warn(`WARNING: sanitizing unsafe style value ${t} (see http://g.co/ng/security#xss).`),'unsafe')}function ps(t){const e=ys();
```

```
b=Kt(p[1],0),
e&&(b.projection=e.map(t=>Array.from(t))),
```

to

```
if(b=Kt(f,0),void 0!==e){const t=b.projection=[];
for(let n=0; n<this.ngContentSelectors.length; n++){
  const s=e[n];
  t.push(null!=s?Array.from(s):null)
}
```

```
return o.observedAttributes=Object.keys(i),
n.map(({propName:t})=>t)
    .forEach(t=>{
      Object.defineProperty(o.prototype,t,{ ... })
}),o}
```

to

```
return t.observedAttributes=Object.keys(i),t})();
return n.map(({propName:t})=>t)
    .forEach(t=>{
      Object.defineProperty(o.prototype,t,{ ... })
    }),o}
```

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…messages (angular#36989)

In some versions of TypeScript, the transformation of synthetic
`$localize` tagged template literals is broken.
See microsoft/TypeScript#38485

We now compute what the expected final output target of the
compilation will be so that we can generate ES5 compliant
`$localize` calls instead of relying upon TS to do the downleveling
for us.

This is a workaround for the TS compiler bug, which could be removed
when this is fixed. But since it only affects ES5 targeted compilations,
which is now not the norm, it has limited impact on the majority of
Angular projects. So this fix can probably be left in indefinitely.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
With this changer we update the CLI size-tracking changes for uncompressed
main-es2015 file. This file is larger due to new emitted shape of
ES2015 classes in TypeScript 3.9, which are now wrapped in IIFE.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
This is a workaround for a TS 3.9 regression microsoft/TypeScript#38501 where the emitted `__exportStar` helpers have a missing semi-colon at the end of the unnamed function, when targetting UMD, and causes the following runtime error `Uncaught TypeError: (intermediate value)(…) is not a function`.

This is because the anonymous `__exportStar` function will be invoked with the function on the next like as the parameter which is subsequently invoking whatever was returned.

To get around this TS bug, add `importHelpers: true` in your tsconfig. This also, is recommanded to avoid multiple copies of the same helper being inlined, which might cause increase in bundle size.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…6989)

`cli-hello-world-lazy-rollup` fails on a bundle size check because Ivy and VE main-es2015 sizes are different

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…ngular#36989)

TypeScript 3.9 introduced a breaking change where extends `any` no longer acts as `any`, instead it acts as `unknown`.

With this change we retain the behavior we had with TS 3.8 which is;

When using the `EventEmitter` as a type you must always provide a  type;
```ts
let emitter: EventEmitter<string>
```

and when initializing the `EventEmitter` class you can either provide a  type or or use the fallback type which is `any`

```ts
const emitter = new EventEmitter(); // EventEmitter<any>
const emitter = new EventEmitte<string>(); // EventEmitter<string>
``

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
With this change we update the expect of the `module resolution cache` were in the second count with cache the `fileExists` is called less then 700 times.

PR Close angular#36989
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
In the code base there are cases where there is, conceptually, a class
that is represented by a combination of an `interface`
(type declaration) and a `const` (value declaration).

For example:

```
export interface SomeClass {
  count(a?: string): number;
}
export const: SomeClass = class {
  someMethod(a: string = ''): number { ... }
};
```

These were being rendered as interfaces and also not
correctly showing the descriptions and default parameter
values.

In this commit such concepts are now rendered as classes.
The classes that are affected by this are:

* `DebugElement`
* `DebugNode`
* `Type`
* `EventEmitter`
* `TestBed`

Note that while decorators are also defined in this form
they have their own rendering type (`decorator`) and so
are not affecte by this.

PR Close angular#36989
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime cla: yes refactoring Issue that involves refactoring or code-cleanup target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.