Any way to use this with TypeScript and not have "as string" all over the codebase?
See original GitHub issueThis is part question, part feature request.
In my code, I constantly have to typecast:
this.$notify.error({
title: this.$t('auth.invalidSignupTitle') as string,
message: this.$t('general.error') as string,
});
If I don’t, I get this error: Type ‘TranslateResult’ is not assignable to type ‘string’
Is there some workaround for this? Maybe something we can declare once, so it always returns string?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:51
- Comments:13 (2 by maintainers)
Top Results From Across the Web
TypeScript: JavaScript With Syntax For Types.
TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. Try TypeScript Now. Online or...
Read more >Blocking usage of the any type in TypeScript codebases
Blocking usage of the any type in TypeScript codebases. The any type in TypeScript denotes that the value can be anything - string,...
Read more >Why you should not use the type any in TypeScript
In JavaScript, you reassign any type to any variable, or even access attributes that do not exist. Not with TypeScript since TypeScript ......
Read more >TypeScript: Stop Using 'any', There's a Type For That
Chances are you've worked with the `any` type in TypeScript. ... values from code that has been written without TypeScript or a 3rd...
Read more >How To Use Basic Types in TypeScript - DigitalOcean
You can use the void type to define the variable in question as holding no type at all. If you assign the result...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You could also use
$tc
instead of$t
whenever you just need the translation without further ado as this function returns a string always.Did the trick for me.