forked from DimensionDev/Maskbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsconfig.json
169 lines (150 loc) · 7.68 KB
/
tsconfig.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
{
"references": [
// Only list top-level projects here
{ "path": "./packages/polyfills/" },
{ "path": "./packages/mask/" },
{ "path": "./packages/injected-script/main" },
{ "path": "./packages/mask-sdk/main" },
{ "path": "./packages/mask-sdk/public-api" },
{ "path": "./packages/dashboard" },
// Storybooks are considered as a "project" not depended by any other project
{ "path": "./packages/dashboard/stories" },
{ "path": "./packages/theme/stories" },
// Tests
// @masknet/scripts: insert-here 1
{ "path": "./packages/backup-format/tsconfig.tests.json" },
{ "path": "./packages/encryption/tsconfig.tests.json" },
{ "path": "./packages/typed-message/tests/tsconfig.json" },
// All plugins should be type checked too
{ "path": "./packages/plugins" }
],
"compilerOptions": {
"paths": {
// # Why?
// TypeScript project reference requires manually declaring all referenced projects.
// For example, we have 2 projects A and B under /projects/a and /projects/b and B depends on A,
// if we do not list A in the references, when we write
// > /packages/b/src/index.ts
// ```ts
// import { something } from '../../a'
// ```
// If there is no "reference": [{ "path": "../a/tsconfig.json" }] in /packages/b/tsconfig.json,
// TypeScript will complain TS6307: "File '/packages/b/src/index.ts' is not listed within the file list of the project '/packages/b/tsconfig.json'. Projects must list all files or use an 'include' pattern."
// This is error is GOOD because it means TypeScript _can_ automatically detect the missing references.
// # What about monorepo?
// But TypeScript cannot detect the missing references when we install them as monorepo packages.
// Still the project structure above, but A is installed as "@masknet/a" in /packages/b/node_modules/@masknet/a,
// TypeScript will accept the missing reference to the A project,
// because it will go through the "moduleResolution": "Node" resolution, if `.d.ts` file is found,
// the project will _accidentally_ compiles, but TypeScript does DON'T know those packages has dependencies in the project reference graph.
// This will cause the project to randomly fail to be type-checked.
// # Solution
// We use "paths" to map the Node-style import path back to the relative style,
// therefore TypeScript can check the missing dependencies again.
// This will not introduce problems like mapping "@src/" to "/packages/a/src" which is problematic,
// because those projects (if they're correctly configured) is installed in the node_modules,
// so if any toolchain does not support the "paths" feature, it will still work.
// This will bring another problem: now we can reference a project without installing it as a monorepo dependency,
// which is unwanted. We need to take care of this.
"@masknet/backup-format": ["./packages/backup-format/src"],
"@masknet/configuration": ["./packages/configuration/src"],
// ! dashboard is explicitly opt-out of this feature, it and the /packages/mask has circulare reference that TypeScript does not allows.
// "@masknet/dashboard": ["./packages/dashboard/src"],
"@masknet/encryption": ["./packages/encryption/src"],
"@masknet/external-plugin-previewer": ["./packages/external-plugin-previewer/src"],
"@masknet/gun-utils": ["./packages/gun-utils/src"],
"@masknet/injected-script": ["./packages/injected-script/sdk"],
// @masknet/mask is not listed. it does not have a exports/main field in the package.json.
"@masknet/mask-sdk": ["./packages/mask-sdk/server"],
"@masknet/plugin-infra": ["./packages/plugin-infra/src"],
"@masknet/global-types/*": ["./packages/polyfills/types/*"],
"@masknet/public-api": ["./packages/public-api/src"],
// @masknet/scripts is not listed. It does not mean to be installed as a dependency and not join the type check.
"@masknet/shared": ["./packages/shared/src"],
"@masknet/shared-base": ["./packages/shared-base/src"],
"@masknet/shared-base-ui": ["./packages/shared-base-ui/src"],
"@masknet/storybook-shared": ["./packages/storybook-shared/src"],
"@masknet/theme": ["./packages/theme/src"],
// @masknet/web3-constants is not listed. It is not a TS project (only contains JSON files).
// @masknet/web3-contracts is not listed. It is not a TS project (only contains generated JSON and .d.ts files).
"@masknet/web3-providers": ["./packages/web3-providers/src"],
"@masknet/web3-shared-base": ["./packages/web3-shared/base/src"],
"@masknet/web3-shared-evm": ["./packages/web3-shared/evm/src"],
"@masknet/web3-shared-flow": ["./packages/web3-shared/flow/src"],
"@masknet/web3-shared-solana": ["./packages/web3-shared/solana/src"],
"@masknet/typed-message": ["./packages/typed-message/base"],
"@masknet/typed-message/dom": ["./packages/typed-message/dom"],
// @masknet/scripts: insert-here 2
// Plugins
"@masknet/plugin-dao": ["./packages/plugins/DAO/src"],
"@masknet/plugin-debugger": ["./packages/plugins/Debugger/src"],
"@masknet/plugin-example": ["./packages/plugins/example/src"],
"@masknet/plugin-file-service": ["./packages/plugins/FileService/src"],
"@masknet/plugin-evm": ["./packages/plugins/./src"],
"@masknet/plugin-flow": ["./packages/plugins/Flow/src"],
"@masknet/plugin-rss3": ["./packages/plugins/RSS3/src"],
"@masknet/plugin-solana": ["./packages/plugins/Solana/src"],
"@masknet/plugin-template": ["./packages/plugins/template/src"],
"@masknet/plugin-cyberconnect": ["./packages/plugins/CyberConnect/src"],
"@masknet/plugin-go-plus-security": ["./packages/plugins/GoPlusSecurity/src"],
"@masknet/plugin-cross-chain-bridge": ["./packages/plugins/CrossChainBridge/src"],
"@masknet/plugin-web3-profile": ["./packages/plugins/Web3Profile/src"],
// @masknet/scripts: insert-here 3
"@masknet/plugin-wallet": ["./packages/plugins/Wallet/src"]
},
// Classification follows https://www.typescriptlang.org/tsconfig
// Type Checking
"strict": true,
// exactOptionalPropertyTypes: false,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noImplicitThis": true,
// noPropertyAccessFromIndexSignature: false,
// noUncheckedIndexedAccess: false,
// noUnusedLocals: false,
// noUnusedParameters: false,
"useUnknownInCatchVariables": true,
// Modules
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
// Exclude everything by default. Include them in each project on-demand
"types": ["web", "masknet__global-types"],
// Emit
"declaration": true,
"declarationMap": true,
"importsNotUsedAsValues": "error",
"noEmitOnError": true,
// "preserveValueImports": true,
"sourceMap": true,
"stripInternal": true, // skip type emit for @internal types
// JavaScript Support
"allowJs": true,
"checkJs": false,
// Interop Constraints
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
// Language and Environment
"jsx": "react-jsx",
"lib": ["ES2022"], // don't add "DOM", we use @types/web
"target": "ES2021",
"useDefineForClassFields": true,
// Projects
"composite": true,
"incremental": true,
// Completeness
"skipLibCheck": true // skip all type checks for .d.ts files
},
"files": [],
"ts-node": {
"compilerOptions": {
"module": "NodeNext",
"noEmit": false
},
"esm": true,
"swc": true
}
}