question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use GoogleLogin named export in TS project

See original GitHub issue

Although the default export works fine, I get a TS error TS2305: Module '"path/to/node_modules/react-google-login/index"' has no exported member 'GoogleLogin' when I try to use the GoogleLogin named export from the latest release (3.0.2).

import { GoogleLogin } from 'react-google-login';

From what I’ve seen, and if I understand the TS docs, I believe the change made in PR #107 to wrap members in a namespace isn’t necessary.

To reiterate why you shouldn’t try to namespace your module contents, the general idea of namespacing is to provide logical grouping of constructs and to prevent name collisions. Because the module file itself is already a logical grouping, and its top-level name is defined by the code that imports it, it’s unnecessary to use an additional module layer for exported objects.

I was able to resolve the error by removing the namespace wrapper, allowing both the GoogleLogin class to be exported and a default export to be defined. Would you be open to reviewing a PR?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
anthonyjgrovecommented, Jan 1, 2018

@yershalom @corydeppen

Please try react-google-login@3.0.3

0reactions
corydeppencommented, Jan 2, 2018

@anthonyjgrove Yep, that should work. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can't I `import {}` from `export default {}` in typescript
Your util.ts file exports a default export, while you are requesting a named export. You must change your import to request the default ......
Read more >
The guide to adding Google login to your React app
In this article we will learn how Google login works and how we can add it in our React app using a package...
Read more >
Google Authentication | Cypress Documentation
What you'll learn Programmatically authenticate with Google via a custom Cypress command Adapting your Google application for programmatic authentication.
Read more >
How to Implement Login with Google in Nest JS
The first thing to do is to setup the google strategy which is the core of our google login implementation. Create a file...
Read more >
Documentation - Modules - TypeScript
How modules work in TypeScript. ... ParseIntBasedZipCodeValidator.ts. ts. export class ... Default export class and function declaration names are optional.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found