Skip to content

Commit cf44f9f

Browse files
committed
added patches for current exceptions
1 parent 505659d commit cf44f9f

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"test": "vitest",
1212
"lint": "eslint .",
1313
"lint:fix": "eslint --fix .",
14-
"generate-types": "npm run docs && node utils/generate-types"
14+
"generate-types": "npm run docs && node utils/generate-types && node utils/patch"
1515
},
1616
"lint-staged": {
1717
"Gruntfile.js": "eslint",

utils/patch.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const fs = require('fs');
2+
3+
const replace = (path, src, dest) => {
4+
try {
5+
const data = fs
6+
.readFileSync(path, { encoding: 'utf-8' })
7+
.replace(src, dest);
8+
fs.writeFileSync(path, data);
9+
} catch (err) {
10+
console.error(err);
11+
}
12+
};
13+
14+
replace(
15+
"./src/core/structure.d.ts",
16+
"function p5(sketch: object, node: string | HTMLElement): void;",
17+
"function p5: typeof p5"
18+
);
19+
20+
replace(
21+
"./src/webgl/p5.Geometry.d.ts",
22+
"constructor(detailX?: number, detailY?: number, callback?: function);",
23+
`constructor(
24+
detailX?: number,
25+
detailY?: number,
26+
callback?: (this: {
27+
detailY: number,
28+
detailX: number,
29+
vertices: p5.Vector[],
30+
uvs: number[]
31+
}) => void);`
32+
);
33+
34+
// https://github.com/p5-types/p5.ts/issues/31
35+
replace(
36+
"./src/math/random.d.ts",
37+
"function random(choices: Array): any;",
38+
"function random<T>(choices: T[]): T;"
39+
);
40+
41+
replace(
42+
"./src/utilities/array_functions.d.ts",
43+
"function append(array: Array, value: Any): Array;",
44+
"function append<T>(array: T[], value: T): T[];"
45+
);
46+
47+

0 commit comments

Comments
 (0)