Skip to content

Commit

Permalink
Move types to dedicated declaration file
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Feb 10, 2025
1 parent 5112b9d commit ae48501
Show file tree
Hide file tree
Showing 12 changed files with 1,062 additions and 1,288 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import Long from './umd/index.js';
export default Long; // compatible with `import Long from "long"`
import { Long } from './types.js';
export default Long;
1,375 changes: 551 additions & 824 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,22 @@
},
"scripts": {
"build": "esm2umd Long index.js > umd/index.js",
"test": "node tests"
"test": "npm run test:unit && npm run test:typescript",
"test:unit": "node tests",
"test:typescript": "tsc --project tests/typescript/tsconfig.esnext.json && tsc --project tests/typescript/tsconfig.nodenext.json && tsc --project tests/typescript/tsconfig.commonjs.json"
},
"files": [
"index.js",
"index.d.ts",
"umd/index.js",
"umd/index.d.ts",
"umd/package.json",
"types.d.ts",
"LICENSE",
"README.md"
],
"devDependencies": {
"esm2umd": "^0.2.1"
"esm2umd": "^0.2.2",
"typescript": "^5.7.3"
}
}
5 changes: 5 additions & 0 deletions tests/typescript/test-import.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Long from '../../index.js';

Long.fromValue(1);

export default Long;
5 changes: 5 additions & 0 deletions tests/typescript/test-require.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Long = require("../../umd/index.js");

Long.fromValue(1);

export default Long;
6 changes: 6 additions & 0 deletions tests/typescript/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"target": "ESNext",
"noEmit": true
}
}
8 changes: 8 additions & 0 deletions tests/typescript/tsconfig.commonjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "node10"
},
"include": ["./test-require.ts"]
}
7 changes: 7 additions & 0 deletions tests/typescript/tsconfig.esnext.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "ESNext",
},
"include": ["./test-import.ts"]
}
3 changes: 3 additions & 0 deletions tests/typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./tsconfig.commonjs.json"
}
8 changes: 8 additions & 0 deletions tests/typescript/tsconfig.nodenext.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "nodenext",
},
"include": ["./test-import.ts"]
}
Loading

0 comments on commit ae48501

Please sign in to comment.