Skip to content

Introducing AS and ANY keywords #39137

@technohippy

Description

@technohippy

Search Terms

AS ANY capitalize upper case

Suggestion

Introducing AS and ANY keywords instead of or in addition to as and any.

When using as or any, many TS programmers need to have their determination and overcome their inferior feeling to break type-safe code. AS and ANY can express their strong will more than as and any do.

Additionally, capitalized words attract notice so that they can be easily fixed at a later point. as and any have average looking. If they are something to avoid, they should have distinct looking. AS and ANY express that we should avoid to use them.

This feature should be configurable on tsconfig to avoid breaking existing codes.

Use Cases

AS and ANY can be used at any place where as and any are used.

Examples

  • let variable: ANY
  • req.headers AS Headers

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions