Use single-quoted strings in certain places.

This commit is contained in:
Daniel Rosenwasser
2016-02-29 11:13:20 -08:00
parent e23c023ada
commit dbf8b02656
4 changed files with 25 additions and 25 deletions
+1 -1
View File
@@ -1221,7 +1221,7 @@ namespace ts {
// Note: the node text must be exactly "use strict" or 'use strict'. It is not ok for the
// string to contain unicode escapes (as per ES5).
return nodeText === "\"use strict\"" || nodeText === "'use strict'";
return nodeText === '"use strict"' || nodeText === "'use strict'";
}
function bindWorker(node: Node) {
+1 -1
View File
@@ -1159,7 +1159,7 @@ namespace ts {
const isRelative = isExternalModuleNameRelative(moduleName);
if (!isRelative) {
const symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule);
const symbol = getSymbol(globals, '"' + moduleName + '"', SymbolFlags.ValueModule);
if (symbol) {
// merged symbol is module declaration symbol combined with all augmentations
return getMergedSymbol(symbol);
+3 -3
View File
@@ -753,9 +753,9 @@ namespace ts {
if (moduleSpecifier.kind === SyntaxKind.StringLiteral && isBundledEmit && (compilerOptions.out || compilerOptions.outFile)) {
const moduleName = getExternalModuleNameFromDeclaration(host, resolver, parent);
if (moduleName) {
write("\"");
write('"');
write(moduleName);
write("\"");
write('"');
return;
}
}
@@ -1679,7 +1679,7 @@ namespace ts {
host.getCanonicalFileName,
/*isAbsolutePathAnUrl*/ false);
referencePathsOutput += "/// <reference path=\"" + declFileName + "\" />" + newLine;
referencePathsOutput += '/// <reference path="' + declFileName + '" />' + newLine;
}
return addedBundledEmitReference;
+20 -20
View File
@@ -966,7 +966,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
// Any template literal or string literal with an extended escape
// (e.g. "\u{0067}") will need to be downleveled as a escaped string literal.
if (languageVersion < ScriptTarget.ES6 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) {
return getQuotedEscapedLiteralText("\"", node.text, "\"");
return getQuotedEscapedLiteralText('"', node.text, '"');
}
// If we don't need to downlevel and we can reach the original source text using
@@ -979,7 +979,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
// or an escaped quoted form of the original text if it's string-like.
switch (node.kind) {
case SyntaxKind.StringLiteral:
return getQuotedEscapedLiteralText("\"", node.text, "\"");
return getQuotedEscapedLiteralText('"', node.text, '"');
case SyntaxKind.NoSubstitutionTemplateLiteral:
return getQuotedEscapedLiteralText("`", node.text, "`");
case SyntaxKind.TemplateHead:
@@ -1205,9 +1205,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
/// 'Div' for upper-cased or dotted names
function emitTagName(name: Identifier | QualifiedName) {
if (name.kind === SyntaxKind.Identifier && isIntrinsicJsxName((<Identifier>name).text)) {
write("\"");
write('"');
emit(name);
write("\"");
write('"');
}
else {
emit(name);
@@ -1222,9 +1222,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
emit(name);
}
else {
write("\"");
write('"');
emit(name);
write("\"");
write('"');
}
}
@@ -1493,7 +1493,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
emit((<ComputedPropertyName>node).expression);
}
else {
write("\"");
write('"');
if (node.kind === SyntaxKind.NumericLiteral) {
write((<LiteralExpression>node).text);
@@ -1502,7 +1502,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
writeTextOfNode(currentText, node);
}
write("\"");
write('"');
}
}
@@ -1592,7 +1592,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
if (declaration.kind === SyntaxKind.ImportClause) {
// Identifier references default import
write(getGeneratedNameForNode(<ImportDeclaration>declaration.parent));
write(languageVersion === ScriptTarget.ES3 ? "[\"default\"]" : ".default");
write(languageVersion === ScriptTarget.ES3 ? '["default"]' : ".default");
return;
}
else if (declaration.kind === SyntaxKind.ImportSpecifier) {
@@ -1601,7 +1601,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
const name = (<ImportSpecifier>declaration).propertyName || (<ImportSpecifier>declaration).name;
const identifier = getTextOfNodeFromSourceText(currentText, name);
if (languageVersion === ScriptTarget.ES3 && identifier === "default") {
write(`["default"]`);
write('["default"]');
}
else {
write(".");
@@ -3792,7 +3792,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
if (!isEs6Module) {
if (languageVersion !== ScriptTarget.ES3) {
// default value of configurable, enumerable, writable are `false`.
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
write('Object.defineProperty(exports, "__esModule", { value: true });');
writeLine();
}
else {
@@ -3828,7 +3828,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
if (node.flags & NodeFlags.Default) {
emitEs6ExportDefaultCompat(node);
if (languageVersion === ScriptTarget.ES3) {
write("exports[\"default\"]");
write('exports["default"]');
}
else {
write("exports.default");
@@ -6600,7 +6600,7 @@ const _super = (function (geti, seti) {
emitEs6ExportDefaultCompat(node);
emitContainingModuleName(node);
if (languageVersion === ScriptTarget.ES3) {
write("[\"default\"] = ");
write('["default"] = ');
}
else {
write(".default = ");
@@ -7322,11 +7322,11 @@ const _super = (function (geti, seti) {
// Fill in amd-dependency tags
for (const amdDependency of node.amdDependencies) {
if (amdDependency.name) {
aliasedModuleNames.push("\"" + amdDependency.path + "\"");
aliasedModuleNames.push('"' + amdDependency.path + '"');
importAliasNames.push(amdDependency.name);
}
else {
unaliasedModuleNames.push("\"" + amdDependency.path + "\"");
unaliasedModuleNames.push('"' + amdDependency.path + '"');
}
}
@@ -7368,7 +7368,7 @@ const _super = (function (geti, seti) {
}
function emitAMDDependencyList({ aliasedModuleNames, unaliasedModuleNames }: AMDDependencyNames) {
write("[\"require\", \"exports\"");
write('["require", "exports"');
if (aliasedModuleNames.length) {
write(", ");
write(aliasedModuleNames.join(", "));
@@ -7502,7 +7502,7 @@ const _super = (function (geti, seti) {
if (isLineBreak(c)) {
if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) {
const part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1);
result = (result ? result + "\" + ' ' + \"" : "") + escapeString(part);
result = (result ? result + `" + ' ' + "` : "") + escapeString(part);
}
firstNonWhitespace = -1;
}
@@ -7525,7 +7525,7 @@ const _super = (function (geti, seti) {
if (entities[m] !== undefined) {
const ch = String.fromCharCode(entities[m]);
// &quot; needs to be escaped
return ch === "\"" ? "\\\"" : ch;
return ch === '"' ? "\\\"" : ch;
}
else {
return s;
@@ -7569,9 +7569,9 @@ const _super = (function (geti, seti) {
function emitJsxText(node: JsxText) {
switch (compilerOptions.jsx) {
case JsxEmit.React:
write("\"");
write('"');
write(trimReactWhitespaceAndApplyEntities(node));
write("\"");
write('"');
break;
case JsxEmit.Preserve: