Repository navigation
Design Meeting Notes, 1/25/2023 #52469
Copy link
Copy link
Closed
Labels
Design NotesNotes from our design meetingsNotes from our design meetings
Description
ignoreDeprecations in TS 4.9
importsNotUsedAsValuesandpreserveValueImportsare deprecated in favor ofverbatimModuleSyntax- You're supposed to use the
ignoreDeprecationsflag to temporarily disable this as you migrate off the flags. - Can't make a
tsconfig.jsonthat works for both 4.9 and 5.0. - Nice to be able to let a team move over incrementally.
- Want to bring
ignoreDeprecationsback to 4.9- Helps with editor scenarios too while VS Code still ships 4.9.
Moving from barrel imports in our codebase
- In our migration to modules, we use barrel imports to keep things simple-ish, keep initialization order.
- Big task, but Oleksandr Tarasiuk (@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).Yaddafor 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
- ESLint doesn't tie-break sorting well - i.e. if you import
hasDecoratorsandHasDecorators, 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 didtoLowercasefor case insensitivity. - Noticeable for ASCII characters in between - namely the underscore (
_)
- They used
- Organize imports collation #52115
- Uses
Intl.Collatorto do sorting if desired. - Compatible with
eslint-plugin-simple-import-sort.
- Uses
- 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(?)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Design NotesNotes from our design meetingsNotes from our design meetings
Activity
IllusionMH commentedon Jan 27, 2023
Shouldn't they use local workspace TS 5.0 version? Or is it about web only case?
DanielRosenwasser commentedon Jan 27, 2023
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 commentedon Jan 28, 2023
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 commentedon Jan 30, 2023
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 commentedon Jan 30, 2023
Hopefully the natural-sort utility they use is compatible with the
organizeImportsNumericCollationfrom #52115.