assemblyscript-json icon indicating copy to clipboard operation
assemblyscript-json copied to clipboard

"yarn asbuild" failed on latest master

Open ashutoshvarma opened this issue 4 years ago • 4 comments

Summary

While trying to compile from latest master branch kept getting ERROR TS2304: Cannot find name 'null'.


Steps to reproduce

  • git clone https://github.com/nearprotocol/assemblyscript-json
    cd assemblyscript-json
    yarn
    
  • yarn asbuild

Actual Behaviour

yarn run v1.22.5
$ yarn asbuild:untouched && yarn asbuild:optimized
$ asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --sourceMap --validate --debug
WARNING Unknown option '--validate'
ERROR TS2304: Cannot find name 'null'.

   valueOf(): null {
              ~~~~
 in assembly/JSON.ts(252,14)

WARNING AS232: Exported generic function or class has no concrete instances.

     set<T>(key: string, value: T): void {
     ~~~
 in assembly/JSON.ts(358,5)

WARNING AS232: Exported generic function or class has no concrete instances.

 export function from<T>(val: T): Value {
                 ~~~~
 in assembly/JSON.ts(446,17)

WARNING AS232: Exported generic function or class has no concrete instances.

 export function parse<T = Uint8Array>(str: T): Value {
                 ~~~~~
 in assembly/JSON.ts(479,17)

WARNING AS232: Exported generic function or class has no concrete instances.

 export class JSONDecoder<JSONHandlerT extends JSONHandler> {
              ~~~~~~~~~~~
 in assembly/decoder.ts(118,14)

FAILURE 1 compile error(s)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected Behviour Compile to wasm without error

Machine Info


Potential Fix

https://github.com/nearprotocol/assemblyscript-json/blob/ee138a5557a6ca63a7e3143c462f542029857ecc/assembly/JSON.ts#L252

After replacing with below, I was able to compile successfully.

valueOf(): Null | null {

ashutoshvarma avatar Mar 17 '21 12:03 ashutoshvarma

This seems to be a bigger issue with AS and I posted it here: https://github.com/AssemblyScript/assemblyscript/issues/1744

willemneal avatar Mar 18 '21 18:03 willemneal

Ok, I see ~Should I close the PR now?~

How should it be tackle then, cause https://github.com/nearprotocol/assemblyscript-json/pull/168 needs to build the wasm from the latest source. Without the workaround of Null | null it won't be able to build.

ashutoshvarma avatar Mar 18 '21 18:03 ashutoshvarma

Looking into it more, this is a library so it doesn't make much sense to build from the index file. Seeing as we haven't see this error downstream I'm, I think you could just revert that commit in your #168. I just tested it locally and it will build the binary you added without the change.

willemneal avatar Mar 18 '21 20:03 willemneal

Yeah, you are right Just built the helper module without https://github.com/nearprotocol/assemblyscript-json/pull/168/commits/13f3460bda7fe62c459a9bd1a1cbdfe31b37bf6a sucessfully

During initial testing I tried building as-json from the index.ts, so looks like it came from there.

I have reverted the https://github.com/nearprotocol/assemblyscript-json/pull/168/commits/13f3460bda7fe62c459a9bd1a1cbdfe31b37bf6a from #168 and closed the #167

ashutoshvarma avatar Mar 18 '21 20:03 ashutoshvarma