u-now / types-x

eXtend ServiceNow development with type definitions
MIT License
1 stars 3 forks source link

Add JSDoc for RESTMessageV2.d.ts #33

Closed johncaruso closed 5 years ago

emyrold commented 5 years ago

@johncaruso this is kicking my ass... I've been googling the correct syntax for JSDoc where there is a "declare namespace" in the d.ts . in this RESTMessage there are two things I do not know how to address, declare namespace sn_ws {} and at the very bottom type RestHTTPMethods = . I'm cross checking with developer api and do not see the type referenced there and it is highlighted blue lik the declare and constructor.

emyrold commented 5 years ago
declare namespace sn_ws {
  declare class RESTMessageV2 {
    constructor();
    constructor(name: string, methodName: RestHTTPMethods);
    execute(): RESTResponseV2;
    // ...
    setStringParameterNoEscape(name: string, value: string): void;
  }

  type RestHTTPMethods =
    | 'get'
    | 'post'
    | 'delete'
    | 'patch'
    | 'put'
    | 'head'
    | 'delete'
    | 'options';
}
johncaruso commented 5 years ago

Understand that there is overlap between things in JSDoc and d.ts (TypeScript definitions). Not everything needs a JSDoc, if is has a corresponding d.ts.

For this case, while there is a tag for namespaces, there is no point in including it here, as the d.ts itself documents the namespace and a member of that namespace: RESTMessageV2

Now if you were just using plain JavaScript without d.ts files, then you might want to use the tags @namespace and @memberof as documented here: http://usejsdoc.org/tags-namespace.html

Regarding the type RestHTTPMethods, this again is something where a corresponding JSDoc would just duplicate the d.ts. But for your reference, if not using d.ts, it would be:

@typedef {'get' | 'post' | '...'} RestHTTPMethods

(I think.)

On Mon, Mar 11, 2019 at 8:16 AM emyrold notifications@github.com wrote:

declare namespace sn_ws { declare class RESTMessageV2 { constructor(); constructor(name: string, methodName: RestHTTPMethods); execute(): RESTResponseV2; // ... setStringParameterNoEscape(name: string, value: string): void; }

type RestHTTPMethods = | 'get' | 'post' | 'delete' | 'patch' | 'put' | 'head' | 'delete' | 'options'; }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/u-now/types-x/issues/33#issuecomment-471533880, or mute the thread https://github.com/notifications/unsubscribe-auth/AANsjfrzmDvi-GZWeBkE6GiB_nPshZ19ks5vVlc_gaJpZM4bnj0p .