Skip to content

Commit c9d2894

Browse files
authored
fix(2047): Incomplete declaration emit of callback tag with no return tag (#2100)
1 parent 8da7fc7 commit c9d2894

9 files changed

+10
-134
lines changed

internal/parser/reparser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsD
132132
case ast.KindConstructor:
133133
signature = p.factory.NewConstructorDeclaration(clonedModifiers, nil, nil, nil, nil, nil)
134134
case ast.KindJSDocCallbackTag:
135-
signature = p.factory.NewFunctionTypeNode(nil, nil, nil)
135+
signature = p.factory.NewFunctionTypeNode(nil, nil, p.factory.NewKeywordTypeNode(ast.KindAnyKeyword))
136136
default:
137137
panic("Unexpected kind " + fun.Kind.String())
138138
}

testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ declare const example2: {
139139
constructor: () => void;
140140
};
141141
declare function evaluate(): any;
142-
type callback = (error: any, result: any) ;
142+
type callback = (error: any, result: any) => any;
143143
declare const example3: {
144144
/**
145145
* @overload evaluate(options = {}, [callback])
@@ -156,65 +156,3 @@ declare const example3: {
156156
*/
157157
evaluate: (options: any, callback: any) => void;
158158
};
159-
160-
161-
//// [DtsFileErrors]
162-
163-
164-
dist/jsFileAlternativeUseOfOverloadTag.d.ts(34,43): error TS1005: '=>' expected.
165-
166-
167-
==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ====
168-
declare function Example1(value: any): any;
169-
declare const example1: {
170-
/**
171-
* @overload Example1(value)
172-
* Creates Example1
173-
* @param value [String]
174-
*/
175-
constructor: (value: any, options: any) => void;
176-
};
177-
declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any;
178-
declare function Example2(): any;
179-
declare const example2: {
180-
/**
181-
* Example 2
182-
*
183-
* @overload Example2(value)
184-
* Creates Example2
185-
* @param value [String]
186-
* @param secretAccessKey [String]
187-
* @param sessionToken [String]
188-
* @example Creates with string value
189-
* const example = new Example('');
190-
* @overload Example2(options)
191-
* Creates Example2
192-
* @option options value [String]
193-
* @example Creates with options object
194-
* const example = new Example2({
195-
* value: '',
196-
* });
197-
*/
198-
constructor: () => void;
199-
};
200-
declare function evaluate(): any;
201-
type callback = (error: any, result: any) ;
202-
~
203-
!!! error TS1005: '=>' expected.
204-
declare const example3: {
205-
/**
206-
* @overload evaluate(options = {}, [callback])
207-
* Evaluate something
208-
* @note Something interesting
209-
* @param options [map]
210-
* @return [string] returns evaluation result
211-
* @return [null] returns nothing if callback provided
212-
* @callback callback function (error, result)
213-
* If callback is provided it will be called with evaluation result
214-
* @param error [Error]
215-
* @param result [String]
216-
* @see callback
217-
*/
218-
evaluate: (options: any, callback: any) => void;
219-
};
220-

testdata/baselines/reference/submodule/compiler/jsFileAlternativeUseOfOverloadTag.js.diff

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
+ constructor: () => void;
8383
+};
8484
+declare function evaluate(): any;
85-
+type callback = (error: any, result: any) ;
85+
+type callback = (error: any, result: any) => any;
8686
+declare const example3: {
8787
/**
8888
* @overload evaluate(options = {}, [callback])
@@ -99,66 +99,4 @@
9999
- */
100100
-type callback = (error: any, result: any) => any;
101101
+ evaluate: (options: any, callback: any) => void;
102-
+};
103-
+
104-
+
105-
+//// [DtsFileErrors]
106-
+
107-
+
108-
+dist/jsFileAlternativeUseOfOverloadTag.d.ts(34,43): error TS1005: '=>' expected.
109-
+
110-
+
111-
+==== dist/jsFileAlternativeUseOfOverloadTag.d.ts (1 errors) ====
112-
+ declare function Example1(value: any): any;
113-
+ declare const example1: {
114-
+ /**
115-
+ * @overload Example1(value)
116-
+ * Creates Example1
117-
+ * @param value [String]
118-
+ */
119-
+ constructor: (value: any, options: any) => void;
120-
+ };
121-
+ declare function Example2(value: any, secretAccessKey: any, sessionToken: any): any;
122-
+ declare function Example2(): any;
123-
+ declare const example2: {
124-
+ /**
125-
+ * Example 2
126-
+ *
127-
+ * @overload Example2(value)
128-
+ * Creates Example2
129-
+ * @param value [String]
130-
+ * @param secretAccessKey [String]
131-
+ * @param sessionToken [String]
132-
+ * @example Creates with string value
133-
+ * const example = new Example('');
134-
+ * @overload Example2(options)
135-
+ * Creates Example2
136-
+ * @option options value [String]
137-
+ * @example Creates with options object
138-
+ * const example = new Example2({
139-
+ * value: '',
140-
+ * });
141-
+ */
142-
+ constructor: () => void;
143-
+ };
144-
+ declare function evaluate(): any;
145-
+ type callback = (error: any, result: any) ;
146-
+ ~
147-
+!!! error TS1005: '=>' expected.
148-
+ declare const example3: {
149-
+ /**
150-
+ * @overload evaluate(options = {}, [callback])
151-
+ * Evaluate something
152-
+ * @note Something interesting
153-
+ * @param options [map]
154-
+ * @return [string] returns evaluation result
155-
+ * @return [null] returns nothing if callback provided
156-
+ * @callback callback function (error, result)
157-
+ * If callback is provided it will be called with evaluation result
158-
+ * @param error [Error]
159-
+ * @param result [String]
160-
+ * @see callback
161-
+ */
162-
+ evaluate: (options: any, callback: any) => void;
163-
+ };
164-
+
102+
+};

testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ declare namespace MyClass {
3838
declare namespace MyClass {
3939
var staticProperty: number;
4040
}
41-
export type DoneCB = (failures: number) ;
41+
export type DoneCB = (failures: number) => any;
4242
/**
4343
* Callback to be invoked when test execution is complete.
4444
*

testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
+declare namespace MyClass {
1919
+ var staticProperty: number;
2020
+}
21-
+export type DoneCB = (failures: number) ;
21+
+export type DoneCB = (failures: number) => any;
2222
/**
2323
* Callback to be invoked when test execution is complete.
2424
- */

testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ declare namespace BaseFactory {
7070
export = BaseFactory;
7171
//// [file.d.ts]
7272
type BaseFactory = import('./base');
73-
type BaseFactoryFactory = (factory: import('./base')) ;
73+
type BaseFactoryFactory = (factory: import('./base')) => any;
7474
/** @typedef {import('./base')} BaseFactory */
7575
/**
7676
* @callback BaseFactoryFactory

testdata/baselines/reference/submodule/conformance/jsDeclarationsParameterTagReusesInputNodeInEmit1.js.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
- };
2626
-};
2727
+type BaseFactory = import('./base');
28-
+type BaseFactoryFactory = (factory: import('./base')) ;
28+
+type BaseFactoryFactory = (factory: import('./base')) => any;
2929
/** @typedef {import('./base')} BaseFactory */
3030
/**
3131
* @callback BaseFactoryFactory

testdata/baselines/reference/submodule/conformance/templateInsideCallback.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function flatMap(array, iterable = identity) {
113113

114114

115115
//// [templateInsideCallback.d.ts]
116-
type Call = () ;
116+
type Call = () => any;
117117
/**
118118
* @typedef Oops
119119
* @template T

testdata/baselines/reference/submodule/conformance/templateInsideCallback.js.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
- * @returns {T[]}
2929
- */
3030
-declare function flatMap(): any;
31-
+type Call = () ;
31+
+type Call = () => any;
3232
/**
3333
* @typedef Oops
3434
* @template T

0 commit comments

Comments
 (0)