Skip to content

meta: factory function inconsistencies #25349

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

Open
ajafff opened this issue Jul 1, 2018 · 0 comments
Open

meta: factory function inconsistencies #25349

ajafff opened this issue Jul 1, 2018 · 0 comments
Labels
API Relates to the public API for TypeScript Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@ajafff
Copy link
Contributor

ajafff commented Jul 1, 2018

Related to #25220

There are quite a few inconsistencies among the factory functions:

  • naming: sometimes the name doesn't really describe what it does.
    • createStatement instead of createExpressionStatement: what statement does it create?
    • createBinary: maybe binary number literal?
    • createParen: ParenthesizedExpression or ParenthesizedType?
    • createSpread: SpreadElement or SpreadAssignment?
    • createThrow: becomes ambiguous once the ThrowExpression proposal advances to stage 4
    • createDo: becomes ambiguous once the DoExpression proposal advances to stage 4
    • Should all of the factory function names match the name of the Node exactly? If so, should they be renamed while keeping a deprecated alias around for backwards compatibility (like expose createExpressionStatement and updateExpressionStatement #25348)?
  • nullable parameters:
    • createTypeLiteral allows the members parameter to be undefined
    • createInterfaceDeclaration on the other hand requires an array as members parameter
  • overload signatures to avoid creating invalid nodes:
    • createYield has overloads for that purpose
    • createImportClause or createExportDeclaration for example allow all parameters to be undefined, resulting in an invalid node
  • optional parameters:
    • objectAssignmentInitializer in createShorthandPropertyAssignment is optional
    • typeArguments in createTypeReferenceNode is required although it's nullable
  • decorators
    • e.g. createConstructor or createExportAssignment require a decorators parameter although it's an error to have decorators on those nodes
  • modifiers
    • e.g. createExportAssignment requires a modifiers parameter although this node cannot have any modifiers (not even declare)
@mhegazy mhegazy added Bug A bug in TypeScript API Relates to the public API for TypeScript labels Jul 2, 2018
@mhegazy mhegazy added the Help Wanted You can do this label Jul 23, 2018
@mhegazy mhegazy added this to the Community milestone Jul 23, 2018
@RyanCavanaugh RyanCavanaugh modified the milestones: Community, Backlog Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Relates to the public API for TypeScript Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants