-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add TypeScript definitions with JSDoc #7335
Conversation
It seems to me that from the type files generated, that this wouldn't provide much benefit from a Parse Server developing perspective. This is the problem I experienced when I tried to automate the types. Although this will work, it doesn't really add much value / enforce the specific options, such as For example, the automated definition for export function define(functionName: any, handler: any, validationHandler: any): void; Compare that to the manual current definition: interface FunctionRequest<T extends Params = Params> {
installationId?: string;
master?: boolean;
params: T;
user?: User;
}
interface ValidatorField {
type?: any;
constant?: boolean;
default?: any;
options?: any[]|Function;
error?: String;
}
interface ValidatorFields {
[field: string]: ValidatorField;
}
interface Validator {
requireUser?: boolean;
requireMaster?: boolean;
validateMasterKey?: boolean;
skipWithMasterKey?: boolean;
requireAnyUserRoles?: String[]|Function;
requireAllUserRoles?: String[]|Function;
fields?: ValidatorFields|String[];
requireUserKeys?: ValidatorFields|String[];
}
function define(name: string, func: (request: FunctionRequest) => any, validator?: Validator|((request: FunctionRequest) => any)): void; In terms of a user perspective, the two most critical components are obviously that the Parse Server Config in Which to me, would seem that this repo would need a typescript definition for |
This is just a proof of concept that the generation works based on JSDoc. Updating the JSDoc would solve this, we can define interface types and get to exactly what the manual types currently are. That is why I think this approach of decoupling flow from TS and only use JSDoc would be an easy way to go, and eventually allow us gradually implement TS in the repo without any interference. But I am curious to see the flow-to-ts PR and see which one makes more sense. |
Cool, sounds good to me. Does this means that definitions will move away from Flow and instead by TS? |
Closed in favor of #7337. |
New Pull Request Checklist
Issue Description
Currently, Typescript definitions are maintained via DefinitelyTyped which is:
Related issue: #7334
Approach
Add typescript compiler to create TS definitions from JSDoc.
Run
npm run types
to create types in./types/
.Notes:
src/Adapters/Auth/OAuth1Client.js
TODOs before merging