mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Resolving a conflict with #4711
This commit is contained in:
+3
-2
@@ -588,9 +588,10 @@ function deleteTemporaryProjectOutput() {
|
||||
}
|
||||
|
||||
var testTimeout = 20000;
|
||||
desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]'.");
|
||||
desc("Runs the tests using the built run.js file. Syntax is jake runtests. Optional parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]', debug=true.");
|
||||
task("runtests", ["tests", builtLocalDirectory], function() {
|
||||
cleanTestDirs();
|
||||
var debug = process.env.debug || process.env.d;
|
||||
host = "mocha"
|
||||
tests = process.env.test || process.env.tests || process.env.t;
|
||||
var light = process.env.light || false;
|
||||
@@ -613,7 +614,7 @@ task("runtests", ["tests", builtLocalDirectory], function() {
|
||||
reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter';
|
||||
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
|
||||
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
|
||||
var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
|
||||
var cmd = host + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
|
||||
console.log(cmd);
|
||||
exec(cmd, deleteTemporaryProjectOutput);
|
||||
}, {async: true});
|
||||
|
||||
+55
-87
@@ -1573,6 +1573,7 @@ var ts;
|
||||
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
|
||||
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
|
||||
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
|
||||
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -12680,7 +12681,7 @@ var ts;
|
||||
return members;
|
||||
}
|
||||
function resolveTupleTypeMembers(type) {
|
||||
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes)));
|
||||
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true)));
|
||||
var members = createTupleTypeMemberSymbols(type.elementTypes);
|
||||
addInheritedMembers(members, arrayType.properties);
|
||||
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
|
||||
@@ -12972,25 +12973,6 @@ var ts;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function isKnownProperty(type, name) {
|
||||
if (type.flags & 80896 && type !== globalObjectType) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
return !!(resolved.properties.length === 0 ||
|
||||
resolved.stringIndexType ||
|
||||
resolved.numberIndexType ||
|
||||
getPropertyOfType(type, name));
|
||||
}
|
||||
if (type.flags & 49152) {
|
||||
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
|
||||
var t = _a[_i];
|
||||
if (isKnownProperty(t, name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function getSignaturesOfStructuredType(type, kind) {
|
||||
if (type.flags & 130048) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
@@ -13446,7 +13428,7 @@ var ts;
|
||||
}
|
||||
function createTypedPropertyDescriptorType(propertyType) {
|
||||
var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType();
|
||||
return globalTypedPropertyDescriptorType !== emptyObjectType
|
||||
return globalTypedPropertyDescriptorType !== emptyGenericType
|
||||
? createTypeReference(globalTypedPropertyDescriptorType, [propertyType])
|
||||
: emptyObjectType;
|
||||
}
|
||||
@@ -13499,68 +13481,19 @@ var ts;
|
||||
addTypeToSet(typeSet, type, typeSetKind);
|
||||
}
|
||||
}
|
||||
function isObjectLiteralTypeDuplicateOf(source, target) {
|
||||
var sourceProperties = getPropertiesOfObjectType(source);
|
||||
var targetProperties = getPropertiesOfObjectType(target);
|
||||
if (sourceProperties.length !== targetProperties.length) {
|
||||
return false;
|
||||
}
|
||||
for (var _i = 0; _i < sourceProperties.length; _i++) {
|
||||
var sourceProp = sourceProperties[_i];
|
||||
var targetProp = getPropertyOfObjectType(target, sourceProp.name);
|
||||
if (!targetProp ||
|
||||
getDeclarationFlagsFromSymbol(targetProp) & (32 | 64) ||
|
||||
!isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function isTupleTypeDuplicateOf(source, target) {
|
||||
var sourceTypes = source.elementTypes;
|
||||
var targetTypes = target.elementTypes;
|
||||
if (sourceTypes.length !== targetTypes.length) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < sourceTypes.length; i++) {
|
||||
if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function isTypeDuplicateOf(source, target) {
|
||||
if (source === target) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & 32 || source.flags & 64 && !(target.flags & 32)) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & 524288 && target.flags & 80896) {
|
||||
return isObjectLiteralTypeDuplicateOf(source, target);
|
||||
}
|
||||
if (isArrayType(source) && isArrayType(target)) {
|
||||
return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]);
|
||||
}
|
||||
if (isTupleType(source) && isTupleType(target)) {
|
||||
return isTupleTypeDuplicateOf(source, target);
|
||||
}
|
||||
return isTypeIdenticalTo(source, target);
|
||||
}
|
||||
function isTypeDuplicateOfSomeType(candidate, types) {
|
||||
for (var _i = 0; _i < types.length; _i++) {
|
||||
var type = types[_i];
|
||||
if (candidate !== type && isTypeDuplicateOf(candidate, type)) {
|
||||
function isSubtypeOfAny(candidate, types) {
|
||||
for (var i = 0, len = types.length; i < len; i++) {
|
||||
if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function removeDuplicateTypes(types) {
|
||||
function removeSubtypes(types) {
|
||||
var i = types.length;
|
||||
while (i > 0) {
|
||||
i--;
|
||||
if (isTypeDuplicateOfSomeType(types[i], types)) {
|
||||
if (isSubtypeOfAny(types[i], types)) {
|
||||
types.splice(i, 1);
|
||||
}
|
||||
}
|
||||
@@ -13583,7 +13516,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getUnionType(types, noDeduplication) {
|
||||
function getUnionType(types, noSubtypeReduction) {
|
||||
if (types.length === 0) {
|
||||
return emptyObjectType;
|
||||
}
|
||||
@@ -13592,12 +13525,12 @@ var ts;
|
||||
if (containsTypeAny(typeSet)) {
|
||||
return anyType;
|
||||
}
|
||||
if (noDeduplication) {
|
||||
if (noSubtypeReduction) {
|
||||
removeAllButLast(typeSet, undefinedType);
|
||||
removeAllButLast(typeSet, nullType);
|
||||
}
|
||||
else {
|
||||
removeDuplicateTypes(typeSet);
|
||||
removeSubtypes(typeSet);
|
||||
}
|
||||
if (typeSet.length === 1) {
|
||||
return typeSet[0];
|
||||
@@ -14091,6 +14024,26 @@ var ts;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function isKnownProperty(type, name) {
|
||||
if (type.flags & 80896) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) ||
|
||||
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (type.flags & 49152) {
|
||||
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
|
||||
var t = _a[_i];
|
||||
if (isKnownProperty(t, name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function hasExcessProperties(source, target, reportErrors) {
|
||||
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
|
||||
var prop = _a[_i];
|
||||
@@ -14763,7 +14716,7 @@ var ts;
|
||||
return getWidenedTypeOfObjectLiteral(type);
|
||||
}
|
||||
if (type.flags & 16384) {
|
||||
return getUnionType(ts.map(type.types, getWidenedType));
|
||||
return getUnionType(ts.map(type.types, getWidenedType), true);
|
||||
}
|
||||
if (isArrayType(type)) {
|
||||
return createArrayType(getWidenedType(type.typeArguments[0]));
|
||||
@@ -15973,7 +15926,7 @@ var ts;
|
||||
var propertiesTable = {};
|
||||
var propertiesArray = [];
|
||||
var contextualType = getContextualType(node);
|
||||
var typeFlags;
|
||||
var typeFlags = 0;
|
||||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
||||
var memberDecl = _a[_i];
|
||||
var member = memberDecl.symbol;
|
||||
@@ -16014,7 +15967,8 @@ var ts;
|
||||
var stringIndexType = getIndexType(0);
|
||||
var numberIndexType = getIndexType(1);
|
||||
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
|
||||
result.flags |= 524288 | 1048576 | 4194304 | (typeFlags & 14680064);
|
||||
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576;
|
||||
result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064);
|
||||
return result;
|
||||
function getIndexType(kind) {
|
||||
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
|
||||
@@ -17260,7 +17214,7 @@ var ts;
|
||||
}
|
||||
function createPromiseType(promisedType) {
|
||||
var globalPromiseType = getGlobalPromiseType();
|
||||
if (globalPromiseType !== emptyObjectType) {
|
||||
if (globalPromiseType !== emptyGenericType) {
|
||||
promisedType = getAwaitedType(promisedType);
|
||||
return createTypeReference(globalPromiseType, [promisedType]);
|
||||
}
|
||||
@@ -19714,6 +19668,7 @@ var ts;
|
||||
if (baseTypes.length && produceDiagnostics) {
|
||||
var baseType = baseTypes[0];
|
||||
var staticBaseType = getBaseConstructorTypeOfClass(type);
|
||||
checkSourceElement(baseTypeNode.expression);
|
||||
if (baseTypeNode.typeArguments) {
|
||||
ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
|
||||
for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) {
|
||||
@@ -20613,6 +20568,8 @@ var ts;
|
||||
case 209:
|
||||
case 210:
|
||||
case 212:
|
||||
case 241:
|
||||
case 186:
|
||||
case 215:
|
||||
case 245:
|
||||
case 225:
|
||||
@@ -21338,7 +21295,7 @@ var ts;
|
||||
}
|
||||
function createInstantiatedPromiseLikeType() {
|
||||
var promiseLikeType = getGlobalPromiseLikeType();
|
||||
if (promiseLikeType !== emptyObjectType) {
|
||||
if (promiseLikeType !== emptyGenericType) {
|
||||
return createTypeReference(promiseLikeType, [anyType]);
|
||||
}
|
||||
return emptyObjectType;
|
||||
@@ -24454,8 +24411,12 @@ var ts;
|
||||
}
|
||||
}
|
||||
function emitJsxElement(openingNode, children) {
|
||||
var syntheticReactRef = ts.createSynthesizedNode(67);
|
||||
syntheticReactRef.text = 'React';
|
||||
syntheticReactRef.parent = openingNode;
|
||||
emitLeadingComments(openingNode);
|
||||
write("React.createElement(");
|
||||
emitExpressionIdentifier(syntheticReactRef);
|
||||
write(".createElement(");
|
||||
emitTagName(openingNode.tagName);
|
||||
write(", ");
|
||||
if (openingNode.attributes.length === 0) {
|
||||
@@ -24464,7 +24425,8 @@ var ts;
|
||||
else {
|
||||
var attrs = openingNode.attributes;
|
||||
if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) {
|
||||
write("React.__spread(");
|
||||
emitExpressionIdentifier(syntheticReactRef);
|
||||
write(".__spread(");
|
||||
var haveOpenedObjectLiteral = false;
|
||||
for (var i_1 = 0; i_1 < attrs.length; i_1++) {
|
||||
if (attrs[i_1].kind === 237) {
|
||||
@@ -30376,6 +30338,12 @@ var ts;
|
||||
description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
|
||||
paramType: ts.Diagnostics.LOCATION
|
||||
},
|
||||
{
|
||||
name: "suppressExcessPropertyErrors",
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "suppressImplicitAnyIndexErrors",
|
||||
type: "boolean",
|
||||
@@ -30450,7 +30418,7 @@ var ts;
|
||||
return optionNameMapCache;
|
||||
}
|
||||
ts.getOptionNameMap = getOptionNameMap;
|
||||
function parseCommandLine(commandLine) {
|
||||
function parseCommandLine(commandLine, readFile) {
|
||||
var options = {};
|
||||
var fileNames = [];
|
||||
var errors = [];
|
||||
@@ -30509,7 +30477,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
function parseResponseFile(fileName) {
|
||||
var text = ts.sys.readFile(fileName);
|
||||
var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName);
|
||||
if (!text) {
|
||||
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName));
|
||||
return;
|
||||
|
||||
+55
-87
@@ -1573,6 +1573,7 @@ var ts;
|
||||
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
|
||||
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
|
||||
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
|
||||
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -3163,6 +3164,12 @@ var ts;
|
||||
description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
|
||||
paramType: ts.Diagnostics.LOCATION
|
||||
},
|
||||
{
|
||||
name: "suppressExcessPropertyErrors",
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "suppressImplicitAnyIndexErrors",
|
||||
type: "boolean",
|
||||
@@ -3237,7 +3244,7 @@ var ts;
|
||||
return optionNameMapCache;
|
||||
}
|
||||
ts.getOptionNameMap = getOptionNameMap;
|
||||
function parseCommandLine(commandLine) {
|
||||
function parseCommandLine(commandLine, readFile) {
|
||||
var options = {};
|
||||
var fileNames = [];
|
||||
var errors = [];
|
||||
@@ -3296,7 +3303,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
function parseResponseFile(fileName) {
|
||||
var text = ts.sys.readFile(fileName);
|
||||
var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName);
|
||||
if (!text) {
|
||||
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName));
|
||||
return;
|
||||
@@ -13136,7 +13143,7 @@ var ts;
|
||||
return members;
|
||||
}
|
||||
function resolveTupleTypeMembers(type) {
|
||||
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes)));
|
||||
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, true)));
|
||||
var members = createTupleTypeMemberSymbols(type.elementTypes);
|
||||
addInheritedMembers(members, arrayType.properties);
|
||||
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
|
||||
@@ -13428,25 +13435,6 @@ var ts;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function isKnownProperty(type, name) {
|
||||
if (type.flags & 80896 && type !== globalObjectType) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
return !!(resolved.properties.length === 0 ||
|
||||
resolved.stringIndexType ||
|
||||
resolved.numberIndexType ||
|
||||
getPropertyOfType(type, name));
|
||||
}
|
||||
if (type.flags & 49152) {
|
||||
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
|
||||
var t = _a[_i];
|
||||
if (isKnownProperty(t, name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function getSignaturesOfStructuredType(type, kind) {
|
||||
if (type.flags & 130048) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
@@ -13902,7 +13890,7 @@ var ts;
|
||||
}
|
||||
function createTypedPropertyDescriptorType(propertyType) {
|
||||
var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType();
|
||||
return globalTypedPropertyDescriptorType !== emptyObjectType
|
||||
return globalTypedPropertyDescriptorType !== emptyGenericType
|
||||
? createTypeReference(globalTypedPropertyDescriptorType, [propertyType])
|
||||
: emptyObjectType;
|
||||
}
|
||||
@@ -13955,68 +13943,19 @@ var ts;
|
||||
addTypeToSet(typeSet, type, typeSetKind);
|
||||
}
|
||||
}
|
||||
function isObjectLiteralTypeDuplicateOf(source, target) {
|
||||
var sourceProperties = getPropertiesOfObjectType(source);
|
||||
var targetProperties = getPropertiesOfObjectType(target);
|
||||
if (sourceProperties.length !== targetProperties.length) {
|
||||
return false;
|
||||
}
|
||||
for (var _i = 0; _i < sourceProperties.length; _i++) {
|
||||
var sourceProp = sourceProperties[_i];
|
||||
var targetProp = getPropertyOfObjectType(target, sourceProp.name);
|
||||
if (!targetProp ||
|
||||
getDeclarationFlagsFromSymbol(targetProp) & (32 | 64) ||
|
||||
!isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function isTupleTypeDuplicateOf(source, target) {
|
||||
var sourceTypes = source.elementTypes;
|
||||
var targetTypes = target.elementTypes;
|
||||
if (sourceTypes.length !== targetTypes.length) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < sourceTypes.length; i++) {
|
||||
if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function isTypeDuplicateOf(source, target) {
|
||||
if (source === target) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & 32 || source.flags & 64 && !(target.flags & 32)) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & 524288 && target.flags & 80896) {
|
||||
return isObjectLiteralTypeDuplicateOf(source, target);
|
||||
}
|
||||
if (isArrayType(source) && isArrayType(target)) {
|
||||
return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]);
|
||||
}
|
||||
if (isTupleType(source) && isTupleType(target)) {
|
||||
return isTupleTypeDuplicateOf(source, target);
|
||||
}
|
||||
return isTypeIdenticalTo(source, target);
|
||||
}
|
||||
function isTypeDuplicateOfSomeType(candidate, types) {
|
||||
for (var _i = 0; _i < types.length; _i++) {
|
||||
var type = types[_i];
|
||||
if (candidate !== type && isTypeDuplicateOf(candidate, type)) {
|
||||
function isSubtypeOfAny(candidate, types) {
|
||||
for (var i = 0, len = types.length; i < len; i++) {
|
||||
if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function removeDuplicateTypes(types) {
|
||||
function removeSubtypes(types) {
|
||||
var i = types.length;
|
||||
while (i > 0) {
|
||||
i--;
|
||||
if (isTypeDuplicateOfSomeType(types[i], types)) {
|
||||
if (isSubtypeOfAny(types[i], types)) {
|
||||
types.splice(i, 1);
|
||||
}
|
||||
}
|
||||
@@ -14039,7 +13978,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getUnionType(types, noDeduplication) {
|
||||
function getUnionType(types, noSubtypeReduction) {
|
||||
if (types.length === 0) {
|
||||
return emptyObjectType;
|
||||
}
|
||||
@@ -14048,12 +13987,12 @@ var ts;
|
||||
if (containsTypeAny(typeSet)) {
|
||||
return anyType;
|
||||
}
|
||||
if (noDeduplication) {
|
||||
if (noSubtypeReduction) {
|
||||
removeAllButLast(typeSet, undefinedType);
|
||||
removeAllButLast(typeSet, nullType);
|
||||
}
|
||||
else {
|
||||
removeDuplicateTypes(typeSet);
|
||||
removeSubtypes(typeSet);
|
||||
}
|
||||
if (typeSet.length === 1) {
|
||||
return typeSet[0];
|
||||
@@ -14547,6 +14486,26 @@ var ts;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function isKnownProperty(type, name) {
|
||||
if (type.flags & 80896) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) ||
|
||||
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (type.flags & 49152) {
|
||||
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
|
||||
var t = _a[_i];
|
||||
if (isKnownProperty(t, name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function hasExcessProperties(source, target, reportErrors) {
|
||||
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
|
||||
var prop = _a[_i];
|
||||
@@ -15219,7 +15178,7 @@ var ts;
|
||||
return getWidenedTypeOfObjectLiteral(type);
|
||||
}
|
||||
if (type.flags & 16384) {
|
||||
return getUnionType(ts.map(type.types, getWidenedType));
|
||||
return getUnionType(ts.map(type.types, getWidenedType), true);
|
||||
}
|
||||
if (isArrayType(type)) {
|
||||
return createArrayType(getWidenedType(type.typeArguments[0]));
|
||||
@@ -16429,7 +16388,7 @@ var ts;
|
||||
var propertiesTable = {};
|
||||
var propertiesArray = [];
|
||||
var contextualType = getContextualType(node);
|
||||
var typeFlags;
|
||||
var typeFlags = 0;
|
||||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
||||
var memberDecl = _a[_i];
|
||||
var member = memberDecl.symbol;
|
||||
@@ -16470,7 +16429,8 @@ var ts;
|
||||
var stringIndexType = getIndexType(0);
|
||||
var numberIndexType = getIndexType(1);
|
||||
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
|
||||
result.flags |= 524288 | 1048576 | 4194304 | (typeFlags & 14680064);
|
||||
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576;
|
||||
result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064);
|
||||
return result;
|
||||
function getIndexType(kind) {
|
||||
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
|
||||
@@ -17716,7 +17676,7 @@ var ts;
|
||||
}
|
||||
function createPromiseType(promisedType) {
|
||||
var globalPromiseType = getGlobalPromiseType();
|
||||
if (globalPromiseType !== emptyObjectType) {
|
||||
if (globalPromiseType !== emptyGenericType) {
|
||||
promisedType = getAwaitedType(promisedType);
|
||||
return createTypeReference(globalPromiseType, [promisedType]);
|
||||
}
|
||||
@@ -20170,6 +20130,7 @@ var ts;
|
||||
if (baseTypes.length && produceDiagnostics) {
|
||||
var baseType = baseTypes[0];
|
||||
var staticBaseType = getBaseConstructorTypeOfClass(type);
|
||||
checkSourceElement(baseTypeNode.expression);
|
||||
if (baseTypeNode.typeArguments) {
|
||||
ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
|
||||
for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) {
|
||||
@@ -21069,6 +21030,8 @@ var ts;
|
||||
case 209:
|
||||
case 210:
|
||||
case 212:
|
||||
case 241:
|
||||
case 186:
|
||||
case 215:
|
||||
case 245:
|
||||
case 225:
|
||||
@@ -21794,7 +21757,7 @@ var ts;
|
||||
}
|
||||
function createInstantiatedPromiseLikeType() {
|
||||
var promiseLikeType = getGlobalPromiseLikeType();
|
||||
if (promiseLikeType !== emptyObjectType) {
|
||||
if (promiseLikeType !== emptyGenericType) {
|
||||
return createTypeReference(promiseLikeType, [anyType]);
|
||||
}
|
||||
return emptyObjectType;
|
||||
@@ -24910,8 +24873,12 @@ var ts;
|
||||
}
|
||||
}
|
||||
function emitJsxElement(openingNode, children) {
|
||||
var syntheticReactRef = ts.createSynthesizedNode(67);
|
||||
syntheticReactRef.text = 'React';
|
||||
syntheticReactRef.parent = openingNode;
|
||||
emitLeadingComments(openingNode);
|
||||
write("React.createElement(");
|
||||
emitExpressionIdentifier(syntheticReactRef);
|
||||
write(".createElement(");
|
||||
emitTagName(openingNode.tagName);
|
||||
write(", ");
|
||||
if (openingNode.attributes.length === 0) {
|
||||
@@ -24920,7 +24887,8 @@ var ts;
|
||||
else {
|
||||
var attrs = openingNode.attributes;
|
||||
if (ts.forEach(attrs, function (attr) { return attr.kind === 237; })) {
|
||||
write("React.__spread(");
|
||||
emitExpressionIdentifier(syntheticReactRef);
|
||||
write(".__spread(");
|
||||
var haveOpenedObjectLiteral = false;
|
||||
for (var i_1 = 0; i_1 < attrs.length; i_1++) {
|
||||
if (attrs[i_1].kind === 237) {
|
||||
|
||||
Vendored
+2
-1
@@ -1329,6 +1329,7 @@ declare module "typescript" {
|
||||
rootDir?: string;
|
||||
sourceMap?: boolean;
|
||||
sourceRoot?: string;
|
||||
suppressExcessPropertyErrors?: boolean;
|
||||
suppressImplicitAnyIndexErrors?: boolean;
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
@@ -1524,7 +1525,7 @@ declare module "typescript" {
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
declare module "typescript" {
|
||||
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
|
||||
function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine;
|
||||
/**
|
||||
* Read tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
|
||||
+68
-101
@@ -2442,6 +2442,7 @@ var ts;
|
||||
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
|
||||
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
|
||||
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
|
||||
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -15702,7 +15703,7 @@ var ts;
|
||||
return members;
|
||||
}
|
||||
function resolveTupleTypeMembers(type) {
|
||||
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes)));
|
||||
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true)));
|
||||
var members = createTupleTypeMemberSymbols(type.elementTypes);
|
||||
addInheritedMembers(members, arrayType.properties);
|
||||
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
|
||||
@@ -16023,29 +16024,6 @@ var ts;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
// Check if a property with the given name is known anywhere in the given type. In an object
|
||||
// type, a property is considered known if the object type is empty, if it has any index
|
||||
// signatures, or if the property is actually declared in the type. In a union or intersection
|
||||
// type, a property is considered known if it is known in any constituent type.
|
||||
function isKnownProperty(type, name) {
|
||||
if (type.flags & 80896 /* ObjectType */ && type !== globalObjectType) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
return !!(resolved.properties.length === 0 ||
|
||||
resolved.stringIndexType ||
|
||||
resolved.numberIndexType ||
|
||||
getPropertyOfType(type, name));
|
||||
}
|
||||
if (type.flags & 49152 /* UnionOrIntersection */) {
|
||||
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
|
||||
var t = _a[_i];
|
||||
if (isKnownProperty(t, name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function getSignaturesOfStructuredType(type, kind) {
|
||||
if (type.flags & 130048 /* StructuredType */) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
@@ -16559,7 +16537,7 @@ var ts;
|
||||
*/
|
||||
function createTypedPropertyDescriptorType(propertyType) {
|
||||
var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType();
|
||||
return globalTypedPropertyDescriptorType !== emptyObjectType
|
||||
return globalTypedPropertyDescriptorType !== emptyGenericType
|
||||
? createTypeReference(globalTypedPropertyDescriptorType, [propertyType])
|
||||
: emptyObjectType;
|
||||
}
|
||||
@@ -16617,71 +16595,19 @@ var ts;
|
||||
addTypeToSet(typeSet, type, typeSetKind);
|
||||
}
|
||||
}
|
||||
function isObjectLiteralTypeDuplicateOf(source, target) {
|
||||
var sourceProperties = getPropertiesOfObjectType(source);
|
||||
var targetProperties = getPropertiesOfObjectType(target);
|
||||
if (sourceProperties.length !== targetProperties.length) {
|
||||
return false;
|
||||
}
|
||||
for (var _i = 0; _i < sourceProperties.length; _i++) {
|
||||
var sourceProp = sourceProperties[_i];
|
||||
var targetProp = getPropertyOfObjectType(target, sourceProp.name);
|
||||
if (!targetProp ||
|
||||
getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */) ||
|
||||
!isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function isTupleTypeDuplicateOf(source, target) {
|
||||
var sourceTypes = source.elementTypes;
|
||||
var targetTypes = target.elementTypes;
|
||||
if (sourceTypes.length !== targetTypes.length) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < sourceTypes.length; i++) {
|
||||
if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Returns true if the source type is a duplicate of the target type. A source type is a duplicate of
|
||||
// a target type if the the two are identical, with the exception that the source type may have null or
|
||||
// undefined in places where the target type doesn't. This is by design an asymmetric relationship.
|
||||
function isTypeDuplicateOf(source, target) {
|
||||
if (source === target) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & 32 /* Undefined */ || source.flags & 64 /* Null */ && !(target.flags & 32 /* Undefined */)) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & 524288 /* ObjectLiteral */ && target.flags & 80896 /* ObjectType */) {
|
||||
return isObjectLiteralTypeDuplicateOf(source, target);
|
||||
}
|
||||
if (isArrayType(source) && isArrayType(target)) {
|
||||
return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]);
|
||||
}
|
||||
if (isTupleType(source) && isTupleType(target)) {
|
||||
return isTupleTypeDuplicateOf(source, target);
|
||||
}
|
||||
return isTypeIdenticalTo(source, target);
|
||||
}
|
||||
function isTypeDuplicateOfSomeType(candidate, types) {
|
||||
for (var _i = 0; _i < types.length; _i++) {
|
||||
var type = types[_i];
|
||||
if (candidate !== type && isTypeDuplicateOf(candidate, type)) {
|
||||
function isSubtypeOfAny(candidate, types) {
|
||||
for (var i = 0, len = types.length; i < len; i++) {
|
||||
if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function removeDuplicateTypes(types) {
|
||||
function removeSubtypes(types) {
|
||||
var i = types.length;
|
||||
while (i > 0) {
|
||||
i--;
|
||||
if (isTypeDuplicateOfSomeType(types[i], types)) {
|
||||
if (isSubtypeOfAny(types[i], types)) {
|
||||
types.splice(i, 1);
|
||||
}
|
||||
}
|
||||
@@ -16704,12 +16630,14 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
// We always deduplicate the constituent type set based on object identity, but we'll also deduplicate
|
||||
// based on the structure of the types unless the noDeduplication flag is true, which is the case when
|
||||
// creating a union type from a type node and when instantiating a union type. In both of those cases,
|
||||
// structural deduplication has to be deferred to properly support recursive union types. For example,
|
||||
// a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration.
|
||||
function getUnionType(types, noDeduplication) {
|
||||
// We reduce the constituent type set to only include types that aren't subtypes of other types, unless
|
||||
// the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on
|
||||
// object identity. Subtype reduction is possible only when union types are known not to circularly
|
||||
// reference themselves (as is the case with union types created by expression constructs such as array
|
||||
// literals and the || and ?: operators). Named types can circularly reference themselves and therefore
|
||||
// cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is
|
||||
// a named type that circularly references itself.
|
||||
function getUnionType(types, noSubtypeReduction) {
|
||||
if (types.length === 0) {
|
||||
return emptyObjectType;
|
||||
}
|
||||
@@ -16718,12 +16646,12 @@ var ts;
|
||||
if (containsTypeAny(typeSet)) {
|
||||
return anyType;
|
||||
}
|
||||
if (noDeduplication) {
|
||||
if (noSubtypeReduction) {
|
||||
removeAllButLast(typeSet, undefinedType);
|
||||
removeAllButLast(typeSet, nullType);
|
||||
}
|
||||
else {
|
||||
removeDuplicateTypes(typeSet);
|
||||
removeSubtypes(typeSet);
|
||||
}
|
||||
if (typeSet.length === 1) {
|
||||
return typeSet[0];
|
||||
@@ -16739,7 +16667,7 @@ var ts;
|
||||
function getTypeFromUnionTypeNode(node) {
|
||||
var links = getNodeLinks(node);
|
||||
if (!links.resolvedType) {
|
||||
links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true);
|
||||
links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true);
|
||||
}
|
||||
return links.resolvedType;
|
||||
}
|
||||
@@ -17010,7 +16938,7 @@ var ts;
|
||||
return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType));
|
||||
}
|
||||
if (type.flags & 16384 /* Union */) {
|
||||
return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noDeduplication*/ true);
|
||||
return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noSubtypeReduction*/ true);
|
||||
}
|
||||
if (type.flags & 32768 /* Intersection */) {
|
||||
return getIntersectionType(instantiateList(type.types, mapper, instantiateType));
|
||||
@@ -17271,6 +17199,30 @@ var ts;
|
||||
}
|
||||
return 0 /* False */;
|
||||
}
|
||||
// Check if a property with the given name is known anywhere in the given type. In an object type, a property
|
||||
// is considered known if the object type is empty and the check is for assignability, if the object type has
|
||||
// index signatures, or if the property is actually declared in the object type. In a union or intersection
|
||||
// type, a property is considered known if it is known in any constituent type.
|
||||
function isKnownProperty(type, name) {
|
||||
if (type.flags & 80896 /* ObjectType */) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) ||
|
||||
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (type.flags & 49152 /* UnionOrIntersection */) {
|
||||
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
|
||||
var t = _a[_i];
|
||||
if (isKnownProperty(t, name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function hasExcessProperties(source, target, reportErrors) {
|
||||
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
|
||||
var prop = _a[_i];
|
||||
@@ -17999,7 +17951,7 @@ var ts;
|
||||
return getWidenedTypeOfObjectLiteral(type);
|
||||
}
|
||||
if (type.flags & 16384 /* Union */) {
|
||||
return getUnionType(ts.map(type.types, getWidenedType));
|
||||
return getUnionType(ts.map(type.types, getWidenedType), /*noSubtypeReduction*/ true);
|
||||
}
|
||||
if (isArrayType(type)) {
|
||||
return createArrayType(getWidenedType(type.typeArguments[0]));
|
||||
@@ -19438,7 +19390,7 @@ var ts;
|
||||
var propertiesTable = {};
|
||||
var propertiesArray = [];
|
||||
var contextualType = getContextualType(node);
|
||||
var typeFlags;
|
||||
var typeFlags = 0;
|
||||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
||||
var memberDecl = _a[_i];
|
||||
var member = memberDecl.symbol;
|
||||
@@ -19484,7 +19436,8 @@ var ts;
|
||||
var stringIndexType = getIndexType(0 /* String */);
|
||||
var numberIndexType = getIndexType(1 /* Number */);
|
||||
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
|
||||
result.flags |= 524288 /* ObjectLiteral */ | 1048576 /* FreshObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | (typeFlags & 14680064 /* PropagatingFlags */);
|
||||
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */;
|
||||
result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */);
|
||||
return result;
|
||||
function getIndexType(kind) {
|
||||
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
|
||||
@@ -21216,7 +21169,7 @@ var ts;
|
||||
function createPromiseType(promisedType) {
|
||||
// creates a `Promise<T>` type where `T` is the promisedType argument
|
||||
var globalPromiseType = getGlobalPromiseType();
|
||||
if (globalPromiseType !== emptyObjectType) {
|
||||
if (globalPromiseType !== emptyGenericType) {
|
||||
// if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type
|
||||
promisedType = getAwaitedType(promisedType);
|
||||
return createTypeReference(globalPromiseType, [promisedType]);
|
||||
@@ -24248,6 +24201,7 @@ var ts;
|
||||
if (baseTypes.length && produceDiagnostics) {
|
||||
var baseType = baseTypes[0];
|
||||
var staticBaseType = getBaseConstructorTypeOfClass(type);
|
||||
checkSourceElement(baseTypeNode.expression);
|
||||
if (baseTypeNode.typeArguments) {
|
||||
ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
|
||||
for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) {
|
||||
@@ -25227,6 +25181,8 @@ var ts;
|
||||
case 209 /* VariableDeclaration */:
|
||||
case 210 /* VariableDeclarationList */:
|
||||
case 212 /* ClassDeclaration */:
|
||||
case 241 /* HeritageClause */:
|
||||
case 186 /* ExpressionWithTypeArguments */:
|
||||
case 215 /* EnumDeclaration */:
|
||||
case 245 /* EnumMember */:
|
||||
case 225 /* ExportAssignment */:
|
||||
@@ -26049,7 +26005,7 @@ var ts;
|
||||
}
|
||||
function createInstantiatedPromiseLikeType() {
|
||||
var promiseLikeType = getGlobalPromiseLikeType();
|
||||
if (promiseLikeType !== emptyObjectType) {
|
||||
if (promiseLikeType !== emptyGenericType) {
|
||||
return createTypeReference(promiseLikeType, [anyType]);
|
||||
}
|
||||
return emptyObjectType;
|
||||
@@ -29500,9 +29456,13 @@ var ts;
|
||||
}
|
||||
}
|
||||
function emitJsxElement(openingNode, children) {
|
||||
var syntheticReactRef = ts.createSynthesizedNode(67 /* Identifier */);
|
||||
syntheticReactRef.text = 'React';
|
||||
syntheticReactRef.parent = openingNode;
|
||||
// Call React.createElement(tag, ...
|
||||
emitLeadingComments(openingNode);
|
||||
write("React.createElement(");
|
||||
emitExpressionIdentifier(syntheticReactRef);
|
||||
write(".createElement(");
|
||||
emitTagName(openingNode.tagName);
|
||||
write(", ");
|
||||
// Attribute list
|
||||
@@ -29515,7 +29475,8 @@ var ts;
|
||||
// a call to React.__spread
|
||||
var attrs = openingNode.attributes;
|
||||
if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) {
|
||||
write("React.__spread(");
|
||||
emitExpressionIdentifier(syntheticReactRef);
|
||||
write(".__spread(");
|
||||
var haveOpenedObjectLiteral = false;
|
||||
for (var i_1 = 0; i_1 < attrs.length; i_1++) {
|
||||
if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) {
|
||||
@@ -36231,6 +36192,12 @@ var ts;
|
||||
description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
|
||||
paramType: ts.Diagnostics.LOCATION
|
||||
},
|
||||
{
|
||||
name: "suppressExcessPropertyErrors",
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "suppressImplicitAnyIndexErrors",
|
||||
type: "boolean",
|
||||
@@ -36306,7 +36273,7 @@ var ts;
|
||||
return optionNameMapCache;
|
||||
}
|
||||
ts.getOptionNameMap = getOptionNameMap;
|
||||
function parseCommandLine(commandLine) {
|
||||
function parseCommandLine(commandLine, readFile) {
|
||||
var options = {};
|
||||
var fileNames = [];
|
||||
var errors = [];
|
||||
@@ -36368,7 +36335,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
function parseResponseFile(fileName) {
|
||||
var text = ts.sys.readFile(fileName);
|
||||
var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName);
|
||||
if (!text) {
|
||||
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName));
|
||||
return;
|
||||
|
||||
Vendored
+2
-1
@@ -1329,6 +1329,7 @@ declare namespace ts {
|
||||
rootDir?: string;
|
||||
sourceMap?: boolean;
|
||||
sourceRoot?: string;
|
||||
suppressExcessPropertyErrors?: boolean;
|
||||
suppressImplicitAnyIndexErrors?: boolean;
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
@@ -1524,7 +1525,7 @@ declare namespace ts {
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
declare namespace ts {
|
||||
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
|
||||
function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine;
|
||||
/**
|
||||
* Read tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
|
||||
+68
-101
@@ -2442,6 +2442,7 @@ var ts;
|
||||
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: ts.DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
|
||||
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
|
||||
Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
|
||||
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -15702,7 +15703,7 @@ var ts;
|
||||
return members;
|
||||
}
|
||||
function resolveTupleTypeMembers(type) {
|
||||
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes)));
|
||||
var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true)));
|
||||
var members = createTupleTypeMemberSymbols(type.elementTypes);
|
||||
addInheritedMembers(members, arrayType.properties);
|
||||
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
|
||||
@@ -16023,29 +16024,6 @@ var ts;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
// Check if a property with the given name is known anywhere in the given type. In an object
|
||||
// type, a property is considered known if the object type is empty, if it has any index
|
||||
// signatures, or if the property is actually declared in the type. In a union or intersection
|
||||
// type, a property is considered known if it is known in any constituent type.
|
||||
function isKnownProperty(type, name) {
|
||||
if (type.flags & 80896 /* ObjectType */ && type !== globalObjectType) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
return !!(resolved.properties.length === 0 ||
|
||||
resolved.stringIndexType ||
|
||||
resolved.numberIndexType ||
|
||||
getPropertyOfType(type, name));
|
||||
}
|
||||
if (type.flags & 49152 /* UnionOrIntersection */) {
|
||||
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
|
||||
var t = _a[_i];
|
||||
if (isKnownProperty(t, name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function getSignaturesOfStructuredType(type, kind) {
|
||||
if (type.flags & 130048 /* StructuredType */) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
@@ -16559,7 +16537,7 @@ var ts;
|
||||
*/
|
||||
function createTypedPropertyDescriptorType(propertyType) {
|
||||
var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType();
|
||||
return globalTypedPropertyDescriptorType !== emptyObjectType
|
||||
return globalTypedPropertyDescriptorType !== emptyGenericType
|
||||
? createTypeReference(globalTypedPropertyDescriptorType, [propertyType])
|
||||
: emptyObjectType;
|
||||
}
|
||||
@@ -16617,71 +16595,19 @@ var ts;
|
||||
addTypeToSet(typeSet, type, typeSetKind);
|
||||
}
|
||||
}
|
||||
function isObjectLiteralTypeDuplicateOf(source, target) {
|
||||
var sourceProperties = getPropertiesOfObjectType(source);
|
||||
var targetProperties = getPropertiesOfObjectType(target);
|
||||
if (sourceProperties.length !== targetProperties.length) {
|
||||
return false;
|
||||
}
|
||||
for (var _i = 0; _i < sourceProperties.length; _i++) {
|
||||
var sourceProp = sourceProperties[_i];
|
||||
var targetProp = getPropertyOfObjectType(target, sourceProp.name);
|
||||
if (!targetProp ||
|
||||
getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */) ||
|
||||
!isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function isTupleTypeDuplicateOf(source, target) {
|
||||
var sourceTypes = source.elementTypes;
|
||||
var targetTypes = target.elementTypes;
|
||||
if (sourceTypes.length !== targetTypes.length) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < sourceTypes.length; i++) {
|
||||
if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Returns true if the source type is a duplicate of the target type. A source type is a duplicate of
|
||||
// a target type if the the two are identical, with the exception that the source type may have null or
|
||||
// undefined in places where the target type doesn't. This is by design an asymmetric relationship.
|
||||
function isTypeDuplicateOf(source, target) {
|
||||
if (source === target) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & 32 /* Undefined */ || source.flags & 64 /* Null */ && !(target.flags & 32 /* Undefined */)) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & 524288 /* ObjectLiteral */ && target.flags & 80896 /* ObjectType */) {
|
||||
return isObjectLiteralTypeDuplicateOf(source, target);
|
||||
}
|
||||
if (isArrayType(source) && isArrayType(target)) {
|
||||
return isTypeDuplicateOf(source.typeArguments[0], target.typeArguments[0]);
|
||||
}
|
||||
if (isTupleType(source) && isTupleType(target)) {
|
||||
return isTupleTypeDuplicateOf(source, target);
|
||||
}
|
||||
return isTypeIdenticalTo(source, target);
|
||||
}
|
||||
function isTypeDuplicateOfSomeType(candidate, types) {
|
||||
for (var _i = 0; _i < types.length; _i++) {
|
||||
var type = types[_i];
|
||||
if (candidate !== type && isTypeDuplicateOf(candidate, type)) {
|
||||
function isSubtypeOfAny(candidate, types) {
|
||||
for (var i = 0, len = types.length; i < len; i++) {
|
||||
if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function removeDuplicateTypes(types) {
|
||||
function removeSubtypes(types) {
|
||||
var i = types.length;
|
||||
while (i > 0) {
|
||||
i--;
|
||||
if (isTypeDuplicateOfSomeType(types[i], types)) {
|
||||
if (isSubtypeOfAny(types[i], types)) {
|
||||
types.splice(i, 1);
|
||||
}
|
||||
}
|
||||
@@ -16704,12 +16630,14 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
// We always deduplicate the constituent type set based on object identity, but we'll also deduplicate
|
||||
// based on the structure of the types unless the noDeduplication flag is true, which is the case when
|
||||
// creating a union type from a type node and when instantiating a union type. In both of those cases,
|
||||
// structural deduplication has to be deferred to properly support recursive union types. For example,
|
||||
// a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration.
|
||||
function getUnionType(types, noDeduplication) {
|
||||
// We reduce the constituent type set to only include types that aren't subtypes of other types, unless
|
||||
// the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on
|
||||
// object identity. Subtype reduction is possible only when union types are known not to circularly
|
||||
// reference themselves (as is the case with union types created by expression constructs such as array
|
||||
// literals and the || and ?: operators). Named types can circularly reference themselves and therefore
|
||||
// cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is
|
||||
// a named type that circularly references itself.
|
||||
function getUnionType(types, noSubtypeReduction) {
|
||||
if (types.length === 0) {
|
||||
return emptyObjectType;
|
||||
}
|
||||
@@ -16718,12 +16646,12 @@ var ts;
|
||||
if (containsTypeAny(typeSet)) {
|
||||
return anyType;
|
||||
}
|
||||
if (noDeduplication) {
|
||||
if (noSubtypeReduction) {
|
||||
removeAllButLast(typeSet, undefinedType);
|
||||
removeAllButLast(typeSet, nullType);
|
||||
}
|
||||
else {
|
||||
removeDuplicateTypes(typeSet);
|
||||
removeSubtypes(typeSet);
|
||||
}
|
||||
if (typeSet.length === 1) {
|
||||
return typeSet[0];
|
||||
@@ -16739,7 +16667,7 @@ var ts;
|
||||
function getTypeFromUnionTypeNode(node) {
|
||||
var links = getNodeLinks(node);
|
||||
if (!links.resolvedType) {
|
||||
links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true);
|
||||
links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true);
|
||||
}
|
||||
return links.resolvedType;
|
||||
}
|
||||
@@ -17010,7 +16938,7 @@ var ts;
|
||||
return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType));
|
||||
}
|
||||
if (type.flags & 16384 /* Union */) {
|
||||
return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noDeduplication*/ true);
|
||||
return getUnionType(instantiateList(type.types, mapper, instantiateType), /*noSubtypeReduction*/ true);
|
||||
}
|
||||
if (type.flags & 32768 /* Intersection */) {
|
||||
return getIntersectionType(instantiateList(type.types, mapper, instantiateType));
|
||||
@@ -17271,6 +17199,30 @@ var ts;
|
||||
}
|
||||
return 0 /* False */;
|
||||
}
|
||||
// Check if a property with the given name is known anywhere in the given type. In an object type, a property
|
||||
// is considered known if the object type is empty and the check is for assignability, if the object type has
|
||||
// index signatures, or if the property is actually declared in the object type. In a union or intersection
|
||||
// type, a property is considered known if it is known in any constituent type.
|
||||
function isKnownProperty(type, name) {
|
||||
if (type.flags & 80896 /* ObjectType */) {
|
||||
var resolved = resolveStructuredTypeMembers(type);
|
||||
if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) ||
|
||||
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (type.flags & 49152 /* UnionOrIntersection */) {
|
||||
for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
|
||||
var t = _a[_i];
|
||||
if (isKnownProperty(t, name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function hasExcessProperties(source, target, reportErrors) {
|
||||
for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) {
|
||||
var prop = _a[_i];
|
||||
@@ -17999,7 +17951,7 @@ var ts;
|
||||
return getWidenedTypeOfObjectLiteral(type);
|
||||
}
|
||||
if (type.flags & 16384 /* Union */) {
|
||||
return getUnionType(ts.map(type.types, getWidenedType));
|
||||
return getUnionType(ts.map(type.types, getWidenedType), /*noSubtypeReduction*/ true);
|
||||
}
|
||||
if (isArrayType(type)) {
|
||||
return createArrayType(getWidenedType(type.typeArguments[0]));
|
||||
@@ -19438,7 +19390,7 @@ var ts;
|
||||
var propertiesTable = {};
|
||||
var propertiesArray = [];
|
||||
var contextualType = getContextualType(node);
|
||||
var typeFlags;
|
||||
var typeFlags = 0;
|
||||
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
|
||||
var memberDecl = _a[_i];
|
||||
var member = memberDecl.symbol;
|
||||
@@ -19484,7 +19436,8 @@ var ts;
|
||||
var stringIndexType = getIndexType(0 /* String */);
|
||||
var numberIndexType = getIndexType(1 /* Number */);
|
||||
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
|
||||
result.flags |= 524288 /* ObjectLiteral */ | 1048576 /* FreshObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | (typeFlags & 14680064 /* PropagatingFlags */);
|
||||
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */;
|
||||
result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */);
|
||||
return result;
|
||||
function getIndexType(kind) {
|
||||
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
|
||||
@@ -21216,7 +21169,7 @@ var ts;
|
||||
function createPromiseType(promisedType) {
|
||||
// creates a `Promise<T>` type where `T` is the promisedType argument
|
||||
var globalPromiseType = getGlobalPromiseType();
|
||||
if (globalPromiseType !== emptyObjectType) {
|
||||
if (globalPromiseType !== emptyGenericType) {
|
||||
// if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type
|
||||
promisedType = getAwaitedType(promisedType);
|
||||
return createTypeReference(globalPromiseType, [promisedType]);
|
||||
@@ -24248,6 +24201,7 @@ var ts;
|
||||
if (baseTypes.length && produceDiagnostics) {
|
||||
var baseType = baseTypes[0];
|
||||
var staticBaseType = getBaseConstructorTypeOfClass(type);
|
||||
checkSourceElement(baseTypeNode.expression);
|
||||
if (baseTypeNode.typeArguments) {
|
||||
ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
|
||||
for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) {
|
||||
@@ -25227,6 +25181,8 @@ var ts;
|
||||
case 209 /* VariableDeclaration */:
|
||||
case 210 /* VariableDeclarationList */:
|
||||
case 212 /* ClassDeclaration */:
|
||||
case 241 /* HeritageClause */:
|
||||
case 186 /* ExpressionWithTypeArguments */:
|
||||
case 215 /* EnumDeclaration */:
|
||||
case 245 /* EnumMember */:
|
||||
case 225 /* ExportAssignment */:
|
||||
@@ -26049,7 +26005,7 @@ var ts;
|
||||
}
|
||||
function createInstantiatedPromiseLikeType() {
|
||||
var promiseLikeType = getGlobalPromiseLikeType();
|
||||
if (promiseLikeType !== emptyObjectType) {
|
||||
if (promiseLikeType !== emptyGenericType) {
|
||||
return createTypeReference(promiseLikeType, [anyType]);
|
||||
}
|
||||
return emptyObjectType;
|
||||
@@ -29500,9 +29456,13 @@ var ts;
|
||||
}
|
||||
}
|
||||
function emitJsxElement(openingNode, children) {
|
||||
var syntheticReactRef = ts.createSynthesizedNode(67 /* Identifier */);
|
||||
syntheticReactRef.text = 'React';
|
||||
syntheticReactRef.parent = openingNode;
|
||||
// Call React.createElement(tag, ...
|
||||
emitLeadingComments(openingNode);
|
||||
write("React.createElement(");
|
||||
emitExpressionIdentifier(syntheticReactRef);
|
||||
write(".createElement(");
|
||||
emitTagName(openingNode.tagName);
|
||||
write(", ");
|
||||
// Attribute list
|
||||
@@ -29515,7 +29475,8 @@ var ts;
|
||||
// a call to React.__spread
|
||||
var attrs = openingNode.attributes;
|
||||
if (ts.forEach(attrs, function (attr) { return attr.kind === 237 /* JsxSpreadAttribute */; })) {
|
||||
write("React.__spread(");
|
||||
emitExpressionIdentifier(syntheticReactRef);
|
||||
write(".__spread(");
|
||||
var haveOpenedObjectLiteral = false;
|
||||
for (var i_1 = 0; i_1 < attrs.length; i_1++) {
|
||||
if (attrs[i_1].kind === 237 /* JsxSpreadAttribute */) {
|
||||
@@ -36231,6 +36192,12 @@ var ts;
|
||||
description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
|
||||
paramType: ts.Diagnostics.LOCATION
|
||||
},
|
||||
{
|
||||
name: "suppressExcessPropertyErrors",
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
|
||||
experimental: true
|
||||
},
|
||||
{
|
||||
name: "suppressImplicitAnyIndexErrors",
|
||||
type: "boolean",
|
||||
@@ -36306,7 +36273,7 @@ var ts;
|
||||
return optionNameMapCache;
|
||||
}
|
||||
ts.getOptionNameMap = getOptionNameMap;
|
||||
function parseCommandLine(commandLine) {
|
||||
function parseCommandLine(commandLine, readFile) {
|
||||
var options = {};
|
||||
var fileNames = [];
|
||||
var errors = [];
|
||||
@@ -36368,7 +36335,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
function parseResponseFile(fileName) {
|
||||
var text = ts.sys.readFile(fileName);
|
||||
var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName);
|
||||
if (!text) {
|
||||
errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName));
|
||||
return;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "typescript",
|
||||
"author": "Microsoft Corp.",
|
||||
"homepage": "http://typescriptlang.org/",
|
||||
"version": "1.7.0",
|
||||
"version": "1.6.0",
|
||||
"license": "Apache-2.0",
|
||||
"description": "TypeScript is a language for application scale JavaScript development",
|
||||
"keywords": [
|
||||
|
||||
+26
-13
@@ -4013,7 +4013,7 @@ namespace ts {
|
||||
*/
|
||||
function createTypedPropertyDescriptorType(propertyType: Type): Type {
|
||||
let globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType();
|
||||
return globalTypedPropertyDescriptorType !== emptyObjectType
|
||||
return globalTypedPropertyDescriptorType !== emptyGenericType
|
||||
? createTypeReference(<GenericType>globalTypedPropertyDescriptorType, [propertyType])
|
||||
: emptyObjectType;
|
||||
}
|
||||
@@ -4640,7 +4640,9 @@ namespace ts {
|
||||
// and intersection types are further deconstructed on the target side, we don't want to
|
||||
// make the check again (as it might fail for a partial target type). Therefore we obtain
|
||||
// the regular source type and proceed with that.
|
||||
source = getRegularTypeOfObjectLiteral(source);
|
||||
if (target.flags & TypeFlags.UnionOrIntersection) {
|
||||
source = getRegularTypeOfObjectLiteral(source);
|
||||
}
|
||||
}
|
||||
|
||||
let saveErrorInfo = errorInfo;
|
||||
@@ -5111,8 +5113,8 @@ namespace ts {
|
||||
function abstractSignatureRelatedTo(source: Type, sourceSig: Signature, target: Type, targetSig: Signature) {
|
||||
if (sourceSig && targetSig) {
|
||||
|
||||
let sourceDecl = source.symbol && getDeclarationOfKind(source.symbol, SyntaxKind.ClassDeclaration);
|
||||
let targetDecl = target.symbol && getDeclarationOfKind(target.symbol, SyntaxKind.ClassDeclaration);
|
||||
let sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
|
||||
let targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
|
||||
|
||||
if (!sourceDecl) {
|
||||
// If the source object isn't itself a class declaration, it can be freely assigned, regardless
|
||||
@@ -5126,8 +5128,8 @@ namespace ts {
|
||||
let sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
|
||||
let targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
|
||||
|
||||
let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getDeclarationOfKind(sourceReturnType.symbol, SyntaxKind.ClassDeclaration);
|
||||
let targetReturnDecl = targetReturnType && targetReturnType.symbol && getDeclarationOfKind(targetReturnType.symbol, SyntaxKind.ClassDeclaration);
|
||||
let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
|
||||
let targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
|
||||
let sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract;
|
||||
let targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract;
|
||||
|
||||
@@ -5511,6 +5513,7 @@ namespace ts {
|
||||
regularType.constructSignatures = (<ResolvedType>type).constructSignatures;
|
||||
regularType.stringIndexType = (<ResolvedType>type).stringIndexType;
|
||||
regularType.numberIndexType = (<ResolvedType>type).numberIndexType;
|
||||
(<FreshObjectLiteralType>type).regularType = regularType;
|
||||
}
|
||||
return regularType;
|
||||
}
|
||||
@@ -8879,7 +8882,7 @@ namespace ts {
|
||||
// Note, only class declarations can be declared abstract.
|
||||
// In the case of a merged class-module or class-interface declaration,
|
||||
// only the class declaration node will have the Abstract flag set.
|
||||
let valueDecl = expressionType.symbol && getDeclarationOfKind(expressionType.symbol, SyntaxKind.ClassDeclaration);
|
||||
let valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
|
||||
if (valueDecl && valueDecl.flags & NodeFlags.Abstract) {
|
||||
error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name));
|
||||
return resolveErrorCall(node);
|
||||
@@ -9132,7 +9135,7 @@ namespace ts {
|
||||
function createPromiseType(promisedType: Type): Type {
|
||||
// creates a `Promise<T>` type where `T` is the promisedType argument
|
||||
let globalPromiseType = getGlobalPromiseType();
|
||||
if (globalPromiseType !== emptyObjectType) {
|
||||
if (globalPromiseType !== emptyGenericType) {
|
||||
// if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type
|
||||
promisedType = getAwaitedType(promisedType);
|
||||
return createTypeReference(<GenericType>globalPromiseType, [promisedType]);
|
||||
@@ -12631,6 +12634,10 @@ namespace ts {
|
||||
return s.flags & SymbolFlags.Instantiated ? getSymbolLinks(s).target : s;
|
||||
}
|
||||
|
||||
function getClassLikeDeclarationOfSymbol(symbol: Symbol): Declaration {
|
||||
return forEach(symbol.declarations, d => isClassLike(d) ? d : undefined);
|
||||
}
|
||||
|
||||
function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: ObjectType): void {
|
||||
|
||||
// TypeScript 1.0 spec (April 2014): 8.2.3
|
||||
@@ -12668,14 +12675,20 @@ namespace ts {
|
||||
if (derived === base) {
|
||||
// derived class inherits base without override/redeclaration
|
||||
|
||||
let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration);
|
||||
let derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol);
|
||||
|
||||
// It is an error to inherit an abstract member without implementing it or being declared abstract.
|
||||
// If there is no declaration for the derived class (as in the case of class expressions),
|
||||
// then the class cannot be declared abstract.
|
||||
if ( baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) {
|
||||
error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2,
|
||||
typeToString(type), symbolToString(baseProperty), typeToString(baseType));
|
||||
if (baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) {
|
||||
if (derivedClassDecl.kind === SyntaxKind.ClassExpression) {
|
||||
error(derivedClassDecl, Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1,
|
||||
symbolToString(baseProperty), typeToString(baseType));
|
||||
}
|
||||
else {
|
||||
error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2,
|
||||
typeToString(type), symbolToString(baseProperty), typeToString(baseType));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -14589,7 +14602,7 @@ namespace ts {
|
||||
|
||||
function createInstantiatedPromiseLikeType(): ObjectType {
|
||||
let promiseLikeType = getGlobalPromiseLikeType();
|
||||
if (promiseLikeType !== emptyObjectType) {
|
||||
if (promiseLikeType !== emptyGenericType) {
|
||||
return createTypeReference(<GenericType>promiseLikeType, [anyType]);
|
||||
}
|
||||
|
||||
|
||||
@@ -379,10 +379,10 @@ namespace ts {
|
||||
* Read tsconfig.json file
|
||||
* @param fileName The path to the config file
|
||||
*/
|
||||
export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } {
|
||||
export function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic } {
|
||||
let text = "";
|
||||
try {
|
||||
text = sys.readFile(fileName);
|
||||
text = readFile(fileName);
|
||||
}
|
||||
catch (e) {
|
||||
return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace ts {
|
||||
Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." },
|
||||
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." },
|
||||
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." },
|
||||
An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
|
||||
An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." },
|
||||
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
|
||||
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
|
||||
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
|
||||
@@ -427,6 +427,7 @@ namespace ts {
|
||||
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
|
||||
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
|
||||
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
|
||||
Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
|
||||
|
||||
@@ -965,7 +965,7 @@
|
||||
"category": "Error",
|
||||
"code": 2341
|
||||
},
|
||||
"An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.": {
|
||||
"An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.": {
|
||||
"category": "Error",
|
||||
"code": 2342
|
||||
},
|
||||
@@ -1692,11 +1692,16 @@
|
||||
"A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": {
|
||||
"category": "Error",
|
||||
"code": 2651
|
||||
},
|
||||
},
|
||||
"Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead.": {
|
||||
"category": "Error",
|
||||
"code": 2652
|
||||
},
|
||||
"Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2653
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4000
|
||||
|
||||
+151
-108
@@ -186,6 +186,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
/** Sourcemap data that will get encoded */
|
||||
let sourceMapData: SourceMapData;
|
||||
|
||||
/** If removeComments is true, no leading-comments needed to be emitted **/
|
||||
let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker;
|
||||
|
||||
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
|
||||
initializeEmitterWithSourceMaps();
|
||||
}
|
||||
@@ -1292,8 +1295,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
function jsxEmitPreserve(node: JsxElement|JsxSelfClosingElement) {
|
||||
function emitJsxAttribute(node: JsxAttribute) {
|
||||
emit(node.name);
|
||||
write("=");
|
||||
emit(node.initializer);
|
||||
if (node.initializer) {
|
||||
write("=");
|
||||
emit(node.initializer);
|
||||
}
|
||||
}
|
||||
|
||||
function emitJsxSpreadAttribute(node: JsxSpreadAttribute) {
|
||||
@@ -2352,7 +2357,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
operand.kind !== SyntaxKind.PostfixUnaryExpression &&
|
||||
operand.kind !== SyntaxKind.NewExpression &&
|
||||
!(operand.kind === SyntaxKind.CallExpression && node.parent.kind === SyntaxKind.NewExpression) &&
|
||||
!(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression)) {
|
||||
!(operand.kind === SyntaxKind.FunctionExpression && node.parent.kind === SyntaxKind.CallExpression) &&
|
||||
!(operand.kind === SyntaxKind.NumericLiteral && node.parent.kind === SyntaxKind.PropertyAccessExpression)) {
|
||||
emit(operand);
|
||||
return;
|
||||
}
|
||||
@@ -3666,7 +3672,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
function emitFunctionDeclaration(node: FunctionLikeDeclaration) {
|
||||
if (nodeIsMissing(node.body)) {
|
||||
return emitOnlyPinnedOrTripleSlashComments(node);
|
||||
return emitCommentsOnNotEmittedNode(node);
|
||||
}
|
||||
|
||||
// TODO (yuisu) : we should not have special cases to condition emitting comments
|
||||
@@ -4143,7 +4149,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
else if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) {
|
||||
if (!(<MethodDeclaration>member).body) {
|
||||
return emitOnlyPinnedOrTripleSlashComments(member);
|
||||
return emitCommentsOnNotEmittedNode(member);
|
||||
}
|
||||
|
||||
writeLine();
|
||||
@@ -4210,7 +4216,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
function emitMemberFunctionsForES6AndHigher(node: ClassLikeDeclaration) {
|
||||
for (let member of node.members) {
|
||||
if ((member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) && !(<MethodDeclaration>member).body) {
|
||||
emitOnlyPinnedOrTripleSlashComments(member);
|
||||
emitCommentsOnNotEmittedNode(member);
|
||||
}
|
||||
else if (member.kind === SyntaxKind.MethodDeclaration ||
|
||||
member.kind === SyntaxKind.GetAccessor ||
|
||||
@@ -4267,7 +4273,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// Emit the constructor overload pinned comments
|
||||
forEach(node.members, member => {
|
||||
if (member.kind === SyntaxKind.Constructor && !(<ConstructorDeclaration>member).body) {
|
||||
emitOnlyPinnedOrTripleSlashComments(member);
|
||||
emitCommentsOnNotEmittedNode(member);
|
||||
}
|
||||
// Check if there is any non-static property assignment
|
||||
if (member.kind === SyntaxKind.PropertyDeclaration && (<PropertyDeclaration>member).initializer && (member.flags & NodeFlags.Static) === 0) {
|
||||
@@ -4939,63 +4945,61 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitSerializedTypeNode(node: TypeNode) {
|
||||
if (!node) {
|
||||
return;
|
||||
if (node) {
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.VoidKeyword:
|
||||
write("void 0");
|
||||
return;
|
||||
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
emitSerializedTypeNode((<ParenthesizedTypeNode>node).type);
|
||||
return;
|
||||
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
write("Function");
|
||||
return;
|
||||
|
||||
case SyntaxKind.ArrayType:
|
||||
case SyntaxKind.TupleType:
|
||||
write("Array");
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypePredicate:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
write("Boolean");
|
||||
return;
|
||||
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.StringLiteral:
|
||||
write("String");
|
||||
return;
|
||||
|
||||
case SyntaxKind.NumberKeyword:
|
||||
write("Number");
|
||||
return;
|
||||
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
write("Symbol");
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypeReference:
|
||||
emitSerializedTypeReferenceNode(<TypeReferenceNode>node);
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypeQuery:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.IntersectionType:
|
||||
case SyntaxKind.AnyKeyword:
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.fail("Cannot serialize unexpected type node.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.VoidKeyword:
|
||||
write("void 0");
|
||||
return;
|
||||
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
emitSerializedTypeNode((<ParenthesizedTypeNode>node).type);
|
||||
return;
|
||||
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
write("Function");
|
||||
return;
|
||||
|
||||
case SyntaxKind.ArrayType:
|
||||
case SyntaxKind.TupleType:
|
||||
write("Array");
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypePredicate:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
write("Boolean");
|
||||
return;
|
||||
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.StringLiteral:
|
||||
write("String");
|
||||
return;
|
||||
|
||||
case SyntaxKind.NumberKeyword:
|
||||
write("Number");
|
||||
return;
|
||||
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
write("Symbol");
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypeReference:
|
||||
emitSerializedTypeReferenceNode(<TypeReferenceNode>node);
|
||||
return;
|
||||
|
||||
case SyntaxKind.TypeQuery:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.IntersectionType:
|
||||
case SyntaxKind.AnyKeyword:
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.fail("Cannot serialize unexpected type node.");
|
||||
break;
|
||||
}
|
||||
|
||||
write("Object");
|
||||
}
|
||||
|
||||
@@ -5168,7 +5172,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitInterfaceDeclaration(node: InterfaceDeclaration) {
|
||||
emitOnlyPinnedOrTripleSlashComments(node);
|
||||
emitCommentsOnNotEmittedNode(node);
|
||||
}
|
||||
|
||||
function shouldEmitEnumDeclaration(node: EnumDeclaration) {
|
||||
@@ -5290,7 +5294,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
let shouldEmit = shouldEmitModuleDeclaration(node);
|
||||
|
||||
if (!shouldEmit) {
|
||||
return emitOnlyPinnedOrTripleSlashComments(node);
|
||||
return emitCommentsOnNotEmittedNode(node);
|
||||
}
|
||||
let hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node);
|
||||
let emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
|
||||
@@ -6720,7 +6724,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
function emitNodeConsideringCommentsOption(node: Node, emitNodeConsideringSourcemap: (node: Node) => void): void {
|
||||
if (node) {
|
||||
if (node.flags & NodeFlags.Ambient) {
|
||||
return emitOnlyPinnedOrTripleSlashComments(node);
|
||||
return emitCommentsOnNotEmittedNode(node);
|
||||
}
|
||||
|
||||
if (isSpecializedCommentHandling(node)) {
|
||||
@@ -6987,22 +6991,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
return leadingComments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all but the pinned or triple slash comments.
|
||||
* @param ranges The array to be filtered
|
||||
* @param onlyPinnedOrTripleSlashComments whether the filtering should be performed.
|
||||
*/
|
||||
function filterComments(ranges: CommentRange[], onlyPinnedOrTripleSlashComments: boolean): CommentRange[] {
|
||||
// If we're removing comments, then we want to strip out all but the pinned or
|
||||
// triple slash comments.
|
||||
if (ranges && onlyPinnedOrTripleSlashComments) {
|
||||
ranges = filter(ranges, isPinnedOrTripleSlashComment);
|
||||
if (ranges.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
function isPinnedComments(comment: CommentRange) {
|
||||
return currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk &&
|
||||
currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation;
|
||||
}
|
||||
|
||||
return ranges;
|
||||
/**
|
||||
* Determine if the given comment is a triple-slash
|
||||
*
|
||||
* @return true if the comment is a triple-slash comment else false
|
||||
**/
|
||||
function isTripleSlashComment(comment: CommentRange) {
|
||||
// Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
|
||||
// so that we don't end up computing comment string and doing match for all // comments
|
||||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash &&
|
||||
comment.pos + 2 < comment.end &&
|
||||
currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash) {
|
||||
let textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
|
||||
return textSubStr.match(fullTripleSlashReferencePathRegEx) ||
|
||||
textSubStr.match(fullTripleSlashAMDReferencePathRegEx) ?
|
||||
true : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getLeadingCommentsToEmit(node: Node) {
|
||||
@@ -7030,28 +7040,53 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
|
||||
function emitOnlyPinnedOrTripleSlashComments(node: Node) {
|
||||
emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true);
|
||||
/**
|
||||
* Emit comments associated with node that will not be emitted into JS file
|
||||
*/
|
||||
function emitCommentsOnNotEmittedNode(node: Node) {
|
||||
emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false);
|
||||
}
|
||||
|
||||
function emitLeadingComments(node: Node) {
|
||||
return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
|
||||
return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true);
|
||||
}
|
||||
|
||||
function emitLeadingCommentsWorker(node: Node, onlyPinnedOrTripleSlashComments: boolean) {
|
||||
// If the caller only wants pinned or triple slash comments, then always filter
|
||||
// down to that set. Otherwise, filter based on the current compiler options.
|
||||
let leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments);
|
||||
function emitLeadingCommentsWorker(node: Node, isEmittedNode: boolean) {
|
||||
if (compilerOptions.removeComments) {
|
||||
return;
|
||||
}
|
||||
|
||||
let leadingComments: CommentRange[];
|
||||
if (isEmittedNode) {
|
||||
leadingComments = getLeadingCommentsToEmit(node);
|
||||
}
|
||||
else {
|
||||
// If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node,
|
||||
// unless it is a triple slash comment at the top of the file.
|
||||
// For Example:
|
||||
// /// <reference-path ...>
|
||||
// declare var x;
|
||||
// /// <reference-path ...>
|
||||
// interface F {}
|
||||
// The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted
|
||||
if (node.pos === 0) {
|
||||
leadingComments = filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
|
||||
}
|
||||
}
|
||||
|
||||
emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
|
||||
|
||||
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
|
||||
emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment);
|
||||
}
|
||||
|
||||
function emitTrailingComments(node: Node) {
|
||||
if (compilerOptions.removeComments) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Emit the trailing comments only if the parent's end doesn't match
|
||||
let trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
|
||||
let trailingComments = getTrailingCommentsToEmit(node);
|
||||
|
||||
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
|
||||
emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment);
|
||||
@@ -7063,13 +7098,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
* ^ => pos; the function will emit "comment1" in the emitJS
|
||||
*/
|
||||
function emitTrailingCommentsOfPosition(pos: number) {
|
||||
let trailingComments = filterComments(getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
|
||||
if (compilerOptions.removeComments) {
|
||||
return;
|
||||
}
|
||||
|
||||
let trailingComments = getTrailingCommentRanges(currentSourceFile.text, pos);
|
||||
|
||||
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
|
||||
emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
}
|
||||
|
||||
function emitLeadingCommentsOfPosition(pos: number) {
|
||||
function emitLeadingCommentsOfPositionWorker(pos: number) {
|
||||
if (compilerOptions.removeComments) {
|
||||
return;
|
||||
}
|
||||
|
||||
let leadingComments: CommentRange[];
|
||||
if (hasDetachedComments(pos)) {
|
||||
// get comments without detached comments
|
||||
@@ -7080,7 +7123,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
leadingComments = getLeadingCommentRanges(currentSourceFile.text, pos);
|
||||
}
|
||||
|
||||
leadingComments = filterComments(leadingComments, compilerOptions.removeComments);
|
||||
emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
|
||||
|
||||
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
|
||||
@@ -7088,7 +7130,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitDetachedComments(node: TextRange) {
|
||||
let leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
||||
let leadingComments: CommentRange[];
|
||||
if (compilerOptions.removeComments) {
|
||||
// removeComments is true, only reserve pinned comment at the top of file
|
||||
// For example:
|
||||
// /*! Pinned Comment */
|
||||
//
|
||||
// var x = 10;
|
||||
if (node.pos === 0) {
|
||||
leadingComments = filter(getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// removeComments is false, just get detached as normal and bypass the process to filter comment
|
||||
leadingComments = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
||||
}
|
||||
|
||||
if (leadingComments) {
|
||||
let detachedComments: CommentRange[] = [];
|
||||
let lastComment: CommentRange;
|
||||
@@ -7138,20 +7195,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(shebang);
|
||||
}
|
||||
}
|
||||
|
||||
function isPinnedOrTripleSlashComment(comment: CommentRange) {
|
||||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
|
||||
return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation;
|
||||
}
|
||||
// Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
|
||||
// so that we don't end up computing comment string and doing match for all // comments
|
||||
else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash &&
|
||||
comment.pos + 2 < comment.end &&
|
||||
currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.slash &&
|
||||
currentSourceFile.text.substring(comment.pos, comment.end).match(fullTripleSlashReferencePathRegEx)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
|
||||
|
||||
+13
-17
@@ -1058,11 +1058,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseIdentifierName(): Identifier {
|
||||
return createIdentifier(isIdentifierOrKeyword());
|
||||
return createIdentifier(tokenIsIdentifierOrKeyword(token));
|
||||
}
|
||||
|
||||
function isLiteralPropertyName(): boolean {
|
||||
return isIdentifierOrKeyword() ||
|
||||
return tokenIsIdentifierOrKeyword(token) ||
|
||||
token === SyntaxKind.StringLiteral ||
|
||||
token === SyntaxKind.NumericLiteral;
|
||||
}
|
||||
@@ -1086,7 +1086,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isSimplePropertyName() {
|
||||
return token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || isIdentifierOrKeyword();
|
||||
return token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral || tokenIsIdentifierOrKeyword(token);
|
||||
}
|
||||
|
||||
function parseComputedPropertyName(): ComputedPropertyName {
|
||||
@@ -1213,9 +1213,9 @@ namespace ts {
|
||||
case ParsingContext.HeritageClauses:
|
||||
return isHeritageClause();
|
||||
case ParsingContext.ImportOrExportSpecifiers:
|
||||
return isIdentifierOrKeyword();
|
||||
return tokenIsIdentifierOrKeyword(token);
|
||||
case ParsingContext.JsxAttributes:
|
||||
return isIdentifierOrKeyword() || token === SyntaxKind.OpenBraceToken;
|
||||
return tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.OpenBraceToken;
|
||||
case ParsingContext.JsxChildren:
|
||||
return true;
|
||||
case ParsingContext.JSDocFunctionParameters:
|
||||
@@ -1254,7 +1254,7 @@ namespace ts {
|
||||
|
||||
function nextTokenIsIdentifierOrKeyword() {
|
||||
nextToken();
|
||||
return isIdentifierOrKeyword();
|
||||
return tokenIsIdentifierOrKeyword(token);
|
||||
}
|
||||
|
||||
function isHeritageClauseExtendsOrImplementsKeyword(): boolean {
|
||||
@@ -1824,7 +1824,7 @@ namespace ts {
|
||||
// the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword".
|
||||
// In the first case though, ASI will not take effect because there is not a
|
||||
// line terminator after the identifier or keyword.
|
||||
if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) {
|
||||
if (scanner.hasPrecedingLineBreak() && tokenIsIdentifierOrKeyword(token)) {
|
||||
let matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
|
||||
|
||||
if (matchesPattern) {
|
||||
@@ -2282,7 +2282,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (isIdentifierOrKeyword()) {
|
||||
if (tokenIsIdentifierOrKeyword(token)) {
|
||||
return parsePropertyOrMethodSignature();
|
||||
}
|
||||
}
|
||||
@@ -4101,13 +4101,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isIdentifierOrKeyword() {
|
||||
return token >= SyntaxKind.Identifier;
|
||||
}
|
||||
|
||||
function nextTokenIsIdentifierOrKeywordOnSameLine() {
|
||||
nextToken();
|
||||
return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
|
||||
return tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak();
|
||||
}
|
||||
|
||||
function nextTokenIsFunctionKeywordOnSameLine() {
|
||||
@@ -4117,7 +4113,7 @@ namespace ts {
|
||||
|
||||
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() {
|
||||
nextToken();
|
||||
return (isIdentifierOrKeyword() || token === SyntaxKind.NumericLiteral) && !scanner.hasPrecedingLineBreak();
|
||||
return (tokenIsIdentifierOrKeyword(token) || token === SyntaxKind.NumericLiteral) && !scanner.hasPrecedingLineBreak();
|
||||
}
|
||||
|
||||
function isDeclaration(): boolean {
|
||||
@@ -4170,7 +4166,7 @@ namespace ts {
|
||||
case SyntaxKind.ImportKeyword:
|
||||
nextToken();
|
||||
return token === SyntaxKind.StringLiteral || token === SyntaxKind.AsteriskToken ||
|
||||
token === SyntaxKind.OpenBraceToken || isIdentifierOrKeyword();
|
||||
token === SyntaxKind.OpenBraceToken || tokenIsIdentifierOrKeyword(token);
|
||||
case SyntaxKind.ExportKeyword:
|
||||
nextToken();
|
||||
if (token === SyntaxKind.EqualsToken || token === SyntaxKind.AsteriskToken ||
|
||||
@@ -4777,7 +4773,7 @@ namespace ts {
|
||||
|
||||
// It is very important that we check this *after* checking indexers because
|
||||
// the [ token can start an index signature or a computed property name
|
||||
if (isIdentifierOrKeyword() ||
|
||||
if (tokenIsIdentifierOrKeyword(token) ||
|
||||
token === SyntaxKind.StringLiteral ||
|
||||
token === SyntaxKind.NumericLiteral ||
|
||||
token === SyntaxKind.AsteriskToken ||
|
||||
@@ -5320,7 +5316,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isIdentifierOrKeyword();
|
||||
return tokenIsIdentifierOrKeyword(token);
|
||||
}
|
||||
|
||||
export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) {
|
||||
|
||||
+45
-35
@@ -12,7 +12,7 @@ namespace ts {
|
||||
|
||||
let emptyArray: any[] = [];
|
||||
|
||||
export const version = "1.7.0";
|
||||
export const version = "1.6.0";
|
||||
|
||||
export function findConfigFile(searchPath: string): string {
|
||||
let fileName = "tsconfig.json";
|
||||
@@ -358,7 +358,8 @@ namespace ts {
|
||||
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program {
|
||||
let program: Program;
|
||||
let files: SourceFile[] = [];
|
||||
let diagnostics = createDiagnosticCollection();
|
||||
let fileProcessingDiagnostics = createDiagnosticCollection();
|
||||
let programDiagnostics = createDiagnosticCollection();
|
||||
|
||||
let commonSourceDirectory: string;
|
||||
let diagnosticsProducingTypeChecker: TypeChecker;
|
||||
@@ -428,6 +429,7 @@ namespace ts {
|
||||
getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(),
|
||||
getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(),
|
||||
getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(),
|
||||
getFileProcessingDiagnostics: () => fileProcessingDiagnostics
|
||||
};
|
||||
return program;
|
||||
|
||||
@@ -460,6 +462,7 @@ namespace ts {
|
||||
|
||||
// check if program source files has changed in the way that can affect structure of the program
|
||||
let newSourceFiles: SourceFile[] = [];
|
||||
let modifiedSourceFiles: SourceFile[] = [];
|
||||
for (let oldSourceFile of oldProgram.getSourceFiles()) {
|
||||
let newSourceFile = host.getSourceFile(oldSourceFile.fileName, options.target);
|
||||
if (!newSourceFile) {
|
||||
@@ -499,6 +502,7 @@ namespace ts {
|
||||
}
|
||||
// pass the cache of module resolutions from the old source file
|
||||
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
||||
modifiedSourceFiles.push(newSourceFile);
|
||||
}
|
||||
else {
|
||||
// file has no changes - use it as is
|
||||
@@ -515,7 +519,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
files = newSourceFiles;
|
||||
fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
|
||||
|
||||
for (let modifiedFile of modifiedSourceFiles) {
|
||||
fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile);
|
||||
}
|
||||
oldProgram.structureIsReused = true;
|
||||
|
||||
return true;
|
||||
@@ -645,9 +653,10 @@ namespace ts {
|
||||
Debug.assert(!!sourceFile.bindDiagnostics);
|
||||
let bindDiagnostics = sourceFile.bindDiagnostics;
|
||||
let checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken);
|
||||
let programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
|
||||
let fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
let programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
|
||||
return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics);
|
||||
return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -664,7 +673,8 @@ namespace ts {
|
||||
|
||||
function getOptionsDiagnostics(): Diagnostic[] {
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
|
||||
addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics())
|
||||
addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics());
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
@@ -772,10 +782,10 @@ namespace ts {
|
||||
|
||||
if (diagnostic) {
|
||||
if (refFile !== undefined && refEnd !== undefined && refPos !== undefined) {
|
||||
diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...diagnosticArgument));
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos, diagnostic, ...diagnosticArgument));
|
||||
}
|
||||
else {
|
||||
diagnostics.add(createCompilerDiagnostic(diagnostic, ...diagnosticArgument));
|
||||
fileProcessingDiagnostics.add(createCompilerDiagnostic(diagnostic, ...diagnosticArgument));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -797,11 +807,11 @@ namespace ts {
|
||||
// We haven't looked for this file, do so now and cache result
|
||||
let file = host.getSourceFile(fileName, options.target, hostErrorMessage => {
|
||||
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
|
||||
diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
|
||||
Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}
|
||||
else {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}
|
||||
});
|
||||
filesByName.set(canonicalName, file);
|
||||
@@ -837,11 +847,11 @@ namespace ts {
|
||||
let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
|
||||
if (canonicalName !== sourceFileName) {
|
||||
if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) {
|
||||
diagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(refFile, refPos, refEnd - refPos,
|
||||
Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
|
||||
}
|
||||
else {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
|
||||
fileProcessingDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, sourceFileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -877,7 +887,7 @@ namespace ts {
|
||||
return;
|
||||
|
||||
function findModuleSourceFile(fileName: string, nameLiteral: Expression) {
|
||||
return findSourceFile(fileName, /* isDefaultLib */ false, file, nameLiteral.pos, nameLiteral.end);
|
||||
return findSourceFile(fileName, /* isDefaultLib */ false, file, skipTrivia(file.text, nameLiteral.pos), nameLiteral.end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -902,7 +912,7 @@ namespace ts {
|
||||
for (let i = 0, n = Math.min(commonPathComponents.length, sourcePathComponents.length); i < n; i++) {
|
||||
if (commonPathComponents[i] !== sourcePathComponents[i]) {
|
||||
if (i === 0) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -931,7 +941,7 @@ namespace ts {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
let absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
|
||||
if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir));
|
||||
allFilesBelongToPath = false;
|
||||
}
|
||||
}
|
||||
@@ -944,52 +954,52 @@ namespace ts {
|
||||
function verifyCompilerOptions() {
|
||||
if (options.isolatedModules) {
|
||||
if (options.declaration) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
|
||||
}
|
||||
|
||||
if (options.noEmitOnError) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
|
||||
}
|
||||
|
||||
if (options.out) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
|
||||
}
|
||||
|
||||
if (options.outFile) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
|
||||
}
|
||||
}
|
||||
|
||||
if (options.inlineSourceMap) {
|
||||
if (options.sourceMap) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
|
||||
}
|
||||
if (options.mapRoot) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
|
||||
}
|
||||
if (options.sourceRoot) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (options.inlineSources) {
|
||||
if (!options.sourceMap && !options.inlineSourceMap) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided));
|
||||
}
|
||||
}
|
||||
|
||||
if (options.out && options.outFile) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
|
||||
}
|
||||
|
||||
if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) {
|
||||
// Error to specify --mapRoot or --sourceRoot without mapSourceFiles
|
||||
if (options.mapRoot) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
|
||||
}
|
||||
if (options.sourceRoot) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1000,24 +1010,24 @@ namespace ts {
|
||||
let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
|
||||
if (options.isolatedModules) {
|
||||
if (!options.module && languageVersion < ScriptTarget.ES6) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
|
||||
}
|
||||
|
||||
let firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
|
||||
if (firstNonExternalModuleSourceFile) {
|
||||
let span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
|
||||
diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
|
||||
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
|
||||
}
|
||||
}
|
||||
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
|
||||
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
|
||||
}
|
||||
|
||||
// Cannot specify module gen target when in es6 or above
|
||||
if (options.module && languageVersion >= ScriptTarget.ES6) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
|
||||
}
|
||||
|
||||
// there has to be common source directory if user specified --outdir || --sourceRoot
|
||||
@@ -1046,30 +1056,30 @@ namespace ts {
|
||||
|
||||
if (options.noEmit) {
|
||||
if (options.out) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
|
||||
}
|
||||
|
||||
if (options.outFile) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
|
||||
}
|
||||
|
||||
if (options.outDir) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
|
||||
}
|
||||
|
||||
if (options.declaration) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
|
||||
}
|
||||
}
|
||||
|
||||
if (options.emitDecoratorMetadata &&
|
||||
!options.experimentalDecorators) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
|
||||
}
|
||||
|
||||
if (options.experimentalAsyncFunctions &&
|
||||
options.target !== ScriptTarget.ES6) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,11 @@ namespace ts {
|
||||
(message: DiagnosticMessage, length: number): void;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean {
|
||||
return token >= SyntaxKind.Identifier;
|
||||
}
|
||||
|
||||
export interface Scanner {
|
||||
getStartPos(): number;
|
||||
getToken(): SyntaxKind;
|
||||
@@ -1590,7 +1595,7 @@ namespace ts {
|
||||
// Scans a JSX identifier; these differ from normal identifiers in that
|
||||
// they allow dashes
|
||||
function scanJsxIdentifier(): SyntaxKind {
|
||||
if (token === SyntaxKind.Identifier) {
|
||||
if (tokenIsIdentifierOrKeyword(token)) {
|
||||
let firstCharPosition = pos;
|
||||
while (pos < end) {
|
||||
let ch = text.charCodeAt(pos);
|
||||
|
||||
+1
-1
@@ -216,7 +216,7 @@ namespace ts {
|
||||
if (!cachedProgram) {
|
||||
if (configFileName) {
|
||||
|
||||
let result = readConfigFile(configFileName);
|
||||
let result = readConfigFile(configFileName, sys.readFile);
|
||||
if (result.error) {
|
||||
reportDiagnostic(result.error);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
|
||||
@@ -1359,6 +1359,7 @@ namespace ts {
|
||||
/* @internal */ getSymbolCount(): number;
|
||||
/* @internal */ getTypeCount(): number;
|
||||
|
||||
/* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection;
|
||||
// For testing purposes only.
|
||||
/* @internal */ structureIsReused?: boolean;
|
||||
}
|
||||
@@ -2322,5 +2323,7 @@ namespace ts {
|
||||
// operation caused diagnostics to be returned by storing and comparing the return value
|
||||
// of this method before/after the operation is performed.
|
||||
getModificationCount(): number;
|
||||
|
||||
/* @internal */ reattachFileDiagnostics(newFile: SourceFile): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,6 +435,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
|
||||
export let fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
|
||||
|
||||
export function isTypeNode(node: Node): boolean {
|
||||
if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) {
|
||||
@@ -1507,12 +1508,23 @@ namespace ts {
|
||||
add,
|
||||
getGlobalDiagnostics,
|
||||
getDiagnostics,
|
||||
getModificationCount
|
||||
getModificationCount,
|
||||
reattachFileDiagnostics
|
||||
};
|
||||
|
||||
function getModificationCount() {
|
||||
return modificationCount;
|
||||
}
|
||||
|
||||
function reattachFileDiagnostics(newFile: SourceFile): void {
|
||||
if (!hasProperty(fileDiagnostics, newFile.fileName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let diagnostic of fileDiagnostics[newFile.fileName]) {
|
||||
diagnostic.file = newFile;
|
||||
}
|
||||
}
|
||||
|
||||
function add(diagnostic: Diagnostic): void {
|
||||
let diagnostics: Diagnostic[];
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace ts.formatting {
|
||||
*/
|
||||
interface DynamicIndentation {
|
||||
getIndentationForToken(tokenLine: number, tokenKind: SyntaxKind): number;
|
||||
getIndentationForComment(owningToken: SyntaxKind): number;
|
||||
getIndentationForComment(owningToken: SyntaxKind, tokenIndentation: number): number;
|
||||
/**
|
||||
* Indentation for open and close tokens of the node if it is block or another node that needs special indentation
|
||||
* ... {
|
||||
@@ -440,7 +440,7 @@ namespace ts.formatting {
|
||||
|
||||
function getDynamicIndentation(node: Node, nodeStartLine: number, indentation: number, delta: number): DynamicIndentation {
|
||||
return {
|
||||
getIndentationForComment: kind => {
|
||||
getIndentationForComment: (kind, tokenIndentation) => {
|
||||
switch (kind) {
|
||||
// preceding comment to the token that closes the indentation scope inherits the indentation from the scope
|
||||
// .. {
|
||||
@@ -448,9 +448,10 @@ namespace ts.formatting {
|
||||
// }
|
||||
case SyntaxKind.CloseBraceToken:
|
||||
case SyntaxKind.CloseBracketToken:
|
||||
case SyntaxKind.CloseParenToken:
|
||||
return indentation + delta;
|
||||
}
|
||||
return indentation;
|
||||
return tokenIndentation !== Constants.Unknown ? tokenIndentation : indentation;
|
||||
},
|
||||
getIndentationForToken: (line, kind) => {
|
||||
if (nodeStartLine !== line && node.decorators) {
|
||||
@@ -702,8 +703,14 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
if (indentToken) {
|
||||
let indentNextTokenOrTrivia = true;
|
||||
let tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
|
||||
dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) :
|
||||
Constants.Unknown;
|
||||
|
||||
if (currentTokenInfo.leadingTrivia) {
|
||||
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation);
|
||||
let indentNextTokenOrTrivia = true;
|
||||
|
||||
for (let triviaItem of currentTokenInfo.leadingTrivia) {
|
||||
if (!rangeContainsRange(originalRange, triviaItem)) {
|
||||
continue;
|
||||
@@ -711,13 +718,11 @@ namespace ts.formatting {
|
||||
|
||||
switch (triviaItem.kind) {
|
||||
case SyntaxKind.MultiLineCommentTrivia:
|
||||
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
|
||||
indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia);
|
||||
indentNextTokenOrTrivia = false;
|
||||
break;
|
||||
case SyntaxKind.SingleLineCommentTrivia:
|
||||
if (indentNextTokenOrTrivia) {
|
||||
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
|
||||
insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false);
|
||||
indentNextTokenOrTrivia = false;
|
||||
}
|
||||
@@ -730,8 +735,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
// indent token only if is it is in target range and does not overlap with any error ranges
|
||||
if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
|
||||
let tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
|
||||
if (tokenIndentation !== Constants.Unknown) {
|
||||
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
|
||||
|
||||
lastIndentedLine = tokenStart.line;
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace ts.formatting {
|
||||
Scan,
|
||||
RescanGreaterThanToken,
|
||||
RescanSlashToken,
|
||||
RescanTemplateToken
|
||||
RescanTemplateToken,
|
||||
RescanJsxIdentifier
|
||||
}
|
||||
|
||||
export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner {
|
||||
@@ -108,6 +109,20 @@ namespace ts.formatting {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function shouldRescanJsxIdentifier(node: Node): boolean {
|
||||
if (node.parent) {
|
||||
switch(node.parent.kind) {
|
||||
case SyntaxKind.JsxAttribute:
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
case SyntaxKind.JsxClosingElement:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
return node.kind === SyntaxKind.Identifier;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function shouldRescanSlashToken(container: Node): boolean {
|
||||
return container.kind === SyntaxKind.RegularExpressionLiteral;
|
||||
@@ -141,7 +156,9 @@ namespace ts.formatting {
|
||||
? ScanAction.RescanSlashToken
|
||||
: shouldRescanTemplateToken(n)
|
||||
? ScanAction.RescanTemplateToken
|
||||
: ScanAction.Scan
|
||||
: shouldRescanJsxIdentifier(n)
|
||||
? ScanAction.RescanJsxIdentifier
|
||||
: ScanAction.Scan
|
||||
|
||||
if (lastTokenInfo && expectedScanAction === lastScanAction) {
|
||||
// readTokenInfo was called before with the same expected scan action.
|
||||
@@ -176,6 +193,10 @@ namespace ts.formatting {
|
||||
currentToken = scanner.reScanTemplateToken();
|
||||
lastScanAction = ScanAction.RescanTemplateToken;
|
||||
}
|
||||
else if (expectedScanAction === ScanAction.RescanJsxIdentifier && currentToken === SyntaxKind.Identifier) {
|
||||
currentToken = scanner.scanJsxIdentifier();
|
||||
lastScanAction = ScanAction.RescanJsxIdentifier;
|
||||
}
|
||||
else {
|
||||
lastScanAction = ScanAction.Scan;
|
||||
}
|
||||
|
||||
@@ -213,27 +213,11 @@ namespace ts.formatting {
|
||||
public NoSpaceBetweenYieldKeywordAndStar: Rule;
|
||||
public SpaceBetweenYieldOrYieldStarAndOperand: Rule;
|
||||
|
||||
// Async-await
|
||||
// Async functions
|
||||
public SpaceBetweenAsyncAndFunctionKeyword: Rule;
|
||||
public NoSpaceBetweenAsyncAndFunctionKeyword: Rule;
|
||||
public SpaceAfterAwaitKeyword: Rule;
|
||||
public NoSpaceAfterAwaitKeyword: Rule;
|
||||
|
||||
// Type alias declaration
|
||||
public SpaceAfterTypeKeyword: Rule;
|
||||
public NoSpaceAfterTypeKeyword: Rule;
|
||||
|
||||
// Tagged template string
|
||||
public SpaceBetweenTagAndTemplateString: Rule;
|
||||
public NoSpaceBetweenTagAndTemplateString: Rule;
|
||||
|
||||
// Type operation
|
||||
public SpaceBeforeBar: Rule;
|
||||
public NoSpaceBeforeBar: Rule;
|
||||
public SpaceAfterBar: Rule;
|
||||
public NoSpaceAfterBar: Rule;
|
||||
public SpaceBeforeAmpersand: Rule;
|
||||
public SpaceAfterAmpersand: Rule;
|
||||
|
||||
constructor() {
|
||||
///
|
||||
@@ -315,7 +299,7 @@ namespace ts.formatting {
|
||||
|
||||
this.NoSpaceBeforeComma = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CommaToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword, SyntaxKind.AwaitKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterLetConstInVariableDeclaration = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), RuleAction.Space));
|
||||
this.NoSpaceBeforeOpenParenInFuncCall = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), RuleAction.Delete));
|
||||
this.SpaceAfterFunctionInFuncDecl = new Rule(RuleDescriptor.create3(SyntaxKind.FunctionKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space));
|
||||
@@ -347,9 +331,9 @@ namespace ts.formatting {
|
||||
// Use of module as a function call. e.g.: import m2 = module("m2");
|
||||
this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// Add a space around certain TypeScript keywords
|
||||
this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.FromKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.FromKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
// Add a space around certain TypeScript keywords
|
||||
this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword, SyntaxKind.TypeKeyword, SyntaxKind.FromKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.FromKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
|
||||
this.SpaceAfterModuleName = new Rule(RuleDescriptor.create1(SyntaxKind.StringLiteral, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsModuleDeclContext), RuleAction.Space));
|
||||
@@ -384,25 +368,9 @@ namespace ts.formatting {
|
||||
|
||||
// Async-await
|
||||
this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// Type alias declaration
|
||||
this.SpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// template string
|
||||
this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// type operation
|
||||
this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceBeforeAmpersand = new Rule(RuleDescriptor.create3(SyntaxKind.AmpersandToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterAmpersand = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AmpersandToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// These rules are higher in priority than user-configurable rules.
|
||||
this.HighPriorityCommonRules =
|
||||
@@ -430,12 +398,8 @@ namespace ts.formatting {
|
||||
this.NoSpaceBeforeOpenParenInFuncCall,
|
||||
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
|
||||
this.SpaceAfterVoidOperator,
|
||||
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
|
||||
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
|
||||
this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
|
||||
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
|
||||
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
|
||||
this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand,
|
||||
this.SpaceBetweenAsyncAndFunctionKeyword,
|
||||
this.SpaceBetweenTagAndTemplateString,
|
||||
|
||||
// TypeScript-specific rules
|
||||
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
|
||||
@@ -541,6 +505,8 @@ namespace ts.formatting {
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.TypePredicate:
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.IntersectionType:
|
||||
return true;
|
||||
|
||||
// equals in binding elements: function foo([[x, y] = [1, 2]])
|
||||
|
||||
@@ -431,6 +431,7 @@ namespace ts.formatting {
|
||||
case SyntaxKind.ArrayBindingPattern:
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
case SyntaxKind.JsxElement:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
|
||||
@@ -7,6 +7,11 @@ declare var a;
|
||||
(<any>[1,3,]);
|
||||
(<any>"string");
|
||||
(<any>23.0);
|
||||
(<any>1);
|
||||
(<any>1.);
|
||||
(<any>1.0);
|
||||
(<any>12e+34);
|
||||
(<any>0xff);
|
||||
(<any>/regexp/g);
|
||||
(<any>false);
|
||||
(<any>true);
|
||||
@@ -23,6 +28,12 @@ declare var a;
|
||||
declare var A;
|
||||
|
||||
// should keep the parentheses in emit
|
||||
(<any>1).foo;
|
||||
(<any>1.).foo;
|
||||
(<any>1.0).foo;
|
||||
(<any>12e+34).foo;
|
||||
(<any>0xff).foo;
|
||||
(<any>(1.0));
|
||||
(<any>new A).foo;
|
||||
(<any>typeof A).x;
|
||||
(<any>-A).x;
|
||||
@@ -46,6 +57,11 @@ new (<any>A());
|
||||
[1, 3,];
|
||||
"string";
|
||||
23.0;
|
||||
1;
|
||||
1.;
|
||||
1.0;
|
||||
12e+34;
|
||||
0xff;
|
||||
/regexp/g;
|
||||
false;
|
||||
true;
|
||||
@@ -59,6 +75,12 @@ a[0];
|
||||
a.b["0"];
|
||||
a().x;
|
||||
// should keep the parentheses in emit
|
||||
(1).foo;
|
||||
(1.).foo;
|
||||
(1.0).foo;
|
||||
(12e+34).foo;
|
||||
(0xff).foo;
|
||||
(1.0);
|
||||
(new A).foo;
|
||||
(typeof A).x;
|
||||
(-A).x;
|
||||
|
||||
@@ -10,6 +10,11 @@ declare var a;
|
||||
(<any>[1,3,]);
|
||||
(<any>"string");
|
||||
(<any>23.0);
|
||||
(<any>1);
|
||||
(<any>1.);
|
||||
(<any>1.0);
|
||||
(<any>12e+34);
|
||||
(<any>0xff);
|
||||
(<any>/regexp/g);
|
||||
(<any>false);
|
||||
(<any>true);
|
||||
@@ -33,36 +38,42 @@ declare var a;
|
||||
>a : Symbol(a, Decl(castExpressionParentheses.ts, 0, 11))
|
||||
|
||||
declare var A;
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
|
||||
|
||||
// should keep the parentheses in emit
|
||||
(<any>1).foo;
|
||||
(<any>1.).foo;
|
||||
(<any>1.0).foo;
|
||||
(<any>12e+34).foo;
|
||||
(<any>0xff).foo;
|
||||
(<any>(1.0));
|
||||
(<any>new A).foo;
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
|
||||
|
||||
(<any>typeof A).x;
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
|
||||
|
||||
(<any>-A).x;
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
|
||||
|
||||
new (<any>A());
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
|
||||
|
||||
(<Tany>()=> {})();
|
||||
>Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 28, 2))
|
||||
>Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 39, 2))
|
||||
|
||||
(<any>function foo() { })();
|
||||
>foo : Symbol(foo, Decl(castExpressionParentheses.ts, 29, 6))
|
||||
>foo : Symbol(foo, Decl(castExpressionParentheses.ts, 40, 6))
|
||||
|
||||
(<any><number><any>-A).x;
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
|
||||
|
||||
// nested cast, should keep one pair of parenthese
|
||||
(<any><number>(<any>-A)).x;
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
|
||||
|
||||
// nested parenthesized expression, should keep one pair of parenthese
|
||||
(<any>(A))
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
|
||||
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,31 @@ declare var a;
|
||||
><any>23.0 : any
|
||||
>23.0 : number
|
||||
|
||||
(<any>1);
|
||||
>(<any>1) : any
|
||||
><any>1 : any
|
||||
>1 : number
|
||||
|
||||
(<any>1.);
|
||||
>(<any>1.) : any
|
||||
><any>1. : any
|
||||
>1. : number
|
||||
|
||||
(<any>1.0);
|
||||
>(<any>1.0) : any
|
||||
><any>1.0 : any
|
||||
>1.0 : number
|
||||
|
||||
(<any>12e+34);
|
||||
>(<any>12e+34) : any
|
||||
><any>12e+34 : any
|
||||
>12e+34 : number
|
||||
|
||||
(<any>0xff);
|
||||
>(<any>0xff) : any
|
||||
><any>0xff : any
|
||||
>0xff : number
|
||||
|
||||
(<any>/regexp/g);
|
||||
>(<any>/regexp/g) : any
|
||||
><any>/regexp/g : any
|
||||
@@ -104,6 +129,47 @@ declare var A;
|
||||
>A : any
|
||||
|
||||
// should keep the parentheses in emit
|
||||
(<any>1).foo;
|
||||
>(<any>1).foo : any
|
||||
>(<any>1) : any
|
||||
><any>1 : any
|
||||
>1 : number
|
||||
>foo : any
|
||||
|
||||
(<any>1.).foo;
|
||||
>(<any>1.).foo : any
|
||||
>(<any>1.) : any
|
||||
><any>1. : any
|
||||
>1. : number
|
||||
>foo : any
|
||||
|
||||
(<any>1.0).foo;
|
||||
>(<any>1.0).foo : any
|
||||
>(<any>1.0) : any
|
||||
><any>1.0 : any
|
||||
>1.0 : number
|
||||
>foo : any
|
||||
|
||||
(<any>12e+34).foo;
|
||||
>(<any>12e+34).foo : any
|
||||
>(<any>12e+34) : any
|
||||
><any>12e+34 : any
|
||||
>12e+34 : number
|
||||
>foo : any
|
||||
|
||||
(<any>0xff).foo;
|
||||
>(<any>0xff).foo : any
|
||||
>(<any>0xff) : any
|
||||
><any>0xff : any
|
||||
>0xff : number
|
||||
>foo : any
|
||||
|
||||
(<any>(1.0));
|
||||
>(<any>(1.0)) : any
|
||||
><any>(1.0) : any
|
||||
>(1.0) : number
|
||||
>1.0 : number
|
||||
|
||||
(<any>new A).foo;
|
||||
>(<any>new A).foo : any
|
||||
>(<any>new A) : any
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
tests/cases/compiler/classExpressionExtendingAbstractClass.ts(5,9): error TS2653: Non-abstract class expression does not implement inherited abstract member 'foo' from class 'A'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/classExpressionExtendingAbstractClass.ts (1 errors) ====
|
||||
abstract class A {
|
||||
abstract foo(): void;
|
||||
}
|
||||
|
||||
var C = class extends A { // no error reported!
|
||||
~~~~~
|
||||
!!! error TS2653: Non-abstract class expression does not implement inherited abstract member 'foo' from class 'A'.
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//// [classExpressionExtendingAbstractClass.ts]
|
||||
abstract class A {
|
||||
abstract foo(): void;
|
||||
}
|
||||
|
||||
var C = class extends A { // no error reported!
|
||||
};
|
||||
|
||||
|
||||
|
||||
//// [classExpressionExtendingAbstractClass.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(class_1, _super);
|
||||
function class_1() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return class_1;
|
||||
})(A);
|
||||
@@ -1,7 +1,12 @@
|
||||
//// [tests/cases/compiler/commentOnAmbientClass1.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare class C {
|
||||
}
|
||||
|
||||
@@ -15,6 +20,9 @@ declare class E extends C {
|
||||
}
|
||||
|
||||
//// [a.js]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
//// [b.js]
|
||||
///<reference path="a.ts"/>
|
||||
|
||||
@@ -5,13 +5,18 @@ declare class E extends C {
|
||||
>C : Symbol(C, Decl(a.ts, 0, 0))
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare class C {
|
||||
>C : Symbol(C, Decl(a.ts, 0, 0))
|
||||
}
|
||||
|
||||
// Don't keep this comment.
|
||||
declare class D {
|
||||
>D : Symbol(D, Decl(a.ts, 2, 1))
|
||||
>D : Symbol(D, Decl(a.ts, 7, 1))
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,12 @@ declare class E extends C {
|
||||
>C : C
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare class C {
|
||||
>C : C
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
//// [tests/cases/compiler/commentOnAmbientEnum.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare enum C {
|
||||
a,
|
||||
b,
|
||||
@@ -18,6 +23,9 @@ declare enum E {
|
||||
}
|
||||
|
||||
//// [a.js]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
//// [b.js]
|
||||
///<reference path="a.ts"/>
|
||||
|
||||
@@ -4,22 +4,27 @@ declare enum E {
|
||||
>E : Symbol(E, Decl(b.ts, 0, 0))
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare enum C {
|
||||
>C : Symbol(C, Decl(a.ts, 0, 0))
|
||||
|
||||
a,
|
||||
>a : Symbol(C.a, Decl(a.ts, 1, 16))
|
||||
>a : Symbol(C.a, Decl(a.ts, 6, 16))
|
||||
|
||||
b,
|
||||
>b : Symbol(C.b, Decl(a.ts, 2, 6))
|
||||
>b : Symbol(C.b, Decl(a.ts, 7, 6))
|
||||
|
||||
c
|
||||
>c : Symbol(C.c, Decl(a.ts, 3, 6))
|
||||
>c : Symbol(C.c, Decl(a.ts, 8, 6))
|
||||
}
|
||||
|
||||
// Don't keep this comment.
|
||||
declare enum D {
|
||||
>D : Symbol(D, Decl(a.ts, 5, 1))
|
||||
>D : Symbol(D, Decl(a.ts, 10, 1))
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,12 @@ declare enum E {
|
||||
>E : E
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare enum C {
|
||||
>C : C
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
//// [tests/cases/compiler/commentOnAmbientModule.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare module C {
|
||||
function foo();
|
||||
}
|
||||
@@ -20,6 +25,9 @@ declare module E {
|
||||
}
|
||||
|
||||
//// [a.js]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
//// [b.js]
|
||||
///<reference path="a.ts"/>
|
||||
|
||||
@@ -5,28 +5,33 @@ declare module E {
|
||||
|
||||
class foobar extends D.bar {
|
||||
>foobar : Symbol(foobar, Decl(b.ts, 1, 18))
|
||||
>D.bar : Symbol(D.bar, Decl(a.ts, 6, 18))
|
||||
>D : Symbol(D, Decl(a.ts, 3, 1))
|
||||
>bar : Symbol(D.bar, Decl(a.ts, 6, 18))
|
||||
>D.bar : Symbol(D.bar, Decl(a.ts, 11, 18))
|
||||
>D : Symbol(D, Decl(a.ts, 8, 1))
|
||||
>bar : Symbol(D.bar, Decl(a.ts, 11, 18))
|
||||
|
||||
foo();
|
||||
>foo : Symbol(foo, Decl(b.ts, 2, 32))
|
||||
}
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare module C {
|
||||
>C : Symbol(C, Decl(a.ts, 0, 0))
|
||||
|
||||
function foo();
|
||||
>foo : Symbol(foo, Decl(a.ts, 1, 18))
|
||||
>foo : Symbol(foo, Decl(a.ts, 6, 18))
|
||||
}
|
||||
|
||||
// Don't keep this comment.
|
||||
declare module D {
|
||||
>D : Symbol(D, Decl(a.ts, 3, 1))
|
||||
>D : Symbol(D, Decl(a.ts, 8, 1))
|
||||
|
||||
class bar { }
|
||||
>bar : Symbol(bar, Decl(a.ts, 6, 18))
|
||||
>bar : Symbol(bar, Decl(a.ts, 11, 18))
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,12 @@ declare module E {
|
||||
}
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare module C {
|
||||
>C : typeof C
|
||||
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
//// [commentOnAmbientVariable1.ts]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare var v: number;
|
||||
|
||||
// Don't keep this comment.
|
||||
declare var y: number;
|
||||
|
||||
//// [commentOnAmbientVariable1.js]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
=== tests/cases/compiler/commentOnAmbientVariable1.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare var v: number;
|
||||
>v : Symbol(v, Decl(commentOnAmbientVariable1.ts, 1, 11))
|
||||
>v : Symbol(v, Decl(commentOnAmbientVariable1.ts, 6, 11))
|
||||
|
||||
// Don't keep this comment.
|
||||
declare var y: number;
|
||||
>y : Symbol(y, Decl(commentOnAmbientVariable1.ts, 4, 11))
|
||||
>y : Symbol(y, Decl(commentOnAmbientVariable1.ts, 9, 11))
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
=== tests/cases/compiler/commentOnAmbientVariable1.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare var v: number;
|
||||
>v : number
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
//// [tests/cases/compiler/commentOnAmbientfunction.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare function foo();
|
||||
|
||||
// Don't keep this comment.
|
||||
@@ -12,6 +17,9 @@ declare function bar();
|
||||
declare function foobar(a: typeof foo): typeof bar;
|
||||
|
||||
//// [a.js]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
//// [b.js]
|
||||
///<reference path="a.ts"/>
|
||||
|
||||
@@ -4,14 +4,19 @@ declare function foobar(a: typeof foo): typeof bar;
|
||||
>foobar : Symbol(foobar, Decl(b.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(b.ts, 1, 24))
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
>bar : Symbol(bar, Decl(a.ts, 1, 23))
|
||||
>bar : Symbol(bar, Decl(a.ts, 6, 23))
|
||||
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare function foo();
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
// Don't keep this comment.
|
||||
declare function bar();
|
||||
>bar : Symbol(bar, Decl(a.ts, 1, 23))
|
||||
>bar : Symbol(bar, Decl(a.ts, 6, 23))
|
||||
|
||||
|
||||
@@ -7,7 +7,12 @@ declare function foobar(a: typeof foo): typeof bar;
|
||||
>bar : () => any
|
||||
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=========
|
||||
Keep this pinned comment
|
||||
=========
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
declare function foo();
|
||||
>foo : () => any
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
//// [tests/cases/compiler/commentOnElidedModule1.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
module ElidedModule {
|
||||
}
|
||||
|
||||
@@ -15,6 +20,9 @@ module ElidedModule3 {
|
||||
}
|
||||
|
||||
//// [a.js]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
//// [b.js]
|
||||
///<reference path="a.ts"/>
|
||||
|
||||
@@ -4,13 +4,18 @@ module ElidedModule3 {
|
||||
>ElidedModule3 : Symbol(ElidedModule3, Decl(b.ts, 0, 0))
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
module ElidedModule {
|
||||
>ElidedModule : Symbol(ElidedModule, Decl(a.ts, 0, 0))
|
||||
}
|
||||
|
||||
// Don't keep this comment.
|
||||
module ElidedModule2 {
|
||||
>ElidedModule2 : Symbol(ElidedModule2, Decl(a.ts, 2, 1))
|
||||
>ElidedModule2 : Symbol(ElidedModule2, Decl(a.ts, 7, 1))
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,12 @@ module ElidedModule3 {
|
||||
>ElidedModule3 : any
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
module ElidedModule {
|
||||
>ElidedModule : any
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
//// [tests/cases/compiler/commentOnInterface1.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
interface I {
|
||||
}
|
||||
|
||||
@@ -15,6 +20,9 @@ interface I3 {
|
||||
}
|
||||
|
||||
//// [a.js]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
//// [b.js]
|
||||
///<reference path='a.ts'/>
|
||||
|
||||
@@ -4,13 +4,18 @@ interface I3 {
|
||||
>I3 : Symbol(I3, Decl(b.ts, 0, 0))
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
interface I {
|
||||
>I : Symbol(I, Decl(a.ts, 0, 0))
|
||||
}
|
||||
|
||||
// Don't keep this comment.
|
||||
interface I2 {
|
||||
>I2 : Symbol(I2, Decl(a.ts, 2, 1))
|
||||
>I2 : Symbol(I2, Decl(a.ts, 7, 1))
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,12 @@ interface I3 {
|
||||
>I3 : I3
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
interface I {
|
||||
>I : I
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
//// [tests/cases/compiler/commentOnSignature1.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
function foo(n: number): void;
|
||||
// Don't keep this comment.
|
||||
function foo(s: string): void;
|
||||
@@ -33,14 +38,15 @@ function foo2(a: any): void {
|
||||
}
|
||||
|
||||
//// [a.js]
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
function foo(a) {
|
||||
}
|
||||
var c = (function () {
|
||||
/*! keep this pinned comment */
|
||||
function c(a) {
|
||||
}
|
||||
/*! keep this pinned comment */
|
||||
c.prototype.foo = function (a) {
|
||||
};
|
||||
return c;
|
||||
|
||||
@@ -14,49 +14,54 @@ function foo2(a: any): void {
|
||||
>a : Symbol(a, Decl(b.ts, 4, 14))
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
function foo(n: number): void;
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30))
|
||||
>n : Symbol(n, Decl(a.ts, 1, 13))
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30))
|
||||
>n : Symbol(n, Decl(a.ts, 6, 13))
|
||||
|
||||
// Don't keep this comment.
|
||||
function foo(s: string): void;
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30))
|
||||
>s : Symbol(s, Decl(a.ts, 3, 13))
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30))
|
||||
>s : Symbol(s, Decl(a.ts, 8, 13))
|
||||
|
||||
function foo(a: any): void {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 1, 30), Decl(a.ts, 3, 30))
|
||||
>a : Symbol(a, Decl(a.ts, 4, 13))
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0), Decl(a.ts, 6, 30), Decl(a.ts, 8, 30))
|
||||
>a : Symbol(a, Decl(a.ts, 9, 13))
|
||||
}
|
||||
|
||||
class c {
|
||||
>c : Symbol(c, Decl(a.ts, 5, 1))
|
||||
>c : Symbol(c, Decl(a.ts, 10, 1))
|
||||
|
||||
// dont keep this comment
|
||||
constructor(a: string);
|
||||
>a : Symbol(a, Decl(a.ts, 9, 16))
|
||||
>a : Symbol(a, Decl(a.ts, 14, 16))
|
||||
|
||||
/*! keep this pinned comment */
|
||||
constructor(a: number);
|
||||
>a : Symbol(a, Decl(a.ts, 11, 16))
|
||||
>a : Symbol(a, Decl(a.ts, 16, 16))
|
||||
|
||||
constructor(a: any) {
|
||||
>a : Symbol(a, Decl(a.ts, 12, 16))
|
||||
>a : Symbol(a, Decl(a.ts, 17, 16))
|
||||
}
|
||||
|
||||
// dont keep this comment
|
||||
foo(a: string);
|
||||
>foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19))
|
||||
>a : Symbol(a, Decl(a.ts, 16, 8))
|
||||
>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19))
|
||||
>a : Symbol(a, Decl(a.ts, 21, 8))
|
||||
|
||||
/*! keep this pinned comment */
|
||||
foo(a: number);
|
||||
>foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19))
|
||||
>a : Symbol(a, Decl(a.ts, 18, 8))
|
||||
>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19))
|
||||
>a : Symbol(a, Decl(a.ts, 23, 8))
|
||||
|
||||
foo(a: any) {
|
||||
>foo : Symbol(foo, Decl(a.ts, 13, 5), Decl(a.ts, 16, 19), Decl(a.ts, 18, 19))
|
||||
>a : Symbol(a, Decl(a.ts, 19, 8))
|
||||
>foo : Symbol(foo, Decl(a.ts, 18, 5), Decl(a.ts, 21, 19), Decl(a.ts, 23, 19))
|
||||
>a : Symbol(a, Decl(a.ts, 24, 8))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,12 @@ function foo2(a: any): void {
|
||||
>a : any
|
||||
}
|
||||
=== tests/cases/compiler/a.ts ===
|
||||
/*! Keep this pinned comment */
|
||||
/*!=================
|
||||
Keep this pinned
|
||||
=================
|
||||
*/
|
||||
|
||||
/*! Don't keep this pinned comment */
|
||||
function foo(n: number): void;
|
||||
>foo : { (n: number): void; (s: string): void; }
|
||||
>n : number
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//// [decoratorMetadataOnInferredType.ts]
|
||||
|
||||
declare var console: {
|
||||
log(msg: string): void;
|
||||
};
|
||||
|
||||
class A {
|
||||
constructor() { console.log('new A'); }
|
||||
}
|
||||
|
||||
function decorator(target: Object, propertyKey: string) {
|
||||
}
|
||||
|
||||
export class B {
|
||||
@decorator
|
||||
x = new A();
|
||||
}
|
||||
|
||||
|
||||
//// [decoratorMetadataOnInferredType.js]
|
||||
var A = (function () {
|
||||
function A() {
|
||||
console.log('new A');
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
function decorator(target, propertyKey) {
|
||||
}
|
||||
var B = (function () {
|
||||
function B() {
|
||||
this.x = new A();
|
||||
}
|
||||
__decorate([
|
||||
decorator,
|
||||
__metadata('design:type', Object)
|
||||
], B.prototype, "x");
|
||||
return B;
|
||||
})();
|
||||
exports.B = B;
|
||||
@@ -0,0 +1,38 @@
|
||||
=== tests/cases/compiler/decoratorMetadataOnInferredType.ts ===
|
||||
|
||||
declare var console: {
|
||||
>console : Symbol(console, Decl(decoratorMetadataOnInferredType.ts, 1, 11))
|
||||
|
||||
log(msg: string): void;
|
||||
>log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22))
|
||||
>msg : Symbol(msg, Decl(decoratorMetadataOnInferredType.ts, 2, 8))
|
||||
|
||||
};
|
||||
|
||||
class A {
|
||||
>A : Symbol(A, Decl(decoratorMetadataOnInferredType.ts, 3, 2))
|
||||
|
||||
constructor() { console.log('new A'); }
|
||||
>console.log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22))
|
||||
>console : Symbol(console, Decl(decoratorMetadataOnInferredType.ts, 1, 11))
|
||||
>log : Symbol(log, Decl(decoratorMetadataOnInferredType.ts, 1, 22))
|
||||
}
|
||||
|
||||
function decorator(target: Object, propertyKey: string) {
|
||||
>decorator : Symbol(decorator, Decl(decoratorMetadataOnInferredType.ts, 7, 1))
|
||||
>target : Symbol(target, Decl(decoratorMetadataOnInferredType.ts, 9, 19))
|
||||
>Object : Symbol(Object, Decl(lib.d.ts, 92, 1), Decl(lib.d.ts, 223, 11))
|
||||
>propertyKey : Symbol(propertyKey, Decl(decoratorMetadataOnInferredType.ts, 9, 34))
|
||||
}
|
||||
|
||||
export class B {
|
||||
>B : Symbol(B, Decl(decoratorMetadataOnInferredType.ts, 10, 1))
|
||||
|
||||
@decorator
|
||||
>decorator : Symbol(decorator, Decl(decoratorMetadataOnInferredType.ts, 7, 1))
|
||||
|
||||
x = new A();
|
||||
>x : Symbol(x, Decl(decoratorMetadataOnInferredType.ts, 12, 16))
|
||||
>A : Symbol(A, Decl(decoratorMetadataOnInferredType.ts, 3, 2))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
=== tests/cases/compiler/decoratorMetadataOnInferredType.ts ===
|
||||
|
||||
declare var console: {
|
||||
>console : { log(msg: string): void; }
|
||||
|
||||
log(msg: string): void;
|
||||
>log : (msg: string) => void
|
||||
>msg : string
|
||||
|
||||
};
|
||||
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
constructor() { console.log('new A'); }
|
||||
>console.log('new A') : void
|
||||
>console.log : (msg: string) => void
|
||||
>console : { log(msg: string): void; }
|
||||
>log : (msg: string) => void
|
||||
>'new A' : string
|
||||
}
|
||||
|
||||
function decorator(target: Object, propertyKey: string) {
|
||||
>decorator : (target: Object, propertyKey: string) => void
|
||||
>target : Object
|
||||
>Object : Object
|
||||
>propertyKey : string
|
||||
}
|
||||
|
||||
export class B {
|
||||
>B : B
|
||||
|
||||
@decorator
|
||||
>decorator : (target: Object, propertyKey: string) => void
|
||||
|
||||
x = new A();
|
||||
>x : A
|
||||
>new A() : A
|
||||
>A : typeof A
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//// [doNotEmitDetachedComments.ts]
|
||||
/*
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
var x = 10;
|
||||
|
||||
// Single Line comment
|
||||
|
||||
function foo() { }
|
||||
|
||||
|
||||
/*
|
||||
multi-line comment
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
|
||||
function bar() { }
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
|
||||
//// [doNotEmitDetachedComments.js]
|
||||
var x = 10;
|
||||
function foo() { }
|
||||
function bar() { }
|
||||
@@ -0,0 +1,31 @@
|
||||
=== tests/cases/compiler/doNotEmitDetachedComments.ts ===
|
||||
/*
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(doNotEmitDetachedComments.ts, 6, 3))
|
||||
|
||||
// Single Line comment
|
||||
|
||||
function foo() { }
|
||||
>foo : Symbol(foo, Decl(doNotEmitDetachedComments.ts, 6, 11))
|
||||
|
||||
|
||||
/*
|
||||
multi-line comment
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
|
||||
function bar() { }
|
||||
>bar : Symbol(bar, Decl(doNotEmitDetachedComments.ts, 10, 18))
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
=== tests/cases/compiler/doNotEmitDetachedComments.ts ===
|
||||
/*
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
var x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
|
||||
// Single Line comment
|
||||
|
||||
function foo() { }
|
||||
>foo : () => void
|
||||
|
||||
|
||||
/*
|
||||
multi-line comment
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
|
||||
function bar() { }
|
||||
>bar : () => void
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
//// [doNotEmitDetachedCommentsAtStartOfConstructor.ts]
|
||||
class A {
|
||||
constructor() {
|
||||
// Single Line Comment
|
||||
|
||||
var x = 10;
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
constructor() {
|
||||
/*
|
||||
Multi-line comment
|
||||
*/
|
||||
|
||||
var y = 10;
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
constructor() {
|
||||
// Single Line Comment with more than one blank line
|
||||
|
||||
|
||||
var x = 10;
|
||||
}
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor() {
|
||||
/*
|
||||
Multi-line comment with more than one blank line
|
||||
*/
|
||||
|
||||
|
||||
var y = 10;
|
||||
}
|
||||
}
|
||||
|
||||
//// [doNotEmitDetachedCommentsAtStartOfConstructor.js]
|
||||
var A = (function () {
|
||||
function A() {
|
||||
var x = 10;
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
var B = (function () {
|
||||
function B() {
|
||||
var y = 10;
|
||||
}
|
||||
return B;
|
||||
})();
|
||||
var C = (function () {
|
||||
function C() {
|
||||
var x = 10;
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var D = (function () {
|
||||
function D() {
|
||||
var y = 10;
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
@@ -0,0 +1,50 @@
|
||||
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts ===
|
||||
class A {
|
||||
>A : Symbol(A, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 0, 0))
|
||||
|
||||
constructor() {
|
||||
// Single Line Comment
|
||||
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 4, 11))
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
>B : Symbol(B, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 6, 1))
|
||||
|
||||
constructor() {
|
||||
/*
|
||||
Multi-line comment
|
||||
*/
|
||||
|
||||
var y = 10;
|
||||
>y : Symbol(y, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 14, 11))
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 16, 1))
|
||||
|
||||
constructor() {
|
||||
// Single Line Comment with more than one blank line
|
||||
|
||||
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 23, 11))
|
||||
}
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : Symbol(D, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 25, 1))
|
||||
|
||||
constructor() {
|
||||
/*
|
||||
Multi-line comment with more than one blank line
|
||||
*/
|
||||
|
||||
|
||||
var y = 10;
|
||||
>y : Symbol(y, Decl(doNotEmitDetachedCommentsAtStartOfConstructor.ts, 34, 11))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfConstructor.ts ===
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
constructor() {
|
||||
// Single Line Comment
|
||||
|
||||
var x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
>B : B
|
||||
|
||||
constructor() {
|
||||
/*
|
||||
Multi-line comment
|
||||
*/
|
||||
|
||||
var y = 10;
|
||||
>y : number
|
||||
>10 : number
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
constructor() {
|
||||
// Single Line Comment with more than one blank line
|
||||
|
||||
|
||||
var x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
}
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : D
|
||||
|
||||
constructor() {
|
||||
/*
|
||||
Multi-line comment with more than one blank line
|
||||
*/
|
||||
|
||||
|
||||
var y = 10;
|
||||
>y : number
|
||||
>10 : number
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//// [doNotEmitDetachedCommentsAtStartOfFunctionBody.ts]
|
||||
function foo1() {
|
||||
// Single line comment
|
||||
|
||||
return 42;
|
||||
}
|
||||
|
||||
function foo2() {
|
||||
/*
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
return 42;
|
||||
}
|
||||
|
||||
function foo3() {
|
||||
// Single line comment with more than one blank line
|
||||
|
||||
|
||||
return 42;
|
||||
}
|
||||
|
||||
function foo4() {
|
||||
/*
|
||||
|
||||
multi line comment with more than one blank line
|
||||
*/
|
||||
|
||||
return 42;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [doNotEmitDetachedCommentsAtStartOfFunctionBody.js]
|
||||
function foo1() {
|
||||
return 42;
|
||||
}
|
||||
function foo2() {
|
||||
return 42;
|
||||
}
|
||||
function foo3() {
|
||||
return 42;
|
||||
}
|
||||
function foo4() {
|
||||
return 42;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts ===
|
||||
function foo1() {
|
||||
>foo1 : Symbol(foo1, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 0, 0))
|
||||
|
||||
// Single line comment
|
||||
|
||||
return 42;
|
||||
}
|
||||
|
||||
function foo2() {
|
||||
>foo2 : Symbol(foo2, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 4, 1))
|
||||
|
||||
/*
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
return 42;
|
||||
}
|
||||
|
||||
function foo3() {
|
||||
>foo3 : Symbol(foo3, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 14, 1))
|
||||
|
||||
// Single line comment with more than one blank line
|
||||
|
||||
|
||||
return 42;
|
||||
}
|
||||
|
||||
function foo4() {
|
||||
>foo4 : Symbol(foo4, Decl(doNotEmitDetachedCommentsAtStartOfFunctionBody.ts, 21, 1))
|
||||
|
||||
/*
|
||||
|
||||
multi line comment with more than one blank line
|
||||
*/
|
||||
|
||||
return 42;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfFunctionBody.ts ===
|
||||
function foo1() {
|
||||
>foo1 : () => number
|
||||
|
||||
// Single line comment
|
||||
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
|
||||
function foo2() {
|
||||
>foo2 : () => number
|
||||
|
||||
/*
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
|
||||
function foo3() {
|
||||
>foo3 : () => number
|
||||
|
||||
// Single line comment with more than one blank line
|
||||
|
||||
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
|
||||
function foo4() {
|
||||
>foo4 : () => number
|
||||
|
||||
/*
|
||||
|
||||
multi line comment with more than one blank line
|
||||
*/
|
||||
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
//// [doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts]
|
||||
() => {
|
||||
// Single line comment
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
() => {
|
||||
/*
|
||||
multi-line comment
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
() => {
|
||||
// Single line comment with more than one blank line
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
() => {
|
||||
/*
|
||||
multi-line comment with more than one blank line
|
||||
*/
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//// [doNotEmitDetachedCommentsAtStartOfLambdaFunction.js]
|
||||
(function () {
|
||||
return 0;
|
||||
});
|
||||
(function () {
|
||||
return 0;
|
||||
});
|
||||
(function () {
|
||||
return 0;
|
||||
});
|
||||
(function () {
|
||||
return 0;
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts ===
|
||||
() => {
|
||||
No type information for this code. // Single line comment
|
||||
No type information for this code.
|
||||
No type information for this code. return 0;
|
||||
No type information for this code.}
|
||||
No type information for this code.
|
||||
No type information for this code.() => {
|
||||
No type information for this code. /*
|
||||
No type information for this code. multi-line comment
|
||||
No type information for this code. */
|
||||
No type information for this code.
|
||||
No type information for this code. return 0;
|
||||
No type information for this code.}
|
||||
No type information for this code.
|
||||
No type information for this code.() => {
|
||||
No type information for this code. // Single line comment with more than one blank line
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
No type information for this code. return 0;
|
||||
No type information for this code.}
|
||||
No type information for this code.
|
||||
No type information for this code.() => {
|
||||
No type information for this code. /*
|
||||
No type information for this code. multi-line comment with more than one blank line
|
||||
No type information for this code. */
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
No type information for this code. return 0;
|
||||
No type information for this code.}
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
@@ -0,0 +1,43 @@
|
||||
=== tests/cases/compiler/doNotEmitDetachedCommentsAtStartOfLambdaFunction.ts ===
|
||||
() => {
|
||||
>() => { // Single line comment return 0;} : () => number
|
||||
|
||||
// Single line comment
|
||||
|
||||
return 0;
|
||||
>0 : number
|
||||
}
|
||||
|
||||
() => {
|
||||
>() => { /* multi-line comment */ return 0;} : () => number
|
||||
|
||||
/*
|
||||
multi-line comment
|
||||
*/
|
||||
|
||||
return 0;
|
||||
>0 : number
|
||||
}
|
||||
|
||||
() => {
|
||||
>() => { // Single line comment with more than one blank line return 0;} : () => number
|
||||
|
||||
// Single line comment with more than one blank line
|
||||
|
||||
|
||||
return 0;
|
||||
>0 : number
|
||||
}
|
||||
|
||||
() => {
|
||||
>() => { /* multi-line comment with more than one blank line */ return 0;} : () => number
|
||||
|
||||
/*
|
||||
multi-line comment with more than one blank line
|
||||
*/
|
||||
|
||||
|
||||
return 0;
|
||||
>0 : number
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//// [doNotEmitPinnedCommentNotOnTopOfFile.ts]
|
||||
var x = 10;
|
||||
|
||||
/*!
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
var x = 10;
|
||||
|
||||
//// [doNotEmitPinnedCommentNotOnTopOfFile.js]
|
||||
var x = 10;
|
||||
var x = 10;
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts ===
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 0, 3), Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 8, 3))
|
||||
|
||||
/*!
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 0, 3), Decl(doNotEmitPinnedCommentNotOnTopOfFile.ts, 8, 3))
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts ===
|
||||
var x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
|
||||
/*!
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
var x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [doNotEmitPinnedCommentOnNotEmittedNode.ts]
|
||||
|
||||
class C {
|
||||
/*! remove pinned comment anywhere else */
|
||||
public foo(x: string, y: any)
|
||||
public foo(x: string, y: number) { }
|
||||
}
|
||||
|
||||
var x = 10;
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
declare var OData: any;
|
||||
|
||||
//// [doNotEmitPinnedCommentOnNotEmittedNode.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function (x, y) { };
|
||||
return C;
|
||||
})();
|
||||
var x = 10;
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts ===
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 0, 0))
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
public foo(x: string, y: any)
|
||||
>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 33))
|
||||
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 15))
|
||||
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 25))
|
||||
|
||||
public foo(x: string, y: number) { }
|
||||
>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 3, 33))
|
||||
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 4, 15))
|
||||
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 4, 25))
|
||||
}
|
||||
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 7, 3))
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
declare var OData: any;
|
||||
>OData : Symbol(OData, Decl(doNotEmitPinnedCommentOnNotEmittedNode.ts, 10, 11))
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNode.ts ===
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
public foo(x: string, y: any)
|
||||
>foo : (x: string, y: any) => any
|
||||
>x : string
|
||||
>y : any
|
||||
|
||||
public foo(x: string, y: number) { }
|
||||
>foo : (x: string, y: any) => any
|
||||
>x : string
|
||||
>y : number
|
||||
}
|
||||
|
||||
var x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
declare var OData: any;
|
||||
>OData : any
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//// [doNotEmitPinnedCommentOnNotEmittedNodets.ts]
|
||||
|
||||
class C {
|
||||
/*! remove pinned comment anywhere else */
|
||||
public foo(x: string, y: any)
|
||||
public foo(x: string, y: number) { }
|
||||
}
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
declare var OData: any;
|
||||
|
||||
//// [doNotEmitPinnedCommentOnNotEmittedNodets.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function (x, y) { };
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts ===
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 0, 0))
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
public foo(x: string, y: any)
|
||||
>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 33))
|
||||
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 15))
|
||||
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 25))
|
||||
|
||||
public foo(x: string, y: number) { }
|
||||
>foo : Symbol(foo, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 1, 9), Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 3, 33))
|
||||
>x : Symbol(x, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 4, 15))
|
||||
>y : Symbol(y, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 4, 25))
|
||||
}
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
declare var OData: any;
|
||||
>OData : Symbol(OData, Decl(doNotEmitPinnedCommentOnNotEmittedNodets.ts, 8, 11))
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/compiler/doNotEmitPinnedCommentOnNotEmittedNodets.ts ===
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
public foo(x: string, y: any)
|
||||
>foo : (x: string, y: any) => any
|
||||
>x : string
|
||||
>y : any
|
||||
|
||||
public foo(x: string, y: number) { }
|
||||
>foo : (x: string, y: any) => any
|
||||
>x : string
|
||||
>y : number
|
||||
}
|
||||
|
||||
/*! remove pinned comment anywhere else */
|
||||
declare var OData: any;
|
||||
>OData : any
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//// [doNotEmitPinnedDetachedComments.ts]
|
||||
var x = 10;
|
||||
|
||||
/*! Single Line comment */
|
||||
|
||||
function baz() { }
|
||||
|
||||
|
||||
/*!
|
||||
multi-line comment
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
|
||||
function bar() {
|
||||
/*!
|
||||
Remove this comment
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
function foo() {
|
||||
/*! Remove this */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
|
||||
//// [doNotEmitPinnedDetachedComments.js]
|
||||
var x = 10;
|
||||
function baz() { }
|
||||
function bar() {
|
||||
}
|
||||
function foo() {
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
=== tests/cases/compiler/doNotEmitPinnedDetachedComments.ts ===
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(doNotEmitPinnedDetachedComments.ts, 0, 3))
|
||||
|
||||
/*! Single Line comment */
|
||||
|
||||
function baz() { }
|
||||
>baz : Symbol(baz, Decl(doNotEmitPinnedDetachedComments.ts, 0, 11))
|
||||
|
||||
|
||||
/*!
|
||||
multi-line comment
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
|
||||
function bar() {
|
||||
>bar : Symbol(bar, Decl(doNotEmitPinnedDetachedComments.ts, 4, 18))
|
||||
|
||||
/*!
|
||||
Remove this comment
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(doNotEmitPinnedDetachedComments.ts, 21, 1))
|
||||
|
||||
/*! Remove this */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
=== tests/cases/compiler/doNotEmitPinnedDetachedComments.ts ===
|
||||
var x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
|
||||
/*! Single Line comment */
|
||||
|
||||
function baz() { }
|
||||
>baz : () => void
|
||||
|
||||
|
||||
/*!
|
||||
multi-line comment
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
|
||||
function bar() {
|
||||
>bar : () => void
|
||||
|
||||
/*!
|
||||
Remove this comment
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
function foo() {
|
||||
>foo : () => number
|
||||
|
||||
/*! Remove this */
|
||||
|
||||
return 0;
|
||||
>0 : number
|
||||
}
|
||||
|
||||
|
||||
//========================
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [tests/cases/compiler/doNotEmitTripleSlashCommentsInEmptyFile.ts] ////
|
||||
|
||||
//// [file0.ts]
|
||||
|
||||
|
||||
//// [file1.ts]
|
||||
|
||||
//// [file2.ts]
|
||||
/// <reference path="file0.ts" />
|
||||
/// <reference path="file1.ts" />
|
||||
/// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
|
||||
|
||||
//// [file0.js]
|
||||
//// [file1.js]
|
||||
//// [file2.js]
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
/// <reference path="file0.ts" />
|
||||
No type information for this code./// <reference path="file1.ts" />
|
||||
No type information for this code./// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
|
||||
No type information for this code.=== tests/cases/compiler/file0.ts ===
|
||||
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/compiler/file1.ts ===
|
||||
|
||||
No type information for this code.
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
/// <reference path="file0.ts" />
|
||||
No type information for this code./// <reference path="file1.ts" />
|
||||
No type information for this code./// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
|
||||
No type information for this code.=== tests/cases/compiler/file0.ts ===
|
||||
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/compiler/file1.ts ===
|
||||
|
||||
No type information for this code.
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [tests/cases/compiler/doNotEmitTripleSlashCommentsOnNotEmittedNode.ts] ////
|
||||
|
||||
//// [file0.ts]
|
||||
|
||||
/// <reference path="file1.ts" />
|
||||
declare var OData: any;
|
||||
|
||||
//// [file1.ts]
|
||||
/// <reference path="file0.ts" />
|
||||
interface F { }
|
||||
|
||||
|
||||
|
||||
//// [file0.js]
|
||||
//// [file1.js]
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
/// <reference path="file0.ts" />
|
||||
interface F { }
|
||||
>F : Symbol(F, Decl(file1.ts, 0, 0))
|
||||
|
||||
|
||||
=== tests/cases/compiler/file0.ts ===
|
||||
|
||||
/// <reference path="file1.ts" />
|
||||
declare var OData: any;
|
||||
>OData : Symbol(OData, Decl(file0.ts, 2, 11))
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
/// <reference path="file0.ts" />
|
||||
interface F { }
|
||||
>F : F
|
||||
|
||||
|
||||
=== tests/cases/compiler/file0.ts ===
|
||||
|
||||
/// <reference path="file1.ts" />
|
||||
declare var OData: any;
|
||||
>OData : any
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
//// [tests/cases/compiler/doNotemitTripleSlashComments.ts] ////
|
||||
|
||||
//// [file0.ts]
|
||||
|
||||
/// <reference path="file1.ts" />
|
||||
/// <reference path="file2.ts" />
|
||||
/// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
|
||||
var x = 10;
|
||||
|
||||
/// <reference path="file1.ts" />
|
||||
var y = "hello";
|
||||
|
||||
|
||||
/// <reference path="file2.ts" />
|
||||
|
||||
//// [file1.ts]
|
||||
/// <reference path="file0.ts" />
|
||||
|
||||
function foo() { }
|
||||
|
||||
|
||||
/// <reference path="file0.ts" />
|
||||
|
||||
|
||||
var z = "world";
|
||||
|
||||
//// [file2.ts]
|
||||
/// <reference path="file1.ts" />
|
||||
|
||||
|
||||
/// ====================================
|
||||
|
||||
|
||||
function bar() { }
|
||||
|
||||
|
||||
|
||||
|
||||
//// [file0.js]
|
||||
var x = 10;
|
||||
var y = "hello";
|
||||
//// [file1.js]
|
||||
function foo() { }
|
||||
var z = "world";
|
||||
//// [file2.js]
|
||||
function bar() { }
|
||||
@@ -0,0 +1,40 @@
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
/// <reference path="file1.ts" />
|
||||
|
||||
|
||||
/// ====================================
|
||||
|
||||
|
||||
function bar() { }
|
||||
>bar : Symbol(bar, Decl(file2.ts, 0, 0))
|
||||
|
||||
|
||||
|
||||
=== tests/cases/compiler/file0.ts ===
|
||||
|
||||
/// <reference path="file1.ts" />
|
||||
/// <reference path="file2.ts" />
|
||||
/// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(file0.ts, 4, 3))
|
||||
|
||||
/// <reference path="file1.ts" />
|
||||
var y = "hello";
|
||||
>y : Symbol(y, Decl(file0.ts, 7, 3))
|
||||
|
||||
|
||||
/// <reference path="file2.ts" />
|
||||
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
/// <reference path="file0.ts" />
|
||||
|
||||
function foo() { }
|
||||
>foo : Symbol(foo, Decl(file1.ts, 0, 0))
|
||||
|
||||
|
||||
/// <reference path="file0.ts" />
|
||||
|
||||
|
||||
var z = "world";
|
||||
>z : Symbol(z, Decl(file1.ts, 8, 3))
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
=== tests/cases/compiler/file2.ts ===
|
||||
/// <reference path="file1.ts" />
|
||||
|
||||
|
||||
/// ====================================
|
||||
|
||||
|
||||
function bar() { }
|
||||
>bar : () => void
|
||||
|
||||
|
||||
|
||||
=== tests/cases/compiler/file0.ts ===
|
||||
|
||||
/// <reference path="file1.ts" />
|
||||
/// <reference path="file2.ts" />
|
||||
/// <amd-dependency path="/js/libs/hgn.js!app/templates/home" name="compiler"/>
|
||||
var x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
|
||||
/// <reference path="file1.ts" />
|
||||
var y = "hello";
|
||||
>y : string
|
||||
>"hello" : string
|
||||
|
||||
|
||||
/// <reference path="file2.ts" />
|
||||
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
/// <reference path="file0.ts" />
|
||||
|
||||
function foo() { }
|
||||
>foo : () => void
|
||||
|
||||
|
||||
/// <reference path="file0.ts" />
|
||||
|
||||
|
||||
var z = "world";
|
||||
>z : string
|
||||
>"world" : string
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [emitPinnedCommentsOnTopOfFile.ts]
|
||||
/*!
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
var x = 10;
|
||||
|
||||
//// [emitPinnedCommentsOnTopOfFile.js]
|
||||
/*!
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
var x = 10;
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts ===
|
||||
/*!
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
var x = 10;
|
||||
>x : Symbol(x, Decl(emitPinnedCommentsOnTopOfFile.ts, 6, 3))
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/compiler/emitPinnedCommentsOnTopOfFile.ts ===
|
||||
/*!
|
||||
|
||||
multi line
|
||||
comment
|
||||
*/
|
||||
|
||||
var x = 10;
|
||||
>x : number
|
||||
>10 : number
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//// [tests/cases/compiler/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.ts] ////
|
||||
|
||||
//// [file0.ts]
|
||||
|
||||
var x = 10
|
||||
|
||||
//// [file1.ts]
|
||||
/// <reference path="file0.ts" />
|
||||
declare var OData: any;
|
||||
|
||||
/// <reference path="file0.ts" />
|
||||
interface F { }
|
||||
|
||||
|
||||
|
||||
|
||||
//// [file0.js]
|
||||
var x = 10;
|
||||
//// [file1.js]
|
||||
/// <reference path="file0.ts" />
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
/// <reference path="file0.ts" />
|
||||
declare var OData: any;
|
||||
>OData : Symbol(OData, Decl(file1.ts, 1, 11))
|
||||
|
||||
/// <reference path="file0.ts" />
|
||||
interface F { }
|
||||
>F : Symbol(F, Decl(file1.ts, 1, 23))
|
||||
|
||||
|
||||
|
||||
=== tests/cases/compiler/file0.ts ===
|
||||
|
||||
var x = 10
|
||||
>x : Symbol(x, Decl(file0.ts, 1, 3))
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/file1.ts ===
|
||||
/// <reference path="file0.ts" />
|
||||
declare var OData: any;
|
||||
>OData : any
|
||||
|
||||
/// <reference path="file0.ts" />
|
||||
interface F { }
|
||||
>F : F
|
||||
|
||||
|
||||
|
||||
=== tests/cases/compiler/file0.ts ===
|
||||
|
||||
var x = 10
|
||||
>x : number
|
||||
>10 : number
|
||||
|
||||
@@ -4,7 +4,7 @@ tests/cases/compiler/indexTypeCheck.ts(17,2): error TS2413: Numeric index type '
|
||||
tests/cases/compiler/indexTypeCheck.ts(27,2): error TS2413: Numeric index type 'number' is not assignable to string index type 'string'.
|
||||
tests/cases/compiler/indexTypeCheck.ts(32,3): error TS1096: An index signature must have exactly one parameter.
|
||||
tests/cases/compiler/indexTypeCheck.ts(36,3): error TS1023: An index signature parameter type must be 'string' or 'number'.
|
||||
tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
|
||||
tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/indexTypeCheck.ts (7 errors) ====
|
||||
@@ -72,7 +72,7 @@ tests/cases/compiler/indexTypeCheck.ts(51,1): error TS2342: An index expression
|
||||
|
||||
yellow[blue]; // error
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol, or 'any'.
|
||||
!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
|
||||
var x:number[];
|
||||
x[0];
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [jsxEmitAttributeWithPreserve.tsx]
|
||||
|
||||
declare var React: any;
|
||||
<foo data/>
|
||||
|
||||
//// [jsxEmitAttributeWithPreserve.jsx]
|
||||
<foo data/>;
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx ===
|
||||
|
||||
declare var React: any;
|
||||
>React : Symbol(React, Decl(jsxEmitAttributeWithPreserve.tsx, 1, 11))
|
||||
|
||||
<foo data/>
|
||||
>data : Symbol(unknown)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/jsxEmitAttributeWithPreserve.tsx ===
|
||||
|
||||
declare var React: any;
|
||||
>React : any
|
||||
|
||||
<foo data/>
|
||||
><foo data/> : any
|
||||
>foo : any
|
||||
>data : any
|
||||
|
||||
@@ -47,9 +47,9 @@ a / > ;
|
||||
< a;
|
||||
b > ;
|
||||
b > ;
|
||||
<a b= c=></a>;
|
||||
<a b c></a>;
|
||||
b.c > ;
|
||||
<a.b c=></a.b>;
|
||||
<a.b c></a.b>;
|
||||
c > ;
|
||||
<a.b.c></a>;
|
||||
< .a > ;
|
||||
@@ -67,7 +67,7 @@ var x = <div>one</div><div>two</div>;;
|
||||
var x = <div>one</div> /* intervening comment */ /* intervening comment */ <div>two</div>;;
|
||||
<a>{"str"}}</a>;
|
||||
<span className="a"/> id="b" />;
|
||||
<div className=/>>;
|
||||
<div className/>>;
|
||||
<div {...props}/>;
|
||||
|
||||
<div>stuff</div>...props}>;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user