s-panferov / awesome-typescript-loader

Awesome TypeScript loader for webpack
Other
2.35k stars 179 forks source link

Weird transpile of function with returning interface #616

Open ivaxi opened 6 years ago

ivaxi commented 6 years ago

Bug Report

Current Behavior

exported function in DictionaryFormHelpers.ts :

export function getEmptyStateChange(): IDictionaryFormState { console.log('strange things'); return {} as IDictionaryFormState; }; transpile in to: function Wl() { return console.log("strange things"), {} } Result is little strange but worked. Then i change function declaration to:

export function getEmptyStateChange(): IDictionaryFormState { return {} as IDictionaryFormState; };

its become simply in caller scope: var a = { dataLoading: !0 }

thats wrong - dataLoading field cant be 'true' (!0) - its not initilazed by any value.

Intrface declaration: export interface IDictionaryFormState { loadData?: boolean; dataLoading?: boolean; }

function call in parent scope:

const stateChange:IDictionaryFormState = DictionaryFormHelpers.getEmptyStateChange();

Expected behavior/code Im expected that code export function getEmptyStateChange(): IDictionaryFormState { return {} as IDictionaryFormState; }; trianspile in to:

function Wl() { return {} }

I know that this function is dumb output, but it required for type checking in ts. Is it problem with atl?

Environment "babel-loader": "8.0.4", "awesome-typescript-loader": "5.2.1", "@babel/core": "7.1.2",