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

Fixed types for TS 3.6.2 #63

Merged
merged 1 commit into from
Nov 4, 2019
Merged

Conversation

danielepolencic
Copy link
Contributor

The library doesn't work with recent versions of TS.
See #62

How Has This Been Tested?

npx tsc --noEmit

Checklist:

  • I have read the CONTRIBUTING document.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • I have run yarn validate to ensure that tests, typescript and linting are all in order.

@@ -45,5 +45,5 @@ export interface Pagination {

export interface PaginatedResponse<T> {
pagination?: Pagination;
[key: string]: T[] | Pagination;
[key: string]: T[] | Pagination | undefined;
Copy link
Contributor

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]?: ?

Copy link
Contributor Author

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 }
   ~

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@kwelch
Copy link
Contributor

kwelch commented Oct 14, 2019

@benmvp or @jcreamer898 Do either of you have thoughts on this? I don't see any issues with it, but I know little TS.

@kwelch-eb kwelch-eb merged commit a18824b into eventbrite:master Nov 4, 2019
@kwelch-eb
Copy link
Contributor

Thanks for the PR!

@ebtravis
Copy link
Collaborator

ebtravis commented Nov 4, 2019

🎉 This PR is included in version 1.2.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

5 participants