piotrwitek / typesafe-actions

Typesafe utilities for "action-creators" in Redux / Flux Architecture
https://codesandbox.io/s/github/piotrwitek/typesafe-actions/tree/master/codesandbox
MIT License
2.41k stars 98 forks source link

Using RootAction makes TypeScript compilation and vscode intellisense extremly slow #246

Open zdila opened 3 years ago

zdila commented 3 years ago

Description

If we use in our application RootAction as is recommended in the documentation, then TS compilatin is extremly slow and intellisense in VS Code becomes near-unuseable.

import { ActionType } from 'typesafe-actions';

export type RootAction = ActionType<typeof actions>;

It is reproducible with the project https://github.com/FreemapSlovakia/freemap-v3-react (just clone it and do npm i && DEPLOYMENT=www time ./node_modules/.bin/webpack, but currently it has a workaround you can see below).

A workaround is to replace the above code with this:

import { Action } from 'typesafe-actions';

export type RootAction = Action;

The workaround reduces compilation time from 5:40 to 0:35 and makes vscode intellisense fast.

thedillonb commented 3 years ago

We are also hitting this. We have approximately 220 actions and have noticed that complication times are pretty extreme when compiling. Unfortunately, I don't think this really has anything to do with typesave-actions. https://github.com/microsoft/TypeScript/wiki/Performance#preferring-base-types-over-unions is probably describing the problem here.