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

No default export for TypeScript bindings, add Webpack instructions #645

Merged
merged 2 commits into from
Jul 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/integrations/angular2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,14 @@ Then, in your main application file (where ``bootstrap`` is called, e.g. main.ts
]);

Once you've completed these two steps, you are done.

Webpack and Other Module Loaders
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In Webpack and other module loaders, you may need to use the require keyword to load Raven:

.. code-block:: js

import Raven = require('raven-js');
.config('__PUBLIC_DSN__')
.install();
6 changes: 3 additions & 3 deletions typescript/raven-tests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Raven, {RavenOptions} from '..';
import Raven = require('..');

Raven.config('https://public@getsentry.com/1').install();

var options: RavenOptions = {
var options = {
Copy link
Contributor Author

@benvinegar benvinegar Jul 7, 2016

Choose a reason for hiding this comment

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

You cannot explicitly declare things as RavenOptions any more (exporting this depended on default export support), but it will still be type-checked since it is passed as a parameter to Raven.config

logger: 'my-logger',
ignoreUrls: [
/graph\.facebook\.com/i,
Expand All @@ -22,7 +22,7 @@ var options: RavenOptions = {
]
};

Raven.config('https://public@getsentry.com/1', 1).install();
Raven.config('https://public@getsentry.com/1', options).install();

var throwsError = () => {
throw new Error('broken');
Expand Down
6 changes: 3 additions & 3 deletions typescript/raven.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

declare var Raven: RavenStatic;

export default Raven;
export = Raven;

export interface RavenOptions {
interface RavenOptions {
/** The log level associated with this event. Default: error */
level?: string;

Expand Down Expand Up @@ -54,7 +54,7 @@ export interface RavenOptions {
transport?: (options: RavenTransportOptions) => void;
}

export interface RavenStatic {
interface RavenStatic {

/** Raven.js version. */
VERSION: string;
Expand Down