aheber / sfdx-typegen

Generate Typescript d.ts files for Salesforce Aura Component cmp and helper files
3 stars 0 forks source link

Learn and document how to use generated types in Javascript #12

Open aheber opened 5 years ago

aheber commented 5 years ago

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

aheber commented 5 years ago

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);
  }
aheber commented 5 years ago

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