profile
viewpoint

ranma42/languages-compilers-interpreters-2019 2

Languages, compilers and interpreters - 2019/2020

di-unipi-socc/barrel 0

Web-based application for editing and analysing fault-aware management protocols in TOSCA applications.

ranma42/angular 0

One framework. Mobile & desktop.

ranma42/async-lowercase 0

Reproduction for https://github.com/angular/angular/issues/36259

ranma42/components 0

Component infrastructure and Material Design components for Angular

ranma42/coreclr 0

This repo contains the .NET Core runtime, called CoreCLR, and the base library, called mscorlib. It includes the garbage collector, JIT compiler, base .NET data types and many low-level classes.

push eventranma42/angular

Andrea Canciani

commit sha b35fd0c0e01d35d59d6e4325bd29cfa111525638

fix(common): let case conversion pipes accept type unions with `null` (#36259) The old implementation of case conversion types can handle several values which are not strings, but the signature did not reflect this. The new one reports errors when falsy non-string inputs are given to the pipe (such as `false` or `0`) and has a new signature which instead reflects the behaviour on `null` and `undefined`. Fixes #36259 BREAKING CHANGE: The case conversion pipes no longer let falsy values through. They now map both `null` and `undefined` to `null` and raise an exception on invalid input (`0`, `false`, `NaN`) just like most "common pipes". If your code required falsy values to pass through, you need to handle them explicitly.

view details

Andrea Canciani

commit sha 96c1d845a92fab25d82ce7c149a1da7fcb94c182

fix(common): correct and simplify typing of AsyncPipe `AsyncPipe.transform` will never return `undefined`, even when passed `undefined` in input, in contrast with what was declared in the overloads. Additionally the "actual" method signature can be updated to match the most generic case, since the implementation does not rely on wrappers anymore. BREAKING CHANGE: The async pipe no longer claims to return `undefined` for an input that was typed as `undefined`. Note that the code actually returned `null` on `undefined` inputs. In the unlikely case you were relying on this, please fix the typing of the consumers of the pipe output.

view details

Andrea Canciani

commit sha 98fa4593200335e53ab7ebfafde8ae65fad872d5

feat(common): stricter types for DatePipe Make typing of DatePipe stricter to catch some misuses (such as passing an Observable or an array) at compile time. BREAKING CHANGE: The signature of the `date` pipe now explicitly states which types are accepted. This should only cause issues in corner cases, as any other values would result in runtime exceptions.

view details

Andrea Canciani

commit sha 724a2faa052ea5539013bed7cfda3f3e79fb46ba

feat(common): stricter types for number pipes Make typing of number pipes stricter to catch some misuses (such as passing an Observable or an array) at compile time. BREAKING CHANGE: The signatures of the number pipes now explicitly state which types are accepted. This should only cause issues in corner cases, as any other values would result in runtime exceptions.

view details

Andrea Canciani

commit sha b6360f5a23ef3478938fa40d0027b5d6c1853388

fix(common): correct and simplify typing of I18nPluralPipe I18nPluralPipe can actually accept `null` and `undefined` (which are convenient for composing it with the async pipe), but it is currently typed to only accept `number`.

view details

Andrea Canciani

commit sha 92f42264ba13f45d43bba363dab6579301f73437

fix(common): correct and simplify typing of `KeyValuePipe` As shown in the tests, `KeyValuePipe.transform` can accept `undefined`, in which case it always returns `null`. Additionally, the typing for `string` keys can be made generic, so the comparison function is only required to accept the relevant cases. Finally, the typing for `number` records now shows that the comparison function and the result entries will actually receive the string version of the numeric keys, just as shown in the tests. BREAKING CHANGE: The typing of the `keyvalue` pipe has been fixed to report that for input objects that have `number` keys, the result will contain the string representation of the keys. This was already the case and the code has simply been updated to reflect this. Please update the consumers of the pipe output if they were relying on the incorrect types. Note that this does not affect use cases where the input values are `Map`s, so if you need to preserve `number`s, this is an effective way.

view details

Andrea Canciani

commit sha 967dd3eebf59789a26ee33ecd0926d3aa8e7e6a1

fix(common): correct typing and implementation of `SlicePipe` Even in the overloads, state that it can accept `null` and `undefined`, in order to ensure easy composition with `async`. Additionally, change the implementation to return `null` on an `undefined` input, for consistency with other pipes. BREAKING CHANGE: The `slice` pipe now returns `null` for the `undefined` input value, which is consistent with the behavior of most pipes. If you rely on `undefined` being the result in that case, you now need to check for it explicitly.

view details

push time in a month

Pull request review commentangular/angular

Improve typing of common pipes

 export declare class HashLocationStrategy extends LocationStrategy {  export declare class I18nPluralPipe implements PipeTransform {     constructor(_localization: NgLocalization);-    transform(value: number, pluralMap: {+    transform(value: number | null | undefined, pluralMap: {

In a way, it looks like a good idea, as it provides a type-level "documentation" of the behavior in these special cases. OTOH, it looks like a strange commitment from the perspective of the API

ranma42

comment created time in a month

PullRequestReviewEvent

Pull request review commentangular/angular

Improve typing of common pipes

 export class CurrencyPipe implements PipeTransform {   } } -function isEmpty(value: any): boolean {-  return value == null || value === '' || value !== value;+function isValue(value: number|string|null|undefined): value is number|string {+  return !(value == null || value === '' || value !== value);

TypeScript rejects it because value is typed as number|string at that point.

ranma42

comment created time in a month

PullRequestReviewEvent

Pull request review commentangular/angular

Improve typing of common pipes

 import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testin           expect(pipe.transform(5.1234, 'USD', 'Custom name')).toEqual('Custom name5.12');         }); +        it('should return null for NaN', () => {+          expect(pipe.transform(Number.NaN)).toEqual(null);+        });++        it('should return null for null', () => {+          expect(pipe.transform(null)).toEqual(null);+        });++        it('should return null for undefined', () => {+          expect(pipe.transform(undefined)).toEqual(null);+        });+         it('should not support other objects', () => {-          expect(() => pipe.transform({}))+          expect(() => pipe.transform(<any>{}))

I tried enabling the no-angle-bracket-type-assertion lint, but it looks like the codebase is still using them in several places. I guess that kind of "global" refactor is better handled in another (non-BC) pull request.

In the meantime I will fix them in the code I am touching, so that PR will be a little bit simpler ;)

ranma42

comment created time in a month

PullRequestReviewEvent

Pull request review commentangular/angular

Improve typing of common pipes

 import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testin           expect(pipe.transform(5.1234, 'USD', 'Custom name')).toEqual('Custom name5.12');         }); +        it('should return null for NaN', () => {+          expect(pipe.transform(Number.NaN)).toEqual(null);+        });++        it('should return null for null', () => {+          expect(pipe.transform(null)).toEqual(null);+        });++        it('should return null for undefined', () => {+          expect(pipe.transform(undefined)).toEqual(null);+        });+         it('should not support other objects', () => {-          expect(() => pipe.transform({}))+          expect(() => pipe.transform(<any>{}))

oops! this was based on the should not support other objects from case_conversion_pipes_spec.ts, I did not know about the new convention.

I will fix the casts am I adding/modifying. Should I also update the existing <xyz> casts in the files I an touching?

ranma42

comment created time in a month

PullRequestReviewEvent

Pull request review commentangular/angular

Improve typing of common pipes

 export class DecimalPipe implements PipeTransform {    * When not supplied, uses the value of `LOCALE_ID`, which is `en-US` by default.    * See [Setting your app locale](guide/i18n#setting-up-the-locale-of-your-app).    */-  transform(value: any, digitsInfo?: string, locale?: string): string|null {-    if (isEmpty(value)) return null;+  transform(value: number|string, digitsInfo?: string, locale?: string): string|null;

Removing it also makes the pipe very weird when applied to any, as in that case TypeScript uses the first overload (since any overload matches any) instead of the most generic one.

This is very inconvenient when the first overload handles "special" cases (null | undefined) as it causes the result to be typed null as well

ranma42

comment created time in a month

PullRequestReviewEvent

Pull request review commentangular/angular

Improve typing of common pipes

 export class KeyValuePipe implements PipeTransform {   private differ!: KeyValueDiffer<any, any>;   private keyValues: Array<KeyValue<any, any>> = []; -  transform<K, V>(input: null, compareFn?: (a: KeyValue<K, V>, b: KeyValue<K, V>) => number): null;-  transform<V>(-      input: {[key: string]: V}|ReadonlyMap<string, V>,-      compareFn?: (a: KeyValue<string, V>, b: KeyValue<string, V>) => number):-      Array<KeyValue<string, V>>;-  transform<V>(-      input: {[key: string]: V}|ReadonlyMap<string, V>|null,-      compareFn?: (a: KeyValue<string, V>, b: KeyValue<string, V>) => number):-      Array<KeyValue<string, V>>|null;-  transform<V>(-      input: {[key: number]: V}|ReadonlyMap<number, V>,-      compareFn?: (a: KeyValue<number, V>, b: KeyValue<number, V>) => number):-      Array<KeyValue<number, V>>;-  transform<V>(-      input: {[key: number]: V}|ReadonlyMap<number, V>|null,-      compareFn?: (a: KeyValue<number, V>, b: KeyValue<number, V>) => number):-      Array<KeyValue<number, V>>|null;   transform<K, V>(       input: ReadonlyMap<K, V>,       compareFn?: (a: KeyValue<K, V>, b: KeyValue<K, V>) => number): Array<KeyValue<K, V>>;+  transform<K extends number, V>(+      input: Record<K, V>, compareFn?: (a: KeyValue<string, V>, b: KeyValue<string, V>) => number):+      Array<KeyValue<string, V>>;+  transform<K extends string, V>(+      input: Record<K, V>|ReadonlyMap<K, V>,+      compareFn?: (a: KeyValue<K, V>, b: KeyValue<K, V>) => number): Array<KeyValue<K, V>>;+  transform(+      input: null|undefined,+      compareFn?: (a: KeyValue<unknown, unknown>, b: KeyValue<unknown, unknown>) => number): null;   transform<K, V>(-      input: ReadonlyMap<K, V>|null,+      input: ReadonlyMap<K, V>|null|undefined,+      compareFn?: (a: KeyValue<K, V>, b: KeyValue<K, V>) => number): Array<KeyValue<K, V>>|null;+  transform<K extends number, V>(+      input: Record<K, V>|null|undefined,+      compareFn?: (a: KeyValue<string, V>, b: KeyValue<string, V>) => number):

as above

ranma42

comment created time in a month

PullRequestReviewEvent

Pull request review commentangular/angular

Improve typing of common pipes

 export class KeyValuePipe implements PipeTransform {   private differ!: KeyValueDiffer<any, any>;   private keyValues: Array<KeyValue<any, any>> = []; -  transform<K, V>(input: null, compareFn?: (a: KeyValue<K, V>, b: KeyValue<K, V>) => number): null;-  transform<V>(-      input: {[key: string]: V}|ReadonlyMap<string, V>,-      compareFn?: (a: KeyValue<string, V>, b: KeyValue<string, V>) => number):-      Array<KeyValue<string, V>>;-  transform<V>(-      input: {[key: string]: V}|ReadonlyMap<string, V>|null,-      compareFn?: (a: KeyValue<string, V>, b: KeyValue<string, V>) => number):-      Array<KeyValue<string, V>>|null;-  transform<V>(-      input: {[key: number]: V}|ReadonlyMap<number, V>,-      compareFn?: (a: KeyValue<number, V>, b: KeyValue<number, V>) => number):-      Array<KeyValue<number, V>>;-  transform<V>(-      input: {[key: number]: V}|ReadonlyMap<number, V>|null,-      compareFn?: (a: KeyValue<number, V>, b: KeyValue<number, V>) => number):-      Array<KeyValue<number, V>>|null;   transform<K, V>(       input: ReadonlyMap<K, V>,       compareFn?: (a: KeyValue<K, V>, b: KeyValue<K, V>) => number): Array<KeyValue<K, V>>;+  transform<K extends number, V>(+      input: Record<K, V>, compareFn?: (a: KeyValue<string, V>, b: KeyValue<string, V>) => number):

no, the keyvalue pipe passes the number keys as strings in the case of a Record<number, V> object :(

I tried to explain it in the commit message, but maybe it is not explicit enough (and maybe we should also add a comment in the code to explain it, so it does not get lost in the git history)

ranma42

comment created time in a month

PullRequestReviewEvent

Pull request review commentangular/angular

Improve typing of common pipes

 export declare class HashLocationStrategy extends LocationStrategy {  export declare class I18nPluralPipe implements PipeTransform {     constructor(_localization: NgLocalization);-    transform(value: number, pluralMap: {+    transform(value: number | null | undefined, pluralMap: {

sure! :) should I go forward with that?

ranma42

comment created time in a month

PullRequestReviewEvent

pull request commentangular/angular

Improve typing of common pipes

I just noticed that in one of the commit messages I skipped a word :(

"The typing of the keyvalue has been fixed..." instead of "The typing of the keyvalue pipi has been fixed..."

ranma42

comment created time in a month

push eventranma42/angular

JiaLiPassion

commit sha 27cc56b359a542761af5d9fba61db26d4f3f30b1

fix(zone.js): add missing types field in package.json (#38585) Close #38584 In zone.js 0.11.1, the `types` field is missing in the `package.json`, the reason is in zone.js 0.11.0, the `files` field is used to specify the types, but it cause the npm package not contain any bundles issue, so zone.js 0.11.1 remove the `files` field, which cause the `type` definition gone. This PR concat the `zone.js.d.ts`, `zone.configurations.api.ts`, `zone.api.extensions.ts` types into a single `zone.d.ts` file. PR Close #38585

view details

Wagner Maciel

commit sha da14b72550a60dbc7ec833c2400312d5674a15a5

refactor(dev-infra): add default params to runBenchmark (#38748) * Use '' as the default for 'url' * Use [] as the default for 'params' * Use true as the default for 'ignoreBrowserSynchronization' PR Close #38748

view details

Pete Bacon Darwin

commit sha 66129f8ea6434b489de824052656ad5bb3fce4ac

docs: clarify what fixes are merged to LTS versions (#38788) PR Close #38788

view details

JoostK

commit sha 15207e3c9c9ba26a6f41b497ab9f0f299486927c

fix(compiler): detect pipes in ICUs in template binder (#38810) Recent work on compiler internals in #38539 led to an unexpected failure, where a pipe used exclusively inside of an ICU would no longer be emitted into the compilation output. This caused runtime errors due to missing pipes. The issue occurred because the change in #38539 would determine the set of used pipes up-front, independent from the template compilation using the `R3TargetBinder`. However, `R3TargetBinder` did not consider expressions within ICUs, so any pipe usages within those expressions would not be detected. This fix unblocks #38539 and also concerns upcoming linker work, given that prelink compilations would not go through full template compilation but only `R3TargetBinder`. PR Close #38810

view details

Sonu Kapoor

commit sha f667e374a969f857709be8d8921065d238b9588f

build: create sample router app (#38714) This commit creates a sample router test application to introduce the symbol tests. It serves as a guard to ensure that any future work on the router package does not unintentionally increase the payload size. PR Close #38714

view details

Sonu Kapoor

commit sha 57c442f9308d1b04db0e28feae85be41690540a3

build(router): update symbols for routing app (#38817) This commit updates the golden symbol files for the routing app. PR Close #38817

view details

Joey Perrott

commit sha 6768fe9927ad4b9b81c5f8094c42c771d1047f56

fix(dev-infra): correct build setup for dev-infra (#38815) Correct's the missing dependencies and incorrect build dependencies for the dev-infra bazel targets. PR Close #38815

view details

George Kalpakas

commit sha 354138eba9c8cb276062b793572265fb380d2bec

build(docs-infra): upgrade cli command docs sources to 800ba9271 (#38827) Updating [angular#master](https://github.com/angular/angular/tree/master) from [cli-builds#master](https://github.com/angular/cli-builds/tree/master). ## Relevant changes in [commit range](https://github.com/angular/cli-builds/compare/32391604b...800ba9271): **Modified** - help/build.json - help/serve.json PR Close #38827

view details

Paul Gschwendtner

commit sha e162da07538a4b1379ec1092ba30e891c804a93c

refactor(dev-infra): do not validate config file multiple times (#38808) Currently we validate the configuration file on each `getConfig` invocation. We can only validate once since the configuration is cached. Also while being at it, renames the cache variables to lower-case as those do not represent constants (which are convention-wise upper case). PR Close #38808

view details

JoostK

commit sha 077f51685a87a0f674e4f53cf7269ad4a731c7db

perf(compiler-cli): only emit directive/pipe references that are used (#38539) For the compilation of a component, the compiler has to prepare some information about the directives and pipes that are used in the template. This information includes an expression for directives/pipes, for usage within the compilation output. For large NgModule compilation scopes this has shown to introduce a performance hotspot, as the generation of expressions is quite expensive. This commit reduces the performance overhead by only generating expressions for the directives/pipes that are actually used within the template, significantly cutting down on the compiler's resolve phase. PR Close #38539

view details

JoostK

commit sha 297c060ae797c2fdad55fffc34d83e4a6a4b3948

perf(compiler-cli): optimize computation of type-check scope information (#38539) When type-checking a component, the declaring NgModule scope is used to create a directive matcher that contains flattened directive metadata, i.e. the metadata of a directive and its base classes. This computation is done for all components, whereas the type-check scope is constant per NgModule. Additionally, the flattening of metadata is constant per directive instance so doesn't necessarily have to be recomputed for each component. This commit introduces a `TypeCheckScopes` class that is responsible for flattening directives and computing the scope per NgModule. It caches the computed results as appropriate to avoid repeated computation. PR Close #38539

view details

santoshyadavdev

commit sha 3934f0a8332df5c0f22ce0b3f419a618ec11eee0

docs(elements): convert the `ng add` command to code-example (#38834) the command was hardly visible currently changing it to shell for visibility PR Close #38834

view details

Joey Perrott

commit sha 78e1ecb16134ba62abeba48624ae056909cbb220

feat(dev-infra): allow local ng-dev configuration to error on invalid commit messages (#38784) As part of the commit message conformance check, local commit message checks are made to be warnings rather than failures. An additional local option is also in place to allow for the commit message validation failures to be considered errors instead. PR Close #38784

view details

Joey Perrott

commit sha 284c70ee9d6db1ff0e1d8cd84fcd5d79696f3d39

build: add tag to symbol-extractor tests (#38819) Add a tag to symbol-extractor tests to allow for bazel querying. PR Close #38819

view details

Joey Perrott

commit sha 593bd594e3419a2c834707e0f5d1dc86e1f94418

build: create temporary script for symbol extractor tests (#38819) Creates a temporary script to running all symbol extractor tests. PR Close #38819

view details

Joey Perrott

commit sha e00535a2a4c40f54bf858edde1be6c17e19d6e6b

fix(dev-infra): remove ANSI escape codes from log file outputs (#38792) Remove the ANSI codes from the log file outputs to make the ng-dev log files more readable. PR Close #38792

view details

Joey Perrott

commit sha b9ca6d20ccd4372222303953c34aa67df84fd965

feat(dev-infra): include CI status check in the caretaker check (#38779) Add a CI status check in the ng-dev caretaker check command. PR Close #38779

view details

JoostK

commit sha f0688b4d186546760f21125cd3f64ae87d7fa476

perf(ngcc): introduce cache for sharing data across entry-points (#38840) ngcc creates typically two `ts.Program` instances for each entry-point, one for processing sources and another one for processing the typings. The creation of these programs is somewhat expensive, as it concerns module resolution and parsing of source files. This commit implements several layers of caching to optimize the creation of programs: 1. A shared module resolution cache across all entry-points within a single invocation of ngcc. Both the sources and typings program benefit from this cache. 2. Sharing the parsed `ts.SourceFile` for a single entry-point between the sources and typings program. 3. Sharing parsed `ts.SourceFile`s of TypeScript's default libraries across all entry-points within a single invocation. Some of these default library typings are large and therefore expensive to parse, so sharing the parsed source files across all entry-points offers a significant performance improvement. Using a bare CLI app created using `ng new` + `ng add @angular/material`, the above changes offer a 3-4x improvement in ngcc's processing time when running synchronously and ~2x improvement for asynchronous runs. PR Close #38840

view details

JoostK

commit sha fd44d84a331d246d4e63b8a48e8a55983e8237f8

perf(ngcc): reduce maximum worker count (#38840) Recent optimizations to ngcc have significantly reduced the total time it takes to process `node_modules`, to such extend that sharding across multiple processes has become less effective. Previously, running ngcc asynchronously would allow for up to 8 workers to be allocated, however these workers have to repeat work that could otherwise be shared. Because ngcc is now able to reuse more shared computations, the overhead of multiple workers is increased and therefore becomes less effective. As an additional benefit, having fewer workers requires less memory and less startup time. To give an idea, using the following test setup: ```bash npx @angular/cli new perf-test cd perf-test yarn ng add @angular/material ./node_modules/.bin/ngcc --properties es2015 module main \ --first-only --create-ivy-entry-points ``` We observe the following figures on CI: | | 10.1.1 | PR #38840 | | ----------------- | --------- | --------- | | Sync | 85s | 25s | | Async (8 workers) | 22s | 16s | | Async (4 workers) | - | 11s | In addition to changing the default number of workers, ngcc will now use the environment variable `NGCC_MAX_WORKERS` that may be configured to either reduce or increase the number of workers. PR Close #38840

view details

JoostK

commit sha a1c1c450dce859aea95eaa6c4702380b550f3b07

test(ngcc): load standard files only once (#38840) In the integration test suite of ngcc, we load a set of files from `node_modules` into memory. This includes the `typescript` package and `@angular` scoped packages, which account for a large number of large files that needs to be loaded from disk. This commit moves this work to the top-level, such that it doesn't have to be repeated in all tests. PR Close #38840

view details

push time in a month

pull request commentangular/angular

Improve typing of common pipes

I tried to fix all of the issues you noticed, namely:

  • bad overload ordering (TypeScript resolves on a first-matching basis, so the specific overloads must appear before the generic ones)
  • incomplete typing around null | undefined
  • missing notices about BREAKING CHANGES

In doing so I also noticed that the typing of KeyValuePipe was still incorrect: if it is passed a value which is typed as Record<number, V> it actually returns the keys as strings. The typing has been updated accordingly (the tests already check for this).

ranma42

comment created time in a month

push eventranma42/angular

Andrea Canciani

commit sha 8f1be78e36fe54d28573e7bee1476dc79e9987ec

fix(common): let case conversion pipes accept type unions with `null` (#36259) The old implementation of case conversion types can handle several values which are not strings, but the signature did not reflect this. The new one reports errors when falsy non-string inputs are given to the pipe (such as `false` or `0`) and has a new signature which instead reflcts the behaviour on `null` and `undefined`. Fixes #36259 BREAKING CHANGE: The case conversion pipes no longer let falsy values through. They now map both `null` and `undefined` to `null` and raise an exception on invalid input (`0`, `false`, `NaN`) just like most "common pipes". If your code required falsy values to pass through, you need to handle them explicitly.

view details

Andrea Canciani

commit sha 81014ceb4958855b5a33f041c979d4781aff0e8d

fix(common): correct and simplify typing of AsyncPipe `AsyncPipe.transform` will never return `undefined`, even when passed `undefined` in input, in contrast with what was declared in the overloads. Additionally the "actual" method signature can be updated to match the most generic case, since the implementation does not rely on wrappers anymore. BREAKING CHANGE: The async pipe no longer claims to return `undefined` for an input that was typed as `undefined`. Note that the code actually returned `null` on `undefined` inputs. In the unlikely case you were relying on this, please fix the typing of the consumers of the pipe output.

view details

Andrea Canciani

commit sha c1cdaf01abbf01066e32b6495c15ace5617d1a3a

feat(common): stricter types for DatePipe Make typing of DatePipe stricter to catch some misuses (such as passing an Observable or an array) at compile time. BREAKING CHANGE: The signature of the `date` pipe now explicitly states which types are accepted. This should only cause issues in corner cases, as any other values would result in runtime exceptions.

view details

Andrea Canciani

commit sha 62c4682d559621ccc74710091283a790b0787d09

feat(common): stricter types for number pipes Make typing of number pipes stricter to catch some misuses (such as passing an Observable or an array) at compile time. BREAKING CHANGE: The signatures of the number pipes now explicitly state which types are accepted. This should only cause issues in corner cases, as any other values would result in runtime exceptions.

view details

Andrea Canciani

commit sha 6569a3875a654d48779d50a5a3973aee019e888d

fix(common): correct and simplify typing of I18nPluralPipe I18nPluralPipe can actually accept `null` and `undefined` (which are convenient for composing it with the async pipe), but it is currently typed to only accept `number`.

view details

Andrea Canciani

commit sha 56f97c289a66ed095c6f25a3b1497927aaedaec5

fix(common): correct and simplify typing of `KeyValuePipe` As shown in the tests, `KeyValuePipe.transform` can accept `undefined`, in which case it always returns `null`. Additionally, the typing for `string` keys can be made generic, so the comparison function is only required to accept the relevant cases. Finally, the typing for `number` records now shows that the comparison function and the result entries will actually receive the string version of the numeric keys, just as shown in the tests. BREAKING CHANGE: The typing of the `keyvalue` has been fixed to report that for input objects that have `number` keys, the result will contain the string representation of the keys. This was already the case and the code has simply been updated to reflect this. Please update the consumers of the pipe output if they were relying on the incorrect types. Note that this does not affect use cases where the input values are `Map`s, so if you need to preserve `number`s, this is an effective way.

view details

Andrea Canciani

commit sha 8369a9210c3efcc82ee06350f5c855d57b776450

fix(common): correct typing and implementation of `SlicePipe` Even in the overloads, state that it can accept `null` and `undefined`, in order to ensure easy composition with `async`. Additionally, change the implementation to return `null` on an `undefined` input, for consistency with other pipes. BREAKING CHANGE: The `slice` pipe now returns `null` for the `undefined` input value, which is consistent with the behavior of most pipes. If you rely on `undefined` being the result in that case, you now need to check for it explicitly.

view details

push time in a month

pull request commentangular/angular

Improve typing of common pipes

you are right, the overloads should be listed from the most specific to the most generic

ranma42

comment created time in a month

pull request commentangular/angular

Improve typing of common pipes

Hi @ranma42, quick update: we ran tests in Google's codebase and found out that there are some part of code that require updates in order to land this change. We'll be look into these cases and keep this thread updated on the progress.

This PR introduces a breaking change, so we need to include the BREAKING CHANGE section into one of the commit message to describe what the change is and what developers should do to resolve the problem is they come across it.

Several commits introduce some kind of breaking change. They are somewhat related, as they are all typing changes on the pipes, but each is independent and possibly different. It is better to add the BREAKING CHANGE section to each of them (explaining what that specific commit is breaking) or should I put it in the first/last commit of the branch?

ranma42

comment created time in a month

Pull request review commentangular/angular

Improve typing of common pipes

 export class AsyncPipe implements OnDestroy, PipeTransform {     }   } -  transform<T>(obj: null): null;-  transform<T>(obj: undefined): undefined;-  transform<T>(obj: Observable<T>|null|undefined): T|null;-  transform<T>(obj: Promise<T>|null|undefined): T|null;+  transform<T>(obj: Observable<T>|Promise<T>|null|undefined): T|null;   transform(obj: Observable<any>|Promise<any>|null|undefined): any {

since the object wrapping has been removed, we might avoid even just use the "strict" signature, if we like it better:

  transform<T>(obj: Observable<T>|Promise<T>|null|undefined): T|null {

note that this would not change anything for the API consumers

ranma42

comment created time in a month

PullRequestReviewEvent

pull request commentangular/angular

Improve typing of common pipes

@petebacondarwin this PR was assigned new tags, so I rebased it.

Note that I only fixed the conflicts; I did not address this comment, but I can certainly do it if it it is desired 😄

ranma42

comment created time in a month

pull request commentangular/angular

Improve typing of common pipes

rebased

ranma42

comment created time in a month

push eventranma42/angular

Ajit Singh

commit sha 8924ec14746da21cba6583bb5042feb9220f2e65

test(docs-infra): add end to end tests for api reference (#37612) Api search functionality only had unit tests @gkalpak suggested we should have some e2e tests too. Added some end to end tests. Fixes #35170 PR Close #37612

view details

Ajit Singh

commit sha a0595f4b4f8d07fdefd4aeaa4d7c9beb549ecddb

fix(forms): change error message (#37643) Error message mention that ngModel and ngModelChange will be removed in Angular v7 but right not now sure when it will be removed so changed it to a future version PR Close #37643

view details

Pete Bacon Darwin

commit sha bedc0451a07620e47961091ee6ea7651b83d8ffc

docs(ngcc): add additional next steps to an error (#37672) The file-writing error in the this commit can also be the result of the ngcc process dying in the middle of writing files. This commit improves the error message to offer a resolution in case this is the reason for the error. Fixes #36393 PR Close #37672

view details

Joey Perrott

commit sha 29490cce30595c6c84b3fce78f8b2ec9a31d537f

build: set up caretaker note label in merge tooling (#37675) Leverage the caretaker note label configuration in ng-dev's merge tooling to prompt the caretaker for confirmation when a PR has the `PR action: merge-assistance` label. This should help to surface for the caretaker, PRs which may need additional steps taken, announcement messaging, etc. PR Close #37675

view details

Paul Gschwendtner

commit sha cc3b1ebd969e062a7d9d2dbdd5acb710023815bf

refactor: cleanup unused dependencies in benchpress package (#37676) Removes unused packages from the benchpress `package.json`. That helps with deduping dependencies, and avoiding unused code being downloaded. PR Close #37676

view details

Paul Gschwendtner

commit sha f3ec37ebbfb75d4ab8b425252ea2a4e6aca18ce5

release(benchpress): bump version to v0.2.1 and update `@angular/core` peer dependency (#37676) Updates the version of `@angular/benchpress` to the next patch version. i.e. `v0.2.1`. Additionally, the peer dependency on `@angular/core` has been updated to be satisifed with Angular v10 and v11. Benchpress should be at least compatibe with the next two major versions as it does not rely on any deprecated API from `@angular/core`. PR Close #37676

view details

Trung Vo

commit sha 666e6d15fa6f89e5b95211be0fb1a486f123508b

docs: Replace $emdash; with an actual em dash (#37723) fix documentation in the lifecycle hooks guide where $emdash; was not being replaced by an actual em dash (-) PR Close #37723

view details

Alex Rickabaugh

commit sha 49679975363ae491f0d6661e33d64ed8e79267c3

ci(compiler-cli): exempt compiler-cli .bazel files from dev-infra approval (#37558) Previously, dev-infra approval (via PullApprove) was required for all .bazel files in the monorepo, including those in packages/compiler-cli. The compiler-cli package is a little special in this sense: * it's not shipped to NPM in the APF * it uses lots of internal subpackages to organize and test its code As a result: * changes to compiler-cli BUILD.bazel files are not user visible and don't have larger implications for the packages published to NPM, unlike changes to other BUILD.bazel files in the repo * the requirement for dev-infra approval for BUILD.bazel changes is overly burdensome, because compiler-cli build files change more rapidly than those of other packages. This commit exempts the compiler-cli's build files from the requirement for dev-infra approval. It will be sufficient for such files to be approved by the normal compiler reviewers. PR Close #37558

view details

Keen Yee Liau

commit sha 1c1eb3045c269e3792af9b0da3c7ca17317a2f64

docs: Add support schedule for v10 (#37745) This commit adds the support schedule for v10. v10.0.0 was released on June 24, 2020. Active support ends six months later, on Dec 24, 2020. Long term support ends a year after that, on Dec 24, 2021. PR Close #37745

view details

Wagner Maciel

commit sha 5218916a7e8d6dd7aab17698ef3c1dd69d95e041

feat(dev-infra): add a way to pass assets down to a benchmark application (#37695) * add a param called ng_assets to the component_benchmark macro to allow static assets to be provided to the base angular app, not just through the ts_devserver PR Close #37695

view details

Manduro

commit sha 80d0067048e4568cb20ddf898122984d19e35707

fix(router): `RouterLinkActive` should run CD when setting `isActive` (#21411) When using the routerLinkActive directive inside a component that is using ChangeDetectionStrategy.OnPush and lazy loaded module routes the routerLinkActive directive does not update after clicking a link to a lazy loaded route that has not already been loaded. Also the OnPush nav component does not set routerLinkActive correctly when the default route loads, the non-OnPush nav component works fine. regression caused by #15943 closes #19934 PR Close #21411

view details

Anas Barghoud

commit sha 2170ea270ac1d5881958c92bec7601afbf03c9b1

fix(router): fix error when calling ParamMap.get function (#31599) fix this.params.hasOwnProperty is not a function in case of creating an object using Object.create() PR Close #31599

view details

Krzysztof Grzybek

commit sha 616543ded07d632438185f3df6f3b73591cdaf80

fix(router): add null support for RouterLink directive (#32616) Value of "undefined" passed as segment in routerLink is stringified to string "undefined". This change introduces the same behavior for value of "null". PR Close #32616

view details

Oussama Ben Brahim

commit sha 77b62a52c0dc86bc3947778d161087e970768789

fix(forms): handle form groups/arrays own pending async validation (#22575) introduce a boolean to track form groups/arrays own pending async validation to distinguish between pending state due to children and pending state due to own validation Fixes #10064 PR Close #22575

view details

Sonu Kapoor

commit sha e36d5b201abc64025cfef286ddeae9c81c735275

fix(forms): correct usage of `selectedOptions` (#37620) Previously, `registerOnChange` used `hasOwnProperty` to identify if the property is supported. However, this does not work as the `selectedOptions` property is an inherited property. This commit fixes this by verifying the property on the prototype instead. Closes #37433 PR Close #37620

view details

Ajit Singh

commit sha ef1fb6dee4404c7dc421c7175cb5f156d427196e

fix(common): date pipe gives wrong week number (#37632) Date pipe is giving wrong week number when used with the date format 'w'. If first week(according to Iso) has some days in previous year Fixes #33961 PR Close #37632

view details

Dmitrij Kuba

commit sha 8a745081307c16644796c333531edcb4591ce235

fix(http): avoid abort a request when fetch operation is completed (#37367) `abort` method is calling, even if fetch operation is completed Fixes https://github.com/angular/angular/issues/36537 PR Close #37367

view details

Igor Minar

commit sha 3a698e2d08032a021c145420e1a90e89f65a36f3

feat(docs-infra): update deploy-to-firebase.sh script to support v9 multisite setup (#37721) v9.angular.io was used to pilot the firebase hosting multisites setup for angular.io. The deployments so far have been done manually to control the deployment process. This change, automates the deployment for v9.angular.io so that future deployments can be made from the CI. See https://angular-team.atlassian.net/browse/DEV-125 for more info. In the process of updating the scripts I rediscovered a bug in the deploy-to-firebase.sh script that incorrect compared two numbers as strings. This previously worked correctly because we were comparing single digit numbers. With the release of v10, we now compare 9 > 10 which behaves differently for strings and numbers. The bug was fixed by switching to an arithmetic comparison of the two variables. This bug has been fixed on the master branch but not on the 9.1.x branch. I realized this during the rebase, but found my version to be a bit cleaner, so I kept it. PR Close #37721

view details

Sonu Kapoor

commit sha 2b2146bc58a1289c204cdd84e792eeab0a954f0d

docs: Uses correct component in the `MessageService` (#37666) This commit uses the correct component (`HeroesComponent`) in the. `MessageService`. Previously, the `MessageService` was using `HeroeService`. Closes #37654 PR Close #37666

view details

Pete Bacon Darwin

commit sha 6abb8d0d915edb01fd03bd458abf427f98bdd470

feat(compiler-cli): add `SourceFile.getOriginalLocation()` to sourcemaps package (#32912) This method will allow us to find the original location given a generated location, which is useful in fine grained work with source-mapping. E.g. in `$localize` tooling. PR Close #32912

view details

push time in a month

delete branch ranma42/angular

delete branch : fix/false-ngif

delete time in a month

push eventranma42/angular

George Kalpakas

commit sha 2021ad12cf211db2170a5bfe194d7ec3429146b8

ci(docs-infra): skip deploying RC version when lexicographically smaller than stable (#37426) The angular.io production deployment script (`deploy-to-firebase.sh`) compares the major version corresponding to the current branch (e.g. `8` for branch `8.1.x`) against the major stable version (e.g. `9` if the current stable version is `9.1.0`). It then uses the result of that comparison to determine whether the current branch corresponds to a newer version than stable (i.e. an RC version) and thus should not be deployed or to an older version and thus may need to be deployed to an archive vX.angular.io project. Previously, the script was using string comparison (`<`) to compare the two major versions. This could produce incorrect results for an RC major version that is numerically greater than the stable but lexicographically smaller. For example, 10 vs 9 (10 is numerically greater but lexicographically smaller than 9). Example of a CI job that incorrectly tried to deploy an RC branch to production: https://circleci.com/gh/angular/angular/726414 This commit fixes it by switching to an integer comparison (i.e. using the `-lt` operator). PR Close #37426

view details

Pete Bacon Darwin

commit sha 6e7bd939f6901539305de0917350c5ebc328e775

perf(ngcc): cache parsed tsconfig between runs (#37417) This commit will store a cached copy of the parsed tsconfig that can be reused if the tsconfig path is the same. This will improve the ngcc "noop" case, where there is no processing to do, when the entry-points have already been processed. Previously we were parsing this config every time we checked for entry-points to process, which can take up to seconds in some cases. Resolves #36882 PR Close #37417

view details

Alan Agius

commit sha c61decf7e5aaf7e7b238b78ecafb3b3c52e6fab1

docs: add blank line before header (#37391) Currently, `Formatting your source code` is not being formatted as a header because of a missing empty line. PR Close #37391

view details

Pete Bacon Darwin

commit sha 7f98b87ca0f6f0c99cc8d6c0ae09b6c5d8f9c483

fix(ngcc): ensure that more dependencies are found by `EsmDependencyHost` (#37075) Previously this host was skipping files if they had imports that spanned multiple lines, or if the import was a dynamic import expression. PR Close #37075

view details

Pete Bacon Darwin

commit sha 4d69da57cac94385de2d008ef33a5303094b72b8

refactor(ngcc): move shared code into `DependencyHostBase` (#37075) The various dependency hosts had a lot of duplicated code. This commit refactors them to move this into the base class. PR Close #37075

view details

Pete Bacon Darwin

commit sha 07a80161182298e8fdacf0ece0413f8c0200f030

fix(ngcc): capture dynamic import expressions as well as declarations (#37075) Previously we only checked for static import declaration statements. This commit also finds import paths from dynamic import expressions. Also this commit should speed up processing: Previously we were parsing the source code contents into a `ts.SourceFile` and then walking the parsed AST to find import paths. Generating an AST is unnecessary work and it is faster and creates less memory pressure to just scan the source code contents with the TypeScript scanner, identifying import paths from the tokens. PR Close #37075

view details

Pete Bacon Darwin

commit sha 57411c85b9119c9061795eea363f509151c91203

feat(ngcc): implement a program-based entry-point finder (#37075) This finder is designed to only process entry-points that are reachable by the program defined by a tsconfig.json file. It is triggered by calling `mainNgcc()` with the `findEntryPointsFromTsConfigProgram` option set to true. It is ignored if a `targetEntryPointPath` has been provided as well. It is triggered from the command line by adding the `--use-program-dependencies` option, which is also ignored if the `--target` option has been provided. Using this option can speed up processing in cases where there is a large number of dependencies installed but only a small proportion of the entry-points are actually imported into the application. PR Close #37075

view details

Joey Perrott

commit sha c025357fb86562ba2105ec2c9f55adb45cdb8327

feat(dev-infra): Add oauth scope check to ensure necessary permissions for merge tooling (#37421) Adds an assertion that the provided TOKEN has OAuth scope permissions for `repo` as this is required for all merge attempts. On failure, provides detailed error message with remediation steps for the user. PR Close #37421

view details

Paul Gschwendtner

commit sha b2bd38699b0595d0a35b501f20251f8715a9fd1c

fix(dev-infra): properly determine oauth scopes for git client token (#37439) We recently added a better reporting mechanism for oauth tokens in the dev-infra git util. Unfortunately the logic broke as part of addressing PR review feedback. Right now, always the empty promise from `oauthScopes` will be used as `getAuthScopes` considers it as the already-requested API value. This is not the case as the default promise is also truthy. We should just fix this by making the property nullable. PR Close #37439

view details

Andrew Scott

commit sha c8f7fc22c77882ae4c737c76fda7d474bf5e87b2

refactor(dev-infra): change required base commit sha (#37424) Update the commit sha to require that PRs have been rebased beyond the one which has new header requirements so we don't get failures after merging PR Close #37424

view details

Joey Perrott

commit sha dffcca73e41c13801a414d17fda924bfdc49da49

fix(dev-infra): clean up usages within pullapprove tooling (#37338) Clean up pullapprove tooling to use newly created common utils. Additionally, use newly created logging levels rather than verbose flagging. PR Close #37338

view details

Joey Perrott

commit sha 753fed285cb7c54ef7fef89d541b1fd7cab55a17

build: add dev-infra to tslint selected files (#37233) Adds the dev-infra files to the scope of files on which tslint is enforced. This will allow for better code management/conformance. PR Close #37233

view details

Joey Perrott

commit sha 4e7a4543b85c3929e925300d2888d67c9bb24541

style(dev-infra): correct tslint failures in dev-infra directory (#37233) Fixes tslint failures in dev-infra directory as the directory is now part of the tslint enforced files. PR Close #37233

view details

Igor Minar

commit sha eb6ba9ac807dfef878ee28ba995bf3cfab8bd915

docs: fix various typos (#37443) This change just fixes various typos and misspellings across several docs. I've included also a fix for an issue surfaced via #37423. Closes #37423 PR Close #37443

view details

Lars Gyrup Brink Nielsen

commit sha 3569fdf45195c36713e43a91a4feba4fa3c9facf

fix(common): prevent duplicate URL change notifications (#37404) Prevent duplicate notifications from being emitted when multiple URL change listeners are registered using Location#onUrlChange. PR Close #37404

view details

Amadou Sall

commit sha e31208beb18c806f24a36afb4a1772c60ff525f8

docs: fix minor error in the "Structural directives" guide (#37452) The sample code used in this guide uses [class.od]="odd". But, in another portion of the guide, [ngClass]="odd" is mentioned instead. PR Close #37452

view details

George Kalpakas

commit sha d4c0962c7b9bb1150342c714202a784266fbcffc

refactor(dev-infra): use the `exec()` helper from `utils/shelljs` whenever possible (#37444) There is an `exec()` helper provided by `utils/shelljs.ts`, which is a wrapper around ShellJS' `exec()` with some default options (currently `silent: true`). The intention is to avoid having to pass these options to every invocation of the `exec()` function. This commit updates all code inside `dev-infra/` to use this helper whenever possible). NOTE: For simplicity, the `utils/shelljs` helper does not support some of the less common call signatures of the original `exec()` helper, so in some cases we still need to use the original. PR Close #37444

view details

Pete Bacon Darwin

commit sha 818d93d7e9691f702447c765da4bf59cd33676ec

fix(ngcc): find decorated constructor params on IIFE wrapped classes (#37436) Now in TS 3.9, classes in ES2015 can be wrapped in an IIFE. This commit ensures that we still find the static properties that contain decorator information, even if they are attached to the adjacent node of the class, rather than the implementation or declaration. Fixes #37330 PR Close #37436

view details

Joey Perrott

commit sha 85b6c94cc6d4dd1cfae68fc14575d0efa57574b3

refactor(dev-infra): move GitClient to common util (#37318) Moves GitClient from merge script into common utils for unified method of performing git actions throughout the ng-dev toolset. PR Close #37318

view details

George Kalpakas

commit sha 569d1ef583fc46107d0f9c3f8bcfb2dff7b00c00

refactor(elements): remove unnecessary non-null assertions and `as any` type-casts (#36161) This commit removes some unnecessary non-null assertions (`!`) and `as any` type-casts from the `elements` package. PR Close #36161

view details

push time in a month

Pull request review commentziglang/zig

std: Add std.math.divCeil

 fn testDivFloor() void {     testing.expect((divFloor(f32, -5.0, 3.0) catch unreachable) == -2.0); } +pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T {+    @setRuntimeSafety(false);+    if (numerator <= 0) return divTrunc(T, numerator, denominator);+    if (@typeInfo(T) == .Float) {+        if (denominator == 0) return error.DivisionByZero;+        return @ceil(numerator / denominator);+    }+    return (try divFloor(T, numerator - 1, denominator)) + 1;+}++test "math.divCeil" {+    testDivCeil();+    comptime testDivCeil();+}+fn testDivCeil() void {+    testing.expect((divCeil(i32, 5, 3) catch unreachable) == 2);

I would recommend testing all of the sign combinations

    testing.expect((divCeil(i32, -5, -3) catch unreachable) == 2);
    testing.expect((divCeil(i32, 5, -3) catch unreachable) == 2);
katesuyu

comment created time in 2 months

PullRequestReviewEvent

Pull request review commentangular/angular

Improve typing of common pipes

 export class KeyValuePipe implements PipeTransform {   private differ!: KeyValueDiffer<any, any>;   private keyValues: Array<KeyValue<any, any>> = []; -  transform<K, V>(input: null, compareFn?: (a: KeyValue<K, V>, b: KeyValue<K, V>) => number): null;+  transform<K, V>(

Yes :) That has already been changed in https://github.com/angular/angular/pull/37311 and will stay like that when these changes are rebased

ranma42

comment created time in 2 months

PullRequestReviewEvent

PR opened zlib-ng/zlib-ng

Correct some typos in README.md

Jus some minor typos :)

+3 -3

0 comment

1 changed file

pr created time in 2 months

push eventranma42/zlib-ng

Andrea Canciani

commit sha 5cf555b6535fea301a60c2d524dabb98c6de2f75

Correct some typos in README.md Jus some minor typos :)

view details

push time in 2 months

fork ranma42/zlib-ng

zlib replacement with optimizations for "next generation" systems.

fork in 2 months

pull request commentTheodo-UK/nestjs-admin

Fix #163, #174, #166

In the meantime this fix is available by installing nestjs-admin from the npm branch of the same repo:

npm install git+https://github.com/xtrinch/nestjs-admin.git#e81af9a394cdb4d49640f9e962ccc5b0973a28bf

Thank you @xtrinch 🎉

xtrinch

comment created time in 2 months

pull request commentrust-lang/rust

Improve slice.binary_search_by()'s best-case performance to O(1)

@pickfire it's kind of suspicious that the worst_case benchmarks are actually the fastest ones... I am not sure about it, but I guess it might be caused by the compiler being able to see through the inputs of the binary search, as they are not black_boxed

Folyd

comment created time in 3 months

pull request commentrust-lang/rust

Improve slice.binary_search_by()'s best-case performance to O(1)

Quaternary search has been discussed (and rejected) in https://github.com/rust-lang/rust/issues/74547

Folyd

comment created time in 3 months

PR opened ionic-team/ionic-native-google-maps

Fix `Map.setDiv` with an HTMLElement

Currently the setDiv method always fails if it is performed on an element which belongs to the document body, because of an inverted check.

The check can be trivially fixed. Should we also handle explicitly the case in which there is no offsetParent (as in the Map constructor?)

+1 -1

0 comment

1 changed file

pr created time in 3 months

push eventranma42/ionic-native-google-maps

Andrea Canciani

commit sha 7147ef81290dc385794e9f13c675775cedb8a00e

Fix `Map.setDiv` with an HTMLElement Currently the `setDiv` method always fails if it is performed on an element which belongs to the document body, because of an inverted check.

view details

push time in 3 months

pull request commentangular/angular

Improve typing of common pipes

I would hate to miss again the merge window, but I am not in a rush to get this merged (the projects I work on that would benefit from this are mostly fine with some additional casts).

ranma42

comment created time in 3 months

more