Two issues but I'm hitting them both here in case I'm missing something simple.
npm install auth0-js --save
typings install auth0 --save --ambient
import * as Auth0 from 'auth0-js';
The exported typings module is named "auth0" while the npm package is "auth0-js". I get around this problem by tweaking the bottom of index.d.ts to declare module "auth0-js" { ... but it's not ideal.
Definition
interface Auth0Static {
getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
}
Implementation
Auth0.prototype.getDelegationToken = function (options, callback) {...
Would love to be told I'm making a stupid mistake
To complicate matters, Typings has gone 1.0 and has some breaking changes.
typings install auth0 --save --ambient
is now
typings install dt~auth0 --save --global
and the folder structure inside the typings folder has changed (making the problem with editing auth0/index.d.ts immediately apparent).
Watching this thread.
Anyone has a workaround for this?
I've begun work on this here: https://github.com/westy92/DefinitelyTyped/tree/fix-auth0.
My PR (https://github.com/DefinitelyTyped/DefinitelyTyped/pull/10653) was just merged. This should now be fixed!
This just caused me a world of pain. @westy92 one of the issues mentioned in the OP is still not fixed with your PR:
the module is still exported as "auth0" when it should be "auth0-js"
I somehow missed that string. I'll submit a PR shortly.
Thanks. There are actually a number of other issues with the typings file, once I've completed my implementation I'll share.
As I mentioned in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/10721#issuecomment-242801261, there are _two_ packages for auth0, so both auth0 and auth0-js are equally valid.
I still get this error after I install types
npm install auth0-js --save
npm install @types/auth0-js --save
import { Auth0 } from 'auth0-js';
Module '"auth0-js"' has no exported member 'Auth0'.
@CrisLi there is no Auth0 class. Try:
import * as Auth0 from 'auth0-js';
@westy92 I have tried
import * as Auth0 from 'auth0-js';
The error became
node_modules/@types/auth0-js/index.d.ts' is not a module.
The package.json snippet is:
"@types/auth0-js": "^8.1.0",
"angular2-jwt": "^0.1.28",
"auth0-js": "^8.2.0",
I have the same issue as @CrisLi. I was able to fix it locally by changing the top line from:
declare module auth0 {
to
declare module 'auth0-js' {
Not sure how this affects backwards compatibility or if there are any other issues.
For now, I did the following to make the typings work:
"typeRoots": ["./types"] to tsconfig.jsonindex.d.ts from node_modules/@types/auth0-js to types/auth0-jsindex.d.ts filenode_modules/@types/auth0-jsThe above steps require TS >v.2.0.0 and possibly modeResulotion set to node.
I was looking through this trying to figure out the issue, and it looks like it may have been fixed in https://github.com/DefinitelyTyped/DefinitelyTyped/commit/625be7cb6522b3d004b2fe93ace7357686eeb3a4. Can you grab the latest version (8.3.0) and try again?
I fixed this issue in v7 but it appears to have regressed in earlier versions of v8.
Most helpful comment
To complicate matters, Typings has gone 1.0 and has some breaking changes.
typings install auth0 --save --ambientis now
typings install dt~auth0 --save --globaland the folder structure inside the typings folder has changed (making the problem with editing auth0/index.d.ts immediately apparent).
Watching this thread.