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

Design Meeting Notes, 1/25/2023 #52469

Closed
DanielRosenwasser opened this issue Jan 27, 2023 · 5 comments
Closed

Design Meeting Notes, 1/25/2023 #52469

DanielRosenwasser opened this issue Jan 27, 2023 · 5 comments
Labels
Design Notes Notes from our design meetings

Comments

@DanielRosenwasser
Copy link
Member

ignoreDeprecations in TS 4.9

#51909

  • importsNotUsedAsValues and preserveValueImports are deprecated in favor of verbatimModuleSyntax
  • You're supposed to use the ignoreDeprecations flag to temporarily disable this as you migrate off the flags.
  • Can't make a tsconfig.json that works for both 4.9 and 5.0.
  • Nice to be able to let a team move over incrementally.
  • Want to bring ignoreDeprecations back to 4.9
    • Helps with editor scenarios too while VS Code still ships 4.9.

Moving from barrel imports in our codebase

#51455
#51590

  • In our migration to modules, we use barrel imports to keep things simple-ish, keep initialization order.
  • Big task, but @a-tarasyuk took it on.
  • Had to resolve issues with cycles, seems like it's fine.
    • Gives some benefits that now some tools can analyze our codebase to detect cycles.
  • Makes moving code around harder.
    • But that is an empathy gap between us an our users.
    • We should think about editor features to help here in 5.1
    • Also, would be nice if we could detect cycles in some way.
  • Some instances where we still use (ts as any).Yadda for preserved const enums.
  • By explicitly declaring what the parser imports from, other tools can more-easily tree shake from us.
  • Also Use ESM for our executables (tsc, tsserver, typingsInstaller) #51440
    • Previously, these attempts ran into crashes due to circularities.
    • Fixing the cycles would allow many of these to operate correctly.
  • So Convert debug namespace into a module, direct import #51455
    • Seems uncontroversial.
  • Use ESM for our executables (tsc, tsserver, typingsInstaller) #51440
    • Something to be said about flat files.
    • Would be nice to ship an ESM version
  • Moving to direct imports?
    • Seems okay.

Import Sorting

#52090

  • ESLint doesn't tie-break sorting well - i.e. if you import hasDecorators and HasDecorators, the two might flip.
    • So it's not a stable sort!?
    • No.
  • We made more internationally-sensitive changes in Add option for organize imports case sensitivity #51733.
    • Compatible with what? ESLint doesn't give deterministic (or is it stable?) sorting, we do.
    • Based on eslint/sort-imports.
      • They used toUppercase, we did toLowercase for case insensitivity.
      • Noticeable for ASCII characters in between - namely the underscore (_)
  • Organize imports collation #52115
    • Uses Intl.Collator to do sorting if desired.
    • Compatible with eslint-plugin-simple-import-sort.
  • Does Prettier do import sorting?
    • No.
    • Thankfully. Don't need 30 tools fighting with each other. 😅
  • dprint does if you want, and it's compatible!
  • Sounds like we have good-enough coverage to say "we support all of them."
  • So okay with changing our repo to new linter options?
    • Seems fine.
  • Aside: need to copy settings over for auto-imports(?)
@DanielRosenwasser DanielRosenwasser added the Design Notes Notes from our design meetings label Jan 27, 2023
@IllusionMH
Copy link
Contributor

Helps with editor scenarios too while VS Code still ships 4.9.

Shouldn't they use local workspace TS 5.0 version? Or is it about web only case?

@DanielRosenwasser
Copy link
Member Author

IIRC, VS Code doesn't use the workspace version until you opt into it - but either way, your team might be using a local workspace version of 4.9 while you are trying to upgrade to 5.0.

@MartinJohns
Copy link
Contributor

IIRC, VS Code doesn't use the workspace version until you opt into it

Yeah, by default VS Code uses whatever TypeScript version it ships with (currently 4.9). This is a security feature, because the locally installed TypeScript version could potentially be malicious code.

@lukeapage
Copy link

Prettier can sort imports via a plug-in - we use it because it has better overall support than eslint. https://github.com/trivago/prettier-plugin-sort-imports

@DanielRosenwasser
Copy link
Member Author

DanielRosenwasser commented Jan 30, 2023

Hopefully the natural-sort utility they use is compatible with the organizeImportsNumericCollation from #52115.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Notes Notes from our design meetings
Projects
None yet
Development

No branches or pull requests

5 participants