Skip to content

Static properties' types fail to be inferred #1252

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
willemneal opened this issue May 5, 2020 · 1 comment · Fixed by #1259
Closed

Static properties' types fail to be inferred #1252

willemneal opened this issue May 5, 2020 · 1 comment · Fixed by #1259
Labels

Comments

@willemneal
Copy link
Contributor

Here is an example in webassembly studio: https://webassembly.studio/?f=p106fcnkpp

function testGenric<T>(t: T): void {}

class StaticProperties {
  static get x(): i32 {
    return 0;
  }

  get i_x(): i32 {
    return 1;
  }
}

testGenric((new StaticProperties).i_x);
testGenric(StaticProperties.x);
ERROR TS1140: Type argument expected.

 testGenric(StaticProperties.x);
           ^
 in main.ts(18,11)


ERROR: 1 compile error(s)
    at exports.main (https://cdn.jsdelivr.net/npm/assemblyscript@nightly/dist/asc.js:7:826973)
    at Object.eval [as main] (eval at d (https://webassembly.studio/dist/main.bundle.js:1:1), <anonymous>:20:12)
    at r.eval [as promiseMaker] (eval at gulp (https://webassembly.studio/dist/main.bundle.js:1:34093), <anonymous>:28:7)
    at o.makePromise (https://webassembly.studio/dist/main.bundle.js:1:31658)
    at s.runInstance (https://webassembly.studio/dist/main.bundle.js:1:31954)
@dcodeIO dcodeIO added the bug label May 9, 2020
@dcodeIO
Copy link
Member

dcodeIO commented May 9, 2020

Turned out that is due to properties being somewhat special, in that static properties have no real instance but just a prototype. Looking into a refactor so static properties have a singleton instance instead, with the compiler then dealing with Property only.

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 a pull request may close this issue.

2 participants