Skip to content

Commit 18a4c5b

Browse files
Merge pull request #596 from microsoft/main
Create a new pull request by comparing changes across two branches
2 parents 189223d + cd6c0a0 commit 18a4c5b

File tree

9 files changed

+62
-29
lines changed

9 files changed

+62
-29
lines changed

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7058,7 +7058,7 @@
70587058
"category": "Error",
70597059
"code": 9023
70607060
},
7061-
"Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.": {
7061+
"Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.": {
70627062
"category": "Error",
70637063
"code": 9025
70647064
},

src/compiler/transformers/declarations/diagnostics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ export function createGetIsolatedDeclarationErrors(resolver: EmitResolver): (nod
772772
return createExpressionError(node.initializer);
773773
}
774774
const message = addUndefined ?
775-
Diagnostics.Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_supported_with_isolatedDeclarations :
775+
Diagnostics.Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_its_type_This_is_not_supported_with_isolatedDeclarations :
776776
errorByDeclarationKind[node.kind];
777777
const diag = createDiagnosticForNode(node, message);
778778
const targetStr = getTextOfNode(node.name, /*includeTrivia*/ false);

src/harness/fourslashImpl.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,7 +3069,7 @@ export class TestState {
30693069
private verifyFileContent(fileName: string, text: string) {
30703070
const actual = this.getFileContent(fileName);
30713071
if (actual !== text) {
3072-
throw new Error(`verifyFileContent failed:\n${showTextDiff(text, actual)}`);
3072+
throw new Error(`verifyFileContent in file '${fileName}' failed:\n${showTextDiff(text, actual)}`);
30733073
}
30743074
}
30753075

@@ -3404,10 +3404,11 @@ export class TestState {
34043404
return ts.first(ranges);
34053405
}
34063406

3407-
private verifyTextMatches(actualText: string, includeWhitespace: boolean, expectedText: string) {
3407+
private verifyTextMatches(actualText: string, includeWhitespace: boolean, expectedText: string, fileName?: string) {
34083408
const removeWhitespace = (s: string): string => includeWhitespace ? s : this.removeWhitespace(s);
34093409
if (removeWhitespace(actualText) !== removeWhitespace(expectedText)) {
3410-
this.raiseError(`Actual range text doesn't match expected text.\n${showTextDiff(expectedText, actualText)}`);
3410+
const addFileName = fileName ? ` in file '${fileName}'` : "";
3411+
this.raiseError(`Actual range text${addFileName} doesn't match expected text.\n${showTextDiff(expectedText, actualText)}`);
34113412
}
34123413
}
34133414

@@ -3485,7 +3486,7 @@ export class TestState {
34853486
const newText = ts.textChanges.applyChanges(this.getFileContent(this.activeFile.fileName), change.textChanges);
34863487
const newRange = updateTextRangeForTextChanges(this.getOnlyRange(this.activeFile.fileName), change.textChanges);
34873488
const actualText = newText.slice(newRange.pos, newRange.end);
3488-
this.verifyTextMatches(actualText, /*includeWhitespace*/ true, newRangeContent);
3489+
this.verifyTextMatches(actualText, /*includeWhitespace*/ true, newRangeContent, change.fileName);
34893490
}
34903491
else {
34913492
if (newFileContent === undefined) throw ts.Debug.fail();
@@ -3497,7 +3498,7 @@ export class TestState {
34973498
}
34983499
const oldText = this.tryGetFileContent(change.fileName);
34993500
const newContent = change.isNewFile ? ts.first(change.textChanges).newText : ts.textChanges.applyChanges(oldText!, change.textChanges);
3500-
this.verifyTextMatches(newContent, /*includeWhitespace*/ true, expectedNewContent);
3501+
this.verifyTextMatches(newContent, /*includeWhitespace*/ true, expectedNewContent, change.fileName);
35013502
}
35023503
for (const newFileName in newFileContent) {
35033504
ts.Debug.assert(changes.some(c => c.fileName === newFileName), "No change in file", () => newFileName);

src/lib/es2024.sharedmemory.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface SharedArrayBuffer {
2828
*
2929
* [MDN](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/growable)
3030
*/
31-
get growable(): number;
31+
get growable(): boolean;
3232

3333
/**
3434
* If this SharedArrayBuffer is growable, returns the maximum byte length given during construction; returns the byte length if not.

src/services/codefixes/fixMissingTypeAnnotationOnExports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ const errorCodes = [
135135
Diagnostics.Default_exports_can_t_be_inferred_with_isolatedDeclarations.code,
136136
Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations.code,
137137
Diagnostics.Assigning_properties_to_functions_without_declaring_them_is_not_supported_with_isolatedDeclarations_Add_an_explicit_declaration_for_the_properties_assigned_to_this_function.code,
138-
Diagnostics.Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_it_s_type_This_is_not_supported_with_isolatedDeclarations.code,
138+
Diagnostics.Declaration_emit_for_this_parameter_requires_implicitly_adding_undefined_to_its_type_This_is_not_supported_with_isolatedDeclarations.code,
139139
Diagnostics.Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations.code,
140140
Diagnostics.Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit.code,
141141
];

src/services/navigationBar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ function isSynthesized(node: Node) {
760760
// We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }`
761761
// We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };`
762762
function isOwnChild(n: Node, parent: NavigationBarNode): boolean {
763+
if (n.parent === undefined) return false;
763764
const par = isModuleBlock(n.parent) ? n.parent.parent : n.parent;
764765
return par === parent.node || contains(parent.additionalNodes, par);
765766
}

src/typingsInstaller/nodeTypingsInstaller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { execFileSync } from "child_process";
1+
import { execSync } from "child_process";
22
import * as fs from "fs";
33
import * as path from "path";
44

@@ -172,7 +172,7 @@ class NodeTypingsInstaller extends ts.server.typingsInstaller.TypingsInstaller {
172172
this.log.writeLine(`Exec: ${command}`);
173173
}
174174
try {
175-
const stdout = execFileSync(command, { ...options, encoding: "utf-8" });
175+
const stdout = execSync(command, { ...options, encoding: "utf-8" });
176176
if (this.log.isEnabled()) {
177177
this.log.writeLine(` Succeeded. stdout:${indent(sys.newLine, stdout)}`);
178178
}

tests/baselines/reference/transpile/declarationFunctionDeclarations.d.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ export {};
125125

126126

127127
//// [Diagnostics reported]
128-
fnDecl.ts(12,27): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
129-
fnDecl.ts(16,36): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
130-
fnDecl.ts(20,26): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
131-
fnDecl.ts(24,56): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
132-
fnDecl.ts(28,46): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
133-
fnDecl.ts(32,45): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
134-
fnDecl.ts(37,47): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
135-
fnDecl.ts(41,37): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
136-
fnDecl.ts(45,35): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
128+
fnDecl.ts(12,27): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
129+
fnDecl.ts(16,36): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
130+
fnDecl.ts(20,26): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
131+
fnDecl.ts(24,56): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
132+
fnDecl.ts(28,46): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
133+
fnDecl.ts(32,45): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
134+
fnDecl.ts(37,47): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
135+
fnDecl.ts(41,37): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
136+
fnDecl.ts(45,35): error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
137137

138138

139139
==== fnDecl.ts (9 errors) ====
@@ -150,64 +150,64 @@ fnDecl.ts(45,35): error TS9025: Declaration emit for this parameter requires imp
150150
export function fnDeclHasUndefined(p: T | undefined = [], rParam: string): void { };
151151
export function fnDeclBad(p: T = [], rParam: string): void { };
152152
~~~~~~~~~
153-
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
153+
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
154154
!!! related TS9028 fnDecl.ts:12:27: Add a type annotation to the parameter p.
155155

156156
export const fnExprOk1 = function (array: number[] = [], rParam: string): void { };
157157
export const fnExprOk2 = function (array: T | undefined = [], rParam: string): void { };
158158
export const fnExprBad = function (array: T = [], rParam: string): void { };
159159
~~~~~~~~~~~~~
160-
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
160+
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
161161
!!! related TS9028 fnDecl.ts:16:36: Add a type annotation to the parameter array.
162162

163163
export const arrowOk1 = (array: number[] = [], rParam: string): void => { };
164164
export const arrowOk2 = (array: T | undefined = [], rParam: string): void => { };
165165
export const arrowBad = (array: T = [], rParam: string): void => { };
166166
~~~~~~~~~~~~~
167-
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
167+
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
168168
!!! related TS9028 fnDecl.ts:20:26: Add a type annotation to the parameter array.
169169

170170
export const inObjectLiteralFnExprOk1 = { o: function (array: number[] = [], rParam: string): void { } };
171171
export const inObjectLiteralFnExprOk2 = { o: function (array: T | undefined = [], rParam: string): void { } };
172172
export const inObjectLiteralFnExprBad = { o: function (array: T = [], rParam: string): void { } };
173173
~~~~~~~~~~~~~
174-
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
174+
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
175175
!!! related TS9028 fnDecl.ts:24:56: Add a type annotation to the parameter array.
176176

177177
export const inObjectLiteralArrowOk1 = { o: (array: number[] = [], rParam: string): void => { } };
178178
export const inObjectLiteralArrowOk2 = { o: (array: T | undefined = [], rParam: string): void => { } };
179179
export const inObjectLiteralArrowBad = { o: (array: T = [], rParam: string): void => { } };
180180
~~~~~~~~~~~~~
181-
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
181+
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
182182
!!! related TS9028 fnDecl.ts:28:46: Add a type annotation to the parameter array.
183183

184184
export const inObjectLiteralMethodOk1 = { o(array: number[] = [], rParam: string): void { } };
185185
export const inObjectLiteralMethodOk2 = { o(array: T | undefined = [], rParam: string): void { } };
186186
export const inObjectLiteralMethodBad = { o(array: T = [], rParam: string): void { } };
187187
~~~~~~~~~~~~~
188-
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
188+
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
189189
!!! related TS9028 fnDecl.ts:32:45: Add a type annotation to the parameter array.
190190

191191

192192
export class InClassFnExprOk1 { o = function (array: number[] = [], rParam: string): void { } };
193193
export class InClassFnExprOk2 { o = function (array: T | undefined = [], rParam: string): void { } };
194194
export class InClassFnExprBad { o = function (array: T = [], rParam: string): void { } };
195195
~~~~~~~~~~~~~
196-
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
196+
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
197197
!!! related TS9028 fnDecl.ts:37:47: Add a type annotation to the parameter array.
198198

199199
export class InClassArrowOk1 { o = (array: number[] = [], rParam: string): void => { } };
200200
export class InClassArrowOk2 { o = (array: T | undefined = [], rParam: string): void => { } };
201201
export class InClassArrowBad { o = (array: T = [], rParam: string): void => { } };
202202
~~~~~~~~~~~~~
203-
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
203+
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
204204
!!! related TS9028 fnDecl.ts:41:37: Add a type annotation to the parameter array.
205205

206206
export class InClassMethodOk1 { o(array: number[] = [], rParam: string): void { } };
207207
export class InClassMethodOk2 { o(array: T | undefined = [], rParam: string): void { } };
208208
export class InClassMethodBad { o(array: T = [], rParam: string): void { } };
209209
~~~~~~~~~~~~~
210-
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.
210+
!!! error TS9025: Declaration emit for this parameter requires implicitly adding undefined to its type. This is not supported with --isolatedDeclarations.
211211
!!! related TS9028 fnDecl.ts:45:35: Add a type annotation to the parameter array.
212212

213213

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
////function Z() { }
4+
////
5+
////Z.foo = 42
6+
////
7+
////class Z { }
8+
9+
verify.navigationTree({
10+
text: "<global>",
11+
kind: "script",
12+
childItems: [
13+
{
14+
text: "Z",
15+
kind: "class",
16+
childItems: [
17+
{
18+
text: "constructor",
19+
kind: "constructor"
20+
},
21+
{
22+
text: "foo"
23+
}
24+
]
25+
},
26+
{
27+
text: "Z",
28+
kind: "class"
29+
}
30+
]
31+
});

0 commit comments

Comments
 (0)