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

Property 'push' does not exist on type 'number[]'. #2

Closed
notexplosive opened this issue Dec 18, 2018 · 1 comment
Closed

Property 'push' does not exist on type 'number[]'. #2

notexplosive opened this issue Dec 18, 2018 · 1 comment
Labels
enhancement New feature or request

Comments

@notexplosive
Copy link

I've been playing around with this and I really like it so far! However I ran into a weird problem trying to work with arrays.

let arr:number[] = []
arr.push(5)

In the playground this yields __TS__ArrayPush(arr, 5); but instead I get the compile-time (transpile-time?) error: Property 'push' does not exist on type 'number[]'.

@hazzard993
Copy link
Owner

Thanks for the post! 😄

Ah yes, this is because my definition of an array from these definitions is just

interface Array<T> {
    length: number;
}

So push doesn't exist on any [] type.

TypescriptToLua does some special things once you add a dot to array. See this function

I'll add some more properties into Array so they can be used. These will include push

@hazzard993 hazzard993 added the enhancement New feature or request label Dec 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants