DonJayamanne / typescript-notebook

Run JavaScript and TypeScript in node.js within VS Code notebooks with excellent support for debugging, tensorflowjs visulizations, plotly, danfojs, etc
https://marketplace.visualstudio.com/items?itemName=donjayamanne.typescript-notebook
MIT License
905 stars 40 forks source link

Generic function returns `false` rather than an object #40

Closed michaellperry closed 2 years ago

michaellperry commented 2 years ago

I've declared a generic function in a TypeScript file:

export function create<T>(template: T): Wrapper<T> {
    return new Wrapper<T>(template);
}

When I call the function from a Notebook, the answer is the boolean false.

const template: Product = {}
const product = create<Product>(template)
product
false

If I remove the explicit generic and allow the type to be inferred, an object is returned.

const template: Product = {}
const product = create(template)
product
Wrapper {}

Repro attached:

Repro.zip

DonJayamanne commented 2 years ago

Thanks for filing this issue, I've been able to repro this. Apologies for the delay