Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-unsafe-any: Fix bug for number literal type #2712

Merged
merged 1 commit into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/rules/noUnsafeAnyRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ function walk(ctx: Lint.WalkContext<void>, checker: ts.TypeChecker): void {
case ts.SyntaxKind.ImportEqualsDeclaration:
case ts.SyntaxKind.ImportDeclaration:
case ts.SyntaxKind.ExportDeclaration:
// For some reason, these are of type "any".
// These show as type "any" if in type position.
case ts.SyntaxKind.NumericLiteral:
case ts.SyntaxKind.StringLiteral:
return;

Expand Down
4 changes: 2 additions & 2 deletions test/rules/no-unsafe-any/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const num: namespaceImport.T = 0;
}
}

// Ignore string literal in type
function returnsA(): "a";
// Ignore number/string literal in type
function returnsA(): 0 | "a" | null | undefined;

label: for (const x of []) {
break label;
Expand Down