mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-16 15:51:35 -05:00
Merge branch 'master' into FixTripleSlashCompletions
This commit is contained in:
@@ -2165,7 +2165,7 @@ namespace ts {
|
||||
? "any"
|
||||
: (<IntrinsicType>type).intrinsicName);
|
||||
}
|
||||
else if (type.flags & TypeFlags.ThisType) {
|
||||
else if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) {
|
||||
if (inObjectTypeLiteral) {
|
||||
writer.reportInaccessibleThisError();
|
||||
}
|
||||
@@ -3179,7 +3179,7 @@ namespace ts {
|
||||
result.pattern = pattern;
|
||||
}
|
||||
if (hasComputedProperties) {
|
||||
result.flags |= TypeFlags.ObjectLiteralPatternWithComputedProperties;
|
||||
result.isObjectLiteralPatternWithComputedProperties = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -3766,7 +3766,8 @@ namespace ts {
|
||||
(<GenericType>type).instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
|
||||
(<GenericType>type).target = <GenericType>type;
|
||||
(<GenericType>type).typeArguments = type.typeParameters;
|
||||
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter | TypeFlags.ThisType);
|
||||
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
|
||||
type.thisType.isThisType = true;
|
||||
type.thisType.symbol = symbol;
|
||||
type.thisType.constraint = type;
|
||||
}
|
||||
@@ -4968,7 +4969,7 @@ namespace ts {
|
||||
|
||||
function hasConstraintReferenceTo(type: Type, target: TypeParameter): boolean {
|
||||
let checked: Type[];
|
||||
while (type && !(type.flags & TypeFlags.ThisType) && type.flags & TypeFlags.TypeParameter && !contains(checked, type)) {
|
||||
while (type && type.flags & TypeFlags.TypeParameter && !((type as TypeParameter).isThisType) && !contains(checked, type)) {
|
||||
if (type === target) {
|
||||
return true;
|
||||
}
|
||||
@@ -5331,7 +5332,8 @@ namespace ts {
|
||||
type.instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
|
||||
type.target = <GenericType>type;
|
||||
type.typeArguments = type.typeParameters;
|
||||
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter | TypeFlags.ThisType);
|
||||
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
|
||||
type.thisType.isThisType = true;
|
||||
type.thisType.constraint = type;
|
||||
type.declaredProperties = properties;
|
||||
type.declaredCallSignatures = emptyArray;
|
||||
@@ -6647,7 +6649,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
|
||||
if (!(target.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties) && maybeTypeOfKind(target, TypeFlags.ObjectType)) {
|
||||
if (maybeTypeOfKind(target, TypeFlags.ObjectType) &&
|
||||
(!(target.flags & TypeFlags.ObjectType) || !(target as ObjectType).isObjectLiteralPatternWithComputedProperties)) {
|
||||
for (const prop of getPropertiesOfObjectType(source)) {
|
||||
if (!isKnownProperty(target, prop.name)) {
|
||||
if (reportErrors) {
|
||||
@@ -10307,7 +10310,8 @@ namespace ts {
|
||||
patternWithComputedProperties = true;
|
||||
}
|
||||
}
|
||||
else if (contextualTypeHasPattern && !(contextualType.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties)) {
|
||||
else if (contextualTypeHasPattern &&
|
||||
!(contextualType.flags & TypeFlags.ObjectType && (contextualType as ObjectType).isObjectLiteralPatternWithComputedProperties)) {
|
||||
// If object literal is contextually typed by the implied type of a binding pattern, and if the
|
||||
// binding pattern specifies a default value for the property, make the property optional.
|
||||
const impliedProp = getPropertyOfType(contextualType, member.name);
|
||||
@@ -10372,7 +10376,10 @@ namespace ts {
|
||||
const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.Number) : undefined;
|
||||
const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);
|
||||
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral;
|
||||
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags) | (patternWithComputedProperties ? TypeFlags.ObjectLiteralPatternWithComputedProperties : 0);
|
||||
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags);
|
||||
if (patternWithComputedProperties) {
|
||||
result.isObjectLiteralPatternWithComputedProperties = true;
|
||||
}
|
||||
if (inDestructuringPattern) {
|
||||
result.pattern = node;
|
||||
}
|
||||
@@ -10942,7 +10949,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
// An instance property must be accessed through an instance of the enclosing class
|
||||
if (type.flags & TypeFlags.ThisType) {
|
||||
if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) {
|
||||
// get the original type -- represented as the type constraint of the 'this' type
|
||||
type = getConstraintOfTypeParameter(<TypeParameter>type);
|
||||
}
|
||||
@@ -10992,7 +10999,7 @@ namespace ts {
|
||||
const prop = getPropertyOfType(apparentType, right.text);
|
||||
if (!prop) {
|
||||
if (right.text && !checkAndReportErrorForExtendingInterface(node)) {
|
||||
reportNonexistentProperty(right, type.flags & TypeFlags.ThisType ? apparentType : type);
|
||||
reportNonexistentProperty(right, type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ? apparentType : type);
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
@@ -311,9 +311,18 @@ namespace ts {
|
||||
return parseInt(process.version.charAt(1)) >= 4;
|
||||
}
|
||||
|
||||
function isFileSystemCaseSensitive(): boolean {
|
||||
// win32\win64 are case insensitive platforms
|
||||
if (platform === "win32" || platform === "win64") {
|
||||
return false;
|
||||
}
|
||||
// convert current file name to upper case / lower case and check if file exists
|
||||
// (guards against cases when name is already all uppercase or lowercase)
|
||||
return !fileExists(__filename.toUpperCase()) || !fileExists(__filename.toLowerCase());
|
||||
}
|
||||
|
||||
const platform: string = _os.platform();
|
||||
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
|
||||
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
|
||||
const useCaseSensitiveFileNames = isFileSystemCaseSensitive();
|
||||
|
||||
function readFile(fileName: string, encoding?: string): string {
|
||||
if (!fileExists(fileName)) {
|
||||
|
||||
@@ -2308,8 +2308,7 @@ namespace ts {
|
||||
extraVariableDeclarations = [];
|
||||
}
|
||||
// hoist collected variable declarations
|
||||
for (const name in currentState.hoistedLocalVariables) {
|
||||
const identifier = currentState.hoistedLocalVariables[name];
|
||||
for (const identifier of currentState.hoistedLocalVariables) {
|
||||
extraVariableDeclarations.push(createVariableDeclaration(identifier));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,6 +552,7 @@ namespace ts {
|
||||
const savedBlocks = blocks;
|
||||
const savedBlockOffsets = blockOffsets;
|
||||
const savedBlockActions = blockActions;
|
||||
const savedBlockStack = blockStack;
|
||||
const savedLabelOffsets = labelOffsets;
|
||||
const savedLabelExpressions = labelExpressions;
|
||||
const savedNextLabelId = nextLabelId;
|
||||
@@ -566,6 +567,7 @@ namespace ts {
|
||||
blocks = undefined;
|
||||
blockOffsets = undefined;
|
||||
blockActions = undefined;
|
||||
blockStack = undefined;
|
||||
labelOffsets = undefined;
|
||||
labelExpressions = undefined;
|
||||
nextLabelId = 1;
|
||||
@@ -591,6 +593,7 @@ namespace ts {
|
||||
blocks = savedBlocks;
|
||||
blockOffsets = savedBlockOffsets;
|
||||
blockActions = savedBlockActions;
|
||||
blockStack = savedBlockStack;
|
||||
labelOffsets = savedLabelOffsets;
|
||||
labelExpressions = savedLabelExpressions;
|
||||
nextLabelId = savedNextLabelId;
|
||||
|
||||
@@ -2393,8 +2393,6 @@ namespace ts {
|
||||
ContainsObjectLiteral = 1 << 26, // Type is or contains object literal type
|
||||
/* @internal */
|
||||
ContainsAnyFunctionType = 1 << 27, // Type is or contains object literal type
|
||||
ThisType = 1 << 28, // This type
|
||||
ObjectLiteralPatternWithComputedProperties = 1 << 29, // Object literal type implied by binding pattern has computed properties
|
||||
|
||||
/* @internal */
|
||||
Nullable = Undefined | Null,
|
||||
@@ -2463,7 +2461,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Object types (TypeFlags.ObjectType)
|
||||
export interface ObjectType extends Type { }
|
||||
export interface ObjectType extends Type {
|
||||
isObjectLiteralPatternWithComputedProperties?: boolean;
|
||||
}
|
||||
|
||||
// Class and interface types (TypeFlags.Class and TypeFlags.Interface)
|
||||
export interface InterfaceType extends ObjectType {
|
||||
@@ -2558,6 +2558,8 @@ namespace ts {
|
||||
mapper?: TypeMapper; // Instantiation mapper
|
||||
/* @internal */
|
||||
resolvedApparentType: Type;
|
||||
/* @internal */
|
||||
isThisType?: boolean;
|
||||
}
|
||||
|
||||
export const enum SignatureKind {
|
||||
|
||||
@@ -925,7 +925,7 @@ namespace Harness {
|
||||
export const defaultLibFileName = "lib.d.ts";
|
||||
export const es2015DefaultLibFileName = "lib.es2015.d.ts";
|
||||
|
||||
const libFileNameSourceFileMap= ts.createMap<ts.SourceFile>({
|
||||
const libFileNameSourceFileMap = ts.createMap<ts.SourceFile>({
|
||||
[defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest)
|
||||
});
|
||||
|
||||
|
||||
24
src/lib/es5.d.ts
vendored
24
src/lib/es5.d.ts
vendored
@@ -1200,6 +1200,30 @@ interface Array<T> {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
|
||||
@@ -523,6 +523,8 @@ namespace ts.server {
|
||||
process.on("uncaughtException", function (err: Error) {
|
||||
ioSession.logError(err, "unknown");
|
||||
});
|
||||
// See https://github.com/Microsoft/TypeScript/issues/11348
|
||||
(process as any).noAsar = true;
|
||||
// Start listening
|
||||
ioSession.listen();
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
"utilities.ts",
|
||||
"scriptVersionCache.ts",
|
||||
"scriptInfo.ts",
|
||||
"lshost.ts",
|
||||
"lsHost.ts",
|
||||
"typingsCache.ts",
|
||||
"project.ts",
|
||||
"editorServices.ts",
|
||||
|
||||
Reference in New Issue
Block a user