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

[classnames] Support for ES modules #25206

Conversation

alexey-pelykh
Copy link
Contributor

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If adding a new definition:

  • The package does not already provide its own types, or cannot have its .d.ts files generated via --declaration
  • If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
  • Create it with dts-gen --dt, not by basing it on an existing project.
  • tslint.json should be present, and tsconfig.json should have noImplicitAny, noImplicitThis, strictNullChecks, and strictFunctionTypes set to true.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: JedWatson/classnames@915186a
  • Increase the version number in the header if appropriate.
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }.

If removing a declaration:

  • If a package was never on DefinitelyTyped, you don't need to do anything. (If you wrote a package and provided types, you don't need to register it with us.)
  • Delete the package's directory.
  • Add it to notNeededPackages.json.

@typescript-bot
Copy link
Contributor

typescript-bot commented Apr 22, 2018

@alexey-pelykh Thank you for submitting this PR!

🔔 @adidahiya @jkillian @seansfkelley @mradamczyk @marvinhagemeister @NeekSandhu - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Awaiting reviewer feedback labels Apr 22, 2018
@seansfkelley
Copy link
Contributor

@alexey-pelykh how does this relate to #25205?

Copy link
Contributor

@seansfkelley seansfkelley left a comment

Choose a reason for hiding this comment

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

The corresponding change in classNames hasn't been released yet, so it seems these two PRs should block on that lest you break the entire Typescript-React community. :)

There is a ticket to track this release (JedWatson/classnames#152), which I've taken the liberty of pinging the maintainer on.

@typescript-bot typescript-bot added Revision needed This PR needs code changes before it can be merged. and removed Awaiting reviewer feedback labels Apr 23, 2018
@typescript-bot
Copy link
Contributor

@alexey-pelykh One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits or comments. Thank you!

@alexey-pelykh
Copy link
Contributor Author

@seansfkelley the #25205 adds an extra declaration without breaking anything, but I'd rather avoid that approach at all. Indeed, the JedWatson/classnames#152 is not yet there :( I guess it blocks this PR :|

@seansfkelley
Copy link
Contributor

Got it. Totally agree the default import is stylistically preferable, but such a sudden transition for such a widely-used library seems likely to bring down a rain of complaints and bug reports... #25206 might be the best plan (assuming that the library change ever gets merged).

@alexey-pelykh
Copy link
Contributor Author

#25205 is a workaround that would work until/if classnames gets updated and it would allow to use esnext approach.

@seansfkelley
Copy link
Contributor

Ooh, I see, I didn't notice that it exposed a different path for the typings.

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Apr 23, 2018
@typescript-bot
Copy link
Contributor

@alexey-pelykh I haven't seen anything from you in a while and this PR currently has problems that prevent it from being merged. The PR will be closed tomorrow if there aren't new commits to fix the issues.

@typescript-bot typescript-bot added Revision needed This PR needs code changes before it can be merged. Abandoned This PR had no activity for a long time, and is considered abandoned labels Apr 29, 2018
@typescript-bot
Copy link
Contributor

@alexey-pelykh To keep things tidy, we have to close PRs that aren't mergeable but don't have activity from their author. No worries, though - please open a new PR if you'd like to continue with this change. Thank you!

bryphe pushed a commit to onivim/oni that referenced this pull request May 16, 2018
* Add middle click tab closing (#2069)

by adding a onMouseDown directive to both tab file icon and
tab name and checking the resulting React.MouseEvent for a
middle click

* Fix unused imports and whitespace in Tabs ui test (#2069)

* Update Tabs component test snapshot (#2069)

* Fix Tabs ui test to correctly retrieve children (#2069)

* Differentiate between single und multiple tabs in test (#2069)

* Use mousedown event for tab selection and closing (#2069)

by middle clicking and let the tab itself handle the logic
for it by checking React.MouseEvent.button value

* Update classnames dependency to lastest master branch

and write own @types module declaration so that it can be used in
testing nstead of using a mock. The mock does not suffice as the
way the actual module previously had to be imported was
"import * as classNames" where classNames was the actual function.

It is not possible to build a module in typescript/es6 imports, which
will directly return a function in the same way the dependency did
in commonjs module syntax. Instead when defining a function to be
returned as default export it is returned as an Object like this
"{ default: [Function] }", which is correctly resolved when importing
with "import classNames from 'classnames'".

This only previously worked in production as webpacks ts-loader,
handles this issue, whereas when testing the sources are only compiled
with tsc.

There is an update to the classnames dependency on the current master,
but there hasn't been a release since 2006. So options were to setup
webpack for tests as well or add updated classnames dependency which
sets a "default" value on its commonjs exports.

Links for reference:
JedWatson/classnames#152
JedWatson/classnames#106
DefinitelyTyped/DefinitelyTyped#25206
microsoft/TypeScript#2719

* Fix tab click onMouseDown callback

* Test tab clicks to select/close trigger callbacks

* Mock child react components directly to test smaller unit

* Reset calls to callback mocks in each test case

* Add tests for tabs interaction with FileIcon/Sneakable
@alexey-pelykh alexey-pelykh deleted the classnames_support_for_esmodules branch April 14, 2019 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Abandoned This PR had no activity for a long time, and is considered abandoned Popular package This PR affects a popular package (as counted by NPM download counts). Revision needed This PR needs code changes before it can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants