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

ERROR TS2322: Type '~lib/object/Object' is not assignable to type 'module/A'. #2574

Closed
jtenner opened this issue Nov 22, 2022 · 2 comments
Closed
Labels

Comments

@jtenner
Copy link
Contributor

jtenner commented Nov 22, 2022

class Nested {}

class A {
  b: Nested = new Nested();
  // `this` causes some kind of assignable error?
  c: Nested[] = [this.b];
}

export function add(): i32 {
  let a = new A();
  return 42;
}

It produces the following error...

;; ERROR TS2322: Type '~lib/object/Object' is not assignable to type 'module/A'.
;;    :
;;  7 │ c: Nested[] = [this.b];
;;    │                ~~~~
;;    └─ in module.ts(7,18)

I found this error while working on my HTTP parser and needed to do a big refactor. I hit nearly 280 errors because I had to port my lexer combinator rules over to class properties.

Is there a workaround? And where might the problem be located in the compiler? I would love to help.

@jtenner
Copy link
Contributor Author

jtenner commented Nov 22, 2022

Additional information:

There were no constructors in any of these classes.

@dcodeIO dcodeIO added the bug label Nov 22, 2022
HerrCai0907 added a commit to HerrCai0907/assemblyscript that referenced this issue Jan 28, 2023
@dcodeIO
Copy link
Member

dcodeIO commented Jan 31, 2023

I suppose this one has been fixed in #2635?

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

No branches or pull requests

3 participants