Skip to content

Commit 4e61017

Browse files
feat!: setup typescript (#66)
1 parent edd8a79 commit 4e61017

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+65181
-338
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
extends: cheminfo
1+
extends: cheminfo-typescript
22
parserOptions:
33
sourceType: module

.github/workflows/nodejs.yml

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,9 @@ on:
55
branches: master
66
pull_request:
77

8-
env:
9-
NODE_VERSION: 14.x
10-
118
jobs:
12-
lint:
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: actions/checkout@v2
16-
- uses: actions/setup-node@v2
17-
with:
18-
node-version: ${{ env.NODE_VERSION }}
19-
- name: Install dependencies
20-
run: npm install
21-
- name: Run ESLint
22-
run: npm run eslint
23-
test:
24-
runs-on: ubuntu-latest
25-
strategy:
26-
matrix:
27-
node-version: [12.x, 14.x, 16.x]
28-
fail-fast: false
29-
steps:
30-
- uses: actions/checkout@v2
31-
- name: Use Node.js ${{ matrix.node-version }}
32-
uses: actions/setup-node@v2
33-
with:
34-
node-version: ${{ matrix.node-version }}
35-
- name: Install dependencies
36-
run: npm install
37-
- name: Run tests
38-
run: npm run test-coverage
39-
- name: Send coverage report to Codecov
40-
uses: codecov/codecov-action@v1
9+
nodejs:
10+
uses: zakodium/workflows/.github/workflows/nodejs.yml@nodejs-v1
11+
with:
12+
node-version-matrix: '[14, 16]'
13+
lint-check-types: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ dist
66
lib
77
coverage
88
.eslintcache
9+
lib-esm

CHANGELOG.md

Lines changed: 44 additions & 86 deletions
Large diffs are not rendered by default.

examples/data.json

Lines changed: 3947 additions & 1 deletion
Large diffs are not rendered by default.

examples/example.js renamed to examples/example.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { join } from 'path';
1010

1111
import { generateSpectrum } from 'spectrum-generator';
1212

13-
import { gsd, optimizePeaks } from '../src';
13+
import { DataType, gsd, optimizePeaks } from '../src';
1414

1515
const peaks = [
1616
{ x: -0.1, y: 0.2, width: 0.3 },
@@ -20,14 +20,18 @@ const peaks = [
2020
const from = -1;
2121
const to = 1;
2222

23-
const original = generateSpectrum(peaks, { from, to, nbPoints: 101 });
23+
const original = generateSpectrum(peaks, {
24+
from,
25+
to,
26+
nbPoints: 101,
27+
});
2428

2529
let peakList = gsd(original, {
2630
minMaxRatio: 0,
2731
realTopDetection: false,
2832
smoothY: false,
2933
heightFactor: 1,
30-
shape: { kind: 'gaussian' },
34+
shape: { kind: 'gaussian', width: 0 },
3135
});
3236

3337
let optimizedPeaks = optimizePeaks(original, peakList);
@@ -63,8 +67,8 @@ let reconstructed = generateSpectrum(optimizedPeaks, {
6367
to,
6468
nbPoints: 5001,
6569
});
66-
reconstructed.x = Array.from(reconstructed.x)
67-
reconstructed.y = Array.from(reconstructed.y)
70+
reconstructed.x = Array.from(reconstructed.x);
71+
reconstructed.y = Array.from(reconstructed.y);
6872

6973
original.x = Array.from(original.x);
7074
original.y = Array.from(original.y);
File renamed without changes.

jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
};

package.json

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,33 @@
22
"name": "ml-gsd",
33
"version": "7.0.1",
44
"description": "Global Spectra Deconvolution",
5-
"main": "lib/index.js",
6-
"module": "src/index.js",
5+
"main": "./lib/index.js",
6+
"module": "./lib-esm/index.js",
7+
"types": "./lib/index.d.ts",
78
"files": [
89
"lib",
9-
"src"
10+
"src",
11+
"lib-esm"
1012
],
1113
"env": {
1214
"jest": true
1315
},
1416
"scripts": {
1517
"build": "rollup -c && cheminfo-build --entry src/index.js --root GSD",
18+
"check-types": "tsc --noEmit",
19+
"clean": "rimraf lib lib-esm",
1620
"example": "nodemon -w src -w examples/example.js -r esm examples/example.js",
1721
"eslint": "eslint src --cache",
1822
"eslint-fix": "npm run eslint -- --fix",
19-
"compile": "rollup -c",
20-
"prepack": "npm run compile",
23+
"prepack": "npm run compile && npm run tsc",
2124
"prettier": "prettier --check src",
2225
"prettier-write": "prettier --write src",
23-
"test": "npm run test-coverage && npm run eslint",
26+
"test": "npm run test-coverage && npm run eslint && npm run check-types",
2427
"test-only": "jest",
25-
"test-coverage": "jest --coverage"
28+
"test-coverage": "jest --coverage",
29+
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
30+
"tsc-cjs": "tsc --project tsconfig.cjs.json",
31+
"tsc-esm": "tsc --project tsconfig.esm.json"
2632
},
2733
"repository": {
2834
"type": "git",
@@ -45,9 +51,6 @@
4551
"url": "https://github.com/mljs/global-spectral-deconvolution/issues"
4652
},
4753
"homepage": "https://github.com/mljs/global-spectral-deconvolution",
48-
"jest": {
49-
"testEnvironment": "node"
50-
},
5154
"prettier": {
5255
"arrowParens": "always",
5356
"semi": true,
@@ -56,25 +59,28 @@
5659
"trailingComma": "all"
5760
},
5861
"devDependencies": {
59-
"@babel/plugin-transform-modules-commonjs": "^7.15.4",
6062
"@types/jest": "^27.0.2",
6163
"chemcalc": "^3.4.1",
6264
"cheminfo-build": "^1.1.11",
63-
"eslint": "^7.32.0",
64-
"eslint-config-cheminfo": "^5.5.0",
65+
"eslint": "^8.1.0",
66+
"eslint-config-cheminfo-typescript": "^10.1.1",
67+
"eslint-plugin-import": "^2.25.2",
68+
"eslint-plugin-jest": "^25.2.2",
6569
"esm": "^3.2.25",
66-
"jest": "^27.2.4",
67-
"jest-matcher-deep-close-to": "^3.0.0",
68-
"mf-global": "^1.4.6",
70+
"jest": "^27.3.1",
71+
"jest-matcher-deep-close-to": "^3.0.2",
72+
"mf-global": "^1.4.7",
6973
"ml-stat": "^1.3.3",
70-
"nodemon": "^2.0.13",
74+
"nodemon": "^2.0.14",
7175
"prettier": "^2.4.1",
72-
"rollup": "^2.58.0",
73-
"spectrum-generator": "^5.4.0",
76+
"rimraf": "^3.0.2",
77+
"spectrum-generator": "^5.4.1",
78+
"ts-jest": "^27.0.7",
79+
"typescript": "^4.4.4",
7480
"xy-parser": "^3.2.0"
7581
},
7682
"dependencies": {
77-
"cheminfo-types": "^0.5.0",
83+
"cheminfo-types": "^0.6.0",
7884
"ml-peak-shape-generator": "^2.0.2",
7985
"ml-savitzky-golay-generalized": "2.0.3",
8086
"ml-spectra-fitting": "^2.0.0",

0 commit comments

Comments
 (0)