Skip to content

Commit 51c7278

Browse files
committed
fix type errors
1 parent ed67a0d commit 51c7278

File tree

7 files changed

+44
-12
lines changed

7 files changed

+44
-12
lines changed

packages/core/src/client.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export default class Client<T extends Config = Config> {
169169
}
170170

171171
_configure (opts: T, internalPlugins: Plugin<T>[]) {
172-
const schema = internalPlugins.reduce((schema, plugin) => {
172+
const schema: Record<string, any> = internalPlugins.reduce((schema, plugin) => {
173173
if (plugin && plugin.configSchema) return Object.assign({}, schema, plugin.configSchema)
174174
return schema
175175
}, this._schema)
@@ -181,15 +181,15 @@ export default class Client<T extends Config = Config> {
181181

182182
// accumulate configuration and error messages
183183
const { errors, config } = (Object.keys(schema) as (keyof T)[]).reduce((accum: {errors: Record<any, any>, config: Record<any, any>}, key: keyof typeof opts) => {
184-
const defaultValue = schema[key].defaultValue(opts[key])
184+
const defaultValue = schema[key as string].defaultValue(opts[key])
185185

186186
if (opts[key] !== undefined) {
187-
const valid = schema[key].validate(opts[key])
187+
const valid = schema[key as string].validate(opts[key])
188188
if (!valid) {
189-
accum.errors[key] = schema[key].message
189+
accum.errors[key] = schema[key as string].message
190190
accum.config[key] = defaultValue
191191
} else {
192-
if (schema[key].allowPartialObject) {
192+
if (schema[key as string].allowPartialObject) {
193193
accum.config[key] = Object.assign(defaultValue, opts[key])
194194
} else {
195195
accum.config[key] = opts[key]

packages/core/stack-generator.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
declare module 'stack-generator' {
2+
interface StackFrame {
3+
functionName?: string;
4+
fileName?: string;
5+
lineNumber?: number;
6+
columnNumber?: number;
7+
}
8+
9+
interface BacktraceOptions {
10+
maxStackSize?: number;
11+
}
12+
13+
export function backtrace(options?: BacktraceOptions): StackFrame[];
14+
}

packages/core/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"emitDeclarationOnly": true,
1010
"declarationDir": "dist/types"
1111
},
12-
"include": ["src/**/*.ts", "src/**/*.js", "safe-json-stringify.d.ts"]
12+
"include": ["src/**/*.ts", "src/**/*.js", "safe-json-stringify.d.ts", "stack-generator.d.ts"]
1313
}

packages/delivery-react-native/test/delivery.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ type NativeClientEvent = Pick<Event,
2222
| 'groupingHash'
2323
| 'apiKey'
2424
> & {
25-
severityReason: EventWithInternals['_handledState']['severityReason']
26-
user: EventWithInternals['_user']
27-
metadata: EventWithInternals['_metadata']
28-
correlation: EventWithInternals['_correlation']
29-
groupingDiscriminator: EventWithInternals['_groupingDiscriminator']
25+
severityReason: Event['_handledState']['severityReason']
26+
user: Event['_user']
27+
metadata: Event['_metadata']
28+
correlation: Event['_correlation']
29+
groupingDiscriminator: Event['_groupingDiscriminator']
3030
nativeStack: NativeStackIOS | NativeStackAndroid
3131
}
3232

packages/plugin-hono/test/hono.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import { Client, Event, EventDeliveryPayload } from '@bugsnag/core'
22
import plugin from '../src/hono'
33

4+
// Extend the Client type to include _clientContext for testing
5+
declare module '@bugsnag/core' {
6+
interface Client {
7+
_clientContext?: {
8+
run: (client: Client, fn: () => void) => void
9+
}
10+
}
11+
}
12+
413
jest.mock('../src/load-connection-info', () => {
514
return jest.fn().mockResolvedValueOnce({
615
remote: { address: '1.2.3.4', addressType: 'v4', port: '1234' }

packages/plugin-react-native-client-sync/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "../../tsconfig.json",
33
"include": ["."],
44
"compilerOptions": {
5-
"lib": ["es2015", "esnext"],
5+
"lib": ["es2015", "es2022", "esnext"],
66
"types": ["jest", "react-native"],
77
}
88
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// TypeScript 4.8.4 doesn't include Symbol.asyncDispose from ES2023
2+
// This declaration provides the missing symbol for compatibility with Rollup types
3+
declare global {
4+
interface SymbolConstructor {
5+
readonly asyncDispose: unique symbol;
6+
}
7+
}
8+
9+
export {};

0 commit comments

Comments
 (0)