Skip to content
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

enh: interface for entrypoints #214

Open
gillyspy opened this issue Aug 24, 2022 · 2 comments
Open

enh: interface for entrypoints #214

gillyspy opened this issue Aug 24, 2022 · 2 comments

Comments

@gillyspy
Copy link

I do something like this:

in local types

import { EntryPoints } from 'N/types';

interface clientMethods {
  fieldChanged?: EntryPoints.Client.fieldChanged;
  pageInit?: EntryPoints.Client.pageInit;
  localizationContextEnter?: EntryPoints.Client.localizationContextEnter;
  localizationContextExit?: EntryPoints.Client.localizationContextExit;
  validateLine?: EntryPoints.Client.validateLine;
  validateInsert?: EntryPoints.Client.validateInsert;
  validateField?: EntryPoints.Client.validateField;
  validateDelete?: EntryPoints.Client.validateDelete;
  sublistChanged?: EntryPoints.Client.sublistChanged;
  saveRecord?: EntryPoints.Client.saveRecord;
  postSourcing?: EntryPoints.Client.postSourcing;
}

in a module

export const { pageInit } : clientMethods = { 
  pageInit : (context ) => {
    // todo
  }

The reason i do it is be catch simple typos on exported methods that are standard while encapsulating some of the typings to a central, repeatable spot.

If exporting anything that is not standard then I can add it as a union in the project's types.

I think it would be useful to have something like the above clientMethods included in this project. I can do a PR in a few weeks (think of this as a placeholder until then).

@ShawnTalbert
Copy link
Contributor

At our firm, we start all scripts from exemplar templates which serve a similar purpose.

It's worth discussing; should this types library expand beyond describing just the API of individual modules and provide additional guidance on typing for top level scripts?

@MrRob
Copy link
Collaborator

MrRob commented Jun 14, 2024

Hmm, I'm not sure. I kind of think maybe that sort of thing should live in a separate module. But we could include tips / guidance in the ReadMe, or other documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants