Skip to content

Commit 0df46eb

Browse files
committed
added a ts validate script
1 parent aee51e5 commit 0df46eb

File tree

5 files changed

+56
-3
lines changed

5 files changed

+56
-3
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"scripts": {
1919
"test": "echo \"Error: no test specified\" && exit 1",
2020
"lint": "eslint bin core plugins",
21-
"ts:generate": "tsc"
21+
"ts:generate": "tsc -p types/tsconfig.json",
22+
"ts:validate": "tsc -p types/tsconfig-validate.json"
2223
},
2324
"repository": {
2425
"type": "git",

types/index.d.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* init Espruino global vars
3+
* @param {() => void} callback
4+
*/
5+
export function init(callback: () => void): void;
6+
/**
7+
* Send a file to an Espruino on the given port, call the callback when done
8+
* @param {string} port
9+
* @param {string} filename
10+
* @param {() => void} callback
11+
*/
12+
export function sendFile(port: string, filename: string, callback: () => void): void;
13+
/**
14+
* Send code to Espruino
15+
* @param {string} port
16+
* @param {string} code
17+
* @param {() => void} callback
18+
*/
19+
export function sendCode(port: string, code: string, callback: () => void): void;
20+
/**
21+
* Execute an expression on Espruino, call the callback with the result
22+
* @param {string} port
23+
* @param {string} expr
24+
* @param {(result: string) => void} callback
25+
*/
26+
export function expr(port: string, expr: string, callback: (result: string) => void): void;
27+
/**
28+
* Execute a statement on Espruino, call the callback with what is printed to the console
29+
* @param {string} port
30+
* @param {string} expr
31+
* @param {(result: string) => void} callback
32+
*/
33+
export function statement(port: string, expr: string, callback: (result: string) => void): void;
34+
/**
35+
* Flash the given firmware file to an Espruino board.
36+
* @param {string} port
37+
* @param {string} filename
38+
* @param {number} flashOffset
39+
* @param {() => void} callback
40+
*/
41+
export function flash(port: string, filename: string, flashOffset: number, callback: () => void): void;
42+
//# sourceMappingURL=index.d.ts.map

types/index.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/tsconfig-validate.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
// This tsconfig emits no types, it's just used to validate if types being passed are valid with 'checkJs'
3+
"include": ["../*.js", "../core/**/*.js", "../plugins/**/*.js"],
4+
"compilerOptions": {
5+
"allowJs": true,
6+
"checkJs": true,
7+
"noEmit": true
8+
}
9+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"include": ["index.js", "espruino.js"],
2+
"include": ["../index.js"],
33
"compilerOptions": {
44
"allowJs": true,
55
"declaration": true, // Generate d.ts files
66
"emitDeclarationOnly": true,
7-
"outDir": "types",
7+
"outDir": ".",
88
"declarationMap": true // go to js file when using IDE functions like "Go to Definition" in VSCode
99
}
1010
}

0 commit comments

Comments
 (0)