Skip to content

Commit 1e926b3

Browse files
committed
fix .d.ts and add a basic typechecking example/CI
1 parent 5215633 commit 1e926b3

File tree

6 files changed

+105
-5
lines changed

6 files changed

+105
-5
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ jobs:
2323
node-version: ${{ matrix.node-version }}
2424
- run: npm ci
2525
- run: npm test -- run --coverage
26+
- run: npx tsc

lib/mixpanel-node.d.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,6 @@ declare namespace mixpanel {
162162
delete_group(groupKey: string, groupId: string, modifiers?: Modifiers, callback?: Callback): void;
163163
delete_group(groupKey: string, groupId: string, callback: Callback): void;
164164
}
165-
166-
// Export feature flags types for convenience
167-
export { LocalFlagsConfig, RemoteFlagsConfig, FlagContext, SelectedVariant } from './flags/types';
168-
export { default as LocalFeatureFlagsProvider } from './flags/local_flags';
169-
export { default as RemoteFeatureFlagsProvider } from './flags/remote_flags';
170165
}
171166

172167
export = mixpanel;

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
},
2828
"types": "./lib/mixpanel-node.d.ts",
2929
"devDependencies": {
30+
"@types/node": "^24.10.1",
3031
"@vitest/coverage-v8": "^4.0.8",
3132
"nock": "^14.0.10",
3233
"proxyquire": "^2.1.3",
34+
"typescript": "^5.9.3",
3335
"vitest": "^4.0.8"
3436
},
3537
"dependencies": {

tscheck/example.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// example module where typechecking should be working both in code editors and via `tsc`
2+
3+
import Mixpanel from "../lib/mixpanel-node.js";
4+
5+
const mp = Mixpanel.init("asjdf", { local_flags_config: {} });
6+
mp.track("test event");
7+
mp.local_flags?.getVariantValue("color", "blue", { distinct_id: "user_1" });

tsconfig.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
// Visit https://aka.ms/tsconfig to read more about this file
3+
"compilerOptions": {
4+
// File Layout
5+
// "rootDir": "./lib",
6+
// "outDir": "./dist",
7+
8+
// Environment Settings
9+
// See also https://aka.ms/tsconfig/module
10+
"module": "nodenext",
11+
"target": "esnext",
12+
13+
// For nodejs:
14+
"lib": ["esnext"],
15+
"types": ["node"],
16+
17+
"noEmit": true,
18+
19+
"esModuleInterop": true,
20+
21+
// Stricter Typechecking Options
22+
"noUncheckedIndexedAccess": true,
23+
"exactOptionalPropertyTypes": true,
24+
25+
// Style Options
26+
// "noImplicitReturns": true,
27+
// "noImplicitOverride": true,
28+
// "noUnusedLocals": true,
29+
// "noUnusedParameters": true,
30+
// "noFallthroughCasesInSwitch": true,
31+
// "noPropertyAccessFromIndexSignature": true,
32+
33+
// Recommended Options
34+
"strict": true,
35+
// "verbatimModuleSyntax": true,
36+
"isolatedModules": true,
37+
"noUncheckedSideEffectImports": true,
38+
"moduleDetection": "force",
39+
"skipLibCheck": true,
40+
}
41+
}

0 commit comments

Comments
 (0)