Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
Tying to add Typescript extension for Date
import { DatePipe } from '@angular/common';

declare global {
    interface Date {
        transformTo(format: string): string;
    }
}

Date.prototype.transformTo = function(format: string): string{
    return new DatePipe('en-US').transform(this, format);
};

export {};

Results in the error:

Property "transformTo" does not exist on type 'Date'.

I've looked at several S.O. posts and everything looks right. When I have a Date intellisense know the extension method and what it expects. The vs code doesn't show an error. The error only occurs when running 'ng build'

Angular version: 9.1.11

Node Version: 14.8.0

NPM Version: 6.14.15

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!