Skip to content

Commit 465d7f9

Browse files
authoredJul 16, 2021
Merge pull request #18 from piotr-oles/feature/add-global-type-alias-to-runtime
feat: add global assemblyscript types aliases to the runtime
2 parents cd0689c + e658a1b commit 465d7f9

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed
 

‎README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ Node.js >= 12 and [webpack 4 or webpack 5](https://github.com/webpack/webpack)
1818

1919
```sh
2020
# with npm
21-
npm install --save-dev as-loader assemblyscript
21+
npm install as-loader
22+
npm install --save-dev assemblyscript
2223

2324
# with yarn
24-
yarn add --dev as-loader assemblyscript
25+
yarn add as-loader
26+
yarn add --dev assemblyscript
2527
```
2628

2729
The minimal `webpack.config.js`:

‎src/runtime/bind.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
} from "./types";
99
import { context } from "./context";
1010
import { AsBindReturnTypes } from "./types/ref-types";
11+
import "./types/std";
1112

1213
async function instantiate<
1314
TModule,

‎src/runtime/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
AsLoaderModule,
1010
} from "./types";
1111
import { context } from "./context";
12+
import "./types/std";
1213

1314
async function instantiate<TModule>(
1415
module: TModule | string,

‎src/runtime/types/std.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Types
2+
declare type bool = boolean;
3+
declare type i8 = number;
4+
declare type i16 = number;
5+
declare type i32 = number;
6+
declare type isize = number;
7+
declare type u8 = number;
8+
declare type u16 = number;
9+
declare type u32 = number;
10+
declare type usize = number;
11+
declare type f32 = number;
12+
declare type f64 = number;
13+
14+
/** Special type evaluating the indexed access index type. */
15+
declare type indexof<T extends unknown[]> = keyof T;
16+
/** Special type evaluating the indexed access value type. */
17+
declare type valueof<T extends unknown[]> = T[0];

0 commit comments

Comments
 (0)