Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type MergedSheet<T> = { [P in keyof T]?: T[P][] }
- export function groupStyles<T>(
- sheets: Array<T>
- ): MergedSheet<T> {
- const merged: MergedSheet<T> = {}
- for (const sheet of sheets) {
- for (const ele in sheet) {
- if (merged[ele]) {
- merged[ele] = merged[ele] || []
- merged[ele].push(sheet[ele])
- // ^^^^
- // [tsserver 2339] [E] Property 'push' does not exist on type 'MergedSheet<T>[Extract<keyof T, string>]'.
- } else {
- merged[ele] = [sheet[ele]]
- }
- }
- }
- return merged
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement