i ran into error TS2565: Property ‘defaultProps’ is used before being assigned while “npm run build”
OS: WSL2 Ubuntu 18.04 LTS
Redash: v9.0.0 beta ( git clone https://github.com/getredash/redash.git
)
what i installed before:
node: 14.17.2
npm: 6.14.13
typeScript: 4.3.5 // sudo npm install -g typescript
Python: 3.6.9
node-gyp: 8.1.0
Got errors at npm run build
src/components/ColorPicker/Input.tsx:47:38 - error TS2565: Property 'defaultProps' is used before being assigned.
47 type Props = OwnProps & typeof Input.defaultProps;
```src/components/ColorPicker/Input.tsx:47:38 - error TS2565: Property 'defaultProps' is used before being assigned.
47 type Props = OwnProps & typeof Input.defaultProps;
Actually, I already solved this error by moving the statement of the part where Input.defaultProps is declared (line 91) before the part where it is used(line 46).
Before i fix
# used in line 47
type Props = OwnProps & typeof Input.defaultProps;
...
# declared in line 91
Input.defaultProps = {
color: "#FFFFFF",
presetColors: null,
presetColumns: 8,
onChange: () => {},
onPressEnter: () => {},
};
After i fix
# declared in line 46
Input.defaultProps = {
color: "#FFFFFF",
presetColors: null,
presetColumns: 8,
onChange: () => {},
onPressEnter: () => {},
};
# used in line 53
type Props = OwnProps & typeof Input.defaultProps;
...
As you can see it is a simple problem that can be solved by simply changing the declaring statement to be placed before the using statement.
Label.tsx, Swatch.tsx, index.tsx, JsonViewInteractive.tsx, ContextHelp.tsx, Section.tsx, Switch.tsx, createTabbedEditor.tsx …
about 22 files have same error
i want to know why this error occur and how can i fix this error more easily without changing each statement
Please suggest.
Thank you!