You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
Since TypeScript 3.4 there are "const contexts for literal expressions" (microsoft/TypeScript#29510) that allow an as const statement in certain scenarios.
Right now the rule report an error:
// Type assertion on object literals is forbidden, use a type annotation instead.letbar={type: 'foo'}asconst;
The new const assertions are really useful for complex type constructs, specially if they need to be used in discriminated unions.
So, add an option like "allow-const-assertions" to support this case would be very nice.
The text was updated successfully, but these errors were encountered:
Actually these assertions feel a little different to me than type assertions, so I'm tempted to just allow as const by default in the rule. Maybe if someone wants to ban them we can add that option later.
Option to rule Suggestion
Since TypeScript 3.4 there are "const contexts for literal expressions" (microsoft/TypeScript#29510) that allow an
as const
statement in certain scenarios.Right now the rule report an error:
The new const assertions are really useful for complex type constructs, specially if they need to be used in discriminated unions.
So, add an option like "
allow-const-assertions
" to support this case would be very nice.The text was updated successfully, but these errors were encountered: