-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
When should you be able to implicitly return undefined
- We allow people to implicitly return when a type
- is
undefined.
- is
- But no implicit returns when you have
4 | undefined- More importantly, you can't do
Promise<undefined> | undefined.
- More importantly, you can't do
- Let's revisit.
Knip
- Unused code detector - unused code, unreferenced dependencies, etc.
- Used on DefinitelyTyped tools.
- Is able to flag/fix utilities that shouldn't be exported.
- We do like the idea of adding this - the CI time is a bit higher and that does make our workflow for bisecting a bit painful.
- Considering adding it purely in CI and purely on-demand by the team; but not part of
devDependencies.
- Considering adding it purely in CI and purely on-demand by the team; but not part of
Using const enums in value space when using --preserveConstEnums
-
We have all these restrictions around being able to reference const enum declarations as direct values.
const enum E { A = 123, } let x = E; // ❌
- We get around this by writing
(ts as any).SomeEnum - It works because we use
preserveConstEnums.
- We get around this by writing
-
Recently Allow cross-project references to const enums in isolatedModules when referenced project has preserveConstEnums #57914 got merged, says that you can reference
const enummembers from another project underisolatedDeclarationsif the project haspreserveConstEnumsenabled.- This effectively gives us some of the same checks to determine if it's safe to reference the enum declaration itself across files.
- Something we could do within a project before, but not across. Now we can do both.
- This effectively gives us some of the same checks to determine if it's safe to reference the enum declaration itself across files.
-
We need this ourselves to enable
isolatedDeclarations -
Doesn't esbuild just inline enums unconditionally? Regardless of const-ness?
- Could just switch these all to regular enums, turn off
preserveConstEnums - That means we'd always take a perf hit in
servicesfrom enums declared incompiler.- Or in general?
- Maybe acceptable.
- What happens if we start emitting to pure ESM with no bundling?
- Perf hit!
- Could just switch these all to regular enums, turn off
-
In principal, don't like looking up compiler settings from dependency projects.
-
Well we can do what we want, but the request came externally.
-
We preserved originally only for debugging purposes.
-
Not totally against, this, but some of us feel like our own codebase would be better served from dropping
constfrom ourenums. -
Also you want consumers not to inline, but you also don't want
@foo/package-aand@foo/package-bnot to inline between each other. -
Revisit.