Skip to content

Array Create results in undefined #8

@spelltwister

Description

@spelltwister

When the creating an array in typescript, it looks like the generated code is 'valid' but does not produce the expected results.

Consider the following:

class MyClass{
}

GetOutputType returns "MyClass"
var arrayCreateString = $"{typeString}({sizeEvaluationString})";

say the size is 100

var declareVariable = new CodeVariableDeclarationStatement(typeof(IEnumerable<>).MakeGenericType(new [] { typeof(MyClass) }), "variableName", new CodeArrayCreateExpression(typeof(MyClass)))

expected

var variableName : Array = [];

observed

var variableName : Array = MyClass();

I believe what you were going for is:

var variableName : Array = Array(/size/);

However, from the docs, the CreateType property describes the type stored in the array, not the array's type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions