question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

QueryParamsHandling type should be exported

See original GitHub issue

#30816 - The reporter closed it but it shouldn’t have been closed.

🐞 bug report

Affected Package

The issue is caused by package @angular/router

Is this a regression?

Yes, the previous version in which this bug was not present was: Angular 7

Description

The QueryParamsHandling type is no longer exposed. All types that are used in public APIs should be exposed to avoid people having to duplicate the type. Previously, it was accessible via @angular/router/src/config.

πŸ”¬ Minimal Reproduction

N/A

πŸ”₯ Exception or Error




 
libs/shared/layout/src/lib/ctas/link.model.ts(1,37): error TS2307: Cannot find module '@angular/router/src/config'.

🌍 Your Environment

Angular Version:




Angular CLI: 8.0.1
Node: 10.15.2
OS: darwin x64
Angular: 8.1.0-next.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.800.1
@angular-devkit/build-angular      0.800.2
@angular-devkit/build-ng-packagr   0.800.2
@angular-devkit/build-optimizer    0.800.2
@angular-devkit/build-webpack      0.800.2
@angular-devkit/core               8.0.2
@angular-devkit/schematics         8.0.2
@angular/cdk                       8.0.0
@angular/cli                       8.0.1
@angular/flex-layout               8.0.0-beta.26
@ngtools/json-schema               1.1.0
@ngtools/webpack                   8.0.2
@schematics/angular                8.0.2
@schematics/update                 0.800.1
ng-packagr                         5.3.0
rxjs                               6.5.2
typescript                         3.4.5
webpack                            4.30.0

Anything else relevant?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
willyboycommented, Jun 11, 2019

@trotyl Thanks for the APF link.

It’s a possible solution, but there are also other solutions like inline the type signatures without reference to a private type.

I would hope that the Angular team wouldn’t recommend inlining types to external teams. That’s a dangerous recommendation. We have a lot of junior developers who don’t understand that a type should be created for this and would use that recommendation as an excuse for why they duplicated type information.

The latter historically preferred, see #29338 (comment) for more information.

I looked at that comment and I don’t think it applies here.

@trotyl Just chatted about this a bit further with @IgorMinar, and it seems like we should wait to export the FormHooks type until later. Currently, there isn’t good IDE support or API doc support for those kind of union types, and we need to have a longer conversation about the name before we make it public (and can no longer change it).

The API name is already public as queryParamsHandling in NavigationExtras. Even if it were still undergoing name changes, it’s super easy to rename a type in a backwards compatible manner.

export type Bob = {a: number};
export type Joe = Bob;

Anyway, I don’t really care about the semantics of regression/bug. The change is minor and there are at least 3 separate PRs/issues related to it. There were people using the type who now have to duplicate the type in their code. If queryParamsHandling were updated, it would be a full scale refactor to fix the duplicated types (which in our β€œAgile” world, would mean a story which means grooming… don’t ask, it’s frustrating).

Given that the API name is already public and the type is used internally and a name change could easily be done in a backwards compatible manner and that the type was accessible before (whether or not it was a part of the β€œpublic” API) and that best practices should be to reuse types instead of copying and that there is a PR already open, I can’t think of a reason why this shouldn’t be merged with haste.

Semantics aside, can you think of any reason to block this?

0reactions
angular-automatic-lock-bot[bot]commented, Jun 30, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

path/node_modules/@angular/router/router"' has no exported ...
Go to @ angular / router / router "and insert the word 'export' ... export declare type QueryParamsHandling = 'merge' | 'preserve' |...
Read more >
QueryParamsHandling - Angular
How to handle query parameters in a router link. One of: "merge" : Merge new parameters with current parameters. "preserve" : Preserve current...
Read more >
How to use queryParamsHandling In Angular | Akashminds
QueryParamsHandling is a great way to use Angular to manage parameters in your URL. By using this method, you can easily add, remove,Β ......
Read more >
How To Use Query Parameters with Angular Router
To prevent this, you can set queryParamsHandling to either 'preserve' ... export class ProductComponent implements OnInit { order: string;Β ...
Read more >
Exp Routing Queryparamshandling - StackBlitz
Starter project for Angular apps that exports to the Angular CLI.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found