Skip to content
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

new readonly modifiers on Promise.all break lyricist in DT #33559

Closed
sandersn opened this issue Sep 23, 2019 · 1 comment · Fixed by #34501 or #45350
Closed

new readonly modifiers on Promise.all break lyricist in DT #33559

sandersn opened this issue Sep 23, 2019 · 1 comment · Fixed by #34501 or #45350
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@sandersn
Copy link
Member

sandersn commented Sep 23, 2019

Broken by #33057

  1. clone dt
  2. cd ~/dt/types/lyricist
  3. tsl
  4. error on `const songsByArtist: SongByArtist[] = results[5];
Promise
    .all([
        lyricist.album(1, { fetchTracklist: true, textFormat: LyricistTextFormat.PLAIN }),
        lyricist.artist(1, { textFormat: LyricistTextFormat.PLAIN }),
        lyricist.artistByName('any_artist', { textFormat: LyricistTextFormat.PLAIN }),
        lyricist.search('any_song'),
        lyricist.song(1, { fetchLyrics: true, textFormat: LyricistTextFormat.PLAIN }),
        lyricist.songsByArtist(1, { page: 1, perPage: 10, sort: 'asc' }),
    ])
    .then((results) => {
        const album: Album = results[0];
        const artist: Artist = results[1];
        const artistByName: Artist = results[2];
        const searchResult: SearchResult[] = results[3];
        const song: Song = results[4];
        const songsByArtist: SongByArtist[] = results[5];

        console.log('album', album.name);
        console.log('artist', artist.name);
        console.log('artistByName', artistByName.name);
        console.log('searchResult length', searchResult.length);
        console.log('song', song.title);
        console.log('songsByArtist length', songsByArtist.length);
    });

Expected behavior:
No error, and results[5]: SongByArtist[]

Actual behavior:
Error, and results[5]: SearchResult[]

The two types are VERY similar, although I'm not sure that's relevant. My guess is that it's a very subtle inference problem.

@sandersn sandersn added this to the TypeScript 3.7.0 milestone Sep 23, 2019
@sandersn sandersn added Bug A bug in TypeScript High Priority labels Sep 23, 2019
@sandersn sandersn changed the title new readonly modifiers on Promise.all breaks lyricist in DT new readonly modifiers on Promise.all break lyricist in DT Sep 23, 2019
@sandersn
Copy link
Member Author

sandersn commented Oct 1, 2019

I fixed the error in lyricist for now by adding as const after the array argument to all. Once this issue is fixed, we should try removing that to make sure that it works as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment