mockdeep / typewiz

Automatically discover and add missing types in your TypeScript code
https://medium.com/@urish/manual-typing-is-no-fun-introducing-typewiz-58e3e8813f4c
1.1k stars 46 forks source link

Check whether an existing named type is available to apply #38

Open MadaraUchiha opened 6 years ago

MadaraUchiha commented 6 years ago

Given file


type T0 = {foo: string, bar: boolean};

function magic(param) {
  return param;
}

magic({foo: 'hello world', bar: true});

We would like to use T0 as the type, because it's available and it matches our runtime type.

Actual:

//snip
function magic(param: Object) { // or at best {foo: string, bar: boolean} 
// snip

Expected:

// snip
function magic(param: T0) {
// snip

goodnessSquad

urish commented 6 years ago

That'd be awesome!