mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-02-01 17:47:09 +00:00
* Add Typescript to the build * Converts the `helpers.core` to Typescript as an example * Converts the `core.element` to Typescript
26 lines
697 B
JavaScript
26 lines
697 B
JavaScript
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import * as helpers from '../../dist/helpers.js';
|
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
|
|
let fd;
|
|
|
|
try {
|
|
const fn = path.resolve(__dirname, 'autogen_helpers.ts');
|
|
fd = fs.openSync(fn, 'w+');
|
|
fs.writeSync(fd, 'import * as helpers from \'../../src/helpers/types\';\n\n');
|
|
|
|
fs.writeSync(fd, 'const testKeys: unknown[] = [];\n');
|
|
for (const key of Object.keys(helpers)) {
|
|
if (key[0] !== '_' && typeof helpers[key] === 'function') {
|
|
fs.writeSync(fd, `testKeys.push(helpers.${key});\n`);
|
|
}
|
|
}
|
|
} finally {
|
|
if (fd !== undefined) {
|
|
fs.closeSync(fd);
|
|
}
|
|
}
|