Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Fix typings for Typescript 2.9 #425

Merged
merged 2 commits into from Jun 1, 2018
Merged

Conversation

aaronjensen
Copy link
Contributor

No description provided.

type Diff<
T extends string | number | symbol,
U extends string | number | symbol
> = ({[P in T]: P} & {[P in U]: never} & {[x: string]: never})[T]
Copy link
Contributor

Choose a reason for hiding this comment

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

However, after fix this, Glamorous typing will not work with TS <= 2.8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, have you tested that? I'm guessing the in T and in U don't work? this is why flow's approach is better (versioning to lib and flow instead of just lib). Any way, it seems like we should prefer supporting the most recent version of TS, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

@aaronjensen As you said, supporting recent TS version is better. However, if there's a way to support both old and new versions, that's the best, isn't it?
I mean, keyof any will return string | number | symbol for TS@2.9, and string for TS@<=2.8, so how about that?

Copy link
Contributor

Choose a reason for hiding this comment

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

And if we want to support TS@2.9 only, we have Extract from TS@2.8, so we don't need these helpers.

@aaronjensen aaronjensen changed the title Fix preact typings for Typescript 2.9 Fix typings for Typescript 2.9 May 31, 2018
@aaronjensen
Copy link
Contributor Author

@Ailrun I used Exclude since that's 2.8+

@Ailrun
Copy link
Contributor

Ailrun commented May 31, 2018

@aaronjensen So for you, does T extends keyof any look weird? That's why you remove support for TS@>=2.6.2 < 2.8?

@aaronjensen
Copy link
Contributor Author

@Ailrun no, to be honest, I don't know what the full impacts would be of that change so I didn't want to risk it and given that there won't be much other reason to upgrade glamorous it doesn't seem like a big deal to drop support for <2.8

Ailrun
Ailrun previously approved these changes May 31, 2018
@kentcdodds
Copy link
Contributor

Can we get the build working before we merge this please? :)

@aaronjensen
Copy link
Contributor Author

We could yeah, but it has nothing to do w/ this PR, so should it be a separate one? This repo doesn't appear to use a package-lock or a yarn.lock so as new eslint rules get added failures crop up with 0 changes.

Current failures:

[lint] /home/travis/build/paypal/glamorous/src/theme-provider.js
[lint]   16:1  error  componentWillMount is deprecated since React 16.3.0, use UNSAFE_componentWillMount instead, see https://reactjs.org/docs/react-component.html#unsafe_componentwillmount                       react/no-deprecated
[lint]   16:1  error  componentWillReceiveProps is deprecated since React 16.3.0, use UNSAFE_componentWillReceiveProps instead, see https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops  react/no-deprecated
[lint] 
[lint] /home/travis/build/paypal/glamorous/src/with-theme.js
[lint]   16:3  error  componentWillMount is deprecated since React 16.3.0, use UNSAFE_componentWillMount instead, see https://reactjs.org/docs/react-component.html#unsafe_componentwillmount                       react/no-deprecated
[lint]   16:3  error  componentWillReceiveProps is deprecated since React 16.3.0, use UNSAFE_componentWillReceiveProps instead, see https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops  react/no-deprecated

@aaronjensen
Copy link
Contributor Author

I actually get even more lint failures locally 😖

@codecov-io
Copy link

Codecov Report

Merging #425 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #425   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          10     10           
  Lines         177    177           
  Branches       50     50           
=====================================
  Hits          177    177

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c54bbe...b3e75d4. Read the comment docs.

@aaronjensen
Copy link
Contributor Author

Tests are passing now with the deprecated lints being ignored. Maybe a follow-up PR could deal w/ it properly (which would probably require bumping the minimum version of react required)

@@ -71,7 +71,7 @@
"tslint": "^5.8.0",
"tslint-microsoft-contrib": "^5.0.0",
"tsutils": "^2.15.0",
"typescript": "^2.6.2"
"typescript": "^2.9.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Does not this work with TS@2.8?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The snapshot tests won't. This is just a dev dependency.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, snapshot... OK.

Copy link
Contributor

@Ailrun Ailrun left a comment

Choose a reason for hiding this comment

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

LGTM

@kentcdodds kentcdodds merged commit 5136e84 into paypal:master Jun 1, 2018
@aaronjensen aaronjensen deleted the patch-1 branch June 1, 2018 15:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants