Skip to content

Commit 3bd49e4

Browse files
committed
Add another test case and change condition for ns merge to require signature or export content
1 parent 3005f18 commit 3bd49e4

File tree

5 files changed

+170
-2
lines changed

5 files changed

+170
-2
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5778,6 +5778,7 @@ namespace ts {
57785778
return getObjectFlags(typeToSerialize) & (ObjectFlags.Anonymous | ObjectFlags.Mapped) &&
57795779
!getIndexInfoOfType(typeToSerialize, IndexKind.String) &&
57805780
!getIndexInfoOfType(typeToSerialize, IndexKind.Number) &&
5781+
!!(length(getPropertiesOfType(typeToSerialize)) || length(getSignaturesOfType(typeToSerialize, SignatureKind.Call))) &&
57815782
!length(getSignaturesOfType(typeToSerialize, SignatureKind.Construct)) && // TODO: could probably serialize as function + ns + class, now that that's OK
57825783
!getDeclarationWithTypeAnnotation(hostSymbol) &&
57835784
!(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, d => getSourceFileOfNode(d) !== ctxSrc)) &&

tests/baselines/reference/jsDeclarationsReactComponents.js

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,25 @@ TabbedShowLayout.defaultProps = {
7575
tabs: "default value"
7676
};
7777

78-
export default TabbedShowLayout;
79-
78+
export default TabbedShowLayout;
79+
//// [jsDeclarationsReactComponents5.jsx]
80+
import React from 'react';
81+
import PropTypes from 'prop-types';
82+
83+
function Tree({ allowDropOnRoot }) {
84+
return <div />
85+
}
86+
87+
Tree.propTypes = {
88+
classes: PropTypes.object,
89+
};
90+
91+
Tree.defaultProps = {
92+
classes: {},
93+
parentSource: 'parent_id',
94+
};
95+
96+
export default Tree;
8097

8198
//// [jsDeclarationsReactComponents1.js]
8299
"use strict";
@@ -145,6 +162,26 @@ TabbedShowLayout.defaultProps = {
145162
tabs: "default value"
146163
};
147164
exports.default = TabbedShowLayout;
165+
//// [jsDeclarationsReactComponents5.js]
166+
"use strict";
167+
var __importDefault = (this && this.__importDefault) || function (mod) {
168+
return (mod && mod.__esModule) ? mod : { "default": mod };
169+
};
170+
Object.defineProperty(exports, "__esModule", { value: true });
171+
var react_1 = __importDefault(require("react"));
172+
var prop_types_1 = __importDefault(require("prop-types"));
173+
function Tree(_a) {
174+
var allowDropOnRoot = _a.allowDropOnRoot;
175+
return react_1.default.createElement("div", null);
176+
}
177+
Tree.propTypes = {
178+
classes: prop_types_1.default.object,
179+
};
180+
Tree.defaultProps = {
181+
classes: {},
182+
parentSource: 'parent_id',
183+
};
184+
exports.default = Tree;
148185

149186

150187
//// [jsDeclarationsReactComponents1.d.ts]
@@ -190,3 +227,20 @@ declare namespace TabbedShowLayout {
190227
export const tabs: string;
191228
}
192229
}
230+
//// [jsDeclarationsReactComponents5.d.ts]
231+
/// <reference path="../..react16.d.ts" />
232+
export default Tree;
233+
declare function Tree({ allowDropOnRoot }: {
234+
allowDropOnRoot: any;
235+
}): JSX.Element;
236+
declare namespace Tree {
237+
export namespace propTypes {
238+
export const classes: PropTypes.Requireable<object>;
239+
}
240+
export namespace defaultProps {
241+
const classes_1: {};
242+
export { classes_1 as classes };
243+
export const parentSource: string;
244+
}
245+
}
246+
import PropTypes from "prop-types";

tests/baselines/reference/jsDeclarationsReactComponents.symbols

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,47 @@ TabbedShowLayout.defaultProps = {
153153
export default TabbedShowLayout;
154154
>TabbedShowLayout : Symbol(TabbedShowLayout, Decl(jsDeclarationsReactComponents4.jsx, 1, 5), Decl(jsDeclarationsReactComponents4.jsx, 7, 2))
155155

156+
=== tests/cases/conformance/jsdoc/declarations/jsDeclarationsReactComponents5.jsx ===
157+
import React from 'react';
158+
>React : Symbol(React, Decl(jsDeclarationsReactComponents5.jsx, 0, 6))
159+
160+
import PropTypes from 'prop-types';
161+
>PropTypes : Symbol(PropTypes, Decl(jsDeclarationsReactComponents5.jsx, 1, 6))
162+
163+
function Tree({ allowDropOnRoot }) {
164+
>Tree : Symbol(Tree, Decl(jsDeclarationsReactComponents5.jsx, 1, 35), Decl(jsDeclarationsReactComponents5.jsx, 5, 1), Decl(jsDeclarationsReactComponents5.jsx, 9, 2))
165+
>allowDropOnRoot : Symbol(allowDropOnRoot, Decl(jsDeclarationsReactComponents5.jsx, 3, 15))
166+
167+
return <div />
168+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2420, 114))
169+
}
170+
171+
Tree.propTypes = {
172+
>Tree.propTypes : Symbol(Tree.propTypes, Decl(jsDeclarationsReactComponents5.jsx, 5, 1))
173+
>Tree : Symbol(Tree, Decl(jsDeclarationsReactComponents5.jsx, 1, 35), Decl(jsDeclarationsReactComponents5.jsx, 5, 1), Decl(jsDeclarationsReactComponents5.jsx, 9, 2))
174+
>propTypes : Symbol(Tree.propTypes, Decl(jsDeclarationsReactComponents5.jsx, 5, 1))
175+
176+
classes: PropTypes.object,
177+
>classes : Symbol(classes, Decl(jsDeclarationsReactComponents5.jsx, 7, 18))
178+
>PropTypes.object : Symbol(PropTypes.object, Decl(react16.d.ts, 65, 16))
179+
>PropTypes : Symbol(PropTypes, Decl(jsDeclarationsReactComponents5.jsx, 1, 6))
180+
>object : Symbol(PropTypes.object, Decl(react16.d.ts, 65, 16))
181+
182+
};
183+
184+
Tree.defaultProps = {
185+
>Tree.defaultProps : Symbol(Tree.defaultProps, Decl(jsDeclarationsReactComponents5.jsx, 9, 2))
186+
>Tree : Symbol(Tree, Decl(jsDeclarationsReactComponents5.jsx, 1, 35), Decl(jsDeclarationsReactComponents5.jsx, 5, 1), Decl(jsDeclarationsReactComponents5.jsx, 9, 2))
187+
>defaultProps : Symbol(Tree.defaultProps, Decl(jsDeclarationsReactComponents5.jsx, 9, 2))
188+
189+
classes: {},
190+
>classes : Symbol(classes, Decl(jsDeclarationsReactComponents5.jsx, 11, 21))
191+
192+
parentSource: 'parent_id',
193+
>parentSource : Symbol(parentSource, Decl(jsDeclarationsReactComponents5.jsx, 12, 16))
194+
195+
};
196+
197+
export default Tree;
198+
>Tree : Symbol(Tree, Decl(jsDeclarationsReactComponents5.jsx, 1, 35), Decl(jsDeclarationsReactComponents5.jsx, 5, 1), Decl(jsDeclarationsReactComponents5.jsx, 9, 2))
199+

tests/baselines/reference/jsDeclarationsReactComponents.types

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,54 @@ TabbedShowLayout.defaultProps = {
182182
export default TabbedShowLayout;
183183
>TabbedShowLayout : { (prop: { className: string; }): JSX.Element; defaultProps: { tabs: string; }; }
184184

185+
=== tests/cases/conformance/jsdoc/declarations/jsDeclarationsReactComponents5.jsx ===
186+
import React from 'react';
187+
>React : typeof React
188+
189+
import PropTypes from 'prop-types';
190+
>PropTypes : typeof PropTypes
191+
192+
function Tree({ allowDropOnRoot }) {
193+
>Tree : typeof Tree
194+
>allowDropOnRoot : any
195+
196+
return <div />
197+
><div /> : JSX.Element
198+
>div : any
199+
}
200+
201+
Tree.propTypes = {
202+
>Tree.propTypes = { classes: PropTypes.object,} : { classes: PropTypes.Requireable<object>; }
203+
>Tree.propTypes : { classes: PropTypes.Requireable<object>; }
204+
>Tree : typeof Tree
205+
>propTypes : { classes: PropTypes.Requireable<object>; }
206+
>{ classes: PropTypes.object,} : { classes: PropTypes.Requireable<object>; }
207+
208+
classes: PropTypes.object,
209+
>classes : PropTypes.Requireable<object>
210+
>PropTypes.object : PropTypes.Requireable<object>
211+
>PropTypes : typeof PropTypes
212+
>object : PropTypes.Requireable<object>
213+
214+
};
215+
216+
Tree.defaultProps = {
217+
>Tree.defaultProps = { classes: {}, parentSource: 'parent_id',} : { classes: {}; parentSource: string; }
218+
>Tree.defaultProps : { classes: {}; parentSource: string; }
219+
>Tree : typeof Tree
220+
>defaultProps : { classes: {}; parentSource: string; }
221+
>{ classes: {}, parentSource: 'parent_id',} : { classes: {}; parentSource: string; }
222+
223+
classes: {},
224+
>classes : {}
225+
>{} : {}
226+
227+
parentSource: 'parent_id',
228+
>parentSource : string
229+
>'parent_id' : "parent_id"
230+
231+
};
232+
233+
export default Tree;
234+
>Tree : typeof Tree
235+

tests/cases/conformance/jsdoc/declarations/jsDeclarationsReactComponents.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,21 @@ TabbedShowLayout.defaultProps = {
8383
};
8484

8585
export default TabbedShowLayout;
86+
// @filename: jsDeclarationsReactComponents5.jsx
87+
import React from 'react';
88+
import PropTypes from 'prop-types';
89+
90+
function Tree({ allowDropOnRoot }) {
91+
return <div />
92+
}
93+
94+
Tree.propTypes = {
95+
classes: PropTypes.object,
96+
};
97+
98+
Tree.defaultProps = {
99+
classes: {},
100+
parentSource: 'parent_id',
101+
};
102+
103+
export default Tree;

0 commit comments

Comments
 (0)