Skip to content

[RFC] First-class support for TypeScript in the Expo SDK #2164

@ide

Description

@ide

The Expo team is considering adding first-class support for TypeScript to the Expo SDK. For JS type systems (namely TS and Flow) we see a significant preference for TypeScript and in our own experience we find TypeScript to be stable, sufficiently expressive most of the time, and generally positive. We also find that standard, untyped JS works well and will continue to design APIs that work well without a type system.

Why

The primary reason for first-class support for TypeScript is that it is stable and works well without drawing too much on our attention for maintenance. The TypeScript team has done very good work creating smooth upgrade plans (e.g. upgrading from TypeScript 2.x to 3.x is quite smooth) and we've found their work to be reliable. We believe that making more parts of Expo -- in this case, TypeScript -- more reliable will make it more reliable to develop and use apps made with Expo.

Additionally, the very recently released Babel 7 supports TypeScript, which means we can continue to use Babel-based builds for Expo hopefully without introducing too much thrash or instability.

How

In practice, this proposal means that the Expo SDK would move to .ts files and the Flow type hints would be replaced by TypeScript type hints. Today, TypeScript type declarations (https://github.com/DefinitelyTyped/DefinitelyTyped) are helpfully maintained by developers in the Expo community and the Expo SDK provides Flow types; this would switch around where the Expo SDK would provide TypeScript types and the community, if someone were to step up, would maintain Flow type declarations in https://github.com/flow-typed/flow-typed. Given the history of solid work from the TypeScript team, the popularity of TypeScript amongst Expo developers, and the stability and reduced maintenance tax we expect from moving the Expo SDK to TypeScript, we believe this is a high-ROI tradeoff.

Some dependencies of the Expo SDK that aren't maintained by the Expo team, like React Native, Maps, and SVG, may not have complete or accurate type declarations so we expect to start with TypeScript's default non-strict mode, adding stricter options when possible in a forward-looking way (ex: will we be able to keep the strict option when upgrading a dependency in the future?).

Eventually, we may also provide TypeScript support in the new-project templates so it is easy for developers to work with TypeScript from the start. We will continue to design our APIs to work well without TypeScript, which we believe to be responsible, safe, and forward-looking.

Request for comments

We are looking to see how this proposal resonates with Expo developers, especially professionals building apps for business. Along with this RFC thread, we'll also talk to some developers in interviews and at conferences to gauge feedback before making a decision in the coming weeks.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions