scenarioo / scenarioo-js

Scenarioo writer library to produce feature rich e2e test reports, e.g. from Protractor/WebDriverJS tests with Jasmine
http://www.scenarioo.org
MIT License
10 stars 3 forks source link

Fix TS typing regarding enums #46

Closed adiherzog closed 7 years ago

adiherzog commented 7 years ago

Currently using the TypeScript typings does not work. I get the following error:

In ambient enum declarations member initializer must be constant expression.

The problem seems to be that TypeScript enums (ScreenAnnotationClickAction and ScreenAnnotationStyle) don't support strings but only numbers. Instead we could probably use string literal types in index.d.ts, see also here: http://stackoverflow.com/a/15491832

@bruderol Did you not run into this issue yet? How shall we solve it?

bruderol commented 7 years ago

I tested it and it works (see examples). Not understanding your problem.

bruderol commented 7 years ago

could it be a version problem ?? What typescript version are you using?

bruderol commented 7 years ago

Our enums already use string values (see index.d.ts) and this should work with newest typescript. At least it did in our examples.

bruderol commented 7 years ago

@adiherzog please check my answers above and let me know whether it was a version problem and we can close this?

adiherzog commented 7 years ago

@bruderol Enums in TypeScript can't have string values, just numbers, see here: https://www.typescriptlang.org/docs/handbook/enums.html

´´´ Enums allow us to define a set of named numeric constants. An enum can be defined using the enum keyword. ´´´

Or is this a different kind of enum from the ones used in the type definition file?

I'm using "typescript": "^1.8.10", in package.json which currently results in version 1.8.10 to be installed. I see that your examples are using version "typescript": "~2.0.3". So this could really make the difference.

bruderol commented 7 years ago

sorry, but somebody told me that it is allready working with strings. and it works in 2.x.

adiherzog commented 7 years ago

I fixed the problem and made this PR: https://github.com/scenarioo/scenarioo-js/pull/48

bruderol commented 7 years ago

@adiherzog Sorry, i don't get it. In my oppinion there is nothing to fix. Just use TypeScript 2.x Maybe we need discuss this. Your PR is a breaking change.

bruderol commented 7 years ago

ok, now I understand after our discussion today and agree to change it according our discussion and changes by @Dogen91 . see commits on https://github.com/scenarioo/scenarioo-js/pull/48

bruderol commented 7 years ago

done, will be released with 3.0.1 thanks @Dogen91 and @adiherzog