Skip to content
This repository has been archived by the owner. It is now read-only.

feat: typed parser return value #33

Merged
merged 5 commits into from Nov 26, 2018

Conversation

@g-plane
Copy link
Contributor

commented Nov 10, 2018

Previously, type of the return value of parse function is any. This PR makes it strongly typed.

Additions:

  • The options can be undefined now and all the properties of options can be undefined. That is, all the code below are valid:
// We can omit the options:
parse('source code')

// All properties are optional:
parse('source code', {})
  • The properties of the parser result are dynamic. For example, if we disable the tokens option like this:
let ast = parse('', { tokens: false })

The tokens property will not exist in the variable ast.

default

Instead, if we enable the tokens option:

let ast = parse('', { tokens: true })

default

We can find that an additional tokens property is existed on the ast.

@JamesHenry

This comment has been minimized.

Copy link
Owner

commented Nov 22, 2018

Great addition, @g-plane! I had to prioritize getting in the big PR from Ben, would you mind updating this?

Thanks!

@g-plane

This comment has been minimized.

Copy link
Contributor Author

commented Nov 22, 2018

What does it need to be updated?

@j-f1

This comment has been minimized.

Copy link
Contributor

commented Nov 22, 2018

@g-plane It looks like there are merge conflicts now.

@g-plane

This comment has been minimized.

Copy link
Contributor Author

commented Nov 22, 2018

Oh, I'm using mobile phone now so I cannot see the conflicts notice. Sorry!

@j-f1

This comment has been minimized.

Copy link
Contributor

commented Nov 22, 2018

You should try GitHawk! </ad>

Sent with GitHawk

@g-plane

This comment has been minimized.

Copy link
Contributor Author

commented Nov 23, 2018

@JamesHenry Problems are fixed.

(currentProgram: ts.Program) => {
const ast = currentProgram.getSourceFile(options.filePath);
const ast = currentProgram.getSourceFile(
options.filePath || (options.jsx ? 'estree.ts' : 'estree.tsx')

This comment has been minimized.

Copy link
@JamesHenry

JamesHenry Nov 25, 2018

Owner

This filename logic is now separately defined 3 times within this file, can we promote it to be defined once at a higher level?

Other than that the PR LGTM

This comment has been minimized.

Copy link
@g-plane

g-plane Nov 26, 2018

Author Contributor

Updated.

g-plane added some commits Nov 25, 2018

@JamesHenry

This comment has been minimized.

Copy link
Owner

commented Nov 26, 2018

Thanks!

@JamesHenry JamesHenry merged commit 7599aba into JamesHenry:master Nov 26, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@g-plane g-plane deleted the g-plane:typed-return-value branch Nov 26, 2018

@JamesHenry

This comment has been minimized.

Copy link
Owner

commented Nov 26, 2018

🎉 This PR is included in version 5.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.