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

Convert flow types to TS #2828

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
6c2db84
rename .js to .ts
saihaj Oct 20, 2020
46130e9
convert flow's exact object type to TS
saihaj Oct 20, 2020
b7fdc96
convert $ReadonlyArray (flow) to ReadonlyArray (TS)
saihaj Oct 20, 2020
3ab7ecf
convert `+` (flow) to `readonly` (TS)
saihaj Oct 20, 2020
4dde86c
convert `mixed` (flow) to `unknown` (TS)
saihaj Oct 20, 2020
78c2be0
convert `?` (flow) to `Maybe` (TS)
saihaj Apr 14, 2021
65c2257
remove `...` (flow)
saihaj Apr 14, 2021
ea8237f
convert `:` (flow) with `extends` (TS)
saihaj Oct 21, 2020
0ae46e0
strip `%checks` annotations (flow)
saihaj Oct 21, 2020
b979e23
convert flow type spread to `&` (TS)
saihaj Oct 21, 2020
554570d
remove `+` (flow) annotations
saihaj Oct 21, 2020
bd02097
replace `$PropertyType` (flow)
saihaj Oct 21, 2020
20d18f4
remove `<>` (flow) from unions
saihaj Oct 21, 2020
3c5aca9
refactor: TS function overloading
saihaj Oct 26, 2020
64781a9
Type convertion `:` (flow) to `as` in TS
saihaj Oct 27, 2020
e4e9b0c
convert `{...}` (flow) to `{ }` (TS)
saihaj Oct 27, 2020
a6376bc
build: relax tsconfig
saihaj Oct 27, 2020
b62fe3d
make memoize arguments type weakmap
saihaj Oct 30, 2020
c063d56
convert`$ReadOnly` (flow) to `Readonly` (TS)
saihaj Nov 6, 2020
f491016
convert `$Values` (flow) to `keyof` (TS)
saihaj Nov 19, 2020
fdc57c8
remove `<>` (flow)
saihaj Dec 2, 2020
21d05da
convert `$Shape` (flow) to `Partial` (TS)
saihaj Jan 12, 2021
257a3c7
convert `$Keys` (flow) to `keyof` (TS)
saihaj Jan 13, 2021
0212283
enable tests by adding babel ts tranform plugin
saihaj Jan 13, 2021
1599a69
test: disable flow integration test
saihaj Jan 13, 2021
e05758a
build: ignore .d.ts files linting
saihaj Jan 15, 2021
ec59c6e
style: run eslint fix and prettier
saihaj Jan 15, 2021
ba4c76e
remove `$ObjMap` (flow) to fix visitor types
saihaj Jan 15, 2021
8de679b
build: remove eslint flow plugin
saihaj Jan 15, 2021
cb08f35
refactor: remove unused eslint-disable directives
saihaj Jan 15, 2021
8f2ab17
refactor: remove Flow Fix me comments
saihaj Jan 21, 2021
b07f73a
feat: remove flow infrastructure
saihaj Jan 21, 2021
a05b95d
build: rename to TS eslint rules and temporarily disable eslint rules
saihaj Feb 16, 2021
37a41f6
build: enable `@typescript-eslint/no-unused-vars`
saihaj Feb 16, 2021
f4f0440
build: enable `@typescript-eslint/no-invalid-void-type`
saihaj Feb 16, 2021
039def9
build: enable `@typescript-eslint/no-inferrable-types`
saihaj Feb 16, 2021
570b559
build: enable `@typescript-eslint/non-nullable-type-assertion-style`
saihaj Feb 16, 2021
cd91f2a
build: enable `@typescript-eslint/no-unnecessary-type-assertion`
saihaj Feb 16, 2021
207e434
build: enable `@typescript-eslint/consistent-type-definitions`
saihaj Feb 16, 2021
63a1798
build: enable `@typescript-eslint/consistent-type-imports`
saihaj Feb 16, 2021
d490f3d
match `.d.ts` definition
saihaj Feb 17, 2021
1d9a8f9
fix: TS2355 function whose declared type is neither 'void' nor 'any' …
saihaj Feb 17, 2021
99e029f
convert ObjMap to use Record
saihaj Feb 17, 2021
462d04d
refactor: CoercedVariableValues type into union of interfaces
saihaj Feb 17, 2021
89861c5
refactor: convert to use `Record`
saihaj Feb 17, 2021
59971b9
refactor: ensureArray func to return proper typed values
saihaj Feb 17, 2021
d7f9f69
feat: typecast to ensure type safety
saihaj Feb 17, 2021
58185c6
feat: type guard isObjectLike to `Record`
saihaj Feb 17, 2021
a43cbd0
test: use `@ts-expect-error`
saihaj Feb 17, 2021
8dbbcac
build: add @types/node
saihaj Feb 17, 2021
9ad53e8
feat: use `in` operator to check TS type while doing boolean checks
saihaj Feb 17, 2021
e021f1b
TODO: need to fix these TS errors
saihaj Feb 17, 2021
abd7a03
build + CI: add TS type check script
saihaj Feb 17, 2021
329334a
build: add `@types/mocha`
saihaj Feb 18, 2021
261b381
build: add `@types/chai`
saihaj Feb 18, 2021
44222dc
remove $FlowExpectedError[incompatible-call]
saihaj Feb 23, 2021
99921a3
style: run prettier
saihaj Mar 17, 2021
d4aa269
TODO: add `@ts-expect-error` fix me
saihaj Mar 20, 2021
81363f1
feat: Mutable type utility
saihaj Apr 12, 2021
fee1315
TS: improve types mapAsyncIterator-test
saihaj Apr 12, 2021
738956e
fix: instanceOf types
saihaj Apr 14, 2021
23aba04
fix: invariant types
saihaj Apr 14, 2021
948f656
fix: ProvidedRequiredArgumentsRule types
saihaj Apr 14, 2021
72b5a98
fix: introspection type
saihaj Apr 14, 2021
43ce601
add eslint-disable comment
saihaj Apr 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .babelrc-deno.json
@@ -1,7 +1,7 @@
{
"plugins": [
"@babel/plugin-transform-flow-strip-types",
["./resources/add-extension-to-import-paths", { "extension": "js" }],
"@babel/plugin-transform-typescript",
["./resources/add-extension-to-import-paths", { "extension": "ts" }],
"./resources/inline-invariant"
]
}
2 changes: 1 addition & 1 deletion .babelrc-npm.json
@@ -1,6 +1,6 @@
{
"plugins": [
"@babel/plugin-transform-flow-strip-types",
"@babel/plugin-transform-typescript",
"./resources/inline-invariant"
],
"env": {
Expand Down
2 changes: 1 addition & 1 deletion .babelrc.json
@@ -1,4 +1,4 @@
{
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"plugins": ["@babel/plugin-transform-typescript"],
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
}
4 changes: 2 additions & 2 deletions .eslintignore
Expand Up @@ -7,7 +7,7 @@
/npm
/deno

# Ignore Flow typings for 3rd-party libraries
/flow-typed
# Ignore TS files inside integration test
/integrationTests/ts/*.ts

src/**/*.d.ts
97 changes: 19 additions & 78 deletions .eslintrc.yml
Expand Up @@ -250,7 +250,7 @@ rules:
no-self-assign: error
no-self-compare: off # TODO
no-sequences: error
no-throw-literal: error
no-throw-literal: off
no-unmodified-loop-condition: error
no-unused-expressions: error
no-unused-labels: error
Expand Down Expand Up @@ -435,63 +435,6 @@ rules:
yield-star-spacing: off

overrides:
- files: 'src/**/*.js'
parser: '@babel/eslint-parser'
parserOptions:
sourceType: module
plugins:
- flowtype

rules:
##############################################################################
# `eslint-plugin-flowtype` rule list based on `v5.6.x`
# https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype
##############################################################################

flowtype/array-style-complex-type: error
flowtype/array-style-simple-type: error
flowtype/define-flow-type: error
flowtype/newline-after-flow-annotation: error
flowtype/no-dupe-keys: error
flowtype/no-existential-type: off # checked by Flow
flowtype/no-flow-fix-me-comments: off
flowtype/no-internal-flow-type: error
flowtype/no-mixed: off
flowtype/no-mutable-array: off
flowtype/no-primitive-constructor-types: error
flowtype/no-types-missing-file-annotation: off
flowtype/no-unused-expressions: off
flowtype/no-weak-types: [error, { any: false }]
flowtype/require-compound-type-alias: off
flowtype/require-exact-type: off
flowtype/require-indexer-name: error
flowtype/require-inexact-type: off # checked by Flow
flowtype/require-parameter-type: off
flowtype/require-readonly-react-props: off
flowtype/require-return-type: off
flowtype/require-types-at-top: off
flowtype/require-valid-file-annotation: off
flowtype/require-variable-type: off
flowtype/sort-keys: off
flowtype/spread-exact-type: off
flowtype/type-id-match: [error, '^[A-Z]']
flowtype/type-import-style: [error, declaration]
flowtype/use-read-only-spread: error
flowtype/use-flow-type: error

# Bellow rules are disabled because coflicts with Prettier, see:
# https://github.com/prettier/eslint-config-prettier/blob/master/flowtype.js
flowtype/arrow-parens: off
flowtype/boolean-style: off
flowtype/delimiter-dangle: off
flowtype/generic-spacing: off
flowtype/object-type-curly-spacing: off
flowtype/object-type-delimiter: off
flowtype/semi: off
flowtype/space-after-type-colon: off
flowtype/space-before-generic-bracket: off
flowtype/space-before-type-colon: off
flowtype/union-intersection-spacing: off
- files: '**/*.ts'
parser: '@typescript-eslint/parser'
parserOptions:
Expand All @@ -513,22 +456,21 @@ overrides:
'@typescript-eslint/await-thenable': error
'@typescript-eslint/ban-ts-comment': [error, { 'ts-expect-error': false }]
'@typescript-eslint/ban-tslint-comment': error
'@typescript-eslint/ban-types': error
'@typescript-eslint/ban-types': off # TODO temporarily disabled
'@typescript-eslint/class-literal-property-style': off # TODO enable after TS conversion
'@typescript-eslint/consistent-indexed-object-style': off # TODO enable after TS conversion
'@typescript-eslint/consistent-type-assertions':
[error, { assertionStyle: as, objectLiteralTypeAssertions: never }]
'@typescript-eslint/consistent-type-definitions': off # TODO consider
'@typescript-eslint/consistent-type-imports': off # TODO enable after TS conversion
'@typescript-eslint/consistent-type-assertions': off # TODO temporarily disable
'@typescript-eslint/consistent-type-definitions': ['error', 'interface']
'@typescript-eslint/consistent-type-imports': error
'@typescript-eslint/explicit-function-return-type': off # TODO consider
'@typescript-eslint/explicit-member-accessibility': off # TODO consider
'@typescript-eslint/explicit-module-boundary-types': off # TODO consider
'@typescript-eslint/member-ordering': off # TODO consider
'@typescript-eslint/member-ordering': error
'@typescript-eslint/method-signature-style': error
'@typescript-eslint/naming-convention': off # TODO consider
'@typescript-eslint/no-base-to-string': error
'@typescript-eslint/no-confusing-non-null-assertion': error
'@typescript-eslint/no-confusing-void-expression': error
'@typescript-eslint/no-confusing-void-expression': off # TODO temporarily disabled
'@typescript-eslint/no-dynamic-delete': off
'@typescript-eslint/no-empty-interface': error
'@typescript-eslint/no-explicit-any': off # TODO error
Expand All @@ -551,28 +493,28 @@ overrides:
'@typescript-eslint/no-this-alias': error
'@typescript-eslint/no-throw-literal': error
'@typescript-eslint/no-type-alias': off # TODO consider
'@typescript-eslint/no-unnecessary-boolean-literal-compare': error
'@typescript-eslint/no-unnecessary-condition': error
'@typescript-eslint/no-unnecessary-boolean-literal-compare': off #TODO temporarily disabled
'@typescript-eslint/no-unnecessary-condition': off #TODO temporarily disabled
'@typescript-eslint/no-unnecessary-qualifier': error
'@typescript-eslint/no-unnecessary-type-arguments': error
'@typescript-eslint/no-unnecessary-type-assertion': error
'@typescript-eslint/no-unnecessary-type-constraint': off # TODO consider
'@typescript-eslint/no-unnecessary-type-constraint': error
'@typescript-eslint/no-unsafe-argument': off # TODO consider
'@typescript-eslint/no-unsafe-assignment': off # TODO consider
'@typescript-eslint/no-unsafe-call': off # TODO consider
'@typescript-eslint/no-unsafe-member-access': off # TODO consider
'@typescript-eslint/no-unsafe-return': off # TODO consider
'@typescript-eslint/no-var-requires': error
'@typescript-eslint/non-nullable-type-assertion-style': error
'@typescript-eslint/prefer-as-const': off # TODO consider
'@typescript-eslint/prefer-enum-initializers': off # TODO consider
'@typescript-eslint/prefer-as-const': error
'@typescript-eslint/prefer-enum-initializers': error
'@typescript-eslint/prefer-for-of': off # TODO switch to error after TS migration
'@typescript-eslint/prefer-function-type': error
'@typescript-eslint/prefer-includes': off # TODO switch to error after IE11 drop
'@typescript-eslint/prefer-literal-enum-member': error
'@typescript-eslint/prefer-namespace-keyword': error
'@typescript-eslint/prefer-nullish-coalescing': error
'@typescript-eslint/prefer-optional-chain': error
'@typescript-eslint/prefer-optional-chain': off #TODO temporarily disabled
'@typescript-eslint/prefer-readonly': error
'@typescript-eslint/prefer-readonly-parameter-types': off # TODO consider
'@typescript-eslint/prefer-reduce-type-parameter': error
Expand All @@ -581,12 +523,11 @@ overrides:
'@typescript-eslint/prefer-string-starts-ends-with': off # TODO switch to error after IE11 drop
'@typescript-eslint/promise-function-async': off
'@typescript-eslint/require-array-sort-compare': error
'@typescript-eslint/restrict-plus-operands':
[error, { checkCompoundAssignments: true }]
'@typescript-eslint/restrict-template-expressions': error
'@typescript-eslint/restrict-plus-operands': off #TODO temporarily disabled
'@typescript-eslint/restrict-template-expressions': off #TODO temporarily disabled
'@typescript-eslint/sort-type-union-intersection-members': off # TODO consider
'@typescript-eslint/strict-boolean-expressions': off # TODO consider
'@typescript-eslint/switch-exhaustiveness-check': error
'@typescript-eslint/switch-exhaustiveness-check': off #TODO temporarily disabled
'@typescript-eslint/triple-slash-reference': error
'@typescript-eslint/typedef': off
'@typescript-eslint/unbound-method': off # TODO consider
Expand Down Expand Up @@ -623,7 +564,7 @@ overrides:
'@typescript-eslint/no-loop-func': error
'@typescript-eslint/no-loss-of-precision': error
'@typescript-eslint/no-redeclare': error
'@typescript-eslint/no-shadow': error
'@typescript-eslint/no-shadow': off #TODO temporarily disabled
'@typescript-eslint/no-unused-expressions': error
'@typescript-eslint/no-unused-vars':
[
Expand All @@ -636,10 +577,10 @@ overrides:
},
]
'@typescript-eslint/no-useless-constructor': error
'@typescript-eslint/require-await': error
'@typescript-eslint/require-await': off #TODO temporarily disabled
'@typescript-eslint/return-await': error

# Disable for JS, Flow and TS
# Disable for JS and TS
'@typescript-eslint/init-declarations': off
'@typescript-eslint/no-magic-numbers': off
'@typescript-eslint/no-use-before-define': off
Expand Down
42 changes: 0 additions & 42 deletions .flowconfig

This file was deleted.

1 change: 0 additions & 1 deletion .github/CONTRIBUTING.md
Expand Up @@ -73,7 +73,6 @@ ensure your pull request matches the style guides, run `npm run prettier`.
- 80 character line length strongly preferred.
- Prefer `'` over `"`
- ES6 syntax when possible. However do not rely on ES6-specific functions to be available.
- Use [Flow types](https://flowtype.org/).
- Use semicolons;
- Trailing commas,
- Avd abbr wrds.
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -29,15 +29,15 @@ jobs:
- name: Lint ESLint
run: npm run lint

- name: Lint Flow
run: npm run check

- name: Lint Prettier
run: npm run prettier:check

- name: Spellcheck
run: npm run check:spelling

- name: Check Types
run: npm run check

checkForCommonlyIgnoredFiles:
name: Check for commonly ignored files
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.yml
@@ -1,4 +1,4 @@
throw-deprecation: true
check-leaks: true
require:
- '@babel/register'
- 'resources/ts-register.js'
1 change: 0 additions & 1 deletion cspell.yml
Expand Up @@ -24,7 +24,6 @@ words:
- graphiql
- sublinks
- instanceof
- flowtype

# Different names used inside tests
- Skywalker
Expand Down