Skip to content

Commit 0c7d1e9

Browse files
committed
Disable creation of types file
This file is copied from the ESLint config install script
1 parent a7e90c7 commit 0c7d1e9

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ const hasJsxRuntime = (() => {
3434
function writeJson(fileName, object) {
3535
fs.writeFileSync(
3636
fileName,
37-
JSON.stringify(object, null, 2).replace(/\n/g, os.EOL) + os.EOL
37+
JSON.stringify(object, null, 2).replace(/\n/g, os.EOL) + os.EOL,
3838
);
3939
}
4040

4141
function verifyNoTypeScript() {
4242
const typescriptFiles = globby(
4343
['**/*.(ts|tsx)', '!**/node_modules', '!**/*.d.ts'],
44-
{ cwd: paths.appSrc }
44+
{ cwd: paths.appSrc },
4545
);
4646
if (typescriptFiles.length > 0) {
4747
console.warn(
4848
chalk.yellow(
4949
`We detected TypeScript in your project (${chalk.bold(
50-
`src${path.sep}${typescriptFiles[0]}`
51-
)}) and created a ${chalk.bold('tsconfig.json')} file for you.`
52-
)
50+
`src${path.sep}${typescriptFiles[0]}`,
51+
)}) and created a ${chalk.bold('tsconfig.json')} file for you.`,
52+
),
5353
);
5454
console.warn();
5555
return false;
@@ -88,26 +88,26 @@ function verifyTypeScriptSetup() {
8888
console.error(
8989
chalk.bold.red(
9090
`It looks like you're trying to use TypeScript but do not have ${chalk.bold(
91-
'typescript'
92-
)} installed.`
93-
)
91+
'typescript',
92+
)} installed.`,
93+
),
9494
);
9595
console.error(
9696
chalk.bold(
9797
'Please install',
9898
chalk.cyan.bold('typescript'),
9999
'by running',
100100
chalk.cyan.bold(
101-
isYarn ? 'yarn add typescript' : 'npm install typescript'
102-
) + '.'
103-
)
101+
isYarn ? 'yarn add typescript' : 'npm install typescript',
102+
) + '.',
103+
),
104104
);
105105
console.error(
106106
chalk.bold(
107107
'If you are not trying to use TypeScript, please remove the ' +
108108
chalk.cyan('tsconfig.json') +
109-
' file from your package root (and any TypeScript files).'
110-
)
109+
' file from your package root (and any TypeScript files).',
110+
),
111111
);
112112
console.error();
113113
process.exit(1);
@@ -160,7 +160,7 @@ function verifyTypeScriptSetup() {
160160
};
161161

162162
const formatDiagnosticHost = {
163-
getCanonicalFileName: fileName => fileName,
163+
getCanonicalFileName: (fileName) => fileName,
164164
getCurrentDirectory: ts.sys.getCurrentDirectory,
165165
getNewLine: () => os.EOL,
166166
};
@@ -172,7 +172,7 @@ function verifyTypeScriptSetup() {
172172
try {
173173
const { config: readTsConfig, error } = ts.readConfigFile(
174174
paths.appTsConfig,
175-
ts.sys.readFile
175+
ts.sys.readFile,
176176
);
177177

178178
if (error) {
@@ -185,17 +185,17 @@ function verifyTypeScriptSetup() {
185185
// Calling this function also mutates the tsconfig above,
186186
// adding in "include" and "exclude", but the compilerOptions remain untouched
187187
let result;
188-
parsedTsConfig = immer(readTsConfig, config => {
188+
parsedTsConfig = immer(readTsConfig, (config) => {
189189
result = ts.parseJsonConfigFileContent(
190190
config,
191191
ts.sys,
192-
path.dirname(paths.appTsConfig)
192+
path.dirname(paths.appTsConfig),
193193
);
194194
});
195195

196196
if (result.errors && result.errors.length) {
197197
throw new Error(
198-
ts.formatDiagnostic(result.errors[0], formatDiagnosticHost)
198+
ts.formatDiagnostic(result.errors[0], formatDiagnosticHost),
199199
);
200200
}
201201

@@ -206,8 +206,8 @@ function verifyTypeScriptSetup() {
206206
chalk.red.bold(
207207
'Could not parse',
208208
chalk.cyan('tsconfig.json') + '.',
209-
'Please make sure it contains syntactically correct JSON.'
210-
)
209+
'Please make sure it contains syntactically correct JSON.',
210+
),
211211
);
212212
}
213213

@@ -228,35 +228,35 @@ function verifyTypeScriptSetup() {
228228

229229
if (suggested != null) {
230230
if (parsedCompilerOptions[option] === undefined) {
231-
appTsConfig = immer(appTsConfig, config => {
231+
appTsConfig = immer(appTsConfig, (config) => {
232232
config.compilerOptions[option] = suggested;
233233
});
234234
messages.push(
235235
`${coloredOption} to be ${chalk.bold(
236-
'suggested'
237-
)} value: ${chalk.cyan.bold(suggested)} (this can be changed)`
236+
'suggested',
237+
)} value: ${chalk.cyan.bold(suggested)} (this can be changed)`,
238238
);
239239
}
240240
} else if (parsedCompilerOptions[option] !== valueToCheck) {
241-
appTsConfig = immer(appTsConfig, config => {
241+
appTsConfig = immer(appTsConfig, (config) => {
242242
config.compilerOptions[option] = value;
243243
});
244244
messages.push(
245245
`${coloredOption} ${chalk.bold(
246-
valueToCheck == null ? 'must not' : 'must'
246+
valueToCheck == null ? 'must not' : 'must',
247247
)} be ${valueToCheck == null ? 'set' : chalk.cyan.bold(value)}` +
248-
(reason != null ? ` (${reason})` : '')
248+
(reason != null ? ` (${reason})` : ''),
249249
);
250250
}
251251
}
252252

253253
// tsconfig will have the merged "include" and "exclude" by this point
254254
if (parsedTsConfig.include == null) {
255-
appTsConfig = immer(appTsConfig, config => {
255+
appTsConfig = immer(appTsConfig, (config) => {
256256
config.include = ['src'];
257257
});
258258
messages.push(
259-
`${chalk.cyan('include')} should be ${chalk.cyan.bold('src')}`
259+
`${chalk.cyan('include')} should be ${chalk.cyan.bold('src')}`,
260260
);
261261
}
262262

@@ -266,33 +266,33 @@ function verifyTypeScriptSetup() {
266266
chalk.bold(
267267
'Your',
268268
chalk.cyan('tsconfig.json'),
269-
'has been populated with default values.'
270-
)
269+
'has been populated with default values.',
270+
),
271271
);
272272
console.log();
273273
} else {
274274
console.warn(
275275
chalk.bold(
276276
'The following changes are being made to your',
277277
chalk.cyan('tsconfig.json'),
278-
'file:'
279-
)
278+
'file:',
279+
),
280280
);
281-
messages.forEach(message => {
281+
messages.forEach((message) => {
282282
console.warn(' - ' + message);
283283
});
284284
console.warn();
285285
}
286286
writeJson(paths.appTsConfig, appTsConfig);
287287
}
288288

289-
// Reference `react-scripts` types
290-
if (!fs.existsSync(paths.appTypeDeclarations)) {
291-
fs.writeFileSync(
292-
paths.appTypeDeclarations,
293-
`/// <reference types="@upleveled/react-scripts" />${os.EOL}`
294-
);
295-
}
289+
// // Reference `react-scripts` types
290+
// if (!fs.existsSync(paths.appTypeDeclarations)) {
291+
// fs.writeFileSync(
292+
// paths.appTypeDeclarations,
293+
// `/// <reference types="@upleveled/react-scripts" />${os.EOL}`
294+
// );
295+
// }
296296
}
297297

298298
module.exports = verifyTypeScriptSetup;

0 commit comments

Comments
 (0)