Skip to content

Commit eb362fe

Browse files
author
Arthur Ozga
committed
Merge branch 'master' into FixTripleSlashCompletions
2 parents 2e589f1 + 93b8df7 commit eb362fe

File tree

60 files changed

+943
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+943
-128
lines changed

src/compiler/checker.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ namespace ts {
21652165
? "any"
21662166
: (<IntrinsicType>type).intrinsicName);
21672167
}
2168-
else if (type.flags & TypeFlags.ThisType) {
2168+
else if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) {
21692169
if (inObjectTypeLiteral) {
21702170
writer.reportInaccessibleThisError();
21712171
}
@@ -3179,7 +3179,7 @@ namespace ts {
31793179
result.pattern = pattern;
31803180
}
31813181
if (hasComputedProperties) {
3182-
result.flags |= TypeFlags.ObjectLiteralPatternWithComputedProperties;
3182+
result.isObjectLiteralPatternWithComputedProperties = true;
31833183
}
31843184
return result;
31853185
}
@@ -3766,7 +3766,8 @@ namespace ts {
37663766
(<GenericType>type).instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
37673767
(<GenericType>type).target = <GenericType>type;
37683768
(<GenericType>type).typeArguments = type.typeParameters;
3769-
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter | TypeFlags.ThisType);
3769+
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
3770+
type.thisType.isThisType = true;
37703771
type.thisType.symbol = symbol;
37713772
type.thisType.constraint = type;
37723773
}
@@ -4968,7 +4969,7 @@ namespace ts {
49684969

49694970
function hasConstraintReferenceTo(type: Type, target: TypeParameter): boolean {
49704971
let checked: Type[];
4971-
while (type && !(type.flags & TypeFlags.ThisType) && type.flags & TypeFlags.TypeParameter && !contains(checked, type)) {
4972+
while (type && type.flags & TypeFlags.TypeParameter && !((type as TypeParameter).isThisType) && !contains(checked, type)) {
49724973
if (type === target) {
49734974
return true;
49744975
}
@@ -5331,7 +5332,8 @@ namespace ts {
53315332
type.instantiations[getTypeListId(type.typeParameters)] = <GenericType>type;
53325333
type.target = <GenericType>type;
53335334
type.typeArguments = type.typeParameters;
5334-
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter | TypeFlags.ThisType);
5335+
type.thisType = <TypeParameter>createType(TypeFlags.TypeParameter);
5336+
type.thisType.isThisType = true;
53355337
type.thisType.constraint = type;
53365338
type.declaredProperties = properties;
53375339
type.declaredCallSignatures = emptyArray;
@@ -6647,7 +6649,8 @@ namespace ts {
66476649
}
66486650

66496651
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
6650-
if (!(target.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties) && maybeTypeOfKind(target, TypeFlags.ObjectType)) {
6652+
if (maybeTypeOfKind(target, TypeFlags.ObjectType) &&
6653+
(!(target.flags & TypeFlags.ObjectType) || !(target as ObjectType).isObjectLiteralPatternWithComputedProperties)) {
66516654
for (const prop of getPropertiesOfObjectType(source)) {
66526655
if (!isKnownProperty(target, prop.name)) {
66536656
if (reportErrors) {
@@ -10307,7 +10310,8 @@ namespace ts {
1030710310
patternWithComputedProperties = true;
1030810311
}
1030910312
}
10310-
else if (contextualTypeHasPattern && !(contextualType.flags & TypeFlags.ObjectLiteralPatternWithComputedProperties)) {
10313+
else if (contextualTypeHasPattern &&
10314+
!(contextualType.flags & TypeFlags.ObjectType && (contextualType as ObjectType).isObjectLiteralPatternWithComputedProperties)) {
1031110315
// If object literal is contextually typed by the implied type of a binding pattern, and if the
1031210316
// binding pattern specifies a default value for the property, make the property optional.
1031310317
const impliedProp = getPropertyOfType(contextualType, member.name);
@@ -10372,7 +10376,10 @@ namespace ts {
1037210376
const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, IndexKind.Number) : undefined;
1037310377
const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);
1037410378
const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral;
10375-
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags) | (patternWithComputedProperties ? TypeFlags.ObjectLiteralPatternWithComputedProperties : 0);
10379+
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags);
10380+
if (patternWithComputedProperties) {
10381+
result.isObjectLiteralPatternWithComputedProperties = true;
10382+
}
1037610383
if (inDestructuringPattern) {
1037710384
result.pattern = node;
1037810385
}
@@ -10942,7 +10949,7 @@ namespace ts {
1094210949
return true;
1094310950
}
1094410951
// An instance property must be accessed through an instance of the enclosing class
10945-
if (type.flags & TypeFlags.ThisType) {
10952+
if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) {
1094610953
// get the original type -- represented as the type constraint of the 'this' type
1094710954
type = getConstraintOfTypeParameter(<TypeParameter>type);
1094810955
}
@@ -10992,7 +10999,7 @@ namespace ts {
1099210999
const prop = getPropertyOfType(apparentType, right.text);
1099311000
if (!prop) {
1099411001
if (right.text && !checkAndReportErrorForExtendingInterface(node)) {
10995-
reportNonexistentProperty(right, type.flags & TypeFlags.ThisType ? apparentType : type);
11002+
reportNonexistentProperty(right, type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType ? apparentType : type);
1099611003
}
1099711004
return unknownType;
1099811005
}

src/compiler/sys.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,18 @@ namespace ts {
311311
return parseInt(process.version.charAt(1)) >= 4;
312312
}
313313

314+
function isFileSystemCaseSensitive(): boolean {
315+
// win32\win64 are case insensitive platforms
316+
if (platform === "win32" || platform === "win64") {
317+
return false;
318+
}
319+
// convert current file name to upper case / lower case and check if file exists
320+
// (guards against cases when name is already all uppercase or lowercase)
321+
return !fileExists(__filename.toUpperCase()) || !fileExists(__filename.toLowerCase());
322+
}
323+
314324
const platform: string = _os.platform();
315-
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
316-
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
325+
const useCaseSensitiveFileNames = isFileSystemCaseSensitive();
317326

318327
function readFile(fileName: string, encoding?: string): string {
319328
if (!fileExists(fileName)) {

src/compiler/transformers/es6.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,8 +2308,7 @@ namespace ts {
23082308
extraVariableDeclarations = [];
23092309
}
23102310
// hoist collected variable declarations
2311-
for (const name in currentState.hoistedLocalVariables) {
2312-
const identifier = currentState.hoistedLocalVariables[name];
2311+
for (const identifier of currentState.hoistedLocalVariables) {
23132312
extraVariableDeclarations.push(createVariableDeclaration(identifier));
23142313
}
23152314
}

src/compiler/transformers/generators.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ namespace ts {
552552
const savedBlocks = blocks;
553553
const savedBlockOffsets = blockOffsets;
554554
const savedBlockActions = blockActions;
555+
const savedBlockStack = blockStack;
555556
const savedLabelOffsets = labelOffsets;
556557
const savedLabelExpressions = labelExpressions;
557558
const savedNextLabelId = nextLabelId;
@@ -566,6 +567,7 @@ namespace ts {
566567
blocks = undefined;
567568
blockOffsets = undefined;
568569
blockActions = undefined;
570+
blockStack = undefined;
569571
labelOffsets = undefined;
570572
labelExpressions = undefined;
571573
nextLabelId = 1;
@@ -591,6 +593,7 @@ namespace ts {
591593
blocks = savedBlocks;
592594
blockOffsets = savedBlockOffsets;
593595
blockActions = savedBlockActions;
596+
blockStack = savedBlockStack;
594597
labelOffsets = savedLabelOffsets;
595598
labelExpressions = savedLabelExpressions;
596599
nextLabelId = savedNextLabelId;

src/compiler/types.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,8 +2393,6 @@ namespace ts {
23932393
ContainsObjectLiteral = 1 << 26, // Type is or contains object literal type
23942394
/* @internal */
23952395
ContainsAnyFunctionType = 1 << 27, // Type is or contains object literal type
2396-
ThisType = 1 << 28, // This type
2397-
ObjectLiteralPatternWithComputedProperties = 1 << 29, // Object literal type implied by binding pattern has computed properties
23982396

23992397
/* @internal */
24002398
Nullable = Undefined | Null,
@@ -2463,7 +2461,9 @@ namespace ts {
24632461
}
24642462

24652463
// Object types (TypeFlags.ObjectType)
2466-
export interface ObjectType extends Type { }
2464+
export interface ObjectType extends Type {
2465+
isObjectLiteralPatternWithComputedProperties?: boolean;
2466+
}
24672467

24682468
// Class and interface types (TypeFlags.Class and TypeFlags.Interface)
24692469
export interface InterfaceType extends ObjectType {
@@ -2558,6 +2558,8 @@ namespace ts {
25582558
mapper?: TypeMapper; // Instantiation mapper
25592559
/* @internal */
25602560
resolvedApparentType: Type;
2561+
/* @internal */
2562+
isThisType?: boolean;
25612563
}
25622564

25632565
export const enum SignatureKind {

src/harness/harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ namespace Harness {
925925
export const defaultLibFileName = "lib.d.ts";
926926
export const es2015DefaultLibFileName = "lib.es2015.d.ts";
927927

928-
const libFileNameSourceFileMap= ts.createMap<ts.SourceFile>({
928+
const libFileNameSourceFileMap = ts.createMap<ts.SourceFile>({
929929
[defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest)
930930
});
931931

src/lib/es5.d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,30 @@ interface Array<T> {
12001200
* @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.
12011201
*/
12021202
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
1203+
/**
1204+
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
1205+
* @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.
1206+
* @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.
1207+
*/
1208+
map<U>(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U];
1209+
/**
1210+
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
1211+
* @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.
1212+
* @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.
1213+
*/
1214+
map<U>(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U];
1215+
/**
1216+
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
1217+
* @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.
1218+
* @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.
1219+
*/
1220+
map<U>(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U];
1221+
/**
1222+
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
1223+
* @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.
1224+
* @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.
1225+
*/
1226+
map<U>(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U];
12031227
/**
12041228
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
12051229
* @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.

src/server/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ namespace ts.server {
523523
process.on("uncaughtException", function (err: Error) {
524524
ioSession.logError(err, "unknown");
525525
});
526+
// See https://github.com/Microsoft/TypeScript/issues/11348
527+
(process as any).noAsar = true;
526528
// Start listening
527529
ioSession.listen();
528530
}

src/server/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"utilities.ts",
1919
"scriptVersionCache.ts",
2020
"scriptInfo.ts",
21-
"lshost.ts",
21+
"lsHost.ts",
2222
"typingsCache.ts",
2323
"project.ts",
2424
"editorServices.ts",

tests/baselines/reference/anyInferenceAnonymousFunctions.symbols

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ paired.reduce((b3, b4) => b3.concat({}), []);
3535
>b3 : Symbol(b3, Decl(anyInferenceAnonymousFunctions.ts, 13, 15))
3636

3737
paired.map((c1) => c1.count);
38-
>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
38+
>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
3939
>paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3))
40-
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
40+
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
4141
>c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12))
4242
>c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12))
4343

4444
paired.map(function (c2) { return c2.count; });
45-
>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --))
45+
>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
4646
>paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3))
47-
>map : Symbol(Array.map, Decl(lib.d.ts, --, --))
47+
>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
4848
>c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21))
4949
>c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21))
5050

0 commit comments

Comments
 (0)