Skip to content

add index signature to ArrayLike #1547

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

Closed
wants to merge 2 commits into from
Closed

Conversation

trusktr
Copy link
Member

@trusktr trusktr commented Nov 15, 2020

  • I've read the contributing guidelines

Without this change, I get a type error in TypeScript and VS Code (not in AssemblyScript).

The error in TypeScript is:

Element implicitly has an 'any' type because expression of type 'number' can't be used to index type 'ArrayLike<N>'.
  No index signature with a parameter of type 'number' was found on type 'ArrayLike<N>'. ts(7053)

@trusktr trusktr changed the title add index type to ArrayLike add index signature to ArrayLike Nov 15, 2020
@trusktr
Copy link
Member Author

trusktr commented Nov 15, 2020

Without this change, a workaround is to place a // @ts-ignore comment above the offending line, just to satisfy TS.

Copy link
Member

@dcodeIO dcodeIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems OK to uncomment, yeah.

Background: The isArrayLike builtin currently checks that a .length property and an index signature is present, it just doesn't guarantee any types like T. As such I don't remember why exactly the index signature is commented out, but I'd guess that this is left over from an earlier version that didn't guarantee that an index signature is present.

Comment on lines +32 to +33
* Joe Pea (@trusktr) <[email protected]>
* Joe Pea (@trusktr) <[email protected]>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to pick one and stick with the format because the NOTICE file is also parsed to generate contributors in package.json for example.

@MaxGraey
Copy link
Member

MaxGraey commented Nov 17, 2020

At the moment ArrayLike is just a stub to build-ins (like isArrayLike) and no concrete class implements this interface, so these changes doesn't make sense yet.

@dcodeIO dcodeIO mentioned this pull request Feb 4, 2021
1 task
@dcodeIO dcodeIO closed this in #1668 Feb 4, 2021
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

Successfully merging this pull request may close these issues.

3 participants