Microsoft introduces project references in TypeScript 3.0

Microsoft released version 3.0 of its JavaScript plugin TypeScript today, which brings static types, type declarations and type annotations to JavaScript users. Though the company says the update is light on “breaking” changes, TypeScript program manager, Daniel Rosenwasser highlighted the new features such as project references.

According to Rosenwasser, project references were one of the biggest improvements of the release, making it easier for developers to share dependencies between multiple TypeScript projects by allowing tsconfig.json files to reference each other.

“Specifying these dependencies makes it easier to split your code into smaller projects, since it gives TypeScript (and tools around it) a way to understand build ordering and output structure,” Rosenwasser wrote. “That means things like faster builds that work incrementally, and support for transparently navigating, editing, and refactoring across projects. Since 3.0 lays the foundation and exposes the APIs, any build tool should be able to provide this.”

With TypeScript 3.0’s –build flag, users can now build projects and dependencies without the need for external compilers or tools and control the structure of the output, and avoids duplicate dependencies during the build process when using project reference, Rosenwasser explained.

The update also brings along richer tuple types and the new “unknown” type, which behaves similarly to the preexisting “any” type, but will throw up warnings in the IDE when referenced incorrectly.

Finally, the editor has received improved UX elements for error reporting and warnings such as “related error spans,” which “can provide messages on other locations so that users can reason about cause-and-effect of an error,” Rosenwasser wrote. “In some sense, related error messages can give a user not just an explanation, but also breadcrumbs to see where things went wrong.”

More information about these changes and other improvements in TypeScript 3.0 can be found here.