Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to generated type declarations #2327

Draft
wants to merge 3 commits into
base: plat-12947-7
Choose a base branch
from
Draft

Conversation

djskinner
Copy link
Contributor

Goal

Design

Changeset

Testing

Copy link

github-actions bot commented Feb 14, 2025

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 55.62 kB 16.68 kB
After 55.60 kB 16.65 kB
± -19 bytes -27 bytes

code coverage diff

<temporarily disabled>

Generated by 🚫 dangerJS against 834e673

Comment on lines -20 to -25
interface LoggerConfig {
debug: (msg: any) => void
info: (msg: any) => void
warn: (msg: any) => void
error: (msg: any, err?: unknown) => void
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One downside to having babel transpile from TypeScript is that it's not type aware. So if you do:

export { LoggerConfig } from './common'

It fails because LoggerConfig is only a type.

Due to our requirement to support lower TS versions we couldn't do export { type LoggerConfig } from './common' which does fix the issue.

So I moved all the types to common.js which are exported like `export * from './common'`` and there are no complaints.

However, the generated types that TyeScript is now producing still do include the type modifier:

export { default } from './bugsnag';
export type { BrowserBugsnagStatic, BrowserConfig } from './bugsnag';
export * from '@bugsnag/core';

And this can't be solved by us internally not using the type modifier.

To get around this we'll have to use https://www.npmjs.com/package/downlevel-dts as a post-processing step on the types.

An added benefit of this is that internally we'll be able to use type modifier and whatever else we like that is supported by our more recent version of TypeScript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant