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

typescript es6 import, TypeError: Cannot read property 'start' of undefined #1398

Closed
davidbielik opened this issue Oct 27, 2021 · 3 comments · Fixed by #1400
Closed

typescript es6 import, TypeError: Cannot read property 'start' of undefined #1398

davidbielik opened this issue Oct 27, 2021 · 3 comments · Fixed by #1400
Assignees
Labels
api: cloudtrace Issues related to the googleapis/cloud-trace-nodejs API. 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@davidbielik
Copy link

Environment details

  • OS: Mac OS
  • Node.js version: 14.15.4
  • npm version: 7.21.1
  • @google-cloud/trace-agent version: 5.1.5

Steps to reproduce

  1. import TraceAgent from '@google-cloud/trace-agent'
  2. Run TraceAgent.start();
  3. Observe the error TypeError: Cannot read property 'start' of undefined

To fix this, I needed to instead import * as TraceAgent

Suggestions/Questions:

  1. Can this be added to the readme, to help with future integrators using es6/typescript imports?
  2. I wonder why this wasn't caught by typescript? is there something wrong with the typing provided?
@product-auto-label product-auto-label bot added the api: cloudtrace Issues related to the googleapis/cloud-trace-nodejs API. label Oct 27, 2021
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Nov 3, 2021
@dnoe dnoe self-assigned this Nov 9, 2021
dnoe added a commit that referenced this issue Nov 9, 2021
GitHub issue #1398 indicates that a specific incantation is required when using "import" with the trace-agent. This PR updates the README to mention this.
@dnoe
Copy link
Contributor

dnoe commented Nov 9, 2021

I'm part of the team at Google that maintains the Trace backend and we also own this repository. I'm not a Javascript expert, so I'm flying blind a bit and would definitely appreciate your comments on the PR I created to update the README.md. Let me know if there's a clearer way to say it.

I'm not sure why this wasn't caught by Typescript.

@davidbielik
Copy link
Author

Thanks @dnoe

One quick correction to your merged PR:

import * as TraceAgent from '@google-cloud/trace-agent';

instead of

import * from '@google-cloud/trace-agent' as TraceAgent;

@dnoe
Copy link
Contributor

dnoe commented Nov 9, 2021

Thanks for the quick response! I will figure out the proper way to update that README.md so the bot accepts it and we'll get that merged.

dnoe added a commit that referenced this issue Nov 9, 2021
GitHub issue #1398 indicates that a specific incantation is required when using "import" with the trace-agent. This PR updates the README to mention this.
dnoe added a commit that referenced this issue Nov 16, 2021
* Update READM partials to mention how to use import

GitHub issue #1398 indicates that a specific incantation is required when using "import" with the trace-agent. This PR updates the README to mention this.

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: cloudtrace Issues related to the googleapis/cloud-trace-nodejs API. 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
3 participants