I notice in my application that TsLint is suggesting:
static $inject = [
'$http',
'$q',
'$scope',
'configService',
'stateService',
'utilityService'
];
for the above that:
Message 2 TsLint: ' should be "
Is this a suggested standard now for Typescript ?
Strings in JavaScript are contained within a pair of either single quotation marks '' or double quotation marks "". Both quotes represent Strings but be sure to choose one and STICK WITH IT.
Single Quotes are More Common A few repositories of popular JavaScript projects reveals that single quotes are favored over double quotes. You can see that front-end libraries (React, Angualar) have more double quotes than the other libraries as might have to do with the presence of HTML fragments.
use double quotes for strings and single quotes for chars. I prefer to use the same quoting across the board and so stick with double quotes for JS.
There is really no difference in the end between using single or double quotes, meaning they both represent a string in the end. The system doesn't really care which one you use (but you might?). No need to escape the other character within a string.
This was the first result in my google search for: "double vs single quotes typescript."
Considering the accepted answer is a little old (but still valid from the docs) I would like to add this quote from: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines updated on November 27, 2015:
Use double quotes for strings.
Granted "the code is more what you'd call 'guidelines' than actual rules." :)
I would go with single quotes. I pretty much agree with this guy:
- Prefer single quotes (') unless escaping.
Reason: More JavaScript teams do this (e.g.airbnb, standard, npm, node, google/angular, facebook/react). Its easier to type (no shift needed on most keyboards).
Prettier team recommends -
single quotes as welldouble quotes
Also, even dotnet new
templates use single quotes for Angular apps.
There is no particular standard to use single quotes for characters and double quotes for string but it is suggested to use double quotes for strings and vice versa.
From the docs:
Just like JavaScript, TypeScript also uses the double quote (") or single quote (') to surround string data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With