Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@43081j
Copy link
Collaborator

@43081j 43081j commented Sep 30, 2023

There are still some places where we use methods available on our imported ts rather than from the analyzer's reference (analyzer.typescript). This causes various problems with version mismatches and bundling.

These have now been updated to use the analyzer's typescript.

Related question

While doing this change, I noticed we generally follow two common signatures for our functions:

  • (node, analyzer)
  • (ts, node)

For the latter, it does make a sense from a purist point of view... type guards and what not which operate purely on a given AST node don't need the analyzer in theory, so they accept a typescript lib ref instead.

But it does mean we switch back and forth inconsistently sometimes between these signatures. maybe we want to always pass an analyzer and just pull the typescript from that?

There are still some places where we use methods available on our
imported `ts` rather than from the analyzer's reference
(`analyzer.typescript`). This causes various problems with version
mismatches and bundling.

These have now been updated to use the analyzer's typescript.
@changeset-bot
Copy link

changeset-bot bot commented Sep 30, 2023

🦋 Changeset detected

Latest commit: 0ca3a98

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@lit-labs/analyzer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@justinfagnani justinfagnani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@justinfagnani
Copy link
Collaborator

Regarding the API shape question, I noted when I made the change that it's a bit inconsistent: #4029

I think I'd like to see the types narrowed to just what's necessary. There a couple of issues to consider though:

  • It may be a bit cumbersome to pass say a typescript lib, checker and/or program, which is largely what an Analyzer object holds. So sometimes it's just nicer to pass an Analyzer.
  • If functions are too narrow and then need a new argument in the future (say to call another utility that needs it), it'll be a breaking change to widen.

That said, I think it'd be good to clean up now. I'm starting to add template utilities that are useful without full program analysis, like in #4261 and made those just take a typescript and checker (though maybe that should be a Program?).

Another thing is the order of operations. I think the Analyzer or TypeScript lib objects should probably come first in the parameter list.

@justinfagnani justinfagnani merged commit c0195cb into lit:main Oct 4, 2023
@43081j 43081j deleted the ts-type branch October 6, 2023 14:08
rictic pushed a commit that referenced this pull request Oct 6, 2023
fix (labs/analyzer): use analyzer typescript instead of import

There are still some places where we use methods available on our
imported `ts` rather than from the analyzer's reference
(`analyzer.typescript`). This causes various problems with version
mismatches and bundling.

These have now been updated to use the analyzer's typescript.
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

Successfully merging this pull request may close these issues.

2 participants