Skip to content

Commit ae48501

Browse files
committed
Move types to dedicated declaration file
1 parent 5112b9d commit ae48501

12 files changed

+1062
-1288
lines changed

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import Long from './umd/index.js';
2-
export default Long; // compatible with `import Long from "long"`
1+
import { Long } from './types.js';
2+
export default Long;

package-lock.json

Lines changed: 551 additions & 824 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,22 @@
3333
},
3434
"scripts": {
3535
"build": "esm2umd Long index.js > umd/index.js",
36-
"test": "node tests"
36+
"test": "npm run test:unit && npm run test:typescript",
37+
"test:unit": "node tests",
38+
"test:typescript": "tsc --project tests/typescript/tsconfig.esnext.json && tsc --project tests/typescript/tsconfig.nodenext.json && tsc --project tests/typescript/tsconfig.commonjs.json"
3739
},
3840
"files": [
3941
"index.js",
4042
"index.d.ts",
4143
"umd/index.js",
4244
"umd/index.d.ts",
4345
"umd/package.json",
46+
"types.d.ts",
4447
"LICENSE",
4548
"README.md"
4649
],
4750
"devDependencies": {
48-
"esm2umd": "^0.2.1"
51+
"esm2umd": "^0.2.2",
52+
"typescript": "^5.7.3"
4953
}
5054
}

tests/typescript/test-import.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Long from '../../index.js';
2+
3+
Long.fromValue(1);
4+
5+
export default Long;

tests/typescript/test-require.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Long = require("../../umd/index.js");
2+
3+
Long.fromValue(1);
4+
5+
export default Long;

tests/typescript/tsconfig.base.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"noEmit": true
5+
}
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "CommonJS",
5+
"moduleResolution": "node10"
6+
},
7+
"include": ["./test-require.ts"]
8+
}

tests/typescript/tsconfig.esnext.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "ESNext",
5+
},
6+
"include": ["./test-import.ts"]
7+
}

tests/typescript/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./tsconfig.commonjs.json"
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "NodeNext",
5+
"moduleResolution": "nodenext",
6+
},
7+
"include": ["./test-import.ts"]
8+
}

0 commit comments

Comments
 (0)