Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ jobs:
cache: npm
- run: npm install
- run: npm run build
# Against `dist`, through the package's own `exports`, as an application sees it:
# the test expects an error on each member the package marks as internal.
- name: Typecheck the built declarations as a consumer
run: npx tsc -p tests/declarations
# With `skipLibCheck` off: a declaration that names something stripped as internal
# fails here, instead of in an application that checks its libraries.
- name: Typecheck the built declarations themselves
run: npx tsc -p tests/declarations/tsconfig.lib.json
- run: npm run lint

e2e:
Expand Down
2 changes: 2 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export type {
WebhookRetryOptions,
WebhooksModuleAsyncOptions,
WebhooksModuleOptions,
WebhooksModuleRootOptions,
WebhooksModuleStructure,
WebhooksOptionsFactory,
WebhookWorkerOptions,
} from './interfaces/index.js';
Expand Down
16 changes: 16 additions & 0 deletions tests/declarations/consumer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { WebhookVerifier, WebhooksModuleRootOptions, WebhooksModuleStructure } from '@nestjs/webhooks';

// Compile-time checks against the built declarations in `dist`, as a consumer
// sees them. Verified by `tsc -p tests/declarations` after `npm run build`.

// What `forRoot()` takes can be named by an app.
export type Named = [WebhooksModuleRootOptions, WebhooksModuleStructure];

// What the package marks as internal is not in its declarations.
export function internals(verifier: WebhookVerifier) {
// @ts-expect-error internal
verifier.receiverConfig('stripe');
// @ts-expect-error internal
verifier.requireInbox();
verifier.verify;
}
13 changes: 13 additions & 0 deletions tests/declarations/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022",
"strict": true,
"experimentalDecorators": true,
"noEmit": true,
"skipLibCheck": true,
"types": ["node"]
},
"files": ["consumer.ts"]
}
13 changes: 13 additions & 0 deletions tests/declarations/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022",
"strict": true,
"experimentalDecorators": true,
"noEmit": true,
"skipLibCheck": false,
"types": ["node"]
},
"files": ["../../dist/index.d.ts", "../../dist/testing/index.d.ts", "../../dist/postgres/index.d.ts", "../../dist/mysql/index.d.ts"]
}
1 change: 1 addition & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"module": "NodeNext",
"moduleResolution": "NodeNext",
"declaration": true,
"stripInternal": true,
"strict": true,
"removeComments": false,
"noLib": false,
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"tests/**/*"
],
"exclude": [
"node_modules"
"node_modules",
"tests/declarations"
]
}