Closed
Description
Minimal reproduction project attached.
ASWrapDefinitionRepro.zip
- Use
npm run all
to compile and see the output:42
. - Modify index.ts file by removing
// @ts-ignore
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:
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.
assemblyscript/src/definitions.ts
Line 499 in 97dcab6