Skip to content

Commit f4ffef2

Browse files
authored
fix(types): allow "false" in integrations options (#543)
1 parent eb7ff36 commit f4ffef2

File tree

9 files changed

+302
-41
lines changed

9 files changed

+302
-41
lines changed

jest.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import type { JestConfigWithTsJest } from 'ts-jest'
2+
import { JS_EXT_TO_TREAT_AS_ESM, TS_EXT_TO_TREAT_AS_ESM } from 'ts-jest'
23

34
const jestConfig: JestConfigWithTsJest = {
4-
preset: 'ts-jest/presets/js-with-ts-esm',
5+
extensionsToTreatAsEsm: [...JS_EXT_TO_TREAT_AS_ESM, ...TS_EXT_TO_TREAT_AS_ESM],
56
testEnvironment: 'node',
7+
transform: {
8+
'^.+\\.m?[tj]sx?$': ['ts-jest', { useESM: true, tsconfig: './test/tsconfig-jest.json' }],
9+
},
610
// Crashes on CI - https://github.com/facebook/jest/issues/10662
711
// collectCoverage: true,
812
// collectCoverageFrom: [

package.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,21 @@
4141
"lint:fixture": "eslint --ext .vue,.js --no-ignore 'test/fixture/*/.nuxt/sentry.*'",
4242
"release": "release-it",
4343
"test:fixture": "NODE_OPTIONS=--experimental-vm-modules jest --runInBand",
44-
"test": "yarn prepack && yarn lint && yarn test:fixture && yarn lint:fixture",
44+
"test": "yarn prepack && yarn test:fixture && yarn lint:fixture && yarn typecheck",
45+
"typecheck": "tsc",
4546
"coverage": "codecov"
4647
},
48+
"lint-staged": {
49+
"*.{js,ts,vue}": [
50+
"eslint"
51+
]
52+
},
53+
"husky": {
54+
"hooks": {
55+
"pre-commit": "lint-staged && npm run typecheck",
56+
"post-merge": "yarn"
57+
}
58+
},
4759
"dependencies": {
4860
"@sentry/integrations": "^7.45.0",
4961
"@sentry/node": "^7.45.0",
@@ -66,17 +78,20 @@
6678
"@sentry/tracing": "7.45.0",
6779
"@sentry/webpack-plugin": "1.20.0",
6880
"@types/hash-sum": "1.0.0",
69-
"@types/jest": "29.5.0",
81+
"@types/jest": "29.4.3",
7082
"@types/lodash.mergewith": "4.6.7",
7183
"@types/node": "16.18.19",
84+
"@types/request-promise-native": "^1.0.18",
7285
"codecov": "3.8.3",
7386
"eslint": "8.36.0",
7487
"eslint-plugin-jest": "27.2.1",
7588
"globby": "11.1.0",
7689
"hookable": "5.5.2",
77-
"jest": "29.5.0",
90+
"husky": "4.3.8",
91+
"jest": "29.4.3",
92+
"lint-staged": "13.2.0",
7893
"nuxt": "2.16.3",
79-
"playwright-chromium": "1.32.0",
94+
"playwright-chromium": "1.32.1",
8095
"release-it": "15.9.3",
8196
"sass": "1.60.0",
8297
"sentry-testkit": "5.0.5",

src/types/configuration.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { SentryCliPluginOptions } from '@sentry/webpack-plugin'
88
import { Integrations as NodeIntegrations, NodeOptions, Handlers } from '@sentry/node'
99

1010
type IntegrationsConfig<T extends Record<keyof T, IntegrationClass<unknown>>> = Partial<{
11-
[K in keyof T]: ConstructorParameters<T[K]>[0] | Record<string, never>
11+
[K in keyof T]: ConstructorParameters<T[K]>[0] | Record<string, never> | false
1212
}>
1313

1414
type ClientIntegrations = IntegrationsConfig<typeof BrowserIntegrations & typeof PluggableIntegrations>

test/fixture/default/nuxt.config.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ const config = {
1111
resourceHints: false,
1212
},
1313
modules: [
14-
SentryModule,
14+
/** @type {import('@nuxt/types').Module} */(/** @type {unknown} */(SentryModule)),
1515
],
1616
sentry: {
1717
dsn: 'https://fe8b7df6ea7042f69d7a97c66c2934f7@sentry.io.nuxt/1429779',
1818
clientIntegrations: {
1919
// Integration from @Sentry/browser package.
2020
TryCatch: { eventTarget: false },
21+
ReportingObserver: false,
2122
},
2223
customClientIntegrations: '~/config/custom-client-integrations.js',
2324
tracing: true,

test/fixture/lazy/nuxt.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const config = {
99
resourceHints: false,
1010
},
1111
modules: [
12-
SentryModule,
12+
/** @type {import('@nuxt/types').Module} */(/** @type {unknown} */(SentryModule)),
1313
],
1414
sentry: {
1515
lazy: true,

test/fixture/with-lazy-config/nuxt.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const config = {
99
resourceHints: false,
1010
},
1111
modules: [
12-
SentryModule,
12+
/** @type {import('@nuxt/types').Module} */(/** @type {unknown} */(SentryModule)),
1313
],
1414
sentry: {
1515
dsn: 'https://fe8b7df6ea7042f69d7a97c66c2934f7@sentry.io.nuxt/1429779',

test/tsconfig-jest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"checkJs": false,
5+
},
6+
}

tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"allowJs": true,
44
"baseUrl": ".",
5-
"checkJs": false,
5+
"checkJs": true,
66
"esModuleInterop": true,
77
"lib": [
88
"ESNext",
@@ -15,12 +15,15 @@
1515
"strict": true,
1616
"types": [
1717
"jest",
18+
"node",
1819
],
1920
},
2021
"include": [
2122
"./src/",
23+
"./test/",
2224
],
2325
"exclude": [
26+
"./dist",
2427
"./node_modules/",
2528
"./src/templates/plugin.*.js",
2629
]

0 commit comments

Comments
 (0)