diff --git a/.eslintignore b/.eslintignore index 73270f08b..d2b87fc6a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,5 @@ dist /docs examples node_modules +types types/demo diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a01aadc2..bf23ddb41 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 just test-node-compatibility - # typescript checks that the our Typescript definitions can be compiled without errors + # typescript checks that TypeScript declarations and compatibility tests compile without errors typescript: runs-on: ubuntu-latest steps: @@ -44,11 +44,7 @@ jobs: - uses: actions/setup-node@v7 with: node-version: 24 - - run: | - cd types/demo - npm install - cd ../../ - just install typescript + - run: just install typescript lint: runs-on: ubuntu-latest steps: diff --git a/.npmignore b/.npmignore index ede4dd4da..f5efe921a 100644 --- a/.npmignore +++ b/.npmignore @@ -10,10 +10,7 @@ !/prop_types.js !/README.md !/src/**/* -!/types/**/* !/UPGRADE_GUIDE.md # Here we exclude files that we pulled in from above that should be removed .DS_Store -types/.eslintrc -types/demo diff --git a/.prettierignore b/.prettierignore index 07356dd88..34b7584b3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -11,5 +11,6 @@ examples official/fixtures/ package-lock.json style_guides/ +types/ vendor/ venv/ diff --git a/package.json b/package.json index 3fde45065..28d6e7883 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,14 @@ "homepage": "https://easypost.com", "exports": { ".": { - "types": "./types/index.d.ts", + "types": "./dist/types/index.d.ts", "import": "./dist/easypost.mjs", "require": "./dist/easypost.js" } }, "main": "./dist/easypost.js", "module": "./dist/easypost.mjs", - "types": "./types/index.d.ts", + "types": "./dist/types/index.d.ts", "repository": { "type": "git", "url": "git://github.com/easypost/easypost-node.git" @@ -31,12 +31,12 @@ "formatCheck": "prettier --check .", "lint": "eslint --ext .js,.ts --ignore-pattern 'examples/**' .", "lintFix": "eslint --ext .js,.ts --ignore-pattern 'examples/**' --fix .", - "prepublishOnly": "npm run clean && npm run build && npm run test && npm run lint && npm run formatCheck", + "prepublishOnly": "npm run clean && npm run build && npm run typescript:declarations && npm run test && npm run lint && npm run formatCheck", "scan": "npx audit-ci -m --config ./audit-ci.jsonc", "test": "npm run typescript:test && cross-env NODE_ENV=test vitest run", "test:node-compatibility": "cross-env NODE_ENV=test node ./test/node_compatibility", "typescript": "npm run typescript:declarations && npm run typescript:source && npm run typescript:compat", - "typescript:declarations": "npx tsc -p tsconfig.json", + "typescript:declarations": "rm -rf ./dist/types && npx tsc -p tsconfig.json", "typescript:test": "npx tsc -p tsconfig.test-services.json", "typescript:source": "npx tsc -p tsconfig.build.json", "typescript:compat": "npx tsc -p tsconfig.type-tests.json", diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 000000000..5e70bb213 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,3 @@ +import EasyPostClient from './easypost'; + +export default EasyPostClient; diff --git a/test/services/claim.test.ts b/test/services/claim.test.ts index 6ad56cff5..95e060cea 100644 --- a/test/services/claim.test.ts +++ b/test/services/claim.test.ts @@ -9,7 +9,7 @@ import type ShipmentServiceFactory from '../../src/services/shipment_service'; import Fixture from '../helpers/fixture'; import * as setupPolly from '../helpers/setup_polly'; -/** @typedef {import("../../types/EasyPost").default} Client */ +/** @typedef {import("../../src/easypost").default} Client */ type ClaimTestCreateInput = Parameters['create']>[0]; type ShipmentTestCreateInput = Parameters['create']>[0]; diff --git a/tsconfig.json b/tsconfig.json index 1f0f4c7ed..e2377ec65 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,15 @@ { "extends": "./tsconfig.base.json", "compilerOptions": { - "noEmit": true + "allowJs": true, + "checkJs": false, + "noImplicitAny": false, + "declaration": true, + "emitDeclarationOnly": true, + "rootDir": "./src", + "outDir": "./dist/types", + "noEmit": false }, - "include": ["types"] + "include": ["src/**/*.js", "src/**/*.ts"], + "exclude": ["dist/**", "docs/**", "coverage/**", "node_modules/**"] }