mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
[be] tsconfig: useUnknownInCatchVariables
This commit is contained in:
1 parent
3d2a05490f
commit
7db2388fff
3 files changed
+24
-12
No files matched your search
@@ -52,7 +52,18 @@ export function logCodegenFunction(step: string, fn: CodegenFunction): void {
|
||||
const ast = generate(node);
|
||||
printed = ast.code;
|
||||
} catch (e) {
|
||||
console.log("Error formatting AST: " + e.message);
|
||||
let errMsg: string;
|
||||
if (
|
||||
typeof e === "object" &&
|
||||
e != null &&
|
||||
"message" in e &&
|
||||
typeof e.message === "string"
|
||||
) {
|
||||
errMsg = e.message.toString();
|
||||
} else {
|
||||
errMsg = "[empty]";
|
||||
}
|
||||
console.log("Error formatting AST: " + errMsg);
|
||||
}
|
||||
if (printed === null) {
|
||||
return;
|
||||
|
||||
@@ -5,26 +5,27 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import { Effect, ValueKind, validateEnvironmentConfig } from "..";
|
||||
import {
|
||||
CompilerError,
|
||||
Effect,
|
||||
ValueKind,
|
||||
validateEnvironmentConfig,
|
||||
} from "..";
|
||||
|
||||
describe("parseConfigPragma()", () => {
|
||||
it("passing null throws", () => {
|
||||
expect(() => validateEnvironmentConfig(null as any)).toThrow();
|
||||
});
|
||||
|
||||
// tests that the errror message remains useful
|
||||
// tests that the error message remains useful
|
||||
it("passing incorrect value throws", () => {
|
||||
expect.assertions(1);
|
||||
|
||||
try {
|
||||
expect(() => {
|
||||
validateEnvironmentConfig({
|
||||
validateHooksUsage: 1,
|
||||
} as any);
|
||||
} catch (err) {
|
||||
expect(err.message).toBe(
|
||||
'[ReactForget] InvalidConfig: Validation error: Expected boolean, received number at "validateHooksUsage". Update Forget config to fix the error'
|
||||
);
|
||||
}
|
||||
}).toThrowErrorMatchingInlineSnapshot(
|
||||
`"[ReactForget] InvalidConfig: Validation error: Expected boolean, received number at "validateHooksUsage". Update Forget config to fix the error"`
|
||||
);
|
||||
});
|
||||
|
||||
it("can parse stringy enums", () => {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"importsNotUsedAsValues": "remove",
|
||||
"noUncheckedIndexedAccess": false,
|
||||
"noUnusedParameters": false,
|
||||
"useUnknownInCatchVariables": false,
|
||||
"useUnknownInCatchVariables": true,
|
||||
"target": "ES2015",
|
||||
// ideally turn off only during dev, or on a per-file basis
|
||||
"noUnusedLocals": false,
|
||||
|
||||
Reference in new issue
Block a user