Skip to content

Commit

Permalink
chore: fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Aug 27, 2021
1 parent e89ec2e commit 48cfea7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface PunctuatorTokenToText {
[SyntaxKind.AtToken]: '@';
[SyntaxKind.QuestionQuestionToken]: '??';
[SyntaxKind.BacktickToken]: '`';
// [SyntaxKind.HashToken]: '#'; // new in PunctuationSyntaxKind in TS 4.4
[SyntaxKind.HashToken]: '#'; // new in PunctuationSyntaxKind in TS 4.4
[SyntaxKind.EqualsToken]: '=';
[SyntaxKind.PlusEqualsToken]: '+=';
[SyntaxKind.MinusEqualsToken]: '-=';
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/tests/tools/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function createSnapshotTestBlock(
* AST_NODE_TYPE, we rethrow to cause the test to fail
*/
if (/Unknown AST_NODE_TYPE/.exec((error as Error).message)) {
throw new Error(error);
throw error;
}
expect(parse).toThrowErrorMatchingSnapshot();
}
Expand Down
5 changes: 4 additions & 1 deletion packages/scope-manager/tests/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ function nestDescribe(

try {
makeDir.sync(fixture.snapshotPath);
} catch (e) {
} catch (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
e: any
) {
if ('code' in e && e.code === 'EEXIST') {
// already exists - ignored
} else {
Expand Down
5 changes: 3 additions & 2 deletions packages/typescript-estree/tests/ast-alignment/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function parseWithTypeScriptESTree(text: string, jsx = true): parser.AST<any> {
jsx,
});
return result.ast;
} catch (e) {
} catch (e: any) {
throw createError(e.message, e.lineNumber, e.column);
}
}
Expand Down Expand Up @@ -98,7 +98,7 @@ export function parse(
'Please provide a valid parser: either "typescript-estree" or "@babel/parser"',
);
}
} catch (error) {
} catch (error: any) {
const loc = error.loc as TSESTree.LineAndColumnData | undefined;
if (loc) {
error.codeFrame = codeFrameColumns(
Expand All @@ -115,6 +115,7 @@ export function parse(
);
error.message += `\n${error.codeFrame}`;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
result.parseError = error;
}

Expand Down
5 changes: 4 additions & 1 deletion packages/typescript-estree/tests/ast-fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ function nestDescribe(

try {
makeDir.sync(fixture.snapshotPath);
} catch (e) {
} catch (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
e: any
) {
if ('code' in e && e.code === 'EEXIST') {
// already exists - ignored
} else {
Expand Down
10 changes: 8 additions & 2 deletions packages/typescript-estree/tests/lib/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ describe('parseWithNodeMaps()', () => {
it('should have correct column number when strict mode error occurs', () => {
try {
parser.parseWithNodeMaps('function fn(a, a) {\n}');
} catch (err) {
} catch (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
err: any
) {
expect(err.column).toEqual(16);
}
});
Expand Down Expand Up @@ -505,7 +508,10 @@ describe('parseAndGenerateServices', () => {
/**
* Aligns paths between environments, node for windows uses `\`, for linux and mac uses `/`
*/
error.message = (error as Error).message.replace(/\\(?!["])/gm, '/');
(error as Error).message = (error as Error).message.replace(
/\\(?!["])/gm,
'/',
);
throw error;
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-estree/tools/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function createSnapshotTestBlock(
* AST_NODE_TYPE, we rethrow to cause the test to fail
*/
if (/Unknown AST_NODE_TYPE/.exec((error as Error).message)) {
throw new Error(error);
throw error;
}
expect(parse).toThrowErrorMatchingSnapshot();
}
Expand Down

0 comments on commit 48cfea7

Please sign in to comment.