question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript definitions not generated correctly

See original GitHub issue

What are you trying to achieve?

Generate typescript definitions

What do you get instead?

  • Typescript definition file is not generated correctly. Please see the image bellow, where multiple functions definitions are not correct:

whatsapp image 2018-04-01 at 16 06 12

Sugestions:

  • add tests to see that definitions are generated correctly
  • having .d.ts files in your project directly are not the preffered way anymore, rather having a module @types/codeceptjs
  • please add more types to functions, most of them use any

Command used: codeceptjs def .

Details

  • CodeceptJS version: 1.1.7
  • NodeJS Version: 8.11.0
  • Operating System: MacOS
  • WebDriverIO
  • Configuration file:
{
  "bootstrap": "server.typescript.js",
  "tests": "src/*/.test.ts",
  "timeout": 10000,
  "output": "./output",
  "helpers": {
    "WebDriverIO": {
      "url": "http://localhost",
      "browser": "chrome",
      "restart": true
    }
  },
  "include": {
    "I": "./steps_file.js"
  },
  "mocha": {},
  "name": "codecept"
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
liviuignatcommented, Apr 4, 2018

Are there any plans to improve the d.ts generation? Eg:

from

click(locator, context) => any;

to

click(locator: ILocator, context: IContext) => ISomeStronglyTypedResponse

To me the current version is half baked. As typescript got more stable, also the community is increasing rapidly, most of the people starting to prefer it over flow or other similar solutions.

0reactions
DavertMikcommented, Apr 19, 2018

yeah, but still we don’t have much of internal types to be used. We generate types for I object which consists of methods taken from helpers.

Anyway, the TS generator was broken in 1.1.7 but it should be fixed in 1.1.8.

So now by running codeceptjs def you get a list of commands with types:

declare namespace CodeceptJS {
  export interface I {
    amOutsideAngularApp() : void,
    amInsideAngularApp() : void,
    amOnPage(url: string) : void,
    click(locator: ILocator, context?: ILocator) : void,
    click(locator: string, context?: ILocator) : void,
    click(locator: ILocator, context?: string) : void,
    click(locator: string, context?: string) : void,
    doubleClick(locator: ILocator, context?: ILocator) : void,
    doubleClick(locator: string, context?: ILocator) : void,
    doubleClick(locator: ILocator, context?: string) : void,
    doubleClick(locator: string, context?: string) : void,
    rightClick(locator: ILocator, context?: ILocator) : void,
    rightClick(locator: string, context?: ILocator) : void,
    rightClick(locator: ILocator, context?: string) : void,
    rightClick(locator: string, context?: string) : void,
    moveCursorTo(locator: ILocator, offsetX?: string, offsetY?: string) : void,
    moveCursorTo(locator: string, offsetX?: string, offsetY?: string) : void,
    see(text: string, context?: ILocator) : void,
    see(text: string, context?: string) : void,
    seeTextEquals(text: string, context?: ILocator) : void,
    seeTextEquals(text: string, context?: string) : void,
    dontSee(text: string, context?: ILocator) : void,
    dontSee(text: string, context?: string) : void,
    grabBrowserLogs() : Promise,
    grabCurrentUrl() : Promise,
    selectOption(select: ILocator, option: string) : void,
    selectOption(select: string, option: string) : void,
    fillField(field: ILocator, value: string) : void,
    fillField(field: string, value: string) : void,

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript not generating declaration files - Stack Overflow
For whatever reason, I am not getting any .d.ts files. How can I produce definition files correctly? compile command. npx tsc. tsconfig.json.
Read more >
Generating TypeScript Definition Files from JavaScript
Writing JavaScript while still being type-safe and automatically generating TypeScript Definition files for publishing.
Read more >
Surviving the TypeScript Ecosystem — Part 4 - Medium
One thing to remember is that the type definition files in DefinitelyTyped are community sourced. In most cases they are not written by...
Read more >
Typescript Typings: The Complete Guide: @types Compiler ...
Why does it look like Promise type definitions sometimes don't work correctly? Conclusions and Recommendations on to use Typescript type ...
Read more >
Importing TypeScript Definitions - C#/XAML for HTML5 - cshtml5
To force re-generate the C# files from the TypeScript Definition, manually delete the file "TypeScriptDefInfos.xml" that is located in the "obj\Debug" sub- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found