Skip to content

Commit b7c8e09

Browse files
committed
Merge branch 'master' into resolveJsonModule
2 parents 03aee92 + da48790 commit b7c8e09

File tree

51 files changed

+182
-119
lines changed

Some content is hidden

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

51 files changed

+182
-119
lines changed

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4927,7 +4927,7 @@
49274927
"category": "Message",
49284928
"code": 95074
49294929
},
4930-
"Convert to named parameters": {
4930+
"Convert parameters to destructured object": {
49314931
"category": "Message",
49324932
"code": 95075
49334933
}

src/compiler/tsbuild.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,13 @@ namespace ts {
347347
return host;
348348
}
349349

350-
export function createSolutionBuilderHost<T extends BuilderProgram = BuilderProgram>(system = sys, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary) {
350+
export function createSolutionBuilderHost<T extends BuilderProgram = EmitAndSemanticDiagnosticsBuilderProgram>(system = sys, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary) {
351351
const host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) as SolutionBuilderHost<T>;
352352
host.reportErrorSummary = reportErrorSummary;
353353
return host;
354354
}
355355

356-
export function createSolutionBuilderWithWatchHost<T extends BuilderProgram = SemanticDiagnosticsBuilderProgram>(system = sys, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter) {
356+
export function createSolutionBuilderWithWatchHost<T extends BuilderProgram = EmitAndSemanticDiagnosticsBuilderProgram>(system = sys, createProgram?: CreateProgram<T>, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter) {
357357
const host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) as SolutionBuilderWithWatchHost<T>;
358358
const watchHost = createWatchHost(system, reportWatchStatus);
359359
copyProperties(host, watchHost);

src/compiler/watch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ namespace ts {
290290
/**
291291
* Creates the watch compiler host that can be extended with config file or root file names and options host
292292
*/
293-
export function createProgramHost<T extends BuilderProgram>(system: System, createProgram: CreateProgram<T> | undefined): ProgramHost<T> {
293+
export function createProgramHost<T extends BuilderProgram = EmitAndSemanticDiagnosticsBuilderProgram>(system: System, createProgram: CreateProgram<T> | undefined): ProgramHost<T> {
294294
const getDefaultLibLocation = memoize(() => getDirectoryPath(normalizePath(system.getExecutingFilePath())));
295295
let host: DirectoryStructureHost = system;
296296
host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!)

src/harness/fakes.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,9 @@ namespace fakes {
476476
assertDiagnosticMessages(...expectedDiagnostics: ExpectedDiagnostic[]) {
477477
const actual = this.diagnostics.slice().map(d => d.messageText as string);
478478
const expected = expectedDiagnostics.map(expectedDiagnosticToText);
479-
assert.deepEqual(actual, expected, "Diagnostic arrays did not match");
479+
assert.deepEqual(actual, expected, `Diagnostic arrays did not match:
480+
Actual: ${JSON.stringify(actual, /*replacer*/ undefined, " ")}
481+
Expected: ${JSON.stringify(expected, /*replacer*/ undefined, " ")}`);
480482
}
481483

482484
printDiagnostics(header = "== Diagnostics ==") {

src/services/completions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,14 @@ namespace ts.Completions {
703703
case SyntaxKind.PropertyAccessExpression:
704704
propertyAccessToConvert = parent as PropertyAccessExpression;
705705
node = propertyAccessToConvert.expression;
706+
if (node.end === contextToken.pos &&
707+
isCallExpression(node) &&
708+
node.getChildCount(sourceFile) &&
709+
last(node.getChildren(sourceFile)).kind !== SyntaxKind.CloseParenToken) {
710+
// This is likely dot from incorrectly parsed call expression and user is starting to write spread
711+
// eg: Math.min(./**/)
712+
return undefined;
713+
}
706714
break;
707715
case SyntaxKind.QualifiedName:
708716
node = (parent as QualifiedName).left;

src/services/findAllReferences.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,9 @@ namespace ts.FindAllReferences.Core {
11961196

11971197
// For `export { foo as bar }`, rename `foo`, but not `bar`.
11981198
if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) {
1199-
const exportKind = referenceLocation.originalKeywordKind === SyntaxKind.DefaultKeyword ? ExportKind.Default : ExportKind.Named;
1199+
const isDefaultExport = referenceLocation.originalKeywordKind === SyntaxKind.DefaultKeyword
1200+
|| exportSpecifier.name.originalKeywordKind === SyntaxKind.DefaultKeyword;
1201+
const exportKind = isDefaultExport ? ExportKind.Default : ExportKind.Named;
12001202
const exportSymbol = Debug.assertDefined(exportSpecifier.symbol);
12011203
const exportInfo = Debug.assertDefined(getExportInfo(exportSymbol, exportKind, state.checker));
12021204
searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state);

src/services/importTracker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ namespace ts.FindAllReferences {
269269
}
270270

271271
/**
272-
* `import x = require("./x") or `import * as x from "./x"`.
272+
* `import x = require("./x")` or `import * as x from "./x"`.
273273
* An `export =` may be imported by this syntax, so it may be a direct import.
274274
* If it's not a direct import, it will be in `indirectUsers`, so we don't have to do anything here.
275275
*/

src/services/refactors/convertToNamedParameters.ts renamed to src/services/refactors/convertParamsToDestructuredObject.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @internal */
2-
namespace ts.refactor.convertToNamedParameters {
3-
const refactorName = "Convert to named parameters";
2+
namespace ts.refactor.convertParamsToDestructuredObject {
3+
const refactorName = "Convert parameters to destructured object";
44
const minimumParameterLength = 2;
55
registerRefactor(refactorName, { getEditsForAction, getAvailableActions });
66

@@ -12,7 +12,7 @@ namespace ts.refactor.convertToNamedParameters {
1212
const functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, context.program.getTypeChecker());
1313
if (!functionDeclaration) return emptyArray;
1414

15-
const description = getLocaleSpecificMessage(Diagnostics.Convert_to_named_parameters);
15+
const description = getLocaleSpecificMessage(Diagnostics.Convert_parameters_to_destructured_object);
1616
return [{
1717
name: refactorName,
1818
description,

src/services/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"refactors/generateGetAccessorAndSetAccessor.ts",
8585
"refactors/moveToNewFile.ts",
8686
"refactors/addOrRemoveBracesToArrowFunction.ts",
87-
"refactors/convertToNamedParameters.ts",
87+
"refactors/convertParamsToDestructuredObject.ts",
8888
"services.ts",
8989
"breakpoints.ts",
9090
"transform.ts",

src/testRunner/unittests/tsbuild/resolveJsonModule.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
namespace ts {
22
describe("unittests:: tsbuild:: with resolveJsonModule option on project resolveJsonModuleAndComposite", () => {
33
let projFs: vfs.FileSystem;
4+
const { time, tick } = getTime();
45
const allExpectedOutputs = ["/src/dist/src/index.js", "/src/dist/src/index.d.ts", "/src/dist/src/hello.json"];
56
before(() => {
6-
projFs = loadProjectFromDisk("tests/projects/resolveJsonModuleAndComposite");
7+
projFs = loadProjectFromDisk("tests/projects/resolveJsonModuleAndComposite", time);
78
});
89

910
after(() => {
@@ -75,6 +76,7 @@ export default hello.hello`);
7576
}
7677
host.clearDiagnostics();
7778
builder.resetBuildContext();
79+
tick();
7880
builder.buildAllProjects();
7981
host.assertDiagnosticMessages(
8082
getExpectedDiagnosticForProjectsInBuild(configFile),
@@ -99,6 +101,7 @@ export default hello.hello`);
99101
}
100102
host.clearDiagnostics();
101103
builder.resetBuildContext();
104+
tick();
102105
builder.buildAllProjects();
103106
host.assertDiagnosticMessages(
104107
getExpectedDiagnosticForProjectsInBuild(configFile),
@@ -108,9 +111,10 @@ export default hello.hello`);
108111
});
109112

110113
describe("unittests:: tsbuild:: with resolveJsonModule option on project importJsonFromProjectReference", () => {
114+
const { time, tick } = getTime();
111115
let projFs: vfs.FileSystem;
112116
before(() => {
113-
projFs = loadProjectFromDisk("tests/projects/importJsonFromProjectReference");
117+
projFs = loadProjectFromDisk("tests/projects/importJsonFromProjectReference", time);
114118
});
115119

116120
after(() => {
@@ -136,6 +140,7 @@ export default hello.hello`);
136140
assert(fs.existsSync(expectedOutput), `Expect file ${expectedOutput} to exist`);
137141
host.clearDiagnostics();
138142
builder.resetBuildContext();
143+
tick();
139144
builder.buildAllProjects();
140145
host.assertDiagnosticMessages(
141146
getExpectedDiagnosticForProjectsInBuild(stringsConfigFile, mainConfigFile, configFile),

0 commit comments

Comments
 (0)