mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge https://github.com/Microsoft/TypeScript into blockFormParameterIndentation
This commit is contained in:
+13
-16
@@ -88,6 +88,7 @@ module ts {
|
||||
let undefinedType = createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsUndefinedOrNull, "undefined");
|
||||
let nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefinedOrNull, "null");
|
||||
let unknownType = createIntrinsicType(TypeFlags.Any, "unknown");
|
||||
let circularType = createIntrinsicType(TypeFlags.Any, "__circular__");
|
||||
|
||||
let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
@@ -3575,19 +3576,7 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Since removeSubtypes checks the subtype relation, and the subtype relation on a union
|
||||
// may attempt to reduce a union, it is possible that removeSubtypes could be called
|
||||
// recursively on the same set of types. The removeSubtypesStack is used to track which
|
||||
// sets of types are currently undergoing subtype reduction.
|
||||
let removeSubtypesStack: string[] = [];
|
||||
function removeSubtypes(types: Type[]) {
|
||||
let typeListId = getTypeListId(types);
|
||||
if (removeSubtypesStack.lastIndexOf(typeListId) >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeSubtypesStack.push(typeListId);
|
||||
|
||||
let i = types.length;
|
||||
while (i > 0) {
|
||||
i--;
|
||||
@@ -3595,8 +3584,6 @@ module ts {
|
||||
types.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
removeSubtypesStack.pop();
|
||||
}
|
||||
|
||||
function containsAnyType(types: Type[]) {
|
||||
@@ -3651,10 +3638,20 @@ module ts {
|
||||
return type;
|
||||
}
|
||||
|
||||
// Subtype reduction is basically an optimization we do to avoid excessively large union types, which take longer
|
||||
// to process and look strange in quick info and error messages. Semantically there is no difference between the
|
||||
// reduced type and the type itself. So, when we detect a circularity we simply say that the reduced type is the
|
||||
// type itself.
|
||||
function getReducedTypeOfUnionType(type: UnionType): Type {
|
||||
// If union type was created without subtype reduction, perform the deferred reduction now
|
||||
if (!type.reducedType) {
|
||||
type.reducedType = getUnionType(type.types, /*noSubtypeReduction*/ false);
|
||||
type.reducedType = circularType;
|
||||
let reducedType = getUnionType(type.types, /*noSubtypeReduction*/ false);
|
||||
if (type.reducedType === circularType) {
|
||||
type.reducedType = reducedType;
|
||||
}
|
||||
}
|
||||
else if (type.reducedType === circularType) {
|
||||
type.reducedType = type;
|
||||
}
|
||||
return type.reducedType;
|
||||
}
|
||||
|
||||
+11
-1
@@ -459,8 +459,18 @@ module ts {
|
||||
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
|
||||
return 2;
|
||||
}
|
||||
// Per RFC 1738 'file' URI schema has the shape file://<host>/<path>
|
||||
// if <host> is omitted then it is assumed that host value is 'localhost',
|
||||
// however slash after the omitted <host> is not removed.
|
||||
// file:///folder1/file1 - this is a correct URI
|
||||
// file://folder2/file2 - this is an incorrect URI
|
||||
if (path.lastIndexOf("file:///", 0) === 0) {
|
||||
return "file:///".length;
|
||||
}
|
||||
let idx = path.indexOf('://');
|
||||
if (idx !== -1) return idx + 3
|
||||
if (idx !== -1) {
|
||||
return idx + "://".length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1829,7 +1829,34 @@ module ts {
|
||||
if (version !== sourceFile.version) {
|
||||
// Once incremental parsing is ready, then just call into this function.
|
||||
if (!disableIncrementalParsing) {
|
||||
let newSourceFile = updateSourceFile(sourceFile, scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange, aggressiveChecks);
|
||||
let newText: string;
|
||||
|
||||
// grab the fragment from the beginning of the original text to the beginning of the span
|
||||
let prefix = textChangeRange.span.start !== 0
|
||||
? sourceFile.text.substr(0, textChangeRange.span.start)
|
||||
: "";
|
||||
|
||||
// grab the fragment from the end of the span till the end of the original text
|
||||
let suffix = textSpanEnd(textChangeRange.span) !== sourceFile.text.length
|
||||
? sourceFile.text.substr(textSpanEnd(textChangeRange.span))
|
||||
: "";
|
||||
|
||||
if (textChangeRange.newLength === 0) {
|
||||
// edit was a deletion - just combine prefix and suffix
|
||||
newText = prefix && suffix ? prefix + suffix : prefix || suffix;
|
||||
}
|
||||
else {
|
||||
// it was actual edit, fetch the fragment of new text that correspond to new span
|
||||
let changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength);
|
||||
// combine prefix, changed text and suffix
|
||||
newText = prefix && suffix
|
||||
? prefix + changedText + suffix
|
||||
: prefix
|
||||
? (prefix + changedText)
|
||||
: (changedText + suffix);
|
||||
}
|
||||
|
||||
let newSourceFile = updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
|
||||
setSourceFileFields(newSourceFile, scriptSnapshot, version);
|
||||
// after incremental parsing nameTable might not be up-to-date
|
||||
// drop it so it can be lazily recreated later
|
||||
|
||||
Reference in New Issue
Block a user