Oidc-client-js: Create TypeScript definitions; submit them to a registry.

Created on 19 Aug 2016  路  20Comments  路  Source: IdentityModel/oidc-client-js

E.g. it would be great to run:

typings install dt~oidc-client
enhancement

Most helpful comment

Nice. Will you create a new release for this?

All 20 comments

IIRC someone did for an older version of this library. Do they get a copy, or a pointer here?

I'm not sure what you mean. Are you wondering whether they get notified automatically about this GitHub issue?

When a project is added to the registry, is it just a URL back here, or do we upload a snapshot of a typings file?

I believe you add it to the DefinitelyTyped and create a pull request.

Ok, I can look into it.

Looks like the older oidc-user-manager is already in there, so it gives me something to start from.

So it seems I need to be able to compile it and run a test with tsc. I did and the one we have didn't work. Any thoughts on that @jmurphzyo?

I did my best to know WTF I was doing (mainly copying what @rosieks had done with oidc-user-manager) and tried to make these changes and now it compiles: https://github.com/IdentityModel/oidc-client-js/commit/09d42480876c28c0fb2eec29a8805807e0d0c12d

Again, thoughts? What are the right tweaks to submit to DefinitelyTyped?

@brockallen I have had a full load today. I will look at it tomorrow and generate some test. Do you want me to create a pr here? or create a gist for you?

You can fork my PR and submit to that.

I don't see your pr on DefinitelyTyped .

Oh I guess I never made a PR here. Just did it now (to be official): https://github.com/IdentityModel/oidc-client-js/pull/86

Not sure whether this PowerShell script might be useful. When run from the src directory of oidc-client-js, it generates a single file with all the type definitions. Here is the result, which works for me locally when using TypeScript.


Get-ChildItem -Path *.js | foreach { Copy-Item $_ $_.Name.Replace(".js", ".temp.ts") }

Get-ChildItem -Path *.temp.ts | foreach { tsc --declaration $_.Name }

Get-ChildItem -Path *.d.ts -Exclude "_index.d.ts" | `  
    foreach { Get-Content $_ } | `    
    where { !$_.ToString().StartsWith("import") } | `    
    foreach { $_.Replace("export default", "export") } | `    
    foreach { Add-Content _index.d.ts $_ }

Remove-Item *.temp.ts, *.temp.d.ts, *.temp.js

Explanation:

  1. Change all the extensions to .temp.ts.
  2. Use the TypeScript compiler to generate definition files. There will be a bunch of compiler errors, but we can ignore those.
  3. Combine all those files into one. Remove the import statements and remove the default from the export statements.
  4. Cleanup.

Edit: Update link. Update script.

Hi, typings (with vscode) isnt picking up the type definition file, according to the following, it looks for index.d.ts by default, or in the package.json file you can use the "typings": "oidc-client.d.ts" config parameter to explicitly define the file.

http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html

Can i request this is included in the updates to the typigs stuff. Thanks !

@ro- send a PR please.

no worries, here it is #89

@ro- merged. thx

Nice. Will you create a new release for this?

Can I close this now?

Looks like that has broken the use of oidc-client through Webpack.

error TS2656: Exported external package typings file 'c:/project/node_modules/oidc-client/oidc-client.d.ts' is not a module. Please contact the package author to update the package definition.

To fix this you can simply delete the export module section, PR #131

Edit: this problem went away when TypeScript was upgraded to version 2.0.3.

Was this page helpful?
0 / 5 - 0 ratings