advanced-typescript | Advanced TypeScript | Dependency Injection library
kandi X-RAY | advanced-typescript Summary
kandi X-RAY | advanced-typescript Summary
Advanced TypeScript
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of advanced-typescript
advanced-typescript Key Features
advanced-typescript Examples and Code Snippets
Community Discussions
Trending Discussions on advanced-typescript
QUESTION
I'm trying to return a more concise compile error message from a type function and was wondering if it's possible to get a string representation of a type name?
So using this solution (unfortunately the article does not use anchor links so you'll need to search for ErrorBrand) to create an error message, is it possible to do the following:
...ANSWER
Answered 2021-Dec-07 at 12:49No. That is not how Template Literal Types. The "literal types" in the name refers to Typescript literal types:
In addition to the general types string and number, we can refer to specific strings and numbers in type positions.
The "solution" you reference is a hack, and it works by manually coding the error message, e.g. ErrorBrand<'No ponies allowed!'>
. It's an abuse of the type system, for questionable added value, in my opinion, but that's a whole other topic.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install advanced-typescript
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page