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

update numbro.d.ts to use export = instead of export default #232

Merged
merged 2 commits into from Apr 3, 2017

Conversation

Projects
None yet
7 participants
@olmobrutall
Contributor

olmobrutall commented Feb 5, 2017

As https://github.com/foretagsplatsen/numbro/blob/develop/dist/numbro.js shows the module is exported as a namespace (module.exports = numbro;), but the Typescript .d.ts file was exporting it using export default numbro.

This discrepancy makes it impossible to use in TS:

  • If imported using `import numbro from "numbro", then numbro is undefined at runtime.
  • If imported using `import * as numbro from "numbro", TS finds no member.

This commit changes numbro.d.ts to use exports = that is the correct way of representing the current javascript behaviour.

@smajl

This comment has been minimized.

Show comment
Hide comment
@smajl

smajl Feb 6, 2017

Hm, strange, import numbro from "numbro"; works in our project with no problem.

smajl commented Feb 6, 2017

Hm, strange, import numbro from "numbro"; works in our project with no problem.

@BenjaminVanRyseghem

This comment has been minimized.

Show comment
Hide comment
@BenjaminVanRyseghem

BenjaminVanRyseghem Feb 6, 2017

Owner

I don't use TS myself, so I can't really help, sorry 😕

Owner

BenjaminVanRyseghem commented Feb 6, 2017

I don't use TS myself, so I can't really help, sorry 😕

@olmobrutall

This comment has been minimized.

Show comment
Hide comment
@olmobrutall

olmobrutall Feb 6, 2017

Contributor

@smajl, what module loader are you using? I know that babel and SystemJS do some magic vodoo to hide the differences but this 'feature' is being reconsidered as mentioned here: Microsoft/TypeScript#5565

@BenjaminVanRyseghem, in general in ES2016:

  • If export.default = numbro then import numbro from "numbro"
  • If export = numbro then import * as numbro from "numbro"

As I said some loaders/bundlers hack it arround to make things simpler, but actually they make it more confusing...

TS is strict about it an, since numbro.js is not using default, then export = is the right approach.

It works in my machine (TM) and is the same that moment.d.ts is doing: https://github.com/moment/moment/blob/develop/moment.d.ts

Contributor

olmobrutall commented Feb 6, 2017

@smajl, what module loader are you using? I know that babel and SystemJS do some magic vodoo to hide the differences but this 'feature' is being reconsidered as mentioned here: Microsoft/TypeScript#5565

@BenjaminVanRyseghem, in general in ES2016:

  • If export.default = numbro then import numbro from "numbro"
  • If export = numbro then import * as numbro from "numbro"

As I said some loaders/bundlers hack it arround to make things simpler, but actually they make it more confusing...

TS is strict about it an, since numbro.js is not using default, then export = is the right approach.

It works in my machine (TM) and is the same that moment.d.ts is doing: https://github.com/moment/moment/blob/develop/moment.d.ts

@smajl

This comment has been minimized.

Show comment
Hide comment
@smajl

smajl Feb 7, 2017

@olmobrutall We are using JSPM = SystemJS, so that might be the case. Anyway I second your change proposal, it's the correct way. 👍

smajl commented Feb 7, 2017

@olmobrutall We are using JSPM = SystemJS, so that might be the case. Anyway I second your change proposal, it's the correct way. 👍

@olmobrutall

This comment has been minimized.

Show comment
Hide comment
@olmobrutall

olmobrutall Feb 10, 2017

Contributor

@BenjaminVanRyseghem, something missing for this to get merged?

Contributor

olmobrutall commented Feb 10, 2017

@BenjaminVanRyseghem, something missing for this to get merged?

@BenjaminVanRyseghem

This comment has been minimized.

Show comment
Hide comment
@BenjaminVanRyseghem

BenjaminVanRyseghem Feb 13, 2017

Owner

@olmobrutall me missing time 😄

Owner

BenjaminVanRyseghem commented Feb 13, 2017

@olmobrutall me missing time 😄

Show outdated Hide outdated numbro.d.ts Outdated
@olmobrutall

This comment has been minimized.

Show comment
Hide comment
@olmobrutall

olmobrutall Feb 13, 2017

Contributor

fixed :)

Contributor

olmobrutall commented Feb 13, 2017

fixed :)

@olmobrutall

This comment has been minimized.

Show comment
Hide comment
@olmobrutall

olmobrutall Feb 17, 2017

Contributor

C'mon a little bit of attention, I just want to make your library great again (for TS users)

Contributor

olmobrutall commented Feb 17, 2017

C'mon a little bit of attention, I just want to make your library great again (for TS users)

@morlay

This comment has been minimized.

Show comment
Hide comment
@morlay

morlay Feb 18, 2017

Could we release a patch for this?

morlay commented Feb 18, 2017

Could we release a patch for this?

@BenjaminVanRyseghem

This comment has been minimized.

Show comment
Hide comment
@BenjaminVanRyseghem

BenjaminVanRyseghem Feb 20, 2017

Owner

@olmobrutall I would love to have more time dedicated to numbro. If you want to negotiate that with my boss, be my guest 😛

Owner

BenjaminVanRyseghem commented Feb 20, 2017

@olmobrutall I would love to have more time dedicated to numbro. If you want to negotiate that with my boss, be my guest 😛

@olmobrutall

This comment has been minimized.

Show comment
Hide comment
@olmobrutall

olmobrutall Feb 20, 2017

Contributor

We're al in the business of unrecognized and unpayed work in github.

The thing is that numbro is currently unusable for me (and probably like half of the TS users) because of a change that only needs to get merged.

If you think that maintaining the d.ts file is a big burden because there is no contributor using TS and it is seen as an alien technology, just delete the file and let it evolve independently in DefinitelyTyped. They currently don't accept my pull request there (DefinitelyTyped/DefinitelyTyped#14412) because they think the d.ts is maintained here.

Contributor

olmobrutall commented Feb 20, 2017

We're al in the business of unrecognized and unpayed work in github.

The thing is that numbro is currently unusable for me (and probably like half of the TS users) because of a change that only needs to get merged.

If you think that maintaining the d.ts file is a big burden because there is no contributor using TS and it is seen as an alien technology, just delete the file and let it evolve independently in DefinitelyTyped. They currently don't accept my pull request there (DefinitelyTyped/DefinitelyTyped#14412) because they think the d.ts is maintained here.

@olmobrutall

This comment has been minimized.

Show comment
Hide comment
@olmobrutall

olmobrutall Mar 22, 2017

Contributor

My pull request was accepted in DefinitelyTyped/DefinitelyTyped#14412 so I close this pull request...

Contributor

olmobrutall commented Mar 22, 2017

My pull request was accepted in DefinitelyTyped/DefinitelyTyped#14412 so I close this pull request...

@roni-frantchi

This comment has been minimized.

Show comment
Hide comment
@roni-frantchi

roni-frantchi Mar 23, 2017

@olmobrutall Thanks for this one.
Though now, I now find myself in a situation where I can't use the definitions on DefinitlyTyped (since DefinitelyTyped/DefinitelyTyped#14412 (comment)), whilst this definition is still broken due to the faulty export...

How did you get around that?

roni-frantchi commented Mar 23, 2017

@olmobrutall Thanks for this one.
Though now, I now find myself in a situation where I can't use the definitions on DefinitlyTyped (since DefinitelyTyped/DefinitelyTyped#14412 (comment)), whilst this definition is still broken due to the faulty export...

How did you get around that?

@olmobrutall

This comment has been minimized.

Show comment
Hide comment
@olmobrutall

olmobrutall Mar 23, 2017

Contributor

@roni-frantchi, I moved to numeral.js because parsing problem (parse 100.000 in Europe) and the typescript issues

Contributor

olmobrutall commented Mar 23, 2017

@roni-frantchi, I moved to numeral.js because parsing problem (parse 100.000 in Europe) and the typescript issues

@roni-frantchi

This comment has been minimized.

Show comment
Hide comment
@roni-frantchi

roni-frantchi Mar 26, 2017

I moved to numeral.js because parsing problem (parse 100.000 in Europe) and the typescript issues

Thanks @olmobrutall .

@schmuli @brachi-wernick maybe we should consider doing the same.

roni-frantchi commented Mar 26, 2017

I moved to numeral.js because parsing problem (parse 100.000 in Europe) and the typescript issues

Thanks @olmobrutall .

@schmuli @brachi-wernick maybe we should consider doing the same.

@BenjaminVanRyseghem

This comment has been minimized.

Show comment
Hide comment
@BenjaminVanRyseghem

BenjaminVanRyseghem Mar 27, 2017

Owner

@olmobrutall how can I help?
(what parsing problem?)

Owner

BenjaminVanRyseghem commented Mar 27, 2017

@olmobrutall how can I help?
(what parsing problem?)

@olmobrutall

This comment has been minimized.

Show comment
Hide comment
@olmobrutall

olmobrutall Mar 27, 2017

Contributor

The parsing problem was when trying to do this:

número.culture("de-de")
numbro("100.000").format() // returns "100", instead of "100.000"

The same worked with numeral.js unformat method/constructor, but I didn't found the equivalence in numbro.js docs .

I didn't bothered to add the issue since you looked busy.

Contributor

olmobrutall commented Mar 27, 2017

The parsing problem was when trying to do this:

número.culture("de-de")
numbro("100.000").format() // returns "100", instead of "100.000"

The same worked with numeral.js unformat method/constructor, but I didn't found the equivalence in numbro.js docs .

I didn't bothered to add the issue since you looked busy.

@BenjaminVanRyseghem

This comment has been minimized.

Show comment
Hide comment
@BenjaminVanRyseghem

BenjaminVanRyseghem Mar 27, 2017

Owner

please add a ticket 😄

I do am busy, but I am not alone, and when I can find some time, it's good to know what to tackle 😄

Edit: I added #261

Owner

BenjaminVanRyseghem commented Mar 27, 2017

please add a ticket 😄

I do am busy, but I am not alone, and when I can find some time, it's good to know what to tackle 😄

Edit: I added #261

@olmobrutall

This comment has been minimized.

Show comment
Hide comment
@olmobrutall

olmobrutall Apr 2, 2017

Contributor

After the fix of the parse problem (just using unformat), we decided to give numbro a second chance.

Any change of this PR to be merged?

We have our own copy of the d.ts file so we can live without the merge, but I'm quite sure the current implementation is wrong and will create problems by any other developers using TS. It's also the same that moment or numeral are doing...

Contributor

olmobrutall commented Apr 2, 2017

After the fix of the parse problem (just using unformat), we decided to give numbro a second chance.

Any change of this PR to be merged?

We have our own copy of the d.ts file so we can live without the merge, but I'm quite sure the current implementation is wrong and will create problems by any other developers using TS. It's also the same that moment or numeral are doing...

@BenjaminVanRyseghem

This comment has been minimized.

Show comment
Hide comment
@BenjaminVanRyseghem

BenjaminVanRyseghem Apr 3, 2017

Owner

I fine with merging it 😄

But for the record, I have no idea what it's doing 😛

Owner

BenjaminVanRyseghem commented Apr 3, 2017

I fine with merging it 😄

But for the record, I have no idea what it's doing 😛

@BenjaminVanRyseghem BenjaminVanRyseghem merged commit fb56d55 into BenjaminVanRyseghem:develop Apr 3, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@bherila

This comment has been minimized.

Show comment
Hide comment
@bherila

bherila Apr 25, 2017

So what is the proper way to import numbro using typescript now?

bherila commented Apr 25, 2017

So what is the proper way to import numbro using typescript now?

@BenjaminVanRyseghem

This comment has been minimized.

Show comment
Hide comment
@BenjaminVanRyseghem
Owner

BenjaminVanRyseghem commented Apr 26, 2017

@bherila no clue 😄

@schmuli

This comment has been minimized.

Show comment
Hide comment
@schmuli

schmuli Apr 26, 2017

@bherila You should be able to use the * as syntax:

import * as numbro from 'numbro';

schmuli commented Apr 26, 2017

@bherila You should be able to use the * as syntax:

import * as numbro from 'numbro';
@bherila

This comment has been minimized.

Show comment
Hide comment
@bherila

bherila Apr 26, 2017

It worked @schmuli , thanks!

bherila commented Apr 26, 2017

It worked @schmuli , thanks!

@BenjaminVanRyseghem

This comment has been minimized.

Show comment
Hide comment
@BenjaminVanRyseghem

BenjaminVanRyseghem May 2, 2017

Owner

in numbro 1.11.0

Owner

BenjaminVanRyseghem commented May 2, 2017

in numbro 1.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment