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

142
Views
Argument of type 'number' is not assignable to parameter of type 'Date'

I am trying to test a function by passing in a date as a parameter to a function but I'm not to sure where I'm going wrong. It gives an error of "Argument of type 'number' is not assignable to parameter of type 'Date'." when the code is structured this way:

import { Component, OnInit } from '@angular/core';
import { DamageAssessmentReportService } from 'src/app/damage-assessment-report.service';

@Component({
  selector: 'app-fa-daform',
  templateUrl: './fa-daform.component.html',
  styleUrls: ['./fa-daform.component.css']
})
export class FADAFormComponent implements OnInit {

  constructor(private damageAssessmentReportService : DamageAssessmentReportService) { }
  
  //assessmentDescription: string, author: string, reportDateTime: Date
  createNewDAReport(){
    this.damageAssessmentReportService.createDAReport('Testing1','Testing2', 2022-10-10).subscribe(()=>{

    })
  }

  ngOnInit(): void {
  }

}

But changes to "Argument of type 'string' is not assignable to parameter of type 'Date'.ts(2345)" when the code is changed to :

import { Component, OnInit } from '@angular/core';
import { DamageAssessmentReportService } from 'src/app/damage-assessment-report.service';

@Component({
  selector: 'app-fa-daform',
  templateUrl: './fa-daform.component.html',
  styleUrls: ['./fa-daform.component.css']
})
export class FADAFormComponent implements OnInit {

  constructor(private damageAssessmentReportService : DamageAssessmentReportService) { }
  
  //assessmentDescription: string, author: string, reportDateTime: Date
  createNewDAReport(){
    this.damageAssessmentReportService.createDAReport('Testing1','Testing2', '2022-10-10').subscribe(()=>{

    })
  }

  ngOnInit(): void {
  }

}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

createDAReport is expecting a Date object.

this.damageAssessmentReportService.createDAReport('Testing1','Testing2', new Date(2020, 9, 10)).subscribe(() => {
  ...
});
about 4 years ago · Juan Pablo Isaza Report
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!