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.

Pipe name conflict

See original GitHub issue

I’m submitting a … (check one with “x”)

[] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When having 2 pipes with the same name, exported in two different modules, there’s no way to specify which one of them is used nor a error is throw specifying that the current pipe already exists.

@Pipe({ name: 'highlight' })
export class HighlightPipe implements PipeTransform {
//...
}

As an example I had a HiglightPipe in my solution and ng2-selectp was providing other HiglightPipe. The ng2-select was the last module imported and was the used pipe.

Expected behavior

An error specifying that the pipe with that name is already in use or a way to specify which modules pipe to use.

  • Angular version: 2.2.1

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:5
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
LayZeeDKcommented, Jan 20, 2022

@sharshuv-quotient

I suggest using SCAMs and migrating to Standalone Components, Directives, and Pipes in the future.

0reactions
decherneygecommented, Dec 19, 2022

I am curious why it is not recommended that pipes within your codebase should be prefixed the same way components should be prefixed. Here is a link to the pipe naming docs: https://angular.io/guide/styleguide#pipe-names and here is a link to the Component custom prefix docs: https://angular.io/guide/styleguide#component-custom-prefix

Here is the relevant snippet from the Component custom prefix docs that I think also applies to pipes

Do use a custom prefix for a component selector. For example, the prefix toh represents Tour of Heroes and the prefix admin represents an admin feature area.

Do use a prefix that identifies the feature area or the application itself.

Why? Prevents element name collisions with components in other applications and with native HTML elements.

Why? Makes it easier to promote and share the component in other applications.

Why? Components are easy to identify in the DOM.

I feel like all of these points also apply to pipes. For example, it seems better to have an application prefix on a pipe so that when I see one in a template, I know “oh that is a pipe from this app and not a native angular pipe.”

<span>{{someLongTextVariable | ellipsis}}</span>

is that a built in angular thing or does that come from this codebase ?

<span>{{someLongTextVariable | toh-ellipsis}}</span>

Oh the toh app has a ellipsis pipe that it uses to control its rules for truncating long text.

I know there is nothing that prevents a codebase from defining its own preferred practices, but I feel like there is good reason for this to be a community standard practice as well. I am curious if others agree/disagree.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent Named Pipes Conflict - Stack Overflow
Now the open fails with a message of "Cannot listen on pipe name 'net.pipe://localhost/' because another pipe endpoint is already listening on ...
Read more >
class name conflict - how to resolve - MSDN - Microsoft
Trying to use Stripe.net Transaction but VS2019 assumes I want the EF class. Found this where there is talk about using an alias,...
Read more >
Using pipe to set link name for headers conflicts with tables
The following is fixed for files, not for links to headers within files [[file#header|name]]
Read more >
NG0302: Pipe not found! - Angular
Use the pipe name to trace where the pipe is declared and used. To resolve this error, ensure that: If the pipe is...
Read more >
Resolving name conflict during XRef binding - AEC DevBlog
chm on how AutoCAD resolves such name conflicts during XRef binding : If the bPrefixName parameter is set to FALSE, the symbol names...
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