Skip to content
This repository has been 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

Open
patrick-entinux opened this issue Nov 28, 2019 · 0 comments

Comments

@patrick-entinux
Copy link

patrick-entinux commented Nov 28, 2019

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.

@patrick-entinux patrick-entinux changed the title Code transformer parses dynamic property reference to string Code transformer parses dynamic property lookup in brackets to static string lookup Nov 28, 2019
@patrick-entinux patrick-entinux changed the title Code transformer parses dynamic property lookup in brackets to static string lookup Transformer parses dynamic property lookup in brackets to static string lookup Nov 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant