-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fixed types for TS 3.6.2 #63
Conversation
@@ -45,5 +45,5 @@ export interface Pagination { | |||
|
|||
export interface PaginatedResponse<T> { | |||
pagination?: Pagination; | |||
[key: string]: T[] | Pagination; | |||
[key: string]: T[] | Pagination | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to do [key: string]?:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried and it wasn't happy about it
node_modules/eventbrite/lib/types.d.ts:39:18 - error TS1005: ';' expected.
39 [key: string]?: T[] | Pagination;
~
node_modules/eventbrite/lib/types.d.ts:39:19 - error TS1131: Property or signature expected.
39 [key: string]?: T[] | Pagination;
~
node_modules/eventbrite/lib/types.d.ts:39:21 - error TS1131: Property or signature expected.
39 [key: string]?: T[] | Pagination;
~
node_modules/eventbrite/lib/types.d.ts:39:23 - error TS1011: An element access expression should take an argument.
39 [key: string]?: T[] | Pagination;
node_modules/eventbrite/lib/types.d.ts:40:1 - error TS1128: Declaration or statement expected.
40 }
~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for chiming in so later on this. I don't think you can make a property indexer optional, as @danielepolencic already showed.
My question is why is it:
[key: string] T[] | Pagination
Why the | Pagination
? Why would it be a Pagination
. Can it just be:
export interface PaginatedResponse<T> {
pagination: Pagination;
[key: string]: T[];
}
Will that fix it by removing the ambiguity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node_modules/eventbrite/lib/types.d.ts:38:5 - error TS2411: Property 'pagination' of type 'Pagination' is not assignable to string index type 'T[]'.
38 pagination: Pagination;
~~~~~~~~~~
It doesn't work.
@benmvp or @jcreamer898 Do either of you have thoughts on this? I don't see any issues with it, but I know little TS. |
Thanks for the PR! |
🎉 This PR is included in version 1.2.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The library doesn't work with recent versions of TS.
See #62
How Has This Been Tested?
npx tsc --noEmit
Checklist:
yarn validate
to ensure that tests, typescript and linting are all in order.