Any problems with TypeLite involving generics or Enums?

Would you believe I have a plethora of .Net libraries/classes that I want to create typescript definitions for? Typescript is truly amazing! I experimented with simple examples and it worked flawlessly. However, the hiccup I'm facing now is that a particular combination doesn't seem to cooperate. Here's the issue at hand:

[TsClass]
public class Bob<T>
{
    public MyTestEnum MyEnum { get; set; }
    public string TestString { get; set; }
    public string MyProperty { get; set; }
}

[TsEnum]
public enum MyTestEnum
{
    One,
    Two,
    Three
}

The crux of the problem lies in the fact that I can't seem to use both generics <T> and Enum together. It seems one has to be sacrificed for the other to work.

Whenever I attempt to run it, this pesky error pops up:

Error   17  Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.
   at TypeLite.TsModelBuilder.AddEnum(TsEnum tsEnum) in C:\___PROJECTS___\TypeLITE\TypeLite\TsModelBuilder.cs:line 98
   at TypeLite.TsModelBuilder.Add(Type clrType, Boolean includeReferences) in C:\___PROJECTS___\TypeLITE\TypeLite\TsModelBuilder.cs:line 83
   at TypeLite.TsModelBuilder.Add(Assembly assembly) in C:\___PROJECTS___\TypeLITE\TypeLite\TsModelBuilder.cs:line 108
   at TypeLite.Net4.TypeScriptFluentExtensions.ForLoadedAssemblies(TypeScriptFluent ts) in C:\___PROJECTS___\TypeLITE\TypeLite.Net4\TypeScriptFluentExtensions.cs:line 16
   at Microsoft.VisualStudio.TextTemplatingBDE10CD05B2CB4C5419DB79DDF5BA5BA06D673F55FF952439E5971D4E1F394085E3B6D99DC6D1E992221FAC06D0692FFD83BE54FE5AF6A567A491DF31AE26472.GeneratedTextTransformation.TransformText() ..\Scripts\TypeLite.Net4.tt

The issue isn't really about using generics per se (I just want it to work!).

If anyone knows how to navigate around this or can suggest an alternative tool that can handle such scenarios, please do share your insights.

I've already brought this to the attention of the developers (fingers crossed Lukas addresses it soon): https://bitbucket.org/LukasKabrt/typelite/issue/41/issue-with-generics-and-enums

Answer №1

Credit goes to Paul O'Neill for resolving this issue in the most recent update version (0.9.1.8)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Definition file for Typescript Angular 1.5 component

Encountering a problem with typescript and angular 1.5 - when building, an error pops up saying error TS2339: Property 'component' does not exist on type 'IModule'.. Could it be that I overlooked a definition file containing this proper ...

Is it possible to validate a template-driven form without using the model-driven approach?

Attempting to validate a template-driven form in Angular without two-way data binding has proved to be challenging. I have successfully implemented validation using [(ngModel)], but running into an error when trying to validate the form without the MODEL p ...

The presence of React Router in Office JS Excel results in a blank screen

My current project involves developing add-ins for Excel using TypeScript and React. However, I have encountered numerous challenges along the way. Unlike a typical CRA React boilerplate web application, the Office add-in behaves differently. To illustrate ...

Transferring the date from an HTML input to a TypeScript file in Angular when the button

On my HTML page, I have two input fields for dates that need to be passed to the backend along with other parameters when a button is clicked. Here is the current setup: <input [owlDateTime]="dt1" placeholder="From a date" [value]="dateFrom.value"& ...

Changing the row property value of a textarea dynamically based on text input in ReactJS

Here is what I have tried: <textarea rows='2' onChange={e => setSomething(e.target.value)} className='form-control text-area ' value={something} placeholder='write something'> </textarea> output: https://i ...

Leveraging ES6 Symbols in Typescript applications

Attempting to execute the following simple line of code: let INJECTION_KEY = Symbol.for('injection') However, I consistently encounter the error: Cannot find name 'Symbol'. Since I am new to TypeScript, I am unsure if there is somet ...

The compiler is unable to locate the node_module (Error: "Module name not found")

Error: src/app/app.component.ts:4:12 - error TS2591: Cannot find name 'module'. Do you need to install type definitions for node? Try npm i @types/node and then add node to the types field in your tsconfig. 4 moduleId: module.id, When att ...

SQL query encountering issue after introducing apostrophe symbol ''`

SELECT CONCAT ( schoolname ,CASE WHEN schoolcity IS NULL OR schoolcity = '' THEN '' ELSE (', ' + REPLACE(schoolcity, 'ã', 'a')) ...

Setting up Azure DevOps CI/CD for a .NET project targeting an Azure Function App

I need help automating the deployment of a .Net project created in Visual Studio for Azure Function App. The goal is to deploy the function app into an Azure resource group. Currently, I can deploy it manually using the following commands: To build: dotn ...

When utilizing Typescript with React Reduxjs toolkit, there seems to be an issue with reading the state in useSelector. An error message is displayed indicating that the variable loggedIn

I have encountered an error while passing a state from the store.tsx file to the component. The issue lies in the const loggedIn where state.loggedIn.loggedIn is not recognized as a boolean value. Below is the code snippet for the component: import React ...

Calendar extension malfunctioning

I have incorporated a calendar extender into my project, but I am facing some issues with the design of the calendar extender. Below is the code I am using and the design output I am receiving: <td align="right"> From Date: ...

Can you compress and store files in SQL Server using .Net?

We have numerous .Net applications that interact with a SQL Server (2008) to upload and retrieve files. The files are typically stored as varbinary(max) in our database. While it's a common approach, I'm curious if anyone takes the additional st ...

Exploring the features of Typescript involving async/await, Promise, and the use of function

I am currently working on a nodeJS-Express-Typescript project where I need to implement native promises with async/await and also provide default values for functions. Here is a simple example of what I am trying to achieve: sleep(ms: number) { return ...

Guide on utilizing a provider's variable in another provider within Ionic 2/3

In my code, I have a boolean variable called isConnection that is used to monitor network connection status. This variable is defined in a provider named 'network' and can be set to either true or false in different functions. Now, I need to acc ...

What is the best way to access the sender in a click event handler from a toolbartray or another control in WPF

XAML: <ToolBarTray Name="tlbTray" ButtonBase.Click="tlbTray_Click"> <ToolBar Name="tlbFile"> <Button Name="btnOpen"><Image Source="images\folder.png" Stretch="None" /></Button> <Button Name="btnSave"><I ...

Tips for making LINQ Sum() return 0 even when the source collection is empty

Is it possible to modify the query so that if no leads are matched, the sum will be set to 0 instead of throwing an exception? I'm looking for a solution that doesn't involve storing the query and checking query.Any(). double totalEarnings = db. ...

Tips for passing parameters from an anchor click event in TypeScript

Is it possible to send parameters to a click event from an anchor element, or should we not pass params at all? Here is the function I am using: const slideShow = (e: React.MouseEvent<HTMLAnchorElement> | undefined): void => { console.lo ...

Controller issue: Post action functioning properly in one controller but malfunctioning in another controller

My current project involves the creation of a new project by users. The user interface includes various textboxes and a submit button, which triggers a POST request to an API endpoint. This API call then adds a new project entity to the database. Recently, ...

Document Indexing in Deep Neural Network Search

I have a question about the search functionality in DNN. Currently, I am using DNN community edition 7.4 and I am interested in indexing PDF documents for content search. After conducting extensive research, I have come to the following conclusions: By ...

Image not found in next.js

Working Environment ・ next.js ・ typescript ・ styled-components I uploaded the image in the folder inside pages, but it is not showing up. Why is that? // package.json   { "name": "nextapp", "version": &qu ...