Update annotateWithTypeFromJSDoc tests
1. Object literals are single-line now. 2. Index signatures transform to TS index signatures. 3. The refactoring is only available when it could add types.
This commit is contained in:
parent
f374117858
commit
c13506e70c
4 changed files with 89 additions and 7 deletions
73
tests/cases/fourslash/annotateWithTypeFromJSDoc21.ts
Normal file
73
tests/cases/fourslash/annotateWithTypeFromJSDoc21.ts
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
/// <reference path='fourslash.ts' />
|
||||||
|
// @strict: true
|
||||||
|
/////**
|
||||||
|
//// * @return {number}
|
||||||
|
//// */
|
||||||
|
////function /*1*/f(x, y) {
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
/////**
|
||||||
|
//// * @return {number}
|
||||||
|
//// */
|
||||||
|
////function /*2*/g(x, y): number {
|
||||||
|
//// return 0;
|
||||||
|
////}
|
||||||
|
/////**
|
||||||
|
//// * @param {number} x
|
||||||
|
//// */
|
||||||
|
////function /*3*/h(x: number, y): number {
|
||||||
|
//// return 0;
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
/////**
|
||||||
|
//// * @param {number} x
|
||||||
|
//// * @param {string} y
|
||||||
|
//// */
|
||||||
|
////function /*4*/i(x: number, y: string) {
|
||||||
|
////}
|
||||||
|
/////**
|
||||||
|
//// * @param {number} x
|
||||||
|
//// * @return {boolean}
|
||||||
|
//// */
|
||||||
|
////function /*5*/j(x: number, y): boolean {
|
||||||
|
//// return true;
|
||||||
|
////}
|
||||||
|
|
||||||
|
verify.not.applicableRefactorAvailableAtMarker('2');
|
||||||
|
verify.not.applicableRefactorAvailableAtMarker('3');
|
||||||
|
verify.not.applicableRefactorAvailableAtMarker('4');
|
||||||
|
verify.not.applicableRefactorAvailableAtMarker('5');
|
||||||
|
verify.applicableRefactorAvailableAtMarker('1');
|
||||||
|
verify.fileAfterApplyingRefactorAtMarker('1',
|
||||||
|
`/**
|
||||||
|
* @return {number}
|
||||||
|
*/
|
||||||
|
function f(x, y): number {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number}
|
||||||
|
*/
|
||||||
|
function g(x, y): number {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param {number} x
|
||||||
|
*/
|
||||||
|
function h(x: number, y): number {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} x
|
||||||
|
* @param {string} y
|
||||||
|
*/
|
||||||
|
function i(x: number, y: string) {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param {number} x
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
function j(x: number, y): boolean {
|
||||||
|
return true;
|
||||||
|
}`, 'Annotate with type from JSDoc', 'annotate');
|
14
tests/cases/fourslash/annotateWithTypeFromJSDoc22.ts
Normal file
14
tests/cases/fourslash/annotateWithTypeFromJSDoc22.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/// <reference path='fourslash.ts' />
|
||||||
|
// @strict: true
|
||||||
|
////
|
||||||
|
/////** @param {Object<string, boolean>} sb
|
||||||
|
//// * @param {Object<number, string>} ns */
|
||||||
|
////function /*1*/f(sb, ns) {
|
||||||
|
////}
|
||||||
|
verify.applicableRefactorAvailableAtMarker('1');
|
||||||
|
verify.fileAfterApplyingRefactorAtMarker('1',
|
||||||
|
`
|
||||||
|
/** @param {Object<string, boolean>} sb
|
||||||
|
* @param {Object<number, string>} ns */
|
||||||
|
function f(sb: { [s: string]: boolean; }, ns: { [n: number]: string; }) {
|
||||||
|
}`, 'Annotate with type from JSDoc', 'annotate');
|
|
@ -20,9 +20,6 @@ verify.fileAfterApplyingRefactorAtMarker('1',
|
||||||
* @param alpha - the other best parameter
|
* @param alpha - the other best parameter
|
||||||
* @param {*} beta - I have no idea how this got here
|
* @param {*} beta - I have no idea how this got here
|
||||||
*/
|
*/
|
||||||
function f(x: number, y: {
|
function f(x: number, y: { a: string; b: Date; }, z: string, alpha, beta: any) {
|
||||||
a: string;
|
|
||||||
b: Date;
|
|
||||||
}, z: string, alpha, beta: any) {
|
|
||||||
}`, 'Annotate with type from JSDoc', 'annotate');
|
}`, 'Annotate with type from JSDoc', 'annotate');
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,5 @@ verify.fileAfterApplyingRefactorAtMarker('5',
|
||||||
* @param {number?} gamma
|
* @param {number?} gamma
|
||||||
* @param {number!} delta
|
* @param {number!} delta
|
||||||
*/
|
*/
|
||||||
function f(x: any, y: any, z: number | undefined, alpha: number[], beta: (this: {
|
function f(x: any, y: any, z: number | undefined, alpha: number[], beta: (this: { a: string; }, arg1: string, arg2: number) => boolean, gamma: number | null, delta: number) {
|
||||||
a: string;
|
|
||||||
}, arg1: string, arg2: number) => boolean, gamma: number | null, delta: number) {
|
|
||||||
}`, 'Annotate with type from JSDoc', 'annotate');
|
}`, 'Annotate with type from JSDoc', 'annotate');
|
||||||
|
|
Loading…
Reference in a new issue