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, 3/2/2022 #48095

Closed
DanielRosenwasser opened this issue Mar 2, 2022 · 3 comments
Closed

Design Meeting Notes, 3/2/2022 #48095

DanielRosenwasser opened this issue Mar 2, 2022 · 3 comments
Labels
Design Notes Notes from our design meetings

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Mar 2, 2022

Platform-Specific Resolutions and Path Mappings

#21926
https://github.com/afoxman/rnts-example

  • React Native uses a priority list of extensions when resolving a path like ./foo

    • e.g. on iOS, ./foo.ios.js, then ./foo.mobile.js, then ./foo.native.js or something like that.
  • Some set of minimal additions that are easy to reason about and would serve React Native users?

  • Union per module?

    • Not always coherent. ❌
  • Single tsconfig for all platforms? Means different resolutions per file per compilation?

    • ❌, complex.
  • A single set of resolutions per tsconfig.json is easier to stomach.

    • moduleFileExtensions?
    • moduleFileExtensionPrefixes
    • "moduleFileExtensions": ["ios", "mobile", "native", ""]
    • Seems weird. Should force the . at the beginnning.
    • "moduleFileExtensions": [".ios", ".mobile", ".native", ""]
    • Then is suffixes, not prefixes?
  • What does it mean to import from a file with a .js extension?

    • Not really coherent?
    • Kinda is, just trim off the extension and try each suffix with the original extension.
    • That's what the prototype/fork is.
  • Next: remapping types

    • Be able to say "this module specifier points to this module."
    • Doesn't path mapping enable this?
      • Can still end up accidentally picking up types from types field.
    • npm overrides?
      • Not sustainable for several build targets.
  • One issue with path mappings was the need for baseUrl

    • No longer need that either.
  • Does react-native rely on react-native-macos? Does that in turn rely on react-native-native?

  • Do we feel like we're compromising on design? Is this general enough?

    • We feel sufficiently motivated by the scenarios. We don't feel bad about the design, the amount of support it requires is not high, and people using RN or specific build tools will use it.
    • We also feel like there might be a bit of a catch-22 - high correlation between RN and TypeScript. If TS doesn't work well with a feature, could be the case that people naturally avoid it.
  • Would be willing to take a PR on this.

Remapping exports Entries to Input Files

#47925

  • Using Node's ESM self-name references can change your output structure.
    • Explicit composite/rootDir?
      • That is more ideal. But usually our logic works pretty well for
    • Idea here is to resolve to the input file based on the output files of the package.json.
    • Does this tie into last week's discussion topic - resolveFromOutDir?
  • In a sense, doing this means that a self-package reference is implicitly a relative import.
  • Feels like there are a lot of footguns, we can say "if you use a self-package-name, you need to set rootDir".
    • But we can usually figure out the correct rootDir!
  • Conclusion: enforce rootDir - don't let people land in the pit of failure.

Re-computing results from nested variance computations

#48080

  • We try to do an up-front variance calculation for generic interfaces and aliases on types using marker types.
    • Compare to and from instantiatons with different markers.
    • This avoids a bunch of structural comparisons of types, which is great for more complex types.
    • But doing this is technically still an up-front structural check. It just allows us to record variance and know which directions to compare types.
    • Sometimes, when calculating variance, we will run into the same type and end up asking "what is the variance?" In those cases, we give a slightly-incorrect answer that the type is "independent" of a given type parameter.
    • This interacts strangely with our deep-instantiation checks. It creates an ordering problem.
  • Idea (I think): record symbols that impacted variance. Also record instances of when we're calculating variance, and that calculation asks for variance of the same thing in a nested context. Come back to any further results that gave more information to recalculate variance here.
@DanielRosenwasser DanielRosenwasser added the Design Notes Notes from our design meetings label Mar 2, 2022
@alexeagle
Copy link
Contributor

In Bazel's case, there isn't a circularity like that, we do now the rootDir and the outDir ahead of time and those don't depend on what's in the source files or the emit. It's only resolving declarations from prior compilation units that requires a change.

@afoxman
Copy link
Contributor

afoxman commented Mar 9, 2022

Related PR: #48189

@alexeagle
Copy link
Contributor

#48190 shows a working outDir resolution.

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

3 participants