Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

DeepRequiredObject causing issues in Typescript 3.5.1 #93

Closed
amwill04 opened this issue Jun 7, 2019 · 2 comments
Closed

DeepRequiredObject causing issues in Typescript 3.5.1 #93

amwill04 opened this issue Jun 7, 2019 · 2 comments

Comments

@amwill04
Copy link

amwill04 commented Jun 7, 2019

After upgrading to typescript 3.5.1 I am having issues and having to do a lot of manual casting of types.

const Users: {
    user?: {
        dateAdded: Date
    }
} = { user: { dateAdded: new Date() } };
const userDate = idx(Users, _ => _.user.dateAdded)
if (userDate) {
    new Date(userDate) // Errors - Type DeepRequiredObject<Date> is not assignable to type 'number'
}

The following will also fail:

interface UInterface {
    user?: {
        dateAdded: Date;
    };
}

const Users: UInterface = { user: { dateAdded: new Date() } };
const userDate = idx<UInterface, Date>(Users, _ => _.user.dateAdded); // This now fails with
/*
TS2741: Property '[Symbol.toPrimitive]' is missing in type 'DeepRequiredObject<Date>' but is required in type 'Date'
*/
if (userDate) {
    console.log(new Date(userDate));
}

@mohsen1
Copy link
Contributor

mohsen1 commented Jun 8, 2019

Can you make a pull request that upgrades the TypeScript version in this repo and adds a test case that fails? We can go from there.

@amwill04
Copy link
Author

closing this issue as it was how I was doing my types else where. The error message in webstorm was leading me down the wrong path.

Thanks.

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

No branches or pull requests

2 participants