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

[Feature/typescript] Moved Api,Domain,helpers,logic from flow to ts #330

Merged
merged 10 commits into from
Aug 20, 2020

Conversation

unvir
Copy link
Contributor

@unvir unvir commented Aug 9, 2020

No description provided.

unvir and others added 4 commits August 4, 2020 18:12
…moira-alert#327)

* AddingButton converted,
added ts supporting to webpack
added ts supporting to eslint

* Updated less-module import
…eature/typescript

� Conflicts:
�	.eslintrc.json
�	package.json
src/helpers/omitTypes.ts Outdated Show resolved Hide resolved
src/Api/MoiraApiInjection.tsx Outdated Show resolved Hide resolved
src/Api/MoiraApi.ts Outdated Show resolved Hide resolved
src/Api/MoiraApi.ts Outdated Show resolved Hide resolved
src/Api/MoiraApi.ts Show resolved Hide resolved
src/helpers/checkMaintenance.test.ts Show resolved Hide resolved
src/helpers/group-metrics-by-statuses.test.ts Outdated Show resolved Hide resolved
src/helpers/group-metrics-by-statuses.ts Outdated Show resolved Hide resolved
src/logic/parseLocalStorage.ts Outdated Show resolved Hide resolved
src/logic/parseLocationSearch.ts Outdated Show resolved Hide resolved
Copy link

@sashasushko sashasushko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Больше всего из замечаний меня напрягает ренейм через удаление/добавление. В будущем, с компонентами, нужно этого избежать

package.json Outdated
@@ -22,7 +22,7 @@
},
"dependencies": {
"@skbkontur/react-icons": "4.1.0",
"@skbkontur/react-stack-layout": "1.0.3",
"@skbkontur/react-stack-layout": "^1.0.3",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Версии старайся ставить --save-exact

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему? Таким способом не будет автоматического обновления, которое притянет мажорные изменения, зато все мелкие багфиксы будут актуальны в проекте

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Потому что мажорные изменения, увы, бывают breaking-change

Copy link

@sorovlad sorovlad Aug 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вы скорее про patch изменения говорите, мажорные изменения это первая цифра из трех, и если она меняется, то это 99.99% breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sashasushko, @sorovlad Это понятно) но при такой записи "@skbkontur/react-stack-layout": "^1.0.3" не притянется версия с первой цифрой 2. Ее все равно нужно будет вручную править. А вот вторую и третью будет обновлять сам. Насколько я понимаю, это багфиксы и они не могут быть breaking change?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В идеально мире да, не могут. Но бывало, что ломают.
В yarn при вызове "install" обновляются пакеты. Здесь мне нравится подход npm, версии обновляются только при установке или редактировании версии пакетов. И есть команда "ci", которая ставит только что нужно.

src/Api/MoiraApi.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,3 @@
export const purifyConfig = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему-то файл GIT посчитал новым. В таких случаях пропадает история. Старайся делать переименовая через git mv. Конкретно для этого файла сейчас не важно, но для каких-то компонентов - очень.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это происходит автоматически. Я делаю npx @khanacademy/flow-to-ts --write --delete-source src

--write write output to disk instead of STDOUT
--delete-source delete the source file

следом сразу коммит чтобы было проще прослеживать изменения. То есть тут конкретно создаются новые файлы, а не обновляются старые. Почему-то гит иногда понимает что это js -> ts, но я не понял почему

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это правильно, что git ренеймит. Нужно всё так делать. Чтобы git история сохранялась

@@ -0,0 +1,13 @@
export interface ContactConfig {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично про ренейм

src/Domain/ContactType.ts Outdated Show resolved Hide resolved
src/Domain/Maintenance.ts Outdated Show resolved Hide resolved
src/Domain/MoiraUrlParams.ts Outdated Show resolved Hide resolved

export const StatusesInOrder: Status[] = [
export const StatusesInOrder: string[] = [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кажется, здесь потеряли точность. Были определенные строки, а стали любые

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Раньше там работало с Flow, сейчас я вписал константные строки вместо таких же

Statuses.EXCEPTION,
Statuses.NODATA,
Statuses.ERROR,
Statuses.WARN,
Statuses.OK,
Statuses.DEL,

но получил ошибку линта

Type 'string' is not assignable to type '"DEL" | "EXCEPTION" | "NODATA" | "ERROR" | "WARN" | "OK"

tsconfig.json Outdated

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо будет потом подумать и поднять до 2015 или даже выше

src/Api/MoiraApi.ts Outdated Show resolved Hide resolved
src/helpers/group-metrics-by-statuses.ts Outdated Show resolved Hide resolved
src/helpers/omitTypes.ts Outdated Show resolved Hide resolved
@sorovlad sorovlad merged commit 69bbc2c into moira-alert:feature/typescript Aug 20, 2020
sorovlad pushed a commit that referenced this pull request Aug 20, 2020
…330)

* Typescript and eslint settings and transpilled AddingButton component (#327)

* AddingButton converted,
added ts supporting to webpack
added ts supporting to eslint

* Updated less-module import

* Moved Api,Domain,helpers,logic from flow to ts

* Moved Api,Domain,helpers,logic from flow to ts

* Implemented review: renamed interface, removed autoupdate on dependencies

* Added todo, es2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants