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

Support optional properties. #7

Closed
WestonThayer opened this issue Oct 26, 2020 · 3 comments
Closed

Support optional properties. #7

WestonThayer opened this issue Oct 26, 2020 · 3 comments

Comments

@WestonThayer
Copy link

It's common for properties of Typescript interfaces to be optional:

interface Thing {
  foo: string;
  bar?: string;
}

typedPath<Thing>().bar.$path raises an Object is possibly 'undefined' error, when that's probably not desireable.

@bsalex
Copy link
Owner

bsalex commented Nov 15, 2020

Hi @WestonThayer.
Could you try the latest version?
Here is the test that is passing:

expect(tp<OptionalThing>().bar.$path).to.equal('bar');

If it still doesn't work - could you clarify the version of TypeScript you are using?

@WestonThayer
Copy link
Author

Good call, it was an issue with my Typescript version. Upgraded to latest and everything is fine.

@bsalex
Copy link
Owner

bsalex commented Nov 20, 2020

@WestonThayer
I've reproduced the problem you described with typescript in strict mode.
The issue has been fixed here: 0f6d6bb
Please check version 2.1.2

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

2 participants