aheber / sfdx-typegen

Generate Typescript d.ts files for Salesforce Aura Component cmp and helper files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Learn and document how to use generated types in Javascript

aheber opened this issue · comments

commented

Study up on how best to use generated types in traditional Javascript Aura Components using jsconfig.json files.

commented

At the root of the project you can place a jsconfig.json file with the following contents.

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {}
  },
  "include": [
    "force-app/**/*",
    ".sfdx/typings/aura/**/*.d.ts",
    "types/**/*.d.ts"
  ]
}

I also imported my Aura typings folder into the ./types/aura directory
This seems to work well in my test project.

Need to tune the helper d.ts file generation to work with the comment types as well as javascript source files instead of typescript source files.

Will need to provide typing information in Controller and Helper. Might be able to get over that if you can customize the Language Server? Will need to investigate.

/**
   * @param {Cmp.c.TestChild} cmp
   * @param {Aura.Event} event
   * @param {Helper.c.TestChild} helper
   */
  myAction: function(cmp, event, helper) {
    let world = cmp.get("v.world123");
    helper.helperMethod();
    helper.method2(cmp, event);
  }
commented

Built up the d.ts generator to support JSDoc comments for determining types.