add types to WebAssemblyImportDependency

This commit is contained in:
Tobias Koppers 2018-05-11 14:13:06 +02:00
parent 025d3d0836
commit 77e4a2b34c
2 changed files with 16 additions and 8 deletions

15
declarations.d.ts vendored
View File

@ -110,7 +110,7 @@ declare module "@webassemblyjs/ast" {
Start?: (p: NodePath<Start>) => void;
Global?: (p: NodePath<Global>) => void;
}
);
): void;
export class NodePath<T> {
node: T;
}
@ -121,14 +121,15 @@ declare module "@webassemblyjs/ast" {
export class Start extends Node {
index: Identifier;
}
export class ModuleImportDescription {
type: string;
valtype?: string;
id?: Identifier;
signature?: Signature;
}
export class ModuleImport extends Node {
module: string;
descr: {
type: string;
valtype?: string;
id?: Identifier;
signature?: Signature;
};
descr: ModuleImportDescription;
name: string;
}
export class ModuleExport extends Node {

View File

@ -9,13 +9,20 @@ const ModuleDependency = require("./ModuleDependency");
const UnsupportedWebAssemblyFeatureError = require("../wasm/UnsupportedWebAssemblyFeatureError");
/** @typedef {import("../WebpackError")} WebpackError */
/** @typedef {import("@webassemblyjs/ast").ModuleImportDescription} ModuleImportDescription */
class WebAssemblyImportDependency extends ModuleDependency {
/**
* @param {string} request the request
* @param {string} name the imported name
* @param {ModuleImportDescription} description the WASM ast node
* @param {false | string} onlyDirectImport if only direct imports are allowed
*/
constructor(request, name, description, onlyDirectImport) {
super(request);
/** @type {string} */
this.name = name;
/** @type {TODO} */
/** @type {ModuleImportDescription} */
this.description = description;
/** @type {false | string} */
this.onlyDirectImport = onlyDirectImport;