Skip to content

01_Challange unexpected TSC error 'dateStyle' #8

@tadpole2077

Description

@tadpole2077

Issue Overview

Unexpected error on tsc compile.

Steps to Reproduce

error TS2353: Object literal may only specify known properties, and dateStyle does not
exist in type DateTimeFormatOptions

Issue source file: utils.js

function formatDate(date) {
    return date.toLocaleDateString("en-US", {
        dateStyle: "medium"
    });
}

Cause & Solution

Caused by using (tsconfig.js) "target": "ES6" for 01_Challange as per solution file.

dateStyle attribute of common type DateTimeFormatOptions was not added to spec until ES2020

dateStyle Spec Proposal July 2020 Stage 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions