Skip to content

Commit dcec37e

Browse files
authored
fix(58399): [isolatedDeclarations][5.5] Autofix does not work when JSX prop contains a dash (#58478)
1 parent fece7f1 commit dcec37e

File tree

4 files changed

+94
-3
lines changed

4 files changed

+94
-3
lines changed

src/services/utilities.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ import {
332332
SemicolonPreference,
333333
setConfigFileInOptions,
334334
setOriginalNode,
335+
setParentRecursive,
335336
setTextRange,
336337
Signature,
337338
SignatureDeclaration,
@@ -3172,7 +3173,7 @@ export function getPrecedingNonSpaceCharacterPosition(text: string, position: nu
31723173
export function getSynthesizedDeepClone<T extends Node | undefined>(node: T, includeTrivia = true): T {
31733174
const clone = node && getSynthesizedDeepCloneWorker(node);
31743175
if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone);
3175-
return clone;
3176+
return setParentRecursive(clone, /*incremental*/ false);
31763177
}
31773178

31783179
/** @internal */

tests/baselines/reference/extractFunction/extractFunction_VariableDeclaration_Writes_Let_LiteralType1.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function f() {
1010

1111
function f() {
1212
let a = 1;
13-
let x: 8 | 10 | 2 = /*RENAME*/newFunction();
13+
let x: 0o10 | 10 | 0b10 = /*RENAME*/newFunction();
1414
a; x;
1515

1616
function newFunction() {
@@ -23,7 +23,7 @@ function f() {
2323

2424
function f() {
2525
let a = 1;
26-
let x: (8 | 10 | 2) | undefined;
26+
let x: (0o10 | 10 | 0b10) | undefined;
2727
({ x, a } = /*RENAME*/newFunction(a));
2828
a; x;
2929
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
// @isolatedDeclarations: true
4+
// @declaration: true
5+
// @moduleResolution: node
6+
// @target: es2018
7+
// @jsx: react-jsx
8+
9+
// @filename: node_modules/react/package.json
10+
////{
11+
//// "name": "react",
12+
//// "types": "index.d.ts",
13+
////}
14+
15+
// @filename: node_modules/react/index.d.ts
16+
////export = React;
17+
////declare namespace JSX {
18+
//// interface Element extends GlobalJSXElement { }
19+
//// interface IntrinsicElements extends GlobalJSXIntrinsicElements { }
20+
////}
21+
////declare namespace React { }
22+
////declare global {
23+
//// namespace JSX {
24+
//// interface Element { }
25+
//// interface IntrinsicElements { [x: string]: any; }
26+
//// }
27+
////}
28+
////interface GlobalJSXElement extends JSX.Element {}
29+
////interface GlobalJSXIntrinsicElements extends JSX.IntrinsicElements {}
30+
31+
// @filename: node_modules/react/jsx-runtime.d.ts
32+
////import './';
33+
34+
// @filename: node_modules/react/jsx-dev-runtime.d.ts
35+
////import './';
36+
37+
// @filename: /a.tsx
38+
////export const x = <div aria-label="label text" />;
39+
40+
goTo.file("/a.tsx");
41+
verify.codeFix({
42+
description: `Add annotation of type 'JSX.Element'`,
43+
index: 0,
44+
newFileContent: 'export const x: JSX.Element = <div aria-label="label text" />;',
45+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
// @isolatedDeclarations: true
4+
// @declaration: true
5+
// @moduleResolution: node
6+
// @target: es2018
7+
// @jsx: react-jsx
8+
9+
// @filename: node_modules/react/package.json
10+
////{
11+
//// "name": "react",
12+
//// "types": "index.d.ts",
13+
////}
14+
15+
// @filename: node_modules/react/index.d.ts
16+
////export = React;
17+
////declare namespace JSX {
18+
//// interface Element extends GlobalJSXElement { }
19+
//// interface IntrinsicElements extends GlobalJSXIntrinsicElements { }
20+
////}
21+
////declare namespace React { }
22+
////declare global {
23+
//// namespace JSX {
24+
//// interface Element { }
25+
//// interface IntrinsicElements { [x: string]: any; }
26+
//// }
27+
////}
28+
////interface GlobalJSXElement extends JSX.Element {}
29+
////interface GlobalJSXIntrinsicElements extends JSX.IntrinsicElements {}
30+
31+
// @filename: node_modules/react/jsx-runtime.d.ts
32+
////import './';
33+
34+
// @filename: node_modules/react/jsx-dev-runtime.d.ts
35+
////import './';
36+
37+
// @filename: /a.tsx
38+
////export const x = <div aria-label="label text" />;
39+
40+
goTo.file("/a.tsx");
41+
verify.codeFix({
42+
description: `Add satisfies and an inline type assertion with 'JSX.Element'`,
43+
index: 1,
44+
newFileContent: 'export const x = (<div aria-label="label text" />) satisfies JSX.Element as JSX.Element;',
45+
});

0 commit comments

Comments
 (0)