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

util typescript #1328

Merged
merged 21 commits into from Oct 20, 2020
Merged

util typescript #1328

merged 21 commits into from Oct 20, 2020

Conversation

danethurber
Copy link
Contributor

all the typescript!

@danethurber danethurber changed the title [WIP] refactor(util): move to ts files util typescript Oct 13, 2020
@danethurber danethurber marked this pull request as ready for review October 13, 2020 13:59
Copy link
Contributor

@jaketrent jaketrent left a comment

Choose a reason for hiding this comment

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

after root yarn && yarn build,

tsc giving me:

On the first error, rename to storyshots.spec.ts, and should resolve.

design-system/packages/util on  refactor/util-ts [$!] ❯ tsc
src/__specs__/storyshots.spec.tsx:11:31 - error TS2345: Argument of type '{ createNodeMock: () => HTMLDivElement; }' is not assignable to parameter of type 'Function | { renderer?: any; serializer?: any; }'.
  Object literal may only specify known properties, and 'createNodeMock' does not exist in type 'Function | { renderer?: any; serializer?: any; }'.

11   test: snapshotWithOptions({ createNodeMock })
                                 ~~~~~~~~~~~~~~

src/__specs__/use-combined-refs.spec.tsx:13:46 - error TS2322: Type '{ value: string; }' is not assignable to type 'undefined'.

13       useImperativeHandle(combinedRef, () => ({
                                                ~~
14         value: 'ref'
   ~~~~~~~~~~~~~~~~~~~~
15       }))
   ~~~~~~~~

  ../../node_modules/@types/react/index.d.ts:1093:79
    1093     function useImperativeHandle<T, R extends T>(ref: Ref<T>|undefined, init: () => R, deps?: DependencyList): void;
                                                                                       ~~~~~~~
    The expected type comes from the return type of this signature.

src/__specs__/use-combined-refs.spec.tsx:26:46 - error TS2322: Type '{ value: string; }' is not assignable to type 'undefined'.

26       useImperativeHandle(combinedRef, () => ({
                                                ~~
27         value: 'ref'
   ~~~~~~~~~~~~~~~~~~~~
28       }))
   ~~~~~~~~

  ../../node_modules/@types/react/index.d.ts:1093:79
    1093     function useImperativeHandle<T, R extends T>(ref: Ref<T>|undefined, init: () => R, deps?: DependencyList): void;
                                                                                       ~~~~~~~
    The expected type comes from the return type of this signature.

src/__specs__/use-combined-refs.spec.tsx:39:46 - error TS2322: Type '{ value: string; }' is not assignable to type 'undefined'.

39       useImperativeHandle(combinedRef, () => ({
                                                ~~
40         value: 'ref'
   ~~~~~~~~~~~~~~~~~~~~
41       }))
   ~~~~~~~~

  ../../node_modules/@types/react/index.d.ts:1093:79
    1093     function useImperativeHandle<T, R extends T>(ref: Ref<T>|undefined, init: () => R, deps?: DependencyList): void;
                                                                                       ~~~~~~~
    The expected type comes from the return type of this signature.


Found 4 errors.

.eslintignore Outdated Show resolved Hide resolved
packages/util/src/combine-fns.ts Show resolved Hide resolved
@jaketrent
Copy link
Contributor

Dane, not sure if you're planning to do more on this. Are you getting the same 4 tsc errors that I was? Do you plan to address them in new commits?

@danethurber
Copy link
Contributor Author

I'll look and see about the errors. I wasn't getting them when I built but I can def try again

…em into refactor/util-ts

* 'refactor/util-ts' of github.com:pluralsight/design-system:
  refactor(docs): adjust max-width of main
  refactor(docs): rename vars for clarity
  fix(docs): restore the scroll restore, broken by scrollable
  feat(docs): persist sidenav group toggling
  feat(docs): open sidenav group containing active link
  feat(docs): highlight active sidenav link
  fix(docs): make heading more specific for unreliable style order
  fix(docs): hack search thin enough to mostly fit and not disturb scrollbar
  fix(docs): horz align scrollbar on sidenav
  refactor(docs): adjust color of fade to match editor background color
  refactor(docs): spacing page - move toc below heading
* master:
  fix(docs): ssr and sessionstorage
  build: publish
  build: publish
  build: publish
  build: commit lock
  refactor(halo): make props to styles required
  build(halo): tsc strict
  build(halo): return to storyshots.spec.tsx and cleanup
  test(halo): rename storyshots file for ts
  refactor(halo): fully convert to typescript
  refactor(halo): move to ts build
  refactor(halo): move to ts files
  Feat/linerprogress ts conversion (#1332)
  refactor(prop-types): change method of determining NODE_ENV to be compat with webpack5
Copy link
Contributor

@jaketrent jaketrent left a comment

Choose a reason for hiding this comment

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

I still get these errors:

design-system/packages/util on  refactor/util-ts [⇣$!] ❯ tsc --version
Version 4.0.2
design-system/packages/util on  refactor/util-ts [⇣$!] ❯ tsc
src/__specs__/storyshots.spec.tsx:11:31 - error TS2345: Argument of type '{ createNodeMock: () => HTMLDivElement; }' is not assignable to parameter of type 'Function | { renderer?: any; serializer?: any; }'.
  Object literal may only specify known properties, and 'createNodeMock' does not exist in type 'Function | { renderer?: any; serializer?: any; }'.

11   test: snapshotWithOptions({ createNodeMock })
                                 ~~~~~~~~~~~~~~

src/__specs__/use-combined-refs.spec.tsx:13:46 - error TS2322: Type '{ value: string; }' is not assignable to type 'undefined'.

13       useImperativeHandle(combinedRef, () => ({
                                                ~~
14         value: 'ref'
   ~~~~~~~~~~~~~~~~~~~~
15       }))
   ~~~~~~~~

  ../../node_modules/@types/react/index.d.ts:1093:79
    1093     function useImperativeHandle<T, R extends T>(ref: Ref<T>|undefined, init: () => R, deps?: DependencyList): void;
                                                                                       ~~~~~~~
    The expected type comes from the return type of this signature.

src/__specs__/use-combined-refs.spec.tsx:26:46 - error TS2322: Type '{ value: string; }' is not assignable to type 'undefined'.

26       useImperativeHandle(combinedRef, () => ({
                                                ~~
27         value: 'ref'
   ~~~~~~~~~~~~~~~~~~~~
28       }))
   ~~~~~~~~

  ../../node_modules/@types/react/index.d.ts:1093:79
    1093     function useImperativeHandle<T, R extends T>(ref: Ref<T>|undefined, init: () => R, deps?: DependencyList): void;
                                                                                       ~~~~~~~
    The expected type comes from the return type of this signature.

src/__specs__/use-combined-refs.spec.tsx:39:46 - error TS2322: Type '{ value: string; }' is not assignable to type 'undefined'.

39       useImperativeHandle(combinedRef, () => ({
                                                ~~
40         value: 'ref'
   ~~~~~~~~~~~~~~~~~~~~
41       }))
   ~~~~~~~~

  ../../node_modules/@types/react/index.d.ts:1093:79
    1093     function useImperativeHandle<T, R extends T>(ref: Ref<T>|undefined, init: () => R, deps?: DependencyList): void;
                                                                                       ~~~~~~~
    The expected type comes from the return type of this signature.


Found 4 errors.

const fallbackRef = React.useRef()
const ref = forwardedRef || fallbackRef
const ref = React.useRef<HTMLUListElement>()
useImperativeHandle(forwardedRef, () => ref.current)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not null problem for you like mine, eh? 🤷

Copy link
Contributor

@jaketrent jaketrent left a comment

Choose a reason for hiding this comment

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

tsc local is clean for me now!

* master:
  build(deps): bump object-path from 0.11.4 to 0.11.5
  build: publish
  fix(util): drop storybook dep to fix circle dep
  ci: force workspaces
  ci: ignore ts dist files
  test(tag): update because of icon changes
  test(card): update because of icon change
  refactor(icon): convert to typescript
@danethurber danethurber merged commit 7c942d7 into master Oct 20, 2020
@danethurber danethurber deleted the refactor/util-ts branch October 20, 2020 18:47
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.

None yet

2 participants