Skip to content

Commit 1980334

Browse files
committed
Merge branch 'master' into asyncGenerators
2 parents 38b7757 + 71b28a0 commit 1980334

File tree

71 files changed

+1352
-963
lines changed

Some content is hidden

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

71 files changed

+1352
-963
lines changed

src/compiler/checker.ts

Lines changed: 116 additions & 35 deletions
Large diffs are not rendered by default.

src/compiler/declarationEmitter.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,10 @@ namespace ts {
10371037
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
10381038
break;
10391039

1040+
case SyntaxKind.TypeAliasDeclaration:
1041+
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
1042+
break;
1043+
10401044
default:
10411045
Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
10421046
}
@@ -1143,7 +1147,10 @@ namespace ts {
11431147
const prevEnclosingDeclaration = enclosingDeclaration;
11441148
enclosingDeclaration = node;
11451149
emitTypeParameters(node.typeParameters);
1146-
emitHeritageClause(getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false);
1150+
const interfaceExtendsTypes = filter(getInterfaceBaseTypeNodes(node), base => isEntityNameExpression(base.expression));
1151+
if (interfaceExtendsTypes && interfaceExtendsTypes.length) {
1152+
emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false);
1153+
}
11471154
write(" {");
11481155
writeLine();
11491156
increaseIndent();

src/compiler/diagnosticMessages.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@
17511751
"category": "Error",
17521752
"code": 2535
17531753
},
1754-
"Type '{0}' is not constrained to 'keyof {1}'.": {
1754+
"Type '{0}' cannot be used to index type '{1}'.": {
17551755
"category": "Error",
17561756
"code": 2536
17571757
},
@@ -2308,6 +2308,10 @@
23082308
"category": "Error",
23092309
"code": 4082
23102310
},
2311+
"Type parameter '{0}' of exported type alias has or is using private name '{1}'.": {
2312+
"category": "Error",
2313+
"code": 4083
2314+
},
23112315
"Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.": {
23122316
"category": "Message",
23132317
"code": 4090

src/compiler/program.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ namespace ts {
364364

365365
if (typeReferences.length) {
366366
// This containingFilename needs to match with the one used in managed-side
367-
const containingFilename = combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts");
367+
const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
368+
const containingFilename = combinePaths(containingDirectory, "__inferred type names__.ts");
368369
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
369370
for (let i = 0; i < typeReferences.length; i++) {
370371
processTypeReferenceDirective(typeReferences[i], resolutions[i]);

src/compiler/types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,8 +2985,6 @@ namespace ts {
29852985
/* @internal */
29862986
resolvedIndexType: IndexType;
29872987
/* @internal */
2988-
resolvedIndexedAccessTypes: IndexedAccessType[];
2989-
/* @internal */
29902988
isThisType?: boolean;
29912989
}
29922990

@@ -2996,7 +2994,7 @@ namespace ts {
29962994

29972995
export interface IndexedAccessType extends Type {
29982996
objectType: Type;
2999-
indexType: TypeParameter;
2997+
indexType: Type;
30002998
}
30012999

30023000
export const enum SignatureKind {

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,30 @@ namespace ts.projectSystem {
23392339
projectService.openExternalProject({ rootFiles: toExternalFiles([f1.path, config.path]), options: {}, projectFileName: projectName });
23402340
projectService.checkNumberOfProjects({ configuredProjects: 1 });
23412341
});
2342+
2343+
it("types should load from config file path if config exists", () => {
2344+
const f1 = {
2345+
path: "/a/b/app.ts",
2346+
content: "let x = 1"
2347+
};
2348+
const config = {
2349+
path: "/a/b/tsconfig.json",
2350+
content: JSON.stringify({ compilerOptions: { types: ["node"], typeRoots: [] } })
2351+
};
2352+
const node = {
2353+
path: "/a/b/node_modules/@types/node/index.d.ts",
2354+
content: "declare var process: any"
2355+
};
2356+
const cwd = {
2357+
path: "/a/c"
2358+
};
2359+
debugger;
2360+
const host = createServerHost([f1, config, node, cwd], { currentDirectory: cwd.path });
2361+
const projectService = createProjectService(host);
2362+
projectService.openClientFile(f1.path);
2363+
projectService.checkNumberOfProjects({ configuredProjects: 1 });
2364+
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, node.path]);
2365+
});
23422366
});
23432367

23442368
describe("add the missing module file for inferred project", () => {

tests/baselines/reference/asiPreventsParsingAsTypeAlias01.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ var Foo;
1010
>Foo : any
1111

1212
type
13-
>type : undefined
13+
>type : any
1414

1515
Foo = string;
16-
>Foo = string : undefined
16+
>Foo = string : any
1717
>Foo : any
18-
>string : undefined
18+
>string : any
1919

tests/baselines/reference/assignEveryTypeToAny.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ var e = undefined;
5959
>undefined : undefined
6060

6161
x = e;
62-
>x = e : undefined
62+
>x = e : any
6363
>x : any
64-
>e : undefined
64+
>e : any
6565

6666
var e2: typeof undefined;
6767
>e2 : any

tests/baselines/reference/capturedLetConstInLoop3.types

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function foo3(x) {
179179
use(v);
180180
>use(v) : any
181181
>use : (a: any) => any
182-
>v : undefined
182+
>v : any
183183
}
184184

185185
function foo4(x) {
@@ -283,8 +283,8 @@ function foo6(x) {
283283
>y : any
284284

285285
var v = x;
286-
>v : undefined
287-
>x : undefined
286+
>v : any
287+
>x : any
288288

289289
(function() { return x + y + v });
290290
>(function() { return x + y + v }) : () => any
@@ -293,7 +293,7 @@ function foo6(x) {
293293
>x + y : any
294294
>x : any
295295
>y : any
296-
>v : undefined
296+
>v : any
297297

298298
(() => x + y + v);
299299
>(() => x + y + v) : () => any
@@ -302,13 +302,13 @@ function foo6(x) {
302302
>x + y : any
303303
>x : any
304304
>y : any
305-
>v : undefined
305+
>v : any
306306
}
307307

308308
use(v)
309309
>use(v) : any
310310
>use : (a: any) => any
311-
>v : undefined
311+
>v : any
312312
}
313313

314314
function foo7(x) {
@@ -321,8 +321,8 @@ function foo7(x) {
321321
>y : any
322322

323323
var v = x;
324-
>v : undefined
325-
>x : undefined
324+
>v : any
325+
>x : any
326326

327327
(function() { return x + y + v });
328328
>(function() { return x + y + v }) : () => any
@@ -331,7 +331,7 @@ function foo7(x) {
331331
>x + y : any
332332
>x : any
333333
>y : any
334-
>v : undefined
334+
>v : any
335335

336336
(() => x + y + v);
337337
>(() => x + y + v) : () => any
@@ -340,7 +340,7 @@ function foo7(x) {
340340
>x + y : any
341341
>x : any
342342
>y : any
343-
>v : undefined
343+
>v : any
344344

345345
} while (1 === 1);
346346
>1 === 1 : boolean
@@ -350,7 +350,7 @@ function foo7(x) {
350350
use(v);
351351
>use(v) : any
352352
>use : (a: any) => any
353-
>v : undefined
353+
>v : any
354354
}
355355

356356

@@ -574,7 +574,7 @@ function foo3_c(x) {
574574
use(v);
575575
>use(v) : any
576576
>use : (a: any) => any
577-
>v : undefined
577+
>v : any
578578
}
579579

580580
function foo4_c(x) {

tests/baselines/reference/capturedLetConstInLoop3_ES6.types

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function foo3(x) {
180180
use(v);
181181
>use(v) : any
182182
>use : (a: any) => any
183-
>v : undefined
183+
>v : any
184184
}
185185

186186
function foo4(x) {
@@ -284,8 +284,8 @@ function foo6(x) {
284284
>y : any
285285

286286
var v = x;
287-
>v : undefined
288-
>x : undefined
287+
>v : any
288+
>x : any
289289

290290
(function() { return x + y + v });
291291
>(function() { return x + y + v }) : () => any
@@ -294,7 +294,7 @@ function foo6(x) {
294294
>x + y : any
295295
>x : any
296296
>y : any
297-
>v : undefined
297+
>v : any
298298

299299
(() => x + y + v);
300300
>(() => x + y + v) : () => any
@@ -303,13 +303,13 @@ function foo6(x) {
303303
>x + y : any
304304
>x : any
305305
>y : any
306-
>v : undefined
306+
>v : any
307307
}
308308

309309
use(v)
310310
>use(v) : any
311311
>use : (a: any) => any
312-
>v : undefined
312+
>v : any
313313
}
314314

315315
function foo7(x) {
@@ -322,8 +322,8 @@ function foo7(x) {
322322
>y : any
323323

324324
var v = x;
325-
>v : undefined
326-
>x : undefined
325+
>v : any
326+
>x : any
327327

328328
(function() { return x + y + v });
329329
>(function() { return x + y + v }) : () => any
@@ -332,7 +332,7 @@ function foo7(x) {
332332
>x + y : any
333333
>x : any
334334
>y : any
335-
>v : undefined
335+
>v : any
336336

337337
(() => x + y + v);
338338
>(() => x + y + v) : () => any
@@ -341,7 +341,7 @@ function foo7(x) {
341341
>x + y : any
342342
>x : any
343343
>y : any
344-
>v : undefined
344+
>v : any
345345

346346
} while (1 === 1);
347347
>1 === 1 : boolean
@@ -351,7 +351,7 @@ function foo7(x) {
351351
use(v);
352352
>use(v) : any
353353
>use : (a: any) => any
354-
>v : undefined
354+
>v : any
355355
}
356356

357357

@@ -575,7 +575,7 @@ function foo3_c(x) {
575575
use(v);
576576
>use(v) : any
577577
>use : (a: any) => any
578-
>v : undefined
578+
>v : any
579579
}
580580

581581
function foo4_c(x) {

0 commit comments

Comments
 (0)