-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already createdFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Description
TypeScript Version:
3.7.2
Search Terms:
Promise.all, Record
Code
interface MoviesResponse {
movies: [];
}
type CharactersResponse = Record<number, any>;
const getMovies = async (): Promise<MoviesResponse> => ({
movies: [],
})
const getCharacters = async (): Promise<CharactersResponse> => ({
});
(async () => {
const [{ movies }, characters] = await Promise.all([getMovies(), getCharacters()]);
console.log(movies, characters);
})();
Expected behavior:
The first variable in the deconstructed array should be correctly typed as MoviesResponse
, rather than CharactersResponse
. This worked in 3.6.4.
Actual behavior:
Both variables in the deconstructed array are inferred to be CharactersResponse
. So when I try to deconstruct the first argument doing { movies }
, it's an invalid destructuring.
Interestingly, if we update CharactersResponse
to not be a map type, the problem goes away, e.g:
interface CharactersResponse {
characters: any[];
}
const getCharacters = async (): Promise<CharactersResponse> => ({
characters: [],
});
Playground Link:
Related Issues:
None found.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already createdFix AvailableA PR has been opened for this issueA PR has been opened for this issue