-
Notifications
You must be signed in to change notification settings - Fork 12.8k
checkJs: require JSDoc type argument for Array, Object, and Promise in noImplicitAny #32829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
tests/baselines/reference/jsdocArrayObjectPromiseImplicitAny.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
=== tests/cases/compiler/jsdocArrayObjectPromiseImplicitAny.js === | ||
/** @type {Array} */ | ||
var anyArray = [5]; | ||
>anyArray : Symbol(anyArray, Decl(jsdocArrayObjectPromiseImplicitAny.js, 1, 3)) | ||
|
||
/** @type {Array<number>} */ | ||
var numberArray = [5]; | ||
>numberArray : Symbol(numberArray, Decl(jsdocArrayObjectPromiseImplicitAny.js, 4, 3)) | ||
|
||
/** | ||
* @param {Array} arr | ||
* @return {Array} | ||
*/ | ||
function returnAnyArray(arr) { | ||
>returnAnyArray : Symbol(returnAnyArray, Decl(jsdocArrayObjectPromiseImplicitAny.js, 4, 22)) | ||
>arr : Symbol(arr, Decl(jsdocArrayObjectPromiseImplicitAny.js, 10, 24)) | ||
|
||
return arr; | ||
>arr : Symbol(arr, Decl(jsdocArrayObjectPromiseImplicitAny.js, 10, 24)) | ||
} | ||
|
||
/** @type {Promise} */ | ||
var anyPromise = Promise.resolve(5); | ||
>anyPromise : Symbol(anyPromise, Decl(jsdocArrayObjectPromiseImplicitAny.js, 15, 3)) | ||
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) | ||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) | ||
|
||
/** @type {Promise<number>} */ | ||
var numberPromise = Promise.resolve(5); | ||
>numberPromise : Symbol(numberPromise, Decl(jsdocArrayObjectPromiseImplicitAny.js, 18, 3)) | ||
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) | ||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) | ||
|
||
/** | ||
* @param {Promise} pr | ||
* @return {Promise} | ||
*/ | ||
function returnAnyPromise(pr) { | ||
>returnAnyPromise : Symbol(returnAnyPromise, Decl(jsdocArrayObjectPromiseImplicitAny.js, 18, 39)) | ||
>pr : Symbol(pr, Decl(jsdocArrayObjectPromiseImplicitAny.js, 24, 26)) | ||
|
||
return pr; | ||
>pr : Symbol(pr, Decl(jsdocArrayObjectPromiseImplicitAny.js, 24, 26)) | ||
} | ||
|
||
/** @type {Object} */ | ||
var anyObject = {valueOf: 1}; // not an error since assigning to any. | ||
>anyObject : Symbol(anyObject, Decl(jsdocArrayObjectPromiseImplicitAny.js, 29, 3)) | ||
>valueOf : Symbol(valueOf, Decl(jsdocArrayObjectPromiseImplicitAny.js, 29, 17)) | ||
|
||
/** @type {Object<string, number>} */ | ||
var paramedObject = {valueOf: 1}; | ||
>paramedObject : Symbol(paramedObject, Decl(jsdocArrayObjectPromiseImplicitAny.js, 32, 3)) | ||
>valueOf : Symbol(valueOf, Decl(jsdocArrayObjectPromiseImplicitAny.js, 32, 21)) | ||
|
||
/** | ||
* @param {Object} obj | ||
* @return {Object} | ||
*/ | ||
function returnAnyObject(obj) { | ||
>returnAnyObject : Symbol(returnAnyObject, Decl(jsdocArrayObjectPromiseImplicitAny.js, 32, 33)) | ||
>obj : Symbol(obj, Decl(jsdocArrayObjectPromiseImplicitAny.js, 38, 25)) | ||
|
||
return obj; | ||
>obj : Symbol(obj, Decl(jsdocArrayObjectPromiseImplicitAny.js, 38, 25)) | ||
} | ||
|
81 changes: 81 additions & 0 deletions
81
tests/baselines/reference/jsdocArrayObjectPromiseImplicitAny.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
=== tests/cases/compiler/jsdocArrayObjectPromiseImplicitAny.js === | ||
/** @type {Array} */ | ||
var anyArray = [5]; | ||
>anyArray : any[] | ||
>[5] : number[] | ||
>5 : 5 | ||
|
||
/** @type {Array<number>} */ | ||
var numberArray = [5]; | ||
>numberArray : number[] | ||
>[5] : number[] | ||
>5 : 5 | ||
|
||
/** | ||
* @param {Array} arr | ||
* @return {Array} | ||
*/ | ||
function returnAnyArray(arr) { | ||
>returnAnyArray : (arr: any[]) => any[] | ||
>arr : any[] | ||
|
||
return arr; | ||
>arr : any[] | ||
} | ||
|
||
/** @type {Promise} */ | ||
var anyPromise = Promise.resolve(5); | ||
>anyPromise : Promise<any> | ||
>Promise.resolve(5) : Promise<number> | ||
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; } | ||
>Promise : PromiseConstructor | ||
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; } | ||
>5 : 5 | ||
|
||
/** @type {Promise<number>} */ | ||
var numberPromise = Promise.resolve(5); | ||
>numberPromise : Promise<number> | ||
>Promise.resolve(5) : Promise<number> | ||
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; } | ||
>Promise : PromiseConstructor | ||
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; } | ||
>5 : 5 | ||
|
||
/** | ||
* @param {Promise} pr | ||
* @return {Promise} | ||
*/ | ||
function returnAnyPromise(pr) { | ||
>returnAnyPromise : (pr: Promise<any>) => Promise<any> | ||
>pr : Promise<any> | ||
|
||
return pr; | ||
>pr : Promise<any> | ||
} | ||
|
||
/** @type {Object} */ | ||
var anyObject = {valueOf: 1}; // not an error since assigning to any. | ||
>anyObject : any | ||
>{valueOf: 1} : { valueOf: number; } | ||
>valueOf : number | ||
>1 : 1 | ||
|
||
/** @type {Object<string, number>} */ | ||
var paramedObject = {valueOf: 1}; | ||
>paramedObject : { [x: string]: number; } | ||
>{valueOf: 1} : { valueOf: number; } | ||
>valueOf : number | ||
>1 : 1 | ||
|
||
/** | ||
* @param {Object} obj | ||
* @return {Object} | ||
*/ | ||
function returnAnyObject(obj) { | ||
>returnAnyObject : (obj: any) => any | ||
>obj : any | ||
|
||
return obj; | ||
>obj : any | ||
} | ||
|
66 changes: 66 additions & 0 deletions
66
tests/baselines/reference/jsdocArrayObjectPromiseNoImplicitAny.errors.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
tests/cases/compiler/jsdocArrayObjectPromiseNoImplicitAny.js(1,12): error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
tests/cases/compiler/jsdocArrayObjectPromiseNoImplicitAny.js(8,12): error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
tests/cases/compiler/jsdocArrayObjectPromiseNoImplicitAny.js(9,13): error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
tests/cases/compiler/jsdocArrayObjectPromiseNoImplicitAny.js(15,12): error TS2314: Generic type 'Promise<T>' requires 1 type argument(s). | ||
tests/cases/compiler/jsdocArrayObjectPromiseNoImplicitAny.js(22,12): error TS2314: Generic type 'Promise<T>' requires 1 type argument(s). | ||
tests/cases/compiler/jsdocArrayObjectPromiseNoImplicitAny.js(23,13): error TS2314: Generic type 'Promise<T>' requires 1 type argument(s). | ||
tests/cases/compiler/jsdocArrayObjectPromiseNoImplicitAny.js(30,21): error TS2322: Type 'number' is not assignable to type '() => Object'. | ||
|
||
|
||
==== tests/cases/compiler/jsdocArrayObjectPromiseNoImplicitAny.js (7 errors) ==== | ||
/** @type {Array} */ | ||
~~~~~ | ||
!!! error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
var notAnyArray = [5]; | ||
|
||
/** @type {Array<number>} */ | ||
var numberArray = [5]; | ||
|
||
/** | ||
* @param {Array} arr | ||
~~~~~ | ||
!!! error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
* @return {Array} | ||
~~~~~ | ||
!!! error TS2314: Generic type 'Array<T>' requires 1 type argument(s). | ||
*/ | ||
function returnNotAnyArray(arr) { | ||
return arr; | ||
} | ||
|
||
/** @type {Promise} */ | ||
~~~~~~~ | ||
!!! error TS2314: Generic type 'Promise<T>' requires 1 type argument(s). | ||
var notAnyPromise = Promise.resolve(5); | ||
|
||
/** @type {Promise<number>} */ | ||
var numberPromise = Promise.resolve(5); | ||
|
||
/** | ||
* @param {Promise} pr | ||
~~~~~~~ | ||
!!! error TS2314: Generic type 'Promise<T>' requires 1 type argument(s). | ||
* @return {Promise} | ||
~~~~~~~ | ||
!!! error TS2314: Generic type 'Promise<T>' requires 1 type argument(s). | ||
*/ | ||
function returnNotAnyPromise(pr) { | ||
return pr; | ||
} | ||
|
||
/** @type {Object} */ | ||
var notAnyObject = {valueOf: 1}; // error since assigning to Object, not any. | ||
~~~~~~~ | ||
!!! error TS2322: Type 'number' is not assignable to type '() => Object'. | ||
|
||
/** @type {Object<string, number>} */ | ||
var paramedObject = {valueOf: 1}; | ||
|
||
/** | ||
* @param {Object} obj | ||
* @return {Object} | ||
*/ | ||
function returnNotAnyObject(obj) { | ||
return obj; | ||
} | ||
|
69 changes: 69 additions & 0 deletions
69
tests/baselines/reference/jsdocArrayObjectPromiseNoImplicitAny.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
=== tests/cases/compiler/jsdocArrayObjectPromiseNoImplicitAny.js === | ||
/** @type {Array} */ | ||
var notAnyArray = [5]; | ||
>notAnyArray : Symbol(notAnyArray, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 1, 3)) | ||
|
||
/** @type {Array<number>} */ | ||
var numberArray = [5]; | ||
>numberArray : Symbol(numberArray, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 4, 3)) | ||
|
||
/** | ||
* @param {Array} arr | ||
* @return {Array} | ||
*/ | ||
function returnNotAnyArray(arr) { | ||
>returnNotAnyArray : Symbol(returnNotAnyArray, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 4, 22)) | ||
>arr : Symbol(arr, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 10, 27)) | ||
|
||
return arr; | ||
>arr : Symbol(arr, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 10, 27)) | ||
} | ||
|
||
/** @type {Promise} */ | ||
var notAnyPromise = Promise.resolve(5); | ||
>notAnyPromise : Symbol(notAnyPromise, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 15, 3)) | ||
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) | ||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) | ||
|
||
/** @type {Promise<number>} */ | ||
var numberPromise = Promise.resolve(5); | ||
>numberPromise : Symbol(numberPromise, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 18, 3)) | ||
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) | ||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) | ||
|
||
/** | ||
* @param {Promise} pr | ||
* @return {Promise} | ||
*/ | ||
function returnNotAnyPromise(pr) { | ||
>returnNotAnyPromise : Symbol(returnNotAnyPromise, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 18, 39)) | ||
>pr : Symbol(pr, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 24, 29)) | ||
|
||
return pr; | ||
>pr : Symbol(pr, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 24, 29)) | ||
} | ||
|
||
/** @type {Object} */ | ||
var notAnyObject = {valueOf: 1}; // error since assigning to Object, not any. | ||
>notAnyObject : Symbol(notAnyObject, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 29, 3)) | ||
>valueOf : Symbol(valueOf, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 29, 20)) | ||
|
||
/** @type {Object<string, number>} */ | ||
var paramedObject = {valueOf: 1}; | ||
>paramedObject : Symbol(paramedObject, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 32, 3)) | ||
>valueOf : Symbol(valueOf, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 32, 21)) | ||
|
||
/** | ||
* @param {Object} obj | ||
* @return {Object} | ||
*/ | ||
function returnNotAnyObject(obj) { | ||
>returnNotAnyObject : Symbol(returnNotAnyObject, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 32, 33)) | ||
>obj : Symbol(obj, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 38, 28)) | ||
|
||
return obj; | ||
>obj : Symbol(obj, Decl(jsdocArrayObjectPromiseNoImplicitAny.js, 38, 28)) | ||
} | ||
|
81 changes: 81 additions & 0 deletions
81
tests/baselines/reference/jsdocArrayObjectPromiseNoImplicitAny.types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
=== tests/cases/compiler/jsdocArrayObjectPromiseNoImplicitAny.js === | ||
/** @type {Array} */ | ||
var notAnyArray = [5]; | ||
>notAnyArray : any[] | ||
>[5] : number[] | ||
>5 : 5 | ||
|
||
/** @type {Array<number>} */ | ||
var numberArray = [5]; | ||
>numberArray : number[] | ||
>[5] : number[] | ||
>5 : 5 | ||
|
||
/** | ||
* @param {Array} arr | ||
* @return {Array} | ||
*/ | ||
function returnNotAnyArray(arr) { | ||
>returnNotAnyArray : (arr: any[]) => any[] | ||
>arr : any[] | ||
|
||
return arr; | ||
>arr : any[] | ||
} | ||
|
||
/** @type {Promise} */ | ||
var notAnyPromise = Promise.resolve(5); | ||
>notAnyPromise : Promise<any> | ||
>Promise.resolve(5) : Promise<number> | ||
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; } | ||
>Promise : PromiseConstructor | ||
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; } | ||
>5 : 5 | ||
|
||
/** @type {Promise<number>} */ | ||
var numberPromise = Promise.resolve(5); | ||
>numberPromise : Promise<number> | ||
>Promise.resolve(5) : Promise<number> | ||
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; } | ||
>Promise : PromiseConstructor | ||
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; } | ||
>5 : 5 | ||
|
||
/** | ||
* @param {Promise} pr | ||
* @return {Promise} | ||
*/ | ||
function returnNotAnyPromise(pr) { | ||
>returnNotAnyPromise : (pr: Promise<any>) => Promise<any> | ||
>pr : Promise<any> | ||
|
||
return pr; | ||
>pr : Promise<any> | ||
} | ||
|
||
/** @type {Object} */ | ||
var notAnyObject = {valueOf: 1}; // error since assigning to Object, not any. | ||
>notAnyObject : Object | ||
>{valueOf: 1} : { valueOf: number; } | ||
>valueOf : number | ||
>1 : 1 | ||
|
||
/** @type {Object<string, number>} */ | ||
var paramedObject = {valueOf: 1}; | ||
>paramedObject : { [x: string]: number; } | ||
>{valueOf: 1} : { valueOf: number; } | ||
>valueOf : number | ||
>1 : 1 | ||
|
||
/** | ||
* @param {Object} obj | ||
* @return {Object} | ||
*/ | ||
function returnNotAnyObject(obj) { | ||
>returnNotAnyObject : (obj: Object) => Object | ||
>obj : Object | ||
|
||
return obj; | ||
>obj : Object | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these were the minimal change, but they could be negated or split up if that seems clearer