-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
From #54500:
The
alwaysStrict
flag refers to inference of the"use strict";
directive. In TypeScript 6.0, all code will be assumed to be in "strict mode", which is a set of JS semantics that mostly affects syntactic corner cases around reserved words.This lets us be faster because it's no longer necessary to look ahead or repase on constructs like
var x = awaitwhich is legal "sloppy mode" referring to a variable named
await
. This also reduces the number of flags which possibly prevent sharing of source files between projects with different compiler settings.See #61888 for RWC run; we found one codebase that used
static
as a parameter name.
This also lets us be a bit more efficient because our language service (and --build
mode?) tries its best to reuse syntax trees for files belonging to multiple projects. When flags differ across projects, we have to sometimes cache ASTs by creating a composite key of both their paths and their projects' flags. If we can remove alwaysStrict
, we can simplify our code and ensure syntax trees are shared more often. Over time, we may be able to remove all configuration flags that impact sharing.
We may need to clarify a few details here: specifically, are we removing --alwaysStrict
, or just turning it on by default? If the former, that means that in 6.0 we are deprecating --alwaysStrict false
.