Skip to content
This repository was archived by the owner on Feb 26, 2021. It is now read-only.
This repository was archived by the owner on Feb 26, 2021. It is now read-only.

Transformer parses dynamic property lookup in brackets to static string lookup #51

@patrick-etx

Description

@patrick-etx

What I wrote:

const type = oc(questionSet).questions[initialQuestionId].type();

Output after compilation with transformer (formatted for readability):

const type =
  questionSet != null &&
  questionSet.questions != null &&
  questionSet.questions.initialQuestionId != null &&
  questionSet.questions.initialQuestionId.type != null
    ? questionSet.questions.initialQuestionId.type
    : undefined;

However, initialQuestionId is not the name of the key but a variable reference to another string with the property name, the compiled code should look something like:

const type =
  questionSet != null &&
  questionSet.questions != null &&
  questionSet.questions[initialQuestionId] != null &&
  questionSet.questions[initialQuestionId].type != null
    ? questionSet.questions[initialQuestionId].type
    : undefined;

This is using typescript 3.5.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions