-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
"adal" package #12586
Comments
I agree. The types package name needs to match the npm package name. |
The definition matches the structure of the adal-angular package. There is no 'adal' package. |
Is that what breaks Splitting the files should be simple but it is weird to have the type package not match the npm package. |
Looks like this was called I assume we have no typings for "adal-node" at the moment. If we're really just defining |
[mmaitre314] A single type file would break ADAL's layering. The One could argue that ADAL should ship two NPM packages, but at the moment this is not the case. If the type package needs to match the NPM package, it needs to be a single package with two .d.ts files. |
So how are these imported? Does one do |
They are typically loaded via
I got them to load as AMD once (in JS, haven't tried TS for that) but that required shims:
|
Any chance this will get resolved? Not having the @types package match the npm package name basically makes the types package useless. |
Typescript has a |
PRs welcome. |
As far as I can tell, the following changes are needed:
Any suggestions for PRs to fix the main issue of renaming the For reference, I am importing the library with the following imports: import AuthenticationContext from 'adal-angular';
import 'adal-angular/lib/adal-angular';
// The AuthenticationContext needs to be globally available for adal-angular
window['AuthenticationContext'] = AuthenticationContext; |
This PR AzureAD/azure-activedirectory-library-for-nodejs#176 adds type definitions for the node.js specific adal library (adal-node) along with proper tests in TS. |
as of version 0.1.25 adal-node supports type definitions. |
I'm using adal-angular type definition, and when I try to import |
@husseinkorly That's not a type definition issue. It is actually a TypeScript compiler change. You'll need to do the following import. import * as AuthenticationContext from 'adal-angular'; |
@aciccarello this makes everything available under |
I am able to create an instance of this.context = new AuthenticationContext(config); Then to access the protected context: adal.AuthenticationContext; What are you trying to do with |
@aciccarello Here's what I'm trying to do: I'm writing an auth service using adal-angular: |
I would think you'd want something like this: // Import the AuthenticationContext constructor from the `adal-angular` module.
import { AuthenticationContext } from "adal-angular";
...
this.context = new AuthenticationContext(config); or // Import everything from the `adal-angular` module into a variable.
import * as adal from "adal-angular";
...
this.context = new adal.AuthenticationContext(config); |
@craxal do you mean importing from |
@husseinkorly Either/or, it should work for both Typescript and your module loader. The key is knowing how the module exports what you need. By looking at the import { AuthenticationContext } from "adal-angular";
...
this.context = new AuthenticationContext(config); The module has other exports, so you'll want to import them as needed like this: // If you want everything:
import * as adal from "adal-angular";
// ...or just specific things:
import { LoggingLevel } from "adal-angular"; To be sure, you can use a debugger. Drop a breakpoint before you first use the import and examine the import variable's value. |
Okay, so I was using the old This does not seem to work with the Attempt 1import * as AuthenticationContext from 'adal-angular';
const config: any = {};
const context = new AuthenticationContext(config); TypeScript throws the following:
Attempt 2The import { inject, AuthenticationContextOptions } from 'adal-angular';
const config: AuthenticationContextOptions = {};
const context = inject(config);
Proposed SolutionUpdate the type definition to export // In module contexts the class constructor function is the exported object
export = AuthenticationContext;
// This class is defined globally in not in a module context
declare class AuthenticationContext {
constructor(config: AuthenticationContext.Config) {}
// ...
}
declare namespace AuthenticationContext {
export interface Config {}
// any other interfaces to export
} Other changes
I came up with an initial implementation these changes (following the module-class.d.ts template). They need to be improved and testing added before I can open a PR. |
@aciccarello yeah, the problem is that Instead of your proposed solution, TypeScript 2.7 seems to be pushing users to use the
You can read more here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#support-for-import-d-from-cjs-form-commonjs-modules-with---esmoduleinterop |
@unindented I hadn't seen that information so thanks for highlighting it. I still wonder if the the type definition should be changed to match the module implementation. While using the flag may fix things, I don't think developers should be required to use it. I haven't tested it but I assume you should be able to still import the |
I think if adal-angular can add a default export in the source code over here. if (typeof module !== 'undefined' && module.exports) {
module.exports = AuthenticationContext;
module.exports.default = AuthenticationContext; // This extra line would be helpful
module.exports.inject = function (conf) {
return new AuthenticationContext(conf);
};
} This should enable |
@amarzavery While I agree that they should also add it as a default export, I think the DefinitelyTyped repo should match the existing implementation. According to the DefinitelyTyped README
I've created #24727 with this change and some missing properties. |
The The only other issue with the type definitions that I am aware of are the missing angular service types that were removed in 87ad3c1. |
Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the |
adal/index.d.ts
.This does
declare module 'adal'
butnpm info adal
turns up nothing. Did you mean"adal-node"
?(If so, we should deprecate this and move to
@types/adal-node
.)Also, if you want
adal-angular
published it should be in its own directory or listed in thetsconfig
.The text was updated successfully, but these errors were encountered: