Skip to content

Missing wrap() method in generated definition files. Prevents compilation. #1617

Closed
@forcepusher

Description

@forcepusher

Minimal reproduction project attached.
ASWrapDefinitionRepro.zip

  1. Use npm run all to compile and see the output: 42.
  2. Modify index.ts file by removing // @ts-ignore
  3. npm run all again and observe the error:
    index.ts:10:74 - error TS2339: Property 'wrap' does not exist on type 'typeof SomeClass'.

Here's a short overview of the attached repro:

// assembly/index.ts

export class SomeClass {
  public somefield: i32 = 42;
}
export function getSomeClass() : SomeClass {
  return new SomeClass();
}
// index.ts

import SomeModule from './build/module';
import * as Loader from '@assemblyscript/loader';
import * as fs from 'fs';

const wasmModule = Loader.instantiateSync<typeof SomeModule>(fs.readFileSync(__dirname + "/build/module.wasm"));
const someClassPointer = wasmModule.exports.getSomeClass();

// Try removing @ts-ignore, it will no longer compile.
// @ts-ignore
const someClass: SomeModule.SomeClass = wasmModule.exports.SomeClass.wrap(someClassPointer);
console.log(someClass.somefield);

The generated definition file needs to have the wrap method defined for classes, like so:
image

I was told to fix it somewhere around here, but I'm barely two month into web development, so it's a little bit over my head.

var staticMembers = element.prototype.members;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions