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

[TypeScript] Add UserData type for $user.$data to use instead of being Data type #825

Closed
1 of 4 tasks
toreyjs opened this issue Sep 25, 2020 · 2 comments
Closed
1 of 4 tasks

Comments

@toreyjs
Copy link

toreyjs commented Sep 25, 2020

I'm submitting a...

  • Bug report
  • Feature request
  • Documentation issue or request
  • Other... Please describe:

Description

My issue is with $data: Data; in interface User (found here), which uses Data directly instead of having something like "UserData" which inherits from Data, similar to the implementation of JovoData, AppData, and SessionData.

The reason this matters for me is because I'd like to use module augmentation to add fields / typing for each of theses data types (also nice for autocomplete). But when I try to do this with User data, it currently effects all the other types since user data uses just the base type, Data.

example of what I can do with SessionData but not UserData (since it doesn't exist):

interface MySessionData { foo?:string };
declare module 'jovo-core/dist/src/Interfaces' {
	interface SessionData extends MySessionData {}
}

optionally I'd love a built-in way to do this that also disallows using non-defined fields (so that I don't accidentally call $user.$data.foo instead of $session.$data.foo for example) as module augmentation only lets me narrow down fields, but that's not as important (and I'm not exactly sure how that could be achieved anyways, without removing [key: string]: any; which would then force everyone to use module augmentation).

@m-ripper
Copy link
Contributor

m-ripper commented Oct 1, 2020

Hello @toreyjs,

Thanks for the feature-request.
With the 3.1 update, this feature is now available.

@toreyjs
Copy link
Author

toreyjs commented Oct 2, 2020

Thank you!

@toreyjs toreyjs closed this as completed Oct 2, 2020
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