floralvikings / jira-connector

NodeJS Wrapper for the Jira REST API
http://floralvikings.github.io/jira-connector/
MIT License
373 stars 180 forks source link

Add basic type definitions for issueType api #207

Closed G-Rath closed 4 years ago

G-Rath commented 4 years ago

🎉

MrRefactoring commented 4 years ago

You forgot to add issueType to index.d.ts 🙂

G-Rath commented 4 years ago

You forgot to add issueType to index.d.ts 🙂

Good catch!

Plus you've reminded me I should use export = in issueType.d.ts :D

MrRefactoring commented 4 years ago

Can you give a comment about why we use export =, not export declare class ...?

G-Rath commented 4 years ago

Sure!

We use it b/c that represents the export in the js; you can see this in the playground, but in a nutshell, here's what each type of export transpiles to:


export default 'hello';

Becomes

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = 'hello';

export const hello = 'hello';

Becomes

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hello = 'hello';

export = 'hello';

Becomes

"use strict";
module.exports = 'hello';

Since the exports are being done using module.exports, the correct way to represent that in TypeScript is to use export = ... 🙂

MrRefactoring commented 4 years ago

This is new knowledge for me, thanks!

G-Rath commented 4 years ago

No problem! It's a bit of an edge-case in TS land, that you generally don't need to worry about unless you're writing types manually 😎

MrRefactoring commented 4 years ago

Thanks! ðŸĪŠ