card-web icon indicating copy to clipboard operation
card-web copied to clipboard

Use TypeScript

Open jkomoros opened this issue 2 years ago • 5 comments

jkomoros avatar May 27 '22 21:05 jkomoros

https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html https://github.com/lit/lit-element-starter-ts

jkomoros avatar May 29 '22 20:05 jkomoros

  • [ ] Switch to using '@rollup/plugin-typescript' in rollup once card-web-app is a typescript
  • [ ] Configure eslint/typescript: https://khalilstemmler.com/blogs/typescript/eslint-for-typescript/
  • [x] Remove 'allowJs' (if that's useful)
  • [x] Make sure ts-lit-plugin works (does it need an npm install>)
  • [ ] https://redux.js.org/usage/usage-with-typescript
  • [ ] Use ReturnType or something similar to set valid enum values for things like ConfigActioN?
  • [x] Make npm run build not use ';' but '&&' once tsc build doesn't error
  • [x] Enable 'noImplicitAny'
  • [ ] Use the patterns for dispatch and thunk from PWA Starter Kit Typescript branch: https://github.com/Polymer/pwa-starter-kit/blob/template-typescript/src/actions/app.ts
  • [ ] Enable 'strict'
  • [ ] Add types for actions (using the kind type switch) (or maybe don't? https://phryneas.de/redux-typescript-no-discriminating-union)
  • [x] Enable 'noImplicitThis'
  • [x] Try using AppActionCreator on every thunk action creator 🤷
  • [x] Figure out how to use AppActionCreator for async action creators
  • [ ] Enable 'strictNullChecks'
  • [x] Enable 'noEmitOnError'
  • [ ] Make card.full_bleed be a non-optional property (needs a maintenance task?)
  • [x] Fix test failure in npm run test:references introduced in ccf53b1776dab6b3645db7df58fb4a7c88523d93 (actually it looks like 850936405ad6bd60e15d1c597c14fc671d4f0914 ?)
  • [ ] Consider moving tsc build into an intermediate build_ts instead of hidiing all of the generated stuff in src
  • [x] Make permission type name an explicit type, not just string
  • [x] Reordering cards to drag below now jumps two slots down
  • [x] Turn on no-missing-element-type-definition https://marketplace.visualstudio.com/items?itemName=runem.lit-plugin#no-missing-element-type-definition)
  • [x] Verify screenshot service works, after e9b777c0
  • [ ] Figure out a way to get rid of card_diff: NON_AUTOMATIC_MERGE_FIELDS and just use NonAutoMergeableCardDiff type somehow
  • [x] Should CustomEvent.detail have types based on kind?
  • [ ] conceptCardsFromCards should be able to take Cards or Processed cards and return that type and not require casts from downstream users
  • [ ] Use typescript for functions/
  • [x] Fix break in 997123f7f91fb0161e7b48e5f51a675341e7c1f7
  • [ ] Use typescritp for test
  • [x] Deploys are broken because eslint for the functions package breaks. See https://github.com/jkomoros/card-web/issues/601#issuecomment-1157010376 for more. Tracked in #607
  • [x] Fix bug where while loading card says "content goes here" bisect blames: 1fd128c6b70b31daea6cced51da592202132ae56
  • [x] Fix broken basic-card renderer broke in 296fb21b058e55d499207c02a6df960228b1f78b
  • [ ] Figure out if htere's a way to have CardUpdate have ONLY those fields, not extras? https://fettblog.eu/typescript-match-the-exact-object-shape/
  • [ ] Use Redux toolkit for action creators, to handle getting types on actions properly? https://redux-toolkit.js.org/usage/usage-guide see also https://phryneas.de/redux-typescript-no-discriminating-union
  • [ ] Any action creator that is typed AppActionCreator has a signature of any[], which could obscure callsite problems.
  • [x] Consider memoizing objectWithReferences
  • [x] For all if(! ele instance of HTML*Element)) checks in components.ts, instead of doing narrowing via silent return, throw an error.
  • [ ] Use built-in utility types, like Partial, Record, etc: https://www.typescriptlang.org/docs/handbook/utility-types.html
  • [ ] Instead of enumerating globalEvents for https://marketplace.visualstudio.com/items?itemName=runem.lit-plugin#-no-unknown-event, enumerate them in jsdoc above each component that fires them
  • [ ] tweetOrderExtractor should do its own typing
  • [x] Do all todos in events.ts
  • [x] rename card_field_constants.ts to type_constants.ts
  • [ ] Do all TODOs in types.ts
  • [ ] Squelch warnings in npm run build about _decorator and undefined this. Veri
  • [x] Consider using something like https://stackoverflow.com/a/62055863 for Object.keys(), Object.entries(), and Object.values() type safety (we currently do a lot of 'as' assertions, but it seems like those could break if the shape of various objects changed?)
  • [x] Go in and explicitly add implied types to all call signatures (especially in top-level ts files)

jkomoros avatar May 29 '22 20:05 jkomoros

Move all js to ts (including config.secret.json generation), have a git_ignore of src/**.js,

Re copy config.SECRET.json .

Don't have tsc inline files in src (that's super-confusing/messy), just have it in build_ts/

Make sure npm run build works (even if you haven't done npm run serve)

Get eslint errors suprressed in generated files in src/

jkomoros avatar May 29 '22 20:05 jkomoros

Bug introduced in: b842b0b6241abcb3b98d0923804c2483b384e981

    at makeFilterFromConfigurableFilter (collection_description.ts:517:44)
    at filterSetForFilterDefinitionItem (collection_description.ts:582:10)
    at combinedFilterForFilterDefinition (collection_description.ts:629:57)
    at Collection._makeFilteredCards (collection_description.ts:742:57)
    at Collection._ensureFilteredCards (collection_description.ts:757:30)
    at get filteredCards [as filteredCards] (collection_description.ts:784:8)
    at ReferenceBlock._shouldHide (reference-block.ts:86:48)
    at ReferenceBlock.render (reference-block.ts:73:12)
    at ReferenceBlock.update (lit-element.ts:160:24)
    at ReferenceBlock.performUpdate (reactive-element.ts:1303:14)```

jkomoros avatar Jun 02 '22 23:06 jkomoros

Deploys broken with error deploying functions:

Oops! Something went wrong! :(

ESLint: 4.19.1.
ESLint couldn't find the plugin "eslint-plugin-@typescript-eslint". This can happen for a couple different reasons:

1. If ESLint is installed globally, then make sure eslint-plugin-@typescript-eslint is also installed globally. A globally-installed ESLint cannot find a locally-installed plugin.

2. If ESLint is installed locally, then it's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm i eslint-plugin-@typescript-eslint@latest --save-dev

If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.

jkomoros avatar Jun 15 '22 22:06 jkomoros