Files
sentinel/config/tsconfig.base.json
T
zooqueen 07647f64ca Restore node module resolution so the frontend typecheck passes
The TypeScript 7 tsconfig migration in 23d130b and 2984b2f set
config/tsconfig.base.json to `module: node16` / `moduleResolution: node16`
in place of the `commonjs` / `node` pair this fork inherited. That left
`tsc -p config/tsconfig.build.json` — the gate hanzo.yml runs — failing
with 398 errors, the bulk of them:

  static/app/actionCreators/modal.tsx(61,28): error TS2307: Cannot find
  module 'sentry/components/modals/emailVerificationModal' or its
  corresponding type declarations.

Nothing is missing. emailVerificationModal.tsx sits next to its sibling
modals and the `sentry/*` alias points at static/app. node16 grades each
import separately: static imports in these files are read as CommonJS and
resolve, but `import()` is always read as ESM, where a bare directory and
an absent file extension are both errors. The route table and every
lazily loaded modal are written with `import()`, which accounts for all
333 TS2307s and the 9 TS2835s. The same CJS/ESM split produced the 21
TS1479s and 21 TS2305s: node16 honors package `exports` and lands on
different type entry points for marked, screenfull and rrweb.

Webpack resolves this code, through `resolve.alias` in webpack.config.ts,
and webpack has no such modes, so `moduleResolution: node` is what
describes it. Restoring it takes the gate from 398 errors to 0.
`moduleResolution: bundler` also describes webpack and would stay legible
to TS7, but it reads `exports` the way node16 does and leaves 9 genuine
type errors in the rrweb and emotion overlay types; that is a code change
and is not attempted here. `downlevelIteration` stays dropped, it does
nothing at target ES2022.
2026-08-12 20:06:52 -07:00

139 lines
4.2 KiB
JSON

{
"$schema": "http://json.schemastore.org/tsconfig",
"compilerOptions": {
// NOTE: We DO NOT use typescript to compile the application. Babel is
// responsible for handing transformation of tsx files into plain JavaScript
// compiles for the browser (and uses preset-env to determine what ECMA
// features are supported based on our browser usage configuration in
// package.json). `target` DOES NOT affect the babel output! [0]
//
// We DO however, use ts-node to build jest, webpack, and a few other
// {build,dev}-time tools. Because these are run through node, we can
// target what our current version of node supports (see [1])
//
// [0]: https://babeljs.io/docs/en/babel-preset-typescript
// [1]: https://node.green
//
// `moduleResolution` must describe webpack, which is what actually resolves
// these files (see `resolve.alias` in webpack.config.ts). node16 does not:
// it splits resolution into CJS and ESM modes, and every `import()` in a
// .tsx file is graded in ESM mode, where a bare directory and a missing
// file extension are both errors. The whole route table and every lazy
// modal is written that way, so node16 reports ~330 phantom "cannot find
// module 'sentry/...'" on files that are sitting right there.
"module": "commonjs",
"target": "ES2022",
"moduleResolution": "node",
// We add esnext to lib to pull in types for all newer ECMAScript features
"lib": ["esnext", "dom"],
// Skip type checking of all declaration files
"skipLibCheck": true,
// We do not actually use tsc to output any JavaScript anywhere
"noEmit": true,
// Don't do anything to JSX. This doesn't really matter since we don't use
// typescript to compile files, but left here for documentation purposes.
"jsx": "preserve",
"jsxImportSource": "@emotion/react",
// Type checking specific options
"alwaysStrict": false,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": false,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"strictBindCallApply": false,
"useUnknownInCatchVariables": false,
// We do not configure these, but are left here for documentation purposes
//
// allowUnreachableCode
// allowUnusedLabels
// exactOptionalPropertyTypes
// noImplicitOverride
// noPropertyAccessFromIndexSignature
// noUncheckedIndexedAccess
// strictFunctionTypes
// strictNullChecks
// strictPropertyInitialization
// anduseUnknownInCatchVariables
// Emit configuration
"declaration": false,
"declarationMap": false,
"importHelpers": true,
"inlineSources": false,
"noEmitHelpers": true,
"sourceMap": true,
"pretty": false,
// We do not configure these, but are left here for documentation purposes
//
// declarationDir
// emitBOM
// emitDeclarationOnly
// importsNotUsedAsValues
// inlineSourceMap
// mapRoot
// newLine
// noEmitHelpers
// noEmitOnError
// outDir
// outFile
// preserveConstEnums
// preserveValueImports
// removeComments
// sourceRoot
// andstripInternal
// These get overridden when necessary
"allowJs": false,
"checkJs": false,
"esModuleInterop": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"paths": {
"sentry/*": [
"../static/app/*"
],
"sentry-fixture/*": [
"../fixtures/js-stubs/*"
],
"sentry-test/*": [
"../tests/js/sentry-test/*"
],
"sentry-images/*": [
"../static/images/*"
],
"sentry-locale/*": [
"../src/sentry/locale/*"
],
"sentry-logos/*": [
"../src/sentry/static/sentry/images/logos/*"
],
"sentry-fonts/*": [
"../static/fonts/*"
]
},
"plugins": [
// The styled plugin provides language server autocompletion for styled
// component template strings
{ "name": "@styled/typescript-styled-plugin" }
]
},
"include": ["../static/app", "../tests/js", "../fixtures/js-stubs"],
"exclude": ["../node_modules", "../**/*.benchmark.ts"],
"ts-node": {
"transpileOnly": true
}
}