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

Allow const assertions in no-object-literal-type-assertion #4681

Merged
merged 4 commits into from May 7, 2019
Merged
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions src/rules/noObjectLiteralTypeAssertionRule.ts
Expand Up @@ -86,6 +86,12 @@ function walk(ctx: Lint.WalkContext<Options>): void {
if (
isAssertionExpression(node) &&
node.type.kind !== ts.SyntaxKind.AnyKeyword &&
// If using TS >=3.4, allow const assertions
!(
(ts as any).isConstTypeReference &&
node.type.kind === ts.SyntaxKind.TypeReference &&
(ts as any).isConstTypeReference(node.type)
) &&
// Compare with UnknownKeyword if using TS 3.0 or above
(!!(ts.SyntaxKind as any).UnknownKeyword
? node.type.kind !== (ts.SyntaxKind as any).UnknownKeyword
Expand Down