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

convert Client, Session, Breadcrumb, Event, Config to TypeScript #2323

Merged
merged 5 commits into from
Feb 17, 2025
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
36 changes: 17 additions & 19 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ module.exports = api => {
const overrides = []

if (api && api.env('test')) {
presets.push(['@babel/preset-env', {targets: {node: 'current'}}])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in jest we only need to apply the transforms that are needed for whatever node environment we're running

presets.push('@babel/preset-typescript')
plugins.push(['@babel/plugin-proposal-class-properties', { loose: true }])
plugins.push('@babel/plugin-transform-modules-commonjs')
plugins.push('@babel/plugin-proposal-optional-chaining')
overrides.push({
test: 'node_modules/react-native/**/*',
presets: ['module:metro-react-native-babel-preset']
Expand All @@ -22,24 +20,24 @@ module.exports = api => {
test: './packages/plugin-react-navigation/**/*',
presets: ['@babel/preset-react', 'module:metro-react-native-babel-preset']
})
} else {
plugins.push(
['@babel/plugin-transform-arrow-functions'],
['@babel/plugin-transform-block-scoping'],
['@babel/plugin-transform-classes', { loose: true }],
['@babel/plugin-transform-computed-properties', { loose: true }],
['@babel/plugin-transform-destructuring', { loose: true }],
['@babel/plugin-transform-member-expression-literals'],
['@babel/plugin-transform-property-literals'],
['@babel/plugin-transform-parameters', { loose: true }],
['@babel/plugin-transform-shorthand-properties'],
['@babel/plugin-transform-spread', { loose: true }],
['@babel/plugin-transform-template-literals', { loose: true }],
['@babel/plugin-proposal-object-rest-spread', { loose: true }],
['@babel/syntax-object-rest-spread']
)
}

plugins.push(
['@babel/plugin-transform-arrow-functions'],
['@babel/plugin-transform-block-scoping'],
['@babel/plugin-transform-classes', { loose: true }],
['@babel/plugin-transform-computed-properties', { loose: true }],
['@babel/plugin-transform-destructuring', { loose: true }],
['@babel/plugin-transform-member-expression-literals'],
['@babel/plugin-transform-property-literals'],
['@babel/plugin-transform-parameters', { loose: true }],
['@babel/plugin-transform-shorthand-properties'],
['@babel/plugin-transform-spread', { loose: true }],
['@babel/plugin-transform-template-literals', { loose: true }],
['@babel/plugin-proposal-object-rest-spread', { loose: true }],
['@babel/syntax-object-rest-spread']
)

if (api && !api.env('test')) {
api.cache(false)
}
Expand Down
9 changes: 9 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ const c = tseslint.config(
{
files: ['**/*.json', '**/*.[tj]s?(x)', '**/*.cjs', '**/*.mjs'],
},
// Node environment
{
files: ['jest/**/*.[js|mjs]', '**/*/babel.config.js', '**/*/rollup.config.mjs', '.rollup/index.mjs'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure the best way to target these. I think maybe we could assume all [js|mjs] are node environment then override the globals later to remove node for certain browser-only packages etc.

languageOptions: {
globals: {
...globals.node,
},
},
},
// Linting config for TypeScript
{
files: [
Expand Down
Loading
Loading