AssemblyScript / assemblyscript

A TypeScript-like language for WebAssembly.
https://www.assemblyscript.org
Apache License 2.0
16.6k stars 650 forks source link

Fix .d.ts type for Transform#afterCompile #2830

Closed CountBleck closed 3 months ago

CountBleck commented 3 months ago

Changes proposed in this pull request: ⯈ Fix the .d.ts type for Transform#afterCompile

mattjohnsonpint commented 3 months ago

This creates an error in the generated /dist/asc.generated.d.ts:

declare module "types:assemblyscript/lib/binaryen" {
    export * from "types:assemblyscript/binaryen";
    export { default } from "types:assemblyscript/binaryen";
}

types:assemblyscript/binaryen doesn't exist.

I found a solution by modifying:

https://github.com/AssemblyScript/assemblyscript/blob/de174c5f2863ea7947ba4496be4f9028c99d3367/scripts/build-dts.js#L375-L379

to be:

    resolveModuleImport: ({ importedModuleId, currentModuleId }) => {
      if (currentModuleId == "cli/index" && importedModuleId == "../src")
        return prefix + "/src/index";

      if (importedModuleId == "binaryen")
        return "binaryen";

      return null;
    },
CountBleck commented 3 months ago

Closing in favor of #2832