Skip to content

Enable project references by upgrading TypeScript to >3.6 #7807

Closed
@sampsakuronen

Description

@sampsakuronen

TypeScript project references have been available since 3.0. The newest TypeScript (since 3.6) brought APIs exposing this feature. For those unfamiliar with the concept please see this great example project.

Enabling this functionality would greatly improve the way we can share code amongst different apps. It should also increase the build speed as we would have access to incremental builds.

Our use cases would include:

  • Share types between backend and frontend
  • Share common utilities between different frontend apps

Currently tsc --build isn't compatible because it conflicts with some opinions that create-react-app has (e.g. isolatedModules). EDIT: as @ianschmitz pointed out below this opinion actually comes from babel-plugin-transform-typescript.

Quote from Typescript 3.6 release announcement:

APIs to Support --build and --incremental

TypeScript 3.0 introduced support for referencing other projects and building them incrementally using the --build flag. Additionally, TypeScript 3.4 introduced the --incremental flag for saving information about previous compilations to only rebuild certain files. These flags were incredibly useful for structuring projects more flexibly and speeding builds up. Unfortunately, using these flags didn’t work with 3rd party build tools like Gulp and Webpack. TypeScript 3.6 now exposes two sets of APIs to operate on project references and incremental program building.

For creating --incremental builds, users can leverage the createIncrementalProgram and createIncrementalCompilerHost APIs. Users can also re-hydrate old program instances from .tsbuildinfo files generated by this API using the newly exposed readBuilderProgram function, which is only meant to be used as for creating new programs (i.e. you can’t modify the returned instance – it’s only meant to be used for the oldProgram parameter in other create*Program functions).

For leveraging project references, a new createSolutionBuilder function has been exposed, which returns an instance of the new type SolutionBuilder.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions