Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doesn't work with angular 9 version #33

Open
Famin42 opened this issue Feb 14, 2020 · 19 comments
Open

doesn't work with angular 9 version #33

Famin42 opened this issue Feb 14, 2020 · 19 comments

Comments

@Famin42
Copy link

Famin42 commented Feb 14, 2020

I have an error in console, when try to import TimeAgoPipe and add to module declarations.

So, little "crutch" like that solved my problem

...
import { TimeAgoPipe } from 'time-ago-pipe';

@Pipe({
    name: 'timeAgo',
    pure: false
})
export class TimeAgoExtendsPipe extends TimeAgoPipe {}

@NgModule({
    declarations: [
        TimeAgoExtendsPipe,
...
@Nasun4o
Copy link

Nasun4o commented Mar 23, 2020

Same problem with Angular 9.

@benj0c
Copy link

benj0c commented Mar 27, 2020

@AndrewPoyntz did you plan to maintain this lib/repository?

@wisdomrider
Copy link

same problem

@ChaitanyaBabar
Copy link

+1

@Fomin2402 @Nasun4o @wisdomrider
Although disabling aot generates build successfully.

CC: @AndrewPoyntz

@ganholete
Copy link

+1

@sellefrancais
Copy link

sellefrancais commented May 6, 2020

Setting Pipe.pure to "true" and I was confirm it works as expected roughly.

@tomasalles
Copy link

Setting Pipe.pure to "true" and I was confirm it works as expected roughly.

How would you do that?

@ilkeryanizca
Copy link

Does not work with Angular 9. Do you have any suggestions?

@andreitruta
Copy link

Does not work with Angular 9. Do you have any suggestions?
Hello, ilkeryanizca you must do what
Fomin2402 did in his post.

@ChaitanyaBabar
Copy link

Setting Pipe.pure to "true" and I was confirm it works as expected roughly.

How would you do that?

Follow the method provided by @Fomin2402 .

Steps

  1. In your current code implementation you remove the reference TimePipeAgo in your NgModules.
  2. Then extend TimePipeAgo to your own custom implementation i.e. TimeAgoExtendsPipe class.
  3. Use the same decorators provided by @Fomin2402 in above code.

@PsykotropyK
Copy link

Hello, I have the same issue but using @Fomin2402 code raise an error:

Classes decorated with @pipe decorator should implement PipeTransform interface.

@ilkeryanizca
Copy link

Hello everyone and thanks for your answers.
I use 'time-ago-pipe', and it works pretty well. I would recommend.
Have a nice day.

@P3tronius
Copy link

Seems to be the same issue with JsonPipe.

@larsnedb
Copy link

larsnedb commented Jun 3, 2020

It does work in Angular 9 with one little modification:

import {Pipe, PipeTransform} from '@angular/core';
import {TimeAgoPipe} from 'time-ago-pipe';

@Pipe({
  name: 'timeAgo',
  pure: false
})
export class TimeAgoExtendsPipePipe extends TimeAgoPipe implements PipeTransform {

  transform(value: string): string {
    return super.transform(value);
  }
}

Note that you have to implement PipeTransform in order to not get compilation error on @Pipe.
Not sure why I both have to extend a class which implements an interface AND implement the interface. But this TimeAgo has caused me enough troubles now, so I'm happy enough as long as it is working.

@eranamarante
Copy link

eranamarante commented Jun 5, 2020

It does work in Angular 9 with one little modification:

import {Pipe, PipeTransform} from '@angular/core';
import {TimeAgoPipe} from 'time-ago-pipe';

@Pipe({
  name: 'timeAgo',
  pure: false
})
export class TimeAgoExtendsPipePipe extends TimeAgoPipe implements PipeTransform {

  transform(value: string): string {
    return super.transform(value);
  }
}

Note that you have to implement PipeTransform in order to not get compilation error on @Pipe.
Not sure why I both have to extend a class which implements an interface AND implement the interface. But this TimeAgo has caused me enough troubles now, so I'm happy enough as long as it is working.

Hi! the code looks fine, but I still got errors upon compilation :(

EDIT: I got it just by converting my date to string :/

@vatsac
Copy link

vatsac commented Aug 12, 2020

It does work in Angular 9 with one little modification:

import {Pipe, PipeTransform} from '@angular/core';
import {TimeAgoPipe} from 'time-ago-pipe';

@Pipe({
  name: 'timeAgo',
  pure: false
})
export class TimeAgoExtendsPipePipe extends TimeAgoPipe implements PipeTransform {

  transform(value: string): string {
    return super.transform(value);
  }
}

Note that you have to implement PipeTransform in order to not get compilation error on @Pipe.
Not sure why I both have to extend a class which implements an interface AND implement the interface. But this TimeAgo has caused me enough troubles now, so I'm happy enough as long as it is working.

Hi! the code looks fine, but I still got errors upon compilation :(

EDIT: I got it just by converting my date to string :/

please tell me how to convert date to string

@madmacc
Copy link

madmacc commented Nov 19, 2020

I'm getting this with Angular 10 (in Ionic).
The fixes above (including @larsnedb's one ) don't help me.

Fine until I run a prod build.
If I run ionic build --prod I get the error:

ERROR in node_modules/time-ago-pipe/time-ago.pipe.d.ts:3:22 - error NG6002: Appears in the NgModule.imports of PipesModule, but could not be resolved to an NgModule class.

This likely means that the library (time-ago-pipe) which declares TimeAgoPipe has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

EDIT:
I ended up switching to ngx-pipes as it has a timeAgo

@sohaiebCollabCp
Copy link

@Fomin2402 Hello, can you please share with us which is the error you got ? to know if this issue concerns my problem too or not .

thank you in advance

@ryandavie
Copy link

ryandavie commented Jan 8, 2023

Slight modification to allow dates:

import { Pipe, PipeTransform } from '@angular/core';
import { TimeAgoPipe } from 'time-ago-pipe';

@Pipe({
  name: 'timeAgo'
})
export class TimeagoFixPipe extends TimeAgoPipe implements PipeTransform {

  transform(value: Date | string): string {
    return super.transform(value.toString());
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests