Commit 2d57dfb
committed
Clean up the DTS generator
These changes aim to make the code somewhat simpler, although it seems
that the DTS generator will forever remain a mess of some sort. This
commit has no effect on the contents of assemblyscript.generated.d.ts
and asc.generated.d.ts.
Moreover, "wrapper" files generated by the DTS generator (asc.d.ts,
assemblyscript.d.ts, transform.d.ts, transform.cjs, transform.js) are
now included in the tree instead of being generated, since they will
never change. The transform.{c,}js files also use ES6 classes instead of
functions (why not?).
Also, the build.js script now imports build-dts.js instead of spawning
it as a separate process.
The following changes to the generator have been made:
* `options.stdout` is now just a plain array
* `options.main` is assumed nonexistent
* `options.verbose` is assumed true
* `options.sendMessage` is assumed `util.debuglog("dts")`
* use `NODE_DEBUG=dts` to view the logs
* `options.types` is assumed nonexistent
* `options.out` is assumed nonexistent
* `options.resolveModuleId` is assumed nonexistent
* `options.prefix` is assumed to exist
* the use of `new Promise(...)` is now removed
* `import ... = require(...)` statements are assumed to never exist
* double quotes are now used instead of single quotes
* `else` is now on the same line as the ending brace of `if`
* other style changes have been made while I'm at it
* `DTS` is a constant just like `DTSLEN`
* `excludesMap` is now a set called `exclusions`
* `transformTypes` uses `context.factory` to create identifiers
* a duplicate `currentModuleId` variable is now removed
* unneeded merging of `compilerOptions` and `options` is now removed
* `pathUtil.relative()` is used instead of slicing
* arrow functions are used more often
* (and some other things I likely forgot about)1 parent 9fd90aa commit 2d57dfb
File tree
9 files changed
+169
-345
lines changed- dist
- scripts
9 files changed
+169
-345
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments