jsconfig.json option

alwaysStrict

  • Default false
  • Since TypeScript 2.1

JavaScript has a strict mode with tighter rules: some words are reserved, with is forbidden, deleting a plain variable is an error. ES modules and class bodies are always strict; older scripts are strict only with a "use strict" line. alwaysStrict makes TypeScript parse every file as strict and report what strict mode forbids, such as package used as a variable name (TS1212).

It is part of strict. Its other job, writing "use strict" into output files, does not apply with noEmit. TypeScript 6.0 treats all code as strict and deprecates turning it off.

At a glance

Write Leave it to strict; write "alwaysStrict": false only to turn this one check back off
On the command line --alwaysStrict
Type boolean
Default in TypeScript 5.9 false (on when strict is on)
Default from TypeScript 6.0 true: setting it to false is deprecated (TypeScript 6.0)
TypeScript's description Ensure 'use strict' is always emitted.

The description is quoted from TypeScript's own option list (Apache-2.0); see the notices.

Examples

main.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: main.js(2,5): error TS1212: Identifier expected. 'package' is a reserved word in strict mode. main.js(4,13): error TS1212: Identifier expected. 'package' is a reserved word in strict mode. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. main.js(2,5): error TS1212: Identifier expected. 'package' is a reserved word in strict mode. main.js(4,13): error TS1212: Identifier expected. 'package' is a reserved word in strict mode. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. main.js(2,5): error TS1212: Identifier expected. 'package' is a reserved word in strict mode. main.js(4,13): error TS1212: Identifier expected. 'package' is a reserved word in strict mode. checked 21 October 2026
var package = "jswt";error TS1212: Identifier expected. 'package' is a reserved word in strict mode.
console.log(package);error TS1212: Identifier expected. 'package' is a reserved word in strict mode.
alwaysStrict on: a script that uses a reserved word as a name.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": false,
    "target": "es2022",
    "module": "esnext",
    "types": [],
    "moduleResolution": "bundler",
    "alwaysStrict": true
  },
  "include": [
    "*.js"
  ]
}
main.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 : differs, see why TypeScript 6.0.3, run 21 October 2026: differs from 5.9.3. main.js(1,5): error TS1212: Identifier expected. 'package' is a reserved word in strict mode. main.js(2,13): error TS1212: Identifier expected. 'package' is a reserved word in strict mode. 7.0.2 : differs, see why TypeScript 7.0.2, run 21 October 2026: differs from 5.9.3. main.js(1,5): error TS1212: Identifier expected. 'package' is a reserved word in strict mode. main.js(2,13): error TS1212: Identifier expected. 'package' is a reserved word in strict mode. checked 21 October 2026
var package = "jswt";
console.log(package);
alwaysStrict off: the script is parsed in sloppy mode.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": false,
    "target": "es2022",
    "module": "esnext",
    "types": [],
    "moduleResolution": "bundler"
  },
  "include": [
    "*.js"
  ]
}

Which files it affects

Only scripts: files that are not modules, such as classic <script> files in a browser project. The examples use one (no import or export, module: "esnext", no "type" in package.json). ES modules are strict whether or not the option is on, and in TypeScript 5.9 CommonJS files checked under module: "nodenext" are treated as strict too.

Under TypeScript 6.0 and 7.0

Every example on this page also runs under TypeScript 6.0.3 and 7.0.2 when this site is built. One of them reports something different from 5.9.3, the version the page describes; the ✗ on its badge links to its entry below.

Every file is parsed in strict mode

TypeScript 6.0 and 7.0 · options 6.0 deprecates and 7.0 removes

The pattern: A word that strict mode reserves (package, private, static, public) used as a variable name in a project with "strict": false.

Why: 6.0 deprecates alwaysStrict: false: per the release notes, all code is now assumed to be in JavaScript strict mode, whatever strict says. So the reserved word is a syntax error (TS1212) in 6.0 and 7.0, where 5.9 accepted it with strict off. Source: TypeScript 6.0 release notes: Deprecated: --alwaysStrict false.

alwaysStrict off: the script is parsed in sloppy mode main.js

TypeScript 5.9.3

No errors.

TypeScript 6.0.3differs from 5.9.3
main.js(1,5): error TS1212: Identifier expected. 'package' is a reserved word in strict mode.
main.js(2,13): error TS1212: Identifier expected. 'package' is a reserved word in strict mode.
TypeScript 7.0.2differs from 5.9.3
main.js(1,5): error TS1212: Identifier expected. 'package' is a reserved word in strict mode.
main.js(2,13): error TS1212: Identifier expected. 'package' is a reserved word in strict mode.

What works in every version: Rename the variable (pkg for package). A module file (one with import or export) is strict in every version anyway.

Gotchas

  • Scripts that rely on sloppy-mode behavior (assigning to an undeclared variable to create a global, for example) break when they run as modules; this option shows you those spots before you switch.

Sources

Last reviewed 20 October 2026.