Comments (13)
I don't see any problems with requiring .default
as long as it's documented.
from opentracing-javascript.
@yurishkuro Still missing .default
since TypeScript doesn't export the default directly.
from opentracing-javascript.
hm, it worked for me, although bombed on another issue #79, which might be related.
Is there a way to make TypeScript export the default?
from opentracing-javascript.
Not sure, I know it's also the new behaviour of Babel since version 6. For babel there is a plugin to get the old behaviour back, I don't know about TypeScript. This is related to converting import
statements to require
, so a quick and easy solution for node is to simply use require
directly.
from opentracing-javascript.
Found a few discussions about this:
microsoft/TypeScript#2719
microsoft/TypeScript#3337
from opentracing-javascript.
Yeah, I overlooked this in my PR.
from opentracing-javascript.
Given that README uses const apiCompatibilityChecks = ...
(ES6 feature), wouldn't the example be better with import
instead of require
?
import apiCompatibilityChecks from 'opentracing/lib/test/api_compatibility.js';
from opentracing-javascript.
I would go after what the NodeJS LTS versions we are targeting support, and they don't support import
yet (they do support const
, arrow functions, etc). Could be confusing for users if the examples don't run without a transpiler.
.default
has actually been part of the CommonJS spec before NodeJS existed so it's not strictly an ES6 concept :)
from opentracing-javascript.
@felixfbecker @yurishkuro I'm taking a look at open issues... what is the status here? I am not knowledgeable enough about Node to have an opinion, but would like to agree on what we think is best (even if we don't have time to do the work right now).
from opentracing-javascript.
I think this should be fixed in the README on latest master:
const { apiCompatibilityChecks } = require('opentracing/lib/test/api_compatibility.js'); apiCompatibilityChecks(() => new CustomTracer());
(it destructures all the exports and cherry-picks apiComatibilityChecks
)
from opentracing-javascript.
@felixfbecker SGTM!
from opentracing-javascript.
See current master (Fix how requiring apiCompatibilityChecks #85 now merged in) :)
The default export in opentracing/lib/test/api_compatibility.js. is a property on the exports object and thus is accessed with .default
.
There can be only one default property on the exports object.
This property does not therefore need to be destructured.
from opentracing-javascript.
closing per #85
from opentracing-javascript.
Related Issues (20)
- MockTracer._allocSpan is private and can't be overwritten HOT 2
- Why not use interfaces instead of classes? HOT 13
- automatic tracer HOT 2
- Inject and Extract with BINARY format HOT 2
- [Feature Request] forEachBaggageItems on SpanContext
- Default import is not working in some contexts HOT 7
- Left me hanging - "the case where..."
- Trace should provide a method to get active span like other language API does
- Consider marking Span.constructor protected
- Is this project dead? HOT 1
- `__esModule` is `true` while no default export provided, breaks interoperability HOT 2
- trace should expose close function HOT 1
- SpanContext should expose a proper traceId and spanId
- How do I trace requests from the browser? HOT 4
- MockTracer does not allow testing tags
- How to I chain traces over more than two processes? HOT 13
- Type checks won't always work in Reference creating functions HOT 3
- Span tag values should be `string`s, `boolean`s or `number`s HOT 2
- After latest release we have blocker issue HOT 11
- Set a span parent without using the context
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opentracing-javascript.