Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing parsed information #79

Closed
ondratra opened this issue Jul 24, 2018 · 9 comments
Closed

Missing parsed information #79

ondratra opened this issue Jul 24, 2018 · 9 comments

Comments

@ondratra
Copy link
Contributor

Parser unfortunately doesn't return full information about parsed code.

Right now I know about missing

Can we get this fixed, please?

@ondratra
Copy link
Contributor Author

flag for optional property is implemented in this pull request I made #80

@buehler
Copy link
Owner

buehler commented Aug 2, 2018

Things left open:

  • isAsync
  • isStatic
  • isOptional

:)

About the inline types... We need to think about a reasonable and good way to parse those things. It shouldn't kill the parser by loading recursive stuff to do.

@ondratra
Copy link
Contributor Author

ondratra commented Aug 7, 2018

Another important feature is:

  • support for dictionaries

This code

export interface TestInterface {
    [key: string]: number
}

results in this

InterfaceDeclaration {
  name: 'TestInterface',
  isExported: true,
  start: 13,
  end: 97,
  accessors: [],
  properties: [],
  methods: []
}

@ondratra
Copy link
Contributor Author

ondratra commented Aug 7, 2018

and

  • inheritance
export interface TestInterface extends OtherInterface {
    count: number
}

@buehler
Copy link
Owner

buehler commented Aug 9, 2018

Yep, inheritance is already present in #88

@buehler
Copy link
Owner

buehler commented Aug 28, 2018

@ondratra a question:
would (in your opinion) anything that returns a promise be async? actually yes right?
So if the user has public async function this means (automatically) it returns a promise. And if I code public function foo(): Promise<void> I return a promise which is also async and awaitable.

@ondratra
Copy link
Contributor Author

ondratra commented Aug 28, 2018

@buehler Imho it is false.
In case you would like to parse TS file and then 'reconstruct them' from parsed info you could actually get different code. Some examples follow.

When async is explicitly stated it always has to return Promise. Even TS compiler will force you to return Promise.

async function asyncFunction(): Promise<string> {
    return 'result'
}

This function is not explicitely stating async yet it's returning Promise

function indirectAsyncFunction(): Promise<string> {
    return asyncFunction()
}

This async function calls awaits on another async function.

async function complexAsyncFunction(): Promise<string> {
    return await asyncFunction()
}

Notice difference between indirectAsyncFunction() and complexAsyncFunction().
If you add extra async keyword in front of indirectAsyncFunction without further editation(adding await for asyncFunction())
it would actually return Promise<Promise<string>>.

Because of that I think parser should return async flag only for function that explicitly state it.

@buehler
Copy link
Owner

buehler commented Aug 28, 2018

I can definitely live with that explanation.

@buehler
Copy link
Owner

buehler commented Aug 31, 2018

I'm going to close this issue in favor to propper issues for each feature :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants