GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow some per file compiler options by weswigham · Pull Request #49886 · microsoft/TypeScript

Conversation

@weswigham

@weswigham Wesley Wigham (weswigham) commented Jul 12, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

In this PR, we allow certain compiler options to be configured via comments within a file for the scope of that file using a comment of the form // @ts-option [value]. This means you can write, for example:
compiler-option-pragmas

Currently this supports everything in the "strict type checks" and "additional checks" segments of options, which includes:

  • strict
  • noImplicitAny
  • strictNullChecks
  • strictFunctionTypes
  • strictBindCallApply
  • strictPropertyInitialization
  • noImplicitThis
  • useUnknownInCatchVariables
  • alwaysStrict
  • noUnusedLocals
  • noUnusedParameters
  • exactOptionalPropertyTypes
  • noImplicitReturns
  • noFallthroughCasesInSwitch
  • noUncheckedIndexedAccess
  • noImplicitOverride
  • noPropertyAccessFromIndexSignature

Adding more options to this list is just a matter of adding the allowedAsPragma flag to the definition of the option in commandLineParser.ts and using getFileLocalCompilerOption to look up the option at relevant locations, so we can easily add support for more local options as needed (by far the hardest was strictNullChecks).

Fixes #31035

I've wanted to look into this since I originally added the generic pragma-parsing infrastructure for @ts-check and related comments.

To start off the discussion, in the linked issue, Ryan Cavanaugh (@RyanCavanaugh) asked:

It's not really even clear what this means - if you have a type declared in file A, another type in file B, and you try to relate them in file C, whose value of strictFunctionTypes is in play?

Currently in this PR, whichever is stricter. If either file the types originated from has it set, it's related strictly. Could go the other way and relate loosely if either is explicitly non-strict if looser checking is more preferable. Honestly, most of these "which context controls the flag" already have fairly canonical answers, either because we already look up a context to check JS-y-ness (for JS-file-specific-behaviors or error ignoring), or to issue an error in (in which case the error node location is a pretty logical context).

Anyways, I'm hoping this implementation can jumpstart discussion on the value of in-file pragmas for compiler options, specifically with the goal of bikeshedding the syntax and what options we should ultimately expose on a per-file basis. (Technically, I've tried to make the internal APIs for adding new per-file pragmas very type-safe and very easy to use.)

I strongly recommend reviewing this by-commit if possible. Specifically, the changes to strictNullChecks to support this are extensive and are contained in f5134a5.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dasa, jessety, mjbvz, neolectron, reosablo, Xample, amitbeck, softwareCobbler, LvChengbin, Stumblinbear, and 29 more reacted with thumbs up emoji altso, timothy-b, dnalborczyk, rodrigofariow, topaxi, zyhou, repeale, OnurGvnc, therynamo, adamvictorclever, and 21 more reacted with hooray emoji DanielRosenwasser, IOuser, Dremora, timothy-b, voxpelli, dnalborczyk, robpalme, rodrigofariow, topaxi, zyhou, and 34 more reacted with heart emoji dnalborczyk, topaxi, repeale, therynamo, adamvictorclever, shigma, jameskraus, amitbeck, EsdrasAmora, pkwieci1, and 9 more reacted with rocket emoji
All reactions
  • 👍 39 reactions
  • 🎉 31 reactions
  • ❤️ 44 reactions
  • 🚀 19 reactions
@typescript-bot TypeScript Bot (typescript-bot) assigned Wesley Wigham (weswigham) Jul 12, 2022
@typescript-bot TypeScript Bot (typescript-bot) added the Author: Team label Jul 12, 2022
@weswigham

Wesley Wigham (weswigham) commented Jul 12, 2022

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) pack this

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot TypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jul 12, 2022
@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 12, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the tarball bundle task on this PR at 459196b. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@weswigham

Wesley Wigham (weswigham) commented Jul 13, 2022

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) pack this now that baselines should be green again :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 13, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the tarball bundle task on this PR at 97bba40. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MartinJohns

Martin Johns (MartinJohns) commented Jul 13, 2022

Copy link
Copy Markdown
Contributor

Is this opt-in only, or will it be possible to opt-out as well?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@weswigham

Wesley Wigham (weswigham) commented Jul 13, 2022

Copy link
Copy Markdown
Member Author

You should be able to write things like // @ts-strict false and the like. Parameters get parsed the same way they do on the command line.

MartinJohns reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@weswigham

Wesley Wigham (weswigham) commented Jul 13, 2022

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) pack this

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 13, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the tarball bundle task on this PR at ef3813c. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 13, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Hey Wesley Wigham (@weswigham), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/129711/artifacts?artifactName=tgz&fileId=07F2813C225AA6CC371299076DC3BF08FFE79A5C45BC00165AB9D270F70FC3FB02&fileName=/typescript-4.8.0-insiders.20220713.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jakebailey Jake Bailey (jakebailey) mentioned this pull request Jul 17, 2022
Strict type-checking on a per-file basis "@ts-strict" #28306
Open
4 tasks done
@Dremora Kirill Korolyov (Dremora) mentioned this pull request Jul 26, 2022
A project reference setup using both strict and non-strict modes produces errors in VS Code #50035
Closed
@weswigham Wesley Wigham (weswigham) mentioned this pull request Aug 17, 2022
Per file option: strictNullChecks #50347
Closed
Wesley Wigham (weswigham) added 3 commits August 24, 2022 10:55
@weswigham
Parsing for per-file options, WIP
913e68b
WIP 2

Less WIP - Only exactOptionalPropertyTypes and strictNullChecks left

Pragmas are case-insensitive

Fix harness types

Fixup baselines

File-local support for exactOptionalPropertyTypes

Fix lints

Cache getSourceFileOfNode within the checker
@weswigham
Per-file strictNullChecks support
f5134a5
@weswigham
strictNullChecks pragma tests, including cross-file type behavior
b45165d
@weswigham
Wesley Wigham (weswigham) force-pushed the per-file-options branch from ef3813c to b45165d Compare August 24, 2022 18:04
@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) mentioned this pull request Aug 25, 2022
TypeScript 4.9 Iteration Plan #50457
Closed
jakebailey
Jake Bailey (jakebailey) reviewed Aug 30, 2022
View reviewed changes
Comment thread ...nes/reference/genericConditionalConstrainedToUnknownNotAssignableToConcreteObject.errors.txt Resolved

Uh oh!

There was an error while loading. Please reload this page.

@weswigham
Tests for all new pragmas
fe5600e
@weswigham
Wesley Wigham (weswigham) force-pushed the per-file-options branch from 1be381d to fe5600e Compare August 31, 2022 17:38
Wesley Wigham (weswigham) added 2 commits August 31, 2022 11:00
@weswigham
Error on duplicate local compiler options
e25d5a8
@weswigham
Fix lint
5b336c6
@weswigham
Wesley Wigham (weswigham) marked this pull request as ready for review August 31, 2022 18:09
@weswigham
Merge branch 'main' into per-file-options
4bde2e7
@weswigham

Wesley Wigham (weswigham) commented Aug 31, 2022

Copy link
Copy Markdown
Member Author

This should be cleaned up and ready to go, so let's get the bot to do some tests on this iteration (not the much has changed implementation-wise since I ran them on the strict null checks-dedicated draft pr).

TypeScript Bot (@typescript-bot) pack this
TypeScript Bot (@typescript-bot) user test this inline
TypeScript Bot (@typescript-bot) test this
TypeScript Bot (@typescript-bot) run dt
TypeScript Bot (@typescript-bot) perf test this

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 31, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the extended test suite on this PR at 4bde2e7. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 31, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the perf test suite on this PR at 4bde2e7. You can monitor the build here.

Update: The results are in!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Sep 21, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@weswigham), I've started to run the abridged perf test suite on this PR at 5b77328. You can monitor the build here.

Update: The results are in!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Sep 21, 2022

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham)
The results of the perf run you requested are in!

Here they are:

Comparison Report - main..49886

Metric main 49886 Delta Best Worst
Angular - node (v14.15.1, x64)
Memory used 339,137k (± 0.01%) 343,063k (± 0.01%) +3,926k (+ 1.16%) 343,018k 343,104k
Parse Time 2.07s (± 0.56%) 2.08s (± 1.17%) +0.02s (+ 0.73%) 2.05s 2.17s
Bind Time 0.80s (± 0.70%) 0.80s (± 0.59%) +0.00s (+ 0.25%) 0.79s 0.81s
Check Time 5.86s (± 0.41%) 6.38s (± 0.34%) +0.53s (+ 8.98%) 6.34s 6.43s
Emit Time 6.25s (± 0.48%) 6.30s (± 0.74%) +0.05s (+ 0.80%) 6.21s 6.43s
Total Time 14.97s (± 0.28%) 15.56s (± 0.49%) +0.59s (+ 3.94%) 15.45s 15.76s
Compiler-Unions - node (v14.15.1, x64)
Memory used 190,085k (± 0.14%) 193,913k (± 0.13%) +3,828k (+ 2.01%) 192,934k 194,067k
Parse Time 0.86s (± 0.98%) 0.86s (± 0.65%) -0.00s (- 0.12%) 0.85s 0.87s
Bind Time 0.48s (± 1.03%) 0.49s (± 0.61%) +0.00s (+ 0.62%) 0.48s 0.49s
Check Time 6.73s (± 0.34%) 7.32s (± 0.45%) +0.59s (+ 8.70%) 7.21s 7.39s
Emit Time 2.40s (± 0.63%) 2.41s (± 0.88%) +0.01s (+ 0.33%) 2.37s 2.48s
Total Time 10.48s (± 0.25%) 11.07s (± 0.40%) +0.60s (+ 5.69%) 10.95s 11.17s
Monaco - node (v14.15.1, x64)
Memory used 326,573k (± 0.01%) 333,806k (± 0.01%) +7,233k (+ 2.21%) 333,761k 333,858k
Parse Time 1.59s (± 0.79%) 1.59s (± 0.84%) +0.01s (+ 0.57%) 1.56s 1.63s
Bind Time 0.73s (± 0.50%) 0.73s (± 0.82%) 0.00s ( 0.00%) 0.71s 0.74s
Check Time 5.71s (± 0.29%) 6.37s (± 0.42%) +0.66s (+11.56%) 6.31s 6.43s
Emit Time 3.35s (± 0.30%) 3.38s (± 1.04%) +0.03s (+ 0.84%) 3.33s 3.50s
Total Time 11.38s (± 0.24%) 12.07s (± 0.44%) +0.70s (+ 6.12%) 11.97s 12.24s
TFS - node (v14.15.1, x64)
Memory used 289,660k (± 0.01%) 295,349k (± 0.01%) +5,689k (+ 1.96%) 295,298k 295,389k
Parse Time 1.29s (± 0.64%) 1.30s (± 0.43%) +0.00s (+ 0.31%) 1.28s 1.31s
Bind Time 0.79s (± 0.92%) 0.79s (± 0.75%) +0.00s (+ 0.25%) 0.78s 0.81s
Check Time 5.37s (± 0.58%) 5.90s (± 0.38%) +0.53s (+ 9.79%) 5.84s 5.94s
Emit Time 3.60s (± 0.77%) 3.60s (± 0.53%) +0.00s (+ 0.03%) 3.57s 3.65s
Total Time 11.06s (± 0.52%) 11.60s (± 0.18%) +0.54s (+ 4.87%) 11.54s 11.64s
material-ui - node (v14.15.1, x64)
Memory used 436,848k (± 0.00%) 439,032k (± 0.01%) +2,184k (+ 0.50%) 438,969k 439,073k
Parse Time 1.88s (± 0.51%) 1.88s (± 0.64%) +0.01s (+ 0.43%) 1.85s 1.91s
Bind Time 0.58s (± 0.96%) 0.58s (± 0.81%) +0.00s (+ 0.35%) 0.57s 0.59s
Check Time 12.94s (± 0.71%) 14.24s (± 0.48%) +1.29s (+ 9.97%) 14.10s 14.38s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.40s (± 0.61%) 16.70s (± 0.44%) +1.30s (+ 8.46%) 16.54s 16.86s
xstate - node (v14.15.1, x64)
Memory used 547,672k (± 0.01%) 549,070k (± 0.00%) +1,398k (+ 0.26%) 549,029k 549,114k
Parse Time 2.62s (± 0.48%) 2.63s (± 0.63%) +0.01s (+ 0.50%) 2.58s 2.66s
Bind Time 0.98s (± 1.55%) 0.99s (± 1.20%) +0.00s (+ 0.41%) 0.96s 1.02s
Check Time 1.51s (± 0.64%) 1.61s (± 0.68%) +0.10s (+ 6.55%) 1.59s 1.63s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.19s (± 0.41%) 5.30s (± 0.49%) +0.11s (+ 2.04%) 5.22s 5.35s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 49886 10
Baseline main 10

Developer Information:

Download Benchmark

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@swandir swandir mentioned this pull request Oct 6, 2022
Configurable option for isolated type-checking of modules denoland/deno#13564
Closed
@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) mentioned this pull request Oct 31, 2022
TypeScript 5.0 Iteration Plan #51362
Closed
@azu azu (azu) mentioned this pull request Nov 2, 2022
2022-11-02のJS: Node.js 18.12.0 LTS、Babel 7.20.0、TypeScript 4.9 RC jser/jser.github.io#1016
Merged
neolectron
Manu (neolectron) approved these changes Nov 4, 2022
View reviewed changes

@neolectron Manu (neolectron) left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

OzakIOne and potb reacted with thumbs up emoji OzakIOne, potb, and abdatta reacted with laugh emoji OzakIOne, jackymayo, zyhou, potb, sitek94, maheshbansod, abdatta, julianwilkinson, and celluj34 reacted with hooray emoji xiaoxiangmoe, altso, zyhou, zlalvani, potb, neolectron, sitek94, and a7madgamal reacted with eyes emoji
All reactions
  • 👍 2 reactions
  • 😄 3 reactions
  • 🎉 9 reactions
  • 👀 8 reactions
@abdatta

Abhishek Datta (abdatta) commented Jan 10, 2023

Copy link
Copy Markdown

Hi, any updates on this? Now that it is approved, can we expect it to be merged anytime soon?

xiaoxiangmoe, zyhou, sitek94, altso, pkwieci1, maheshbansod, and julianwilkinson reacted with thumbs up emoji
All reactions
  • 👍 7 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@abdatta

Abhishek Datta (abdatta) commented Jan 11, 2023

Copy link
Copy Markdown

TypeScript Bot (@typescript-bot) pack this

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@abdatta

Abhishek Datta (abdatta) commented Jan 13, 2023

Copy link
Copy Markdown

Hey Wesley Wigham (@weswigham), if you don't mind, can you please ask the TypeScript Bot (@typescript-bot) to pack this latest iteration? It seems to listen to the PR author. I wanted to try it out in some local project. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jakebailey

Jake Bailey (jakebailey) commented Jan 13, 2023

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) pack this

abdatta reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 13, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Jake Bailey (@jakebailey), I've started to run the tarball bundle task on this PR at 5b77328. You can monitor the build here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 13, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/142539/artifacts?artifactName=tgz&fileId=84F197BAEF8A6E106505CC1E9EE470B6D941DF8AA3E6B9D2787B60D6817BEDF002&fileName=/typescript-4.9.0-insiders.20230113.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@abdatta

Abhishek Datta (abdatta) commented Jan 13, 2023

Copy link
Copy Markdown

Thanks Jake Bailey (@jakebailey)!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xiaoxiangmoe

ZHAO Jin-Xiang (xiaoxiangmoe) commented Jan 13, 2023

Copy link
Copy Markdown
Contributor

There is only a week before ts 5.0 beta. Maybe this feature will be avaliable after 5.1

abdatta reacted with confused emoji
All reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@abdatta

Abhishek Datta (abdatta) commented Jan 15, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

I'm seeing these kinds of errors despite turning off the check. Is this expected? Ideally it should not be imo as turning off SNC from tsconfig would not generate this error.

image

Playground Link

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eyelidlessness

Trevor Schmidt (eyelidlessness) commented Jan 22, 2023

Copy link
Copy Markdown

I was writing up a much longer background for this, but I’m exhausted on Saturday, and don’t want to lose the context before I bail. I’m happy to come back and fill in details of why I’m asking if it seems really bonkers to ask.

Is there any possibility this could allow specifying:

  • tsconfig path rather than individual config items
  • a range of lines it applies to versus a whole module

The use case prompting me to ask involves using Playwright as a library, and would incredibly simplify its usage (and type safety) for a single function proxy as I transition a library from dependence on Node APIs and native dependencies to be usable in browser. It’s definitely not a common use case, but I can imagine others which might benefit from specifying a given callback is being shuttled off to be executed in an entirely different environment.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Jan 23, 2023

Copy link
Copy Markdown
Member

Hey all, the future of this feature is somewhat uncertain. Any time the type system has to make a decision based on strictness, it now has to walk up to the top of the file and check for strictness directives. If not that, every node (or almost every node) of our syntax trees has to get a little bit bigger to hold onto that information.

This has a type-checking performance impact that is higher than we can accept. There might be some optimizations we can make for the more common case of no file-specific options within a project, but that leads to some unpredictable performance cliffs as soon as one is added.

So this won't make its way into TypeScript 5.0, and it's unclear if we'll be able to bring it in in the future either.

rodelta, vanyauhalin, rlucha, and mizdra reacted with thumbs up emoji Frimko, rachaelbrownie, jd-lacey, and dwm-mcollins reacted with thumbs down emoji voxpelli, mpoc, zyhou, sitek94, altso, abrenneke, abdatta, maheshbansod, neolectron, pvdstel, and 25 more reacted with confused emoji
All reactions
  • 👍 4 reactions
  • 👎 4 reactions
  • 😕 35 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andrewbranch Andrew Branch (andrewbranch) mentioned this pull request May 10, 2023
Proposal: Encode and read emit-affecting compiler options in declaration files #54212
Open
@ssalbdivad David Blass (ssalbdivad) mentioned this pull request Jul 17, 2023
Expanded function return type for certain mapped types in compiled output causes index access error #55049
Closed
@fatcerberus Bruce Pascoe (fatcerberus) mentioned this pull request Jul 19, 2023
Optional nested readonly type changes type of property adding undefined #55058
Closed
@debadree25

Debadree Chatterjee (debadree25) commented May 30, 2024

Copy link
Copy Markdown

Hey all, the future of this feature is somewhat uncertain. Any time the type system has to make a decision based on strictness, it now has to walk up to the top of the file and check for strictness directives. If not that, every node (or almost every node) of our syntax trees has to get a little bit bigger to hold onto that information.

This has a type-checking performance impact that is higher than we can accept. There might be some optimizations we can make for the more common case of no file-specific options within a project, but that leads to some unpredictable performance cliffs as soon as one is added.

So this won't make its way into TypeScript 5.0, and it's unclear if we'll be able to bring it in in the future either.

Can this option be not added as an opt in? like an option in compilerOptions something like "enableIncrementalStrictCheckComments" or something? this can be an incredibly helpful option I think most people would be happy to accept a performance penalty to allow for incremental migration to safer and better code.

I came across this issue searching for a way to enable incremental strict checks on a 50k+ line codebase on which enabling strict checks throws up 3k+ errors 🙈 while i understand plugins exist for this having this on a compiler level can be so much better!

I know no nothing about typescripts development process/priorities so if anything i said here is wrong/doesnt make sense I apologise but I sincerely hope you consider the request!

Thank you to the author and typescript team for their time and effort on this!

altso, jacksonrayhamilton, vitaly-rudenko-deel, rachaelmcq, kellertobias, iansjk, and dwm-mcollins reacted with thumbs up emoji
All reactions
  • 👍 7 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@weswigham Wesley Wigham (weswigham) added the Experiment A fork with an experimental idea which might not make it into master label Aug 13, 2024
@weswigham
Wesley Wigham (weswigham) marked this pull request as draft August 13, 2024 22:26
@elpoelma Elena Poelman (elpoelma) mentioned this pull request Dec 13, 2024
Improved jsdoc/type-checking setup lblod/notulen-prepublish-service#120
Merged
7 tasks done
@tujoworker Tobias Høegh (tujoworker) mentioned this pull request Mar 20, 2025
fix(Forms): enhance typing for FieldBlock and useFieldProps dnbexperience/eufemia#4785
Merged
@sandersn

Nathan Shively-Sanders (sandersn) commented Apr 30, 2025

Copy link
Copy Markdown
Member

Wesley Wigham (@weswigham) is this worth keeping open? Is it worth revisiting in Go?

dwm-mcollins reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dwm-mcollins

dwm-mcollins commented May 23, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Please consider adding this as an opt in option like Debadree Chatterjee (@debadree25) mentioned.

Also im not sure that compiler performance is something that should be optimised for and chosen above this feature, considering the whole point of TS is to optimise for safely typed code? and especially considering the recent improvements after migration to go.

Also, surely you just do a single pass of all the files and store their strictness directives in a hashmap?? so that you dont walk the tree on every single check?

Id pay the one time incremental reduction in compilation time any day over having to live with strictNullChecks: false in the project forever.

as it stands, migrating from non-strict to strict compilations is not a feasible task within a large active project with competing priorities.

The rate of new work being developed by many developers with non-strict ts config, is greater than the amount of files that can be incrementally refactored to strict-checks by whatever developer is spearheading the operation.

having the ability to enforce // Strict TypeScript (@ts-strict) at the top of any new file commits would go a long way in making a migration like this feasible

rosslavery, altso, and cardoso reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@maxdiebold-erg Jon Maxwell Diebold (maxdiebold-erg) mentioned this pull request Nov 20, 2025
MP import error when monitoringQualificationLEEData or monitoringQualificationLMEData is not present US-EPA-CAMD/easey-ui#6980
Open
@typescript-bot TypeScript Bot (typescript-bot) closed this Mar 24, 2026
@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ahejlsberg Anders Hejlsberg (ahejlsberg) Awaiting requested review from ahejlsberg
@jakebailey Jake Bailey (jakebailey) Awaiting requested review from jakebailey
@sandersn Nathan Shively-Sanders (sandersn) Awaiting requested review from sandersn
Copilot code review Copilot
Copilot will automatically review once the pull request is marked ready for review
1 more reviewer
@neolectron Manu (neolectron) neolectron approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@weswigham Wesley Wigham (weswigham)

Labels

Author: Team Experiment A fork with an experimental idea which might not make it into master For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

allow per file compilerOptions

Uh oh!

There was an error while loading. Please reload this page.

13 participants

@weswigham @typescript-bot @MartinJohns @ahejlsberg @xiaoxiangmoe @abdatta @jakebailey @eyelidlessness @DanielRosenwasser @debadree25 @sandersn @dwm-mcollins @neolectron
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.