Commit ed3bcea
committed
fix: make types compile under TypeScript 7.0
Both `@sendgrid/client` and `@sendgrid/mail` ship .d.ts files that
mix `export = instance` with `export {Class}` and silence the
diagnostic with `// @ts-ignore`. Pre-7.0, downstream consumers paid
no cost for this since named imports of the class still resolved.
TS 7.0 (the Go-port `tsgo` beta) tightens the rule and surfaces
TS2616 in every consumer that imports `Client` or `MailService`:
error TS2616: 'Client' can only be imported by using
'import Client = require("@sendgrid/client")' or a default import.
The fix mirrors the runtime: `module.exports = new Client();
module.exports.Client = Client;`. Modeling that as a `Client`
instance with a `Client: typeof Client` instance member lets TS
expose the class through `client.Client` AND through the named
import `import { Client } from "@sendgrid/client"` without any
escape hatches. Same pattern for MailService. Existing TS test
fixtures (incl. `new Client()` and `setClient(client: Client)`)
keep passing under both tsc 5.9 and tsgo 7.0 unchanged.
Also bring tsconfig.json up to TS 7.0 minimums so the test fixtures
type-check under tsgo: drop the removed `baseUrl`, add the now-
required leading `./` to path mappings, and declare `types: ["node"]`
explicitly (auto-load of all @types is gone in 7.0).
Verified with tsc@5.9.3 and @typescript/native-preview@7.0.0-dev.1 parent 498e232 commit ed3bcea
3 files changed
Lines changed: 18 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 62 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
7 | 14 | | |
8 | 15 | | |
9 | 16 | | |
| |||
41 | 48 | | |
42 | 49 | | |
43 | 50 | | |
44 | | - | |
45 | 51 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
0 commit comments