-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(npm): Create and publish typescript defs as npm package
- Loading branch information
Showing
8 changed files
with
183 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,4 @@ jobs: | |
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ inputs.branch }} | ||
path: ./dist/**/* | ||
path: ./dist/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# JsMacros-typescript | ||
Type information for the JsMacros minecraft mod | ||
|
||
# Setup | ||
## Install the package | ||
[Detailed guide](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#installing-a-package) | ||
|
||
1. Generate a personal access token | ||
2. Install the version of the package that matches your mod version (for full releases), or 0.0.0-sha (for beta releases) | ||
`$ npm install jsmacros/jsmacros-typescript@1.7.0` (release 1.7.0) | ||
`$ npm install jsmacros/jsmacros-typescript@0.0.0-30d74d2` (beta-30d74d2) | ||
|
||
## Add a tsconfig.json file | ||
### Mandatory fields | ||
These fields tell typescript to use the ambient type definitions without having to import them | ||
|
||
`compilerOptions.typeRoots: ["node_modules"]` | ||
`compilerOptions.types: ["wagyourtail/jsmacros-typescript"]` | ||
|
||
`skipLibCheck: true`: Prevents typescript from reporting errors in the type declaration file - the errors are caused by differences in the typescript and java type systems and are unavoidable | ||
|
||
### Example config | ||
```json | ||
{ | ||
"include": ["src"], | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"typeRoots": ["node_modules"], | ||
"types": ["jsmacros/jsmacros-typescript"], | ||
"skipLibCheck": true | ||
} | ||
} | ||
``` | ||
|
||
# Compiling | ||
If you're writing typescript then you need to compile it to javascript before you can use it in the mod. | ||
|
||
1. Compile the scripts | ||
Compile once: | ||
`$ tsc` | ||
or compile automatically whenever you make changes to the sources | ||
`$ tsc --watch` | ||
2. In the mod, select the compiled files from the `outDir` folder instead of the source files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference path="headers/Graal.d.ts"/> | ||
/// <reference path="headers/JsMacros.d.ts"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "@jsmacros/jsmacros-typescript", | ||
"version": "0.0.1", | ||
"description": "Typescript definitions & configuration to compile typescript into valid JsMacros code", | ||
"main": "index.d.ts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/JsMacros/JsMacros.git" | ||
}, | ||
"keywords": [ | ||
"minecraft", | ||
"mod", | ||
"jsmacros", | ||
"jsm", | ||
"types", | ||
"typescript", | ||
"macro", | ||
"macros" | ||
], | ||
"files": ["headers", "index.d.ts", "tsconfig.json"], | ||
"author": "William Gray <wagyourtail@wagyourtail.xyz> (https://wagyourtail.xyz/)", | ||
"license": "MPL-2.0", | ||
"bugs": { | ||
"url": "https://github.com/JsMacros/JsMacros/issues" | ||
}, | ||
"homepage": "https://github.com/JsMacros/JsMacros#readme", | ||
"publishConfig": { | ||
"registry": "https://npm.pkg.github.com/" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,9 @@ | |
"skipLibCheck": true | ||
}, | ||
"include": [ | ||
"scripts/**/*.ts", | ||
"headers/*.d.ts" | ||
], | ||
"exclude": [ | ||
"build/*" | ||
] | ||
} | ||
} |