Skip to content

Commit 1218f29

Browse files
committed
Merge branch 'master' into always-check-class-extends
2 parents dabf2a6 + 0ddd847 commit 1218f29

File tree

10 files changed

+107
-11
lines changed

10 files changed

+107
-11
lines changed

scripts/open-user-pr.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function padNum(number: number) {
2020
const userName = process.env.GH_USERNAME;
2121
const reviewers = ["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
@@ -43,7 +43,7 @@ gh.pulls.create({
4343
maintainer_can_modify: true,
4444
title: `🤖 User test baselines have changed`,
4545
head: `${userName}:${branchName}`,
46-
base: "master",
46+
base: process.env.TARGET_BRANCH || "master",
4747
body:
4848
`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).

src/compiler/checker.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ namespace ts {
392392
const literalTypes = createMap<LiteralType>();
393393
const indexedAccessTypes = createMap<IndexedAccessType>();
394394
const conditionalTypes = createMap<Type>();
395+
const substitutionTypes = createMap<SubstitutionType>();
395396
const evolvingArrayTypes: EvolvingArrayType[] = [];
396397
const undefinedProperties = createMap<Symbol>() as UnderscoreEscapedMap<Symbol>;
397398

@@ -8914,9 +8915,15 @@ namespace ts {
89148915
if (substitute.flags & TypeFlags.AnyOrUnknown) {
89158916
return typeVariable;
89168917
}
8918+
const id = `${getTypeId(typeVariable)}>${getTypeId(substitute)}`;
8919+
const cached = substitutionTypes.get(id);
8920+
if (cached) {
8921+
return cached;
8922+
}
89178923
const result = <SubstitutionType>createType(TypeFlags.Substitution);
89188924
result.typeVariable = typeVariable;
89198925
result.substitute = substitute;
8926+
substitutionTypes.set(id, result);
89208927
return result;
89218928
}
89228929

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/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/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/inlinedAliasAssignableToConstraintSameAsAlias.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class A {
3131
>z : A[]
3232

3333
whereRelated< // Works // Type is same as A1, but is not assignable to type A
34-
>whereRelated : <RF extends RelationFields = RelationFields, N extends "x" | "y" | "z" = "x" | "y" | "z", A1 extends A = RF[N] extends A[] ? RF[N][0] : never, A2 extends A = ShouldA<RF, N>>() => number
34+
>whereRelated : <RF extends RelationFields = RelationFields, N extends "x" | "y" | "z" = "x" | "y" | "z", A1 extends A = RF[N] extends A[] ? RF[N][0] : never, A2 extends A = RF[N] extends A[] ? RF[N][0] : never>() => number
3535

3636
RF extends RelationFields = RelationFields,
3737
N extends Name = Name,

tests/baselines/reference/user/TypeScript-React-Native-Starter.log

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Exit Code: 1
22
Standard output:
3-
node_modules/@types/node/globals.d.ts(163,13): error TS2451: Cannot redeclare block-scoped variable 'global'.
4-
node_modules/@types/node/globals.d.ts(217,13): error TS2300: Duplicate identifier 'require'.
5-
node_modules/@types/react-native/index.d.ts(8958,11): error TS2451: Cannot redeclare block-scoped variable 'global'.
6-
node_modules/@types/react-native/index.d.ts(8959,14): error TS2300: Duplicate identifier 'require'.
3+
node_modules/@types/react-native/index.d.ts(3425,42): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
4+
node_modules/@types/react-native/index.d.ts(3438,42): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
5+
node_modules/@types/react-native/index.d.ts(8745,18): error TS2717: Subsequent property declarations must have the same type. Property 'geolocation' must be of type 'Geolocation', but here has type 'GeolocationStatic'.
6+
node_modules/@types/react/index.d.ts(379,23): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later.
77

88

99

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"types": ["jest"]
2+
"types": ["jest"],
3+
"path": "TypeScript-React-Native-Starter/ExampleProject"
34
}

0 commit comments

Comments
 (0)