Skip to content

Commit c9f44f5

Browse files
committed
Merge branch 'master' into update-dom-042019
2 parents 1e7482a + 2c9f7e6 commit c9f44f5

File tree

175 files changed

+2370
-1112
lines changed

Some content is hidden

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

175 files changed

+2370
-1112
lines changed

scripts/open-user-pr.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ function padNum(number: number) {
1818
}
1919

2020
const userName = process.env.GH_USERNAME;
21-
const reviewers = ["weswigham", "sandersn", "RyanCavanaugh"]
21+
const reviewers = process.env.requesting_user ? [process.env.requesting_user] : ["weswigham", "sandersn", "RyanCavanaugh"];
2222
const now = new Date();
23-
const branchName = `user-update-${now.getFullYear()}${padNum(now.getMonth())}${padNum(now.getDay())}`;
23+
const branchName = `user-update-${process.env.TARGET_FORK}-${now.getFullYear()}${padNum(now.getMonth())}${padNum(now.getDay())}${process.env.TARGET_BRANCH ? "-" + process.env.TARGET_BRANCH : ""}`;
2424
const remoteUrl = `https://${process.argv[2]}@github.com/${userName}/TypeScript.git`;
2525
runSequence([
2626
["git", ["checkout", "."]], // reset any changes
@@ -41,23 +41,33 @@ gh.pulls.create({
4141
owner: process.env.TARGET_FORK,
4242
repo: "TypeScript",
4343
maintainer_can_modify: true,
44-
title: `🤖 User test baselines have changed`,
44+
title: `🤖 User test baselines have changed` + (process.env.TARGET_BRANCH ? ` for ${process.env.TARGET_BRANCH}` : ""),
4545
head: `${userName}:${branchName}`,
46-
base: "master",
46+
base: process.env.TARGET_BRANCH || "master",
4747
body:
48-
`Please review the diff and merge if no changes are unexpected.
48+
`${process.env.source_issue ? `This test run was triggerd by a request on https://github.com/Microsoft/TypeScript/pull/${process.env.source_issue} `+"\n" : ""}Please review the diff and merge if no changes are unexpected.
4949
You can view the build log [here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary).
5050
5151
cc ${reviewers.map(r => "@" + r).join(" ")}`,
52-
}).then(r => {
52+
}).then(async r => {
5353
const num = r.data.number;
5454
console.log(`Pull request ${num} created.`);
55-
return gh.pulls.createReviewRequest({
56-
owner: process.env.TARGET_FORK,
57-
repo: "TypeScript",
58-
number: num,
59-
reviewers,
60-
});
55+
if (!process.env.source_issue) {
56+
await gh.pulls.createReviewRequest({
57+
owner: process.env.TARGET_FORK,
58+
repo: "TypeScript",
59+
number: num,
60+
reviewers,
61+
});
62+
}
63+
else {
64+
await gh.issues.createComment({
65+
number: +process.env.source_issue,
66+
owner: "Microsoft",
67+
repo: "TypeScript",
68+
body: `The user suite test run you requested has finished and _failed_. I've opened a [PR with the baseline diff from master](${r.data.html_url}).`
69+
});
70+
}
6171
}).then(() => {
6272
console.log(`Reviewers requested, done.`);
6373
}).catch(e => {

src/compiler/checker.ts

Lines changed: 84 additions & 30 deletions
Large diffs are not rendered by default.

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ namespace ts {
11341134
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: string): boolean {
11351135
const resolutionToFile = getResolvedModule(oldSourceFile!, moduleName);
11361136
const resolvedFile = resolutionToFile && oldProgram!.getSourceFile(resolutionToFile.resolvedFileName);
1137-
if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) {
1137+
if (resolutionToFile && resolvedFile) {
11381138
// In the old program, we resolved to an ambient module that was in the same
11391139
// place as we expected to find an actual module file.
11401140
// We actually need to return 'false' here even though this seems like a 'true' case

src/harness/fourslash.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4507,6 +4507,7 @@ namespace FourSlashInterface {
45074507
typeEntry("Record"),
45084508
typeEntry("Exclude"),
45094509
typeEntry("Extract"),
4510+
typeEntry("Omit"),
45104511
typeEntry("NonNullable"),
45114512
typeEntry("Parameters"),
45124513
typeEntry("ConstructorParameters"),

src/lib/es5.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,11 @@ type Exclude<T, U> = T extends U ? never : T;
14431443
*/
14441444
type Extract<T, U> = T extends U ? T : never;
14451445

1446+
/**
1447+
* Construct a type with the properties of T except for those in type K.
1448+
*/
1449+
type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
1450+
14461451
/**
14471452
* Exclude null and undefined from T
14481453
*/

src/server/project.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,9 @@ namespace ts.server {
958958
);
959959
const elapsed = timestamp() - start;
960960
this.writeLog(`Finishing updateGraphWorker: Project: ${this.getProjectName()} Version: ${this.getProjectVersion()} structureChanged: ${hasNewProgram} Elapsed: ${elapsed}ms`);
961+
if (this.program !== oldProgram) {
962+
this.print();
963+
}
961964
return hasNewProgram;
962965
}
963966

src/testRunner/externalCompileRunner.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface ExecResult {
1010

1111
interface UserConfig {
1212
types: string[];
13+
path?: string;
1314
}
1415

1516
abstract class ExternalCompileRunnerBase extends RunnerBase {
@@ -57,7 +58,7 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
5758
ts.Debug.assert(!!config.types, "Bad format from test.json: Types field must be present.");
5859
types = config.types;
5960

60-
cwd = submoduleDir;
61+
cwd = config.path ? path.join(cwd, config.path) : submoduleDir;
6162
}
6263
if (fs.existsSync(path.join(cwd, "package.json"))) {
6364
if (fs.existsSync(path.join(cwd, "package-lock.json"))) {

src/testRunner/unittests/services/transpile.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,5 +445,13 @@ var x = 0;`, {
445445
}
446446
}
447447
});
448+
449+
transpilesCorrectly("Supports readonly keyword for arrays", "let x: readonly string[];", {
450+
options: { compilerOptions: { module: ModuleKind.CommonJS } }
451+
});
452+
453+
transpilesCorrectly("Supports 'as const' arrays", `([] as const).forEach(k => console.log(k));`, {
454+
options: { compilerOptions: { module: ModuleKind.CommonJS } }
455+
});
448456
});
449457
}

src/testRunner/unittests/tsserver/projectErrors.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,90 @@ namespace ts.projectSystem {
479479
session.clearMessages();
480480
}
481481
});
482+
483+
it("Correct errors when resolution resolves to file that has same ambient module and is also module", () => {
484+
const projectRootPath = "/users/username/projects/myproject";
485+
const aFile: File = {
486+
path: `${projectRootPath}/src/a.ts`,
487+
content: `import * as myModule from "@custom/plugin";
488+
function foo() {
489+
// hello
490+
}`
491+
};
492+
const config: File = {
493+
path: `${projectRootPath}/tsconfig.json`,
494+
content: JSON.stringify({ include: ["src"] })
495+
};
496+
const plugin: File = {
497+
path: `${projectRootPath}/node_modules/@custom/plugin/index.d.ts`,
498+
content: `import './proposed';
499+
declare module '@custom/plugin' {
500+
export const version: string;
501+
}`
502+
};
503+
const pluginProposed: File = {
504+
path: `${projectRootPath}/node_modules/@custom/plugin/proposed.d.ts`,
505+
content: `declare module '@custom/plugin' {
506+
export const bar = 10;
507+
}`
508+
};
509+
const files = [libFile, aFile, config, plugin, pluginProposed];
510+
const host = createServerHost(files);
511+
const session = createSession(host, { canUseEvents: true });
512+
const service = session.getProjectService();
513+
openFilesForSession([aFile], session);
514+
515+
checkNumberOfProjects(service, { configuredProjects: 1 });
516+
session.clearMessages();
517+
checkErrors();
518+
519+
session.executeCommandSeq<protocol.ChangeRequest>({
520+
command: protocol.CommandTypes.Change,
521+
arguments: {
522+
file: aFile.path,
523+
line: 3,
524+
offset: 8,
525+
endLine: 3,
526+
endOffset: 8,
527+
insertString: "o"
528+
}
529+
});
530+
checkErrors();
531+
532+
function checkErrors() {
533+
host.checkTimeoutQueueLength(0);
534+
const expectedSequenceId = session.getNextSeq();
535+
session.executeCommandSeq<protocol.GeterrRequest>({
536+
command: server.CommandNames.Geterr,
537+
arguments: {
538+
delay: 0,
539+
files: [aFile.path],
540+
}
541+
});
542+
543+
host.checkTimeoutQueueLengthAndRun(1);
544+
545+
checkErrorMessage(session, "syntaxDiag", { file: aFile.path, diagnostics: [] }, /*isMostRecent*/ true);
546+
session.clearMessages();
547+
548+
host.runQueuedImmediateCallbacks(1);
549+
550+
checkErrorMessage(session, "semanticDiag", { file: aFile.path, diagnostics: [] });
551+
session.clearMessages();
552+
553+
host.runQueuedImmediateCallbacks(1);
554+
555+
checkErrorMessage(session, "suggestionDiag", {
556+
file: aFile.path,
557+
diagnostics: [
558+
createDiagnostic({ line: 1, offset: 1 }, { line: 1, offset: 44 }, Diagnostics._0_is_declared_but_its_value_is_never_read, ["myModule"], "suggestion", /*reportsUnnecessary*/ true),
559+
createDiagnostic({ line: 2, offset: 10 }, { line: 2, offset: 13 }, Diagnostics._0_is_declared_but_its_value_is_never_read, ["foo"], "suggestion", /*reportsUnnecessary*/ true)
560+
],
561+
});
562+
checkCompleteEvent(session, 2, expectedSequenceId);
563+
session.clearMessages();
564+
}
565+
});
482566
});
483567

484568
describe("unittests:: tsserver:: Project Errors for Configure file diagnostics events", () => {

tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.types

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,24 +136,24 @@ class C2<T, U> {
136136
}
137137
}
138138
var r6 = (new C2()).f<number>(1, '');
139-
>r6 : {}
140-
>(new C2()).f<number>(1, '') : {}
141-
>(new C2()).f : (x: {}, y: {}) => {}
142-
>(new C2()) : C2<{}, {}>
143-
>new C2() : C2<{}, {}>
139+
>r6 : unknown
140+
>(new C2()).f<number>(1, '') : unknown
141+
>(new C2()).f : (x: unknown, y: unknown) => unknown
142+
>(new C2()) : C2<unknown, unknown>
143+
>new C2() : C2<unknown, unknown>
144144
>C2 : typeof C2
145-
>f : (x: {}, y: {}) => {}
145+
>f : (x: unknown, y: unknown) => unknown
146146
>1 : 1
147147
>'' : ""
148148

149149
var r6b = (new C2()).f<number, string, number>(1, '');
150-
>r6b : {}
151-
>(new C2()).f<number, string, number>(1, '') : {}
152-
>(new C2()).f : (x: {}, y: {}) => {}
153-
>(new C2()) : C2<{}, {}>
154-
>new C2() : C2<{}, {}>
150+
>r6b : unknown
151+
>(new C2()).f<number, string, number>(1, '') : unknown
152+
>(new C2()).f : (x: unknown, y: unknown) => unknown
153+
>(new C2()) : C2<unknown, unknown>
154+
>new C2() : C2<unknown, unknown>
155155
>C2 : typeof C2
156-
>f : (x: {}, y: {}) => {}
156+
>f : (x: unknown, y: unknown) => unknown
157157
>1 : 1
158158
>'' : ""
159159

tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.types

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ class C2<T> {
8383
}
8484
}
8585
var r6 = (new C2()).f(1);
86-
>r6 : {}
87-
>(new C2()).f(1) : {}
88-
>(new C2()).f : (x: {}) => {}
89-
>(new C2()) : C2<{}>
90-
>new C2() : C2<{}>
86+
>r6 : unknown
87+
>(new C2()).f(1) : unknown
88+
>(new C2()).f : (x: unknown) => unknown
89+
>(new C2()) : C2<unknown>
90+
>new C2() : C2<unknown>
9191
>C2 : typeof C2
92-
>f : (x: {}) => {}
92+
>f : (x: unknown) => unknown
9393
>1 : 1
9494

9595
interface I2<T> {

0 commit comments

Comments
 (0)