TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Allow some per file compiler options

Open weswigham opened this issue 3 years ago • 68 comments

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, @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 https://github.com/microsoft/TypeScript/pull/49886/commits/f5134a545c5ab657087828e92c3999dc02af037d.

weswigham avatar Jul 12 '22 23:07 weswigham

@typescript-bot pack this

weswigham avatar Jul 12 '22 23:07 weswigham

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

typescript-bot avatar Jul 12 '22 23:07 typescript-bot

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

weswigham avatar Jul 13 '22 00:07 weswigham

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

typescript-bot avatar Jul 13 '22 00:07 typescript-bot

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

MartinJohns avatar Jul 13 '22 06:07 MartinJohns

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.

weswigham avatar Jul 13 '22 07:07 weswigham

@typescript-bot pack this

weswigham avatar Jul 13 '22 19:07 weswigham

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

typescript-bot avatar Jul 13 '22 19:07 typescript-bot

Hey @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]".;

typescript-bot avatar Jul 13 '22 20:07 typescript-bot

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 pack this @typescript-bot user test this inline @typescript-bot test this @typescript-bot run dt @typescript-bot perf test this

weswigham avatar Aug 31 '22 18:08 weswigham

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

typescript-bot avatar Aug 31 '22 18:08 typescript-bot

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

Update: The results are in!

typescript-bot avatar Aug 31 '22 18:08 typescript-bot

Heya @weswigham, I've started to run the tarball bundle task on this PR at 4bde2e71da10b1abf04f99de9bd935448696fd6c. You can monitor the build here.

typescript-bot avatar Aug 31 '22 18:08 typescript-bot

Heya @weswigham, I've started to run the diff-based user code test suite on this PR at 4bde2e71da10b1abf04f99de9bd935448696fd6c. You can monitor the build here.

Update: The results are in!

typescript-bot avatar Aug 31 '22 18:08 typescript-bot

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 4bde2e71da10b1abf04f99de9bd935448696fd6c. You can monitor the build here.

typescript-bot avatar Aug 31 '22 18:08 typescript-bot

@weswigham Here are the results of running the user test suite comparing main and refs/pull/49886/merge:

Something interesting changed - please have a look.

Details

webpack

tsconfig.json

tsconfig.types.json

  • [NEW] error TS2322: Type 'undefined' is not assignable to type 'Pick<ArgumentConfig, "values" | "type">'.
  • [NEW] error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Record<"filter" | "sort" | "result" | "extract" | "filterSorted" | "groupResults" | "sortResults" | "filterResults" | "merge" | "getItemName" | "getItemFactory", Map<string, SyncBailHook<[...], any, UnsetAdditionalOptions>[]>>'.
  • [MISSING] error TS2322: Type 'undefined' is not assignable to type 'Pick<ArgumentConfig, "type" | "values">'.
  • [MISSING] error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Record<"sort" | "filter" | "result" | "extract" | "filterSorted" | "groupResults" | "sortResults" | "filterResults" | "merge" | "getItemName" | "getItemFactory", Map<string, SyncBailHook<[...], any, UnsetAdditionalOptions>[]>>'.

typescript-bot avatar Aug 31 '22 18:08 typescript-bot

Hey @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/133185/artifacts?artifactName=tgz&fileId=99738104B9F8C6122A08A47F6E4906E162B58E2CD37725A530DD9E94E0D93EF802&fileName=/typescript-4.9.0-insiders.20220831.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]".;

typescript-bot avatar Aug 31 '22 18:08 typescript-bot

Heya @weswigham, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here.

typescript-bot avatar Aug 31 '22 18:08 typescript-bot

@weswigham The results of the perf run you requested are in!

Here they are:

Compiler

Comparison Report - main..49886
Metric main 49886 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 363,148k (± 0.02%) 367,453k (± 0.01%) +4,305k (+ 1.19%) 367,353k 367,584k
Parse Time 2.10s (± 0.64%) 2.09s (± 0.58%) -0.01s (- 0.48%) 2.07s 2.13s
Bind Time 0.79s (± 0.84%) 0.79s (± 0.71%) -0.00s (- 0.25%) 0.78s 0.80s
Check Time 6.18s (± 0.69%) 6.67s (± 0.64%) +0.50s (+ 8.06%) 6.59s 6.77s
Emit Time 6.07s (± 0.87%) 6.03s (± 0.72%) -0.04s (- 0.58%) 5.95s 6.17s
Total Time 15.13s (± 0.53%) 15.58s (± 0.46%) +0.45s (+ 3.00%) 15.46s 15.78s
Compiler-Unions - node (v10.16.3, x64)
Memory used 206,058k (± 0.04%) 208,961k (± 0.36%) +2,903k (+ 1.41%) 208,395k 212,005k
Parse Time 0.84s (± 1.01%) 0.84s (± 0.53%) +0.00s (+ 0.36%) 0.83s 0.85s
Bind Time 0.47s (± 1.04%) 0.47s (± 1.11%) -0.00s (- 1.05%) 0.46s 0.48s
Check Time 8.47s (± 0.21%) 9.01s (± 0.49%) +0.54s (+ 6.40%) 8.87s 9.08s
Emit Time 2.50s (± 1.53%) 2.49s (± 1.05%) -0.01s (- 0.40%) 2.43s 2.54s
Total Time 12.29s (± 0.29%) 12.82s (± 0.46%) +0.53s (+ 4.30%) 12.62s 12.91s
Monaco - node (v10.16.3, x64)
Memory used 344,739k (± 0.03%) 351,990k (± 0.02%) +7,251k (+ 2.10%) 351,840k 352,086k
Parse Time 1.61s (± 0.74%) 1.60s (± 0.42%) -0.01s (- 0.50%) 1.58s 1.61s
Bind Time 0.70s (± 0.63%) 0.70s (± 0.49%) -0.01s (- 0.71%) 0.69s 0.70s
Check Time 6.26s (± 0.39%) 6.83s (± 0.50%) +0.57s (+ 9.07%) 6.76s 6.92s
Emit Time 3.23s (± 0.99%) 3.21s (± 0.84%) -0.02s (- 0.74%) 3.16s 3.28s
Total Time 11.81s (± 0.43%) 12.34s (± 0.46%) +0.53s (+ 4.51%) 12.23s 12.49s
TFS - node (v10.16.3, x64)
Memory used 305,921k (± 0.01%) 311,656k (± 0.03%) +5,735k (+ 1.87%) 311,471k 311,847k
Parse Time 1.29s (± 0.70%) 1.29s (± 0.38%) -0.00s (- 0.23%) 1.28s 1.30s
Bind Time 0.68s (± 0.77%) 0.67s (± 0.92%) -0.01s (- 1.18%) 0.66s 0.68s
Check Time 5.51s (± 0.68%) 6.02s (± 0.44%) +0.51s (+ 9.22%) 5.96s 6.08s
Emit Time 3.42s (± 2.11%) 3.36s (± 0.79%) -0.06s (- 1.61%) 3.31s 3.42s
Total Time 10.90s (± 0.83%) 11.33s (± 0.34%) +0.44s (+ 4.01%) 11.22s 11.42s
material-ui - node (v10.16.3, x64)
Memory used 460,722k (± 0.01%) 463,132k (± 0.02%) +2,411k (+ 0.52%) 462,972k 463,355k
Parse Time 1.83s (± 0.82%) 1.82s (± 0.58%) -0.01s (- 0.66%) 1.80s 1.85s
Bind Time 0.58s (± 1.79%) 0.58s (± 1.67%) -0.00s (- 0.52%) 0.56s 0.59s
Check Time 15.81s (± 0.76%) 17.10s (± 0.79%) +1.29s (+ 8.14%) 16.85s 17.37s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 18.23s (± 0.73%) 19.50s (± 0.68%) +1.27s (+ 6.96%) 19.24s 19.78s
xstate - node (v10.16.3, x64)
Memory used 587,723k (± 1.25%) 588,988k (± 1.26%) +1,264k (+ 0.22%) 585,545k 618,876k
Parse Time 2.62s (± 0.47%) 2.60s (± 0.49%) -0.02s (- 0.92%) 2.57s 2.63s
Bind Time 0.92s (± 0.67%) 0.91s (± 0.52%) -0.01s (- 0.87%) 0.90s 0.92s
Check Time 1.63s (± 0.47%) 1.71s (± 0.56%) +0.08s (+ 5.10%) 1.69s 1.72s
Emit Time 0.07s (± 4.13%) 0.07s (± 4.92%) +0.00s (+ 2.78%) 0.07s 0.08s
Total Time 5.24s (± 0.27%) 5.28s (± 0.35%) +0.04s (+ 0.78%) 5.25s 5.33s
Angular - node (v12.1.0, x64)
Memory used 340,592k (± 0.09%) 344,878k (± 0.08%) +4,286k (+ 1.26%) 343,788k 345,195k
Parse Time 2.08s (± 0.57%) 2.09s (± 0.99%) +0.01s (+ 0.43%) 2.05s 2.14s
Bind Time 0.77s (± 0.58%) 0.77s (± 0.68%) +0.00s (+ 0.13%) 0.76s 0.78s
Check Time 5.83s (± 0.64%) 6.31s (± 0.65%) +0.48s (+ 8.21%) 6.24s 6.43s
Emit Time 6.25s (± 0.80%) 6.23s (± 0.80%) -0.02s (- 0.34%) 6.13s 6.35s
Total Time 14.93s (± 0.47%) 15.39s (± 0.59%) +0.47s (+ 3.14%) 15.23s 15.65s
Compiler-Unions - node (v12.1.0, x64)
Memory used 193,897k (± 0.12%) 196,376k (± 0.12%) +2,479k (+ 1.28%) 195,712k 196,679k
Parse Time 0.83s (± 0.99%) 0.83s (± 0.63%) -0.01s (- 0.72%) 0.82s 0.84s
Bind Time 0.47s (± 1.25%) 0.47s (± 0.71%) -0.00s (- 0.84%) 0.46s 0.48s
Check Time 6.68s (± 0.40%) 7.18s (± 0.65%) +0.50s (+ 7.42%) 7.09s 7.31s
Emit Time 2.47s (± 1.87%) 2.46s (± 0.88%) -0.01s (- 0.36%) 2.42s 2.52s
Total Time 10.46s (± 0.56%) 10.94s (± 0.53%) +0.48s (+ 4.56%) 10.83s 11.09s
Monaco - node (v12.1.0, x64)
Memory used 327,692k (± 0.01%) 334,957k (± 0.02%) +7,264k (+ 2.22%) 334,757k 335,054k
Parse Time 1.58s (± 0.97%) 1.57s (± 0.73%) -0.01s (- 0.82%) 1.54s 1.60s
Bind Time 0.70s (± 0.93%) 0.69s (± 0.71%) -0.00s (- 0.57%) 0.69s 0.71s
Check Time 5.85s (± 0.47%) 6.38s (± 0.33%) +0.53s (+ 9.08%) 6.33s 6.43s
Emit Time 3.30s (± 0.74%) 3.28s (± 0.56%) -0.02s (- 0.52%) 3.23s 3.32s
Total Time 11.43s (± 0.45%) 11.92s (± 0.29%) +0.50s (+ 4.34%) 11.85s 11.98s
TFS - node (v12.1.0, x64)
Memory used 290,427k (± 0.08%) 296,224k (± 0.01%) +5,797k (+ 2.00%) 296,174k 296,309k
Parse Time 1.30s (± 1.03%) 1.29s (± 1.03%) -0.00s (- 0.31%) 1.27s 1.33s
Bind Time 0.68s (± 1.18%) 0.67s (± 0.99%) -0.00s (- 0.74%) 0.66s 0.69s
Check Time 5.40s (± 0.57%) 5.86s (± 0.48%) +0.46s (+ 8.56%) 5.81s 5.92s
Emit Time 3.51s (± 0.87%) 3.47s (± 0.80%) -0.04s (- 1.08%) 3.42s 3.54s
Total Time 10.88s (± 0.53%) 11.30s (± 0.46%) +0.42s (+ 3.84%) 11.19s 11.45s
material-ui - node (v12.1.0, x64)
Memory used 439,760k (± 0.09%) 442,037k (± 0.09%) +2,277k (+ 0.52%) 440,987k 442,547k
Parse Time 1.82s (± 0.92%) 1.81s (± 0.49%) -0.01s (- 0.60%) 1.79s 1.83s
Bind Time 0.56s (± 1.07%) 0.55s (± 0.73%) -0.01s (- 1.26%) 0.54s 0.56s
Check Time 12.90s (± 1.45%) 14.20s (± 0.93%) +1.31s (+10.12%) 13.99s 14.54s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.27s (± 1.32%) 16.57s (± 0.80%) +1.29s (+ 8.47%) 16.36s 16.89s
xstate - node (v12.1.0, x64)
Memory used 552,857k (± 1.28%) 550,986k (± 0.01%) -1,871k (- 0.34%) 550,823k 551,185k
Parse Time 2.55s (± 0.65%) 2.54s (± 0.54%) -0.01s (- 0.39%) 2.52s 2.57s
Bind Time 0.89s (± 0.65%) 0.89s (± 1.15%) -0.00s (- 0.11%) 0.87s 0.92s
Check Time 1.49s (± 0.57%) 1.56s (± 0.33%) +0.07s (+ 4.56%) 1.55s 1.57s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.00s (± 0.48%) 5.05s (± 0.41%) +0.04s (+ 0.90%) 5.02s 5.10s
Angular - node (v14.15.1, x64)
Memory used 338,732k (± 0.00%) 342,827k (± 0.01%) +4,095k (+ 1.21%) 342,787k 342,860k
Parse Time 2.08s (± 1.37%) 2.06s (± 0.84%) -0.02s (- 0.91%) 2.04s 2.11s
Bind Time 0.79s (± 0.38%) 0.80s (± 0.47%) +0.00s (+ 0.38%) 0.79s 0.80s
Check Time 5.82s (± 0.45%) 6.34s (± 0.52%) +0.52s (+ 8.93%) 6.26s 6.42s
Emit Time 6.14s (± 0.63%) 6.20s (± 0.55%) +0.05s (+ 0.90%) 6.12s 6.28s
Total Time 14.84s (± 0.46%) 15.40s (± 0.31%) +0.56s (+ 3.79%) 15.30s 15.52s
Compiler-Unions - node (v14.15.1, x64)
Memory used 192,635k (± 0.01%) 195,495k (± 0.38%) +2,860k (+ 1.48%) 195,118k 198,478k
Parse Time 0.86s (± 0.78%) 0.85s (± 0.47%) -0.01s (- 0.93%) 0.84s 0.86s
Bind Time 0.49s (± 0.91%) 0.49s (± 0.77%) -0.00s (- 0.61%) 0.48s 0.49s
Check Time 6.69s (± 0.41%) 7.25s (± 0.30%) +0.56s (+ 8.32%) 7.20s 7.31s
Emit Time 2.39s (± 0.46%) 2.42s (± 0.48%) +0.02s (+ 0.96%) 2.40s 2.45s
Total Time 10.43s (± 0.28%) 11.00s (± 0.24%) +0.57s (+ 5.47%) 10.95s 11.06s
Monaco - node (v14.15.1, x64)
Memory used 326,520k (± 0.01%) 333,749k (± 0.01%) +7,229k (+ 2.21%) 333,695k 333,787k
Parse Time 1.58s (± 0.64%) 1.57s (± 0.62%) -0.01s (- 0.38%) 1.55s 1.59s
Bind Time 0.72s (± 0.77%) 0.72s (± 0.97%) -0.00s (- 0.42%) 0.71s 0.74s
Check Time 5.72s (± 0.28%) 6.35s (± 0.62%) +0.63s (+11.03%) 6.25s 6.42s
Emit Time 3.32s (± 0.72%) 3.33s (± 0.71%) +0.02s (+ 0.57%) 3.28s 3.37s
Total Time 11.33s (± 0.25%) 11.97s (± 0.47%) +0.64s (+ 5.66%) 11.82s 12.07s
TFS - node (v14.15.1, x64)
Memory used 289,622k (± 0.01%) 295,300k (± 0.01%) +5,678k (+ 1.96%) 295,263k 295,356k
Parse Time 1.30s (± 0.73%) 1.31s (± 0.89%) +0.00s (+ 0.08%) 1.29s 1.33s
Bind Time 0.79s (± 0.78%) 0.79s (± 0.70%) +0.00s (+ 0.13%) 0.78s 0.81s
Check Time 5.34s (± 0.39%) 5.88s (± 0.36%) +0.54s (+10.07%) 5.85s 5.95s
Emit Time 3.60s (± 0.64%) 3.56s (± 0.48%) -0.04s (- 1.06%) 3.53s 3.59s
Total Time 11.03s (± 0.37%) 11.53s (± 0.33%) +0.50s (+ 4.53%) 11.47s 11.65s
material-ui - node (v14.15.1, x64)
Memory used 438,198k (± 0.00%) 440,591k (± 0.01%) +2,393k (+ 0.55%) 440,529k 440,666k
Parse Time 1.86s (± 0.40%) 1.85s (± 0.72%) -0.00s (- 0.22%) 1.83s 1.88s
Bind Time 0.58s (± 0.82%) 0.59s (± 1.14%) +0.00s (+ 0.69%) 0.58s 0.61s
Check Time 12.90s (± 0.52%) 14.26s (± 0.52%) +1.36s (+10.53%) 14.12s 14.49s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.34s (± 0.43%) 16.70s (± 0.45%) +1.36s (+ 8.85%) 16.58s 16.94s
xstate - node (v14.15.1, x64)
Memory used 547,392k (± 0.00%) 548,711k (± 0.00%) +1,319k (+ 0.24%) 548,670k 548,751k
Parse Time 2.60s (± 0.32%) 2.60s (± 0.46%) -0.00s (- 0.08%) 2.57s 2.63s
Bind Time 0.97s (± 0.77%) 0.97s (± 1.12%) -0.00s (- 0.10%) 0.96s 1.01s
Check Time 1.54s (± 0.54%) 1.62s (± 0.51%) +0.09s (+ 5.73%) 1.61s 1.64s
Emit Time 0.07s (± 3.14%) 0.07s (± 3.14%) 0.00s ( 0.00%) 0.07s 0.08s
Total Time 5.19s (± 0.30%) 5.26s (± 0.26%) +0.08s (+ 1.50%) 5.23s 5.30s
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 (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v10.16.3, x64)
  • xstate - node (v12.1.0, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 49886 10
Baseline main 10

TSServer

Comparison Report - main..49886
Metric main 49886 Delta Best Worst
Compiler-UnionsTSServer - node (v10.16.3, x64)
Req 1 - updateOpen 1,408ms (± 0.38%) 1,394ms (± 0.44%) -14ms (- 1.02%) 1,382ms 1,408ms
Req 2 - geterr 4,116ms (± 0.43%) 4,377ms (± 0.64%) +262ms (+ 6.35%) 4,308ms 4,427ms
Req 3 - references 231ms (± 0.77%) 232ms (± 0.66%) +1ms (+ 0.35%) 228ms 236ms
Req 4 - navto 172ms (± 1.12%) 170ms (± 0.49%) -3ms (- 1.57%) 167ms 171ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 92ms (± 6.61%) 87ms (± 7.01%) 🟩-6ms (- 6.07%) 67ms 97ms
CompilerTSServer - node (v10.16.3, x64)
Req 1 - updateOpen 1,502ms (± 0.49%) 1,492ms (± 0.38%) -9ms (- 0.61%) 1,472ms 1,500ms
Req 2 - geterr 2,255ms (± 0.49%) 2,420ms (± 0.38%) +165ms (+ 7.29%) 2,398ms 2,436ms
Req 3 - references 242ms (± 0.61%) 244ms (± 0.72%) +2ms (+ 0.66%) 238ms 246ms
Req 4 - navto 184ms (± 1.12%) 183ms (± 0.69%) -2ms (- 0.92%) 180ms 186ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 69ms (± 0.84%) 68ms (± 2.82%) -1ms (- 1.46%) 63ms 70ms
xstateTSServer - node (v10.16.3, x64)
Req 1 - updateOpen 2,095ms (± 0.40%) 2,076ms (± 0.38%) -20ms (- 0.94%) 2,056ms 2,090ms
Req 2 - geterr 804ms (± 0.67%) 842ms (± 0.61%) +38ms (+ 4.69%) 832ms 851ms
Req 3 - references 100ms (± 1.96%) 100ms (± 2.14%) -1ms (- 0.80%) 95ms 103ms
Req 4 - navto 232ms (± 0.74%) 234ms (± 0.98%) +1ms (+ 0.60%) 229ms 238ms
Req 5 - completionInfo count 3,301 (± 0.00%) 3,301 (± 0.00%) 0 ( 0.00%) 3,301 3,301
Req 5 - completionInfo 283ms (± 0.65%) 280ms (± 1.19%) -3ms (- 1.06%) 273ms 287ms
Compiler-UnionsTSServer - node (v12.1.0, x64)
Req 1 - updateOpen 1,404ms (± 0.69%) 1,400ms (± 0.58%) -5ms (- 0.33%) 1,378ms 1,416ms
Req 2 - geterr 3,372ms (± 0.38%) 3,605ms (± 0.35%) +233ms (+ 6.90%) 3,585ms 3,633ms
Req 3 - references 219ms (± 0.91%) 220ms (± 1.18%) +1ms (+ 0.23%) 216ms 226ms
Req 4 - navto 161ms (± 1.14%) 161ms (± 0.94%) -0ms (- 0.19%) 157ms 163ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 60ms (± 5.54%) 61ms (± 9.68%) +1ms (+ 1.68%) 55ms 84ms
CompilerTSServer - node (v12.1.0, x64)
Req 1 - updateOpen 1,493ms (± 0.67%) 1,495ms (± 0.88%) +2ms (+ 0.10%) 1,472ms 1,524ms
Req 2 - geterr 2,164ms (± 0.50%) 2,324ms (± 0.43%) +160ms (+ 7.37%) 2,300ms 2,340ms
Req 3 - references 232ms (± 0.80%) 234ms (± 0.74%) +2ms (+ 0.95%) 231ms 238ms
Req 4 - navto 172ms (± 1.30%) 172ms (± 1.17%) +1ms (+ 0.35%) 167ms 177ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 63ms (± 3.71%) 60ms (± 2.87%) 🟩-3ms (- 4.58%) 58ms 66ms
xstateTSServer - node (v12.1.0, x64)
Req 1 - updateOpen 2,038ms (± 0.66%) 2,027ms (± 0.49%) -11ms (- 0.53%) 2,003ms 2,053ms
Req 2 - geterr 751ms (± 0.44%) 788ms (± 0.56%) +37ms (+ 4.97%) 780ms 801ms
Req 3 - references 67ms (± 0.92%) 67ms (± 1.40%) +0ms (+ 0.60%) 65ms 69ms
Req 4 - navto 224ms (± 1.83%) 224ms (± 1.42%) +1ms (+ 0.27%) 214ms 230ms
Req 5 - completionInfo count 3,301 (± 0.00%) 3,301 (± 0.00%) 0 ( 0.00%) 3,301 3,301
Req 5 - completionInfo 273ms (± 1.21%) 271ms (± 0.81%) -2ms (- 0.66%) 267ms 278ms
Compiler-UnionsTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 1,441ms (± 0.43%) 1,444ms (± 0.77%) +3ms (+ 0.24%) 1,429ms 1,482ms
Req 2 - geterr 3,489ms (± 0.41%) 3,762ms (± 0.35%) +273ms (+ 7.82%) 3,730ms 3,778ms
Req 3 - references 229ms (± 0.66%) 229ms (± 0.63%) 0ms ( 0.00%) 226ms 232ms
Req 4 - navto 168ms (± 0.72%) 170ms (± 0.76%) +1ms (+ 0.71%) 168ms 173ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 56ms (± 1.23%) 55ms (± 2.34%) -0ms (- 0.18%) 54ms 58ms
CompilerTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 1,521ms (± 0.68%) 1,515ms (± 0.60%) -6ms (- 0.39%) 1,499ms 1,542ms
Req 2 - geterr 2,299ms (± 0.50%) 2,462ms (± 0.41%) +164ms (+ 7.11%) 2,439ms 2,486ms
Req 3 - references 242ms (± 0.59%) 242ms (± 0.51%) +0ms (+ 0.08%) 240ms 246ms
Req 4 - navto 178ms (± 0.49%) 178ms (± 0.50%) -1ms (- 0.28%) 176ms 179ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 55ms (± 1.06%) 54ms (± 0.82%) -1ms (- 0.91%) 53ms 55ms
xstateTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,139ms (± 0.57%) 2,128ms (± 0.54%) -11ms (- 0.52%) 2,096ms 2,151ms
Req 2 - geterr 772ms (± 0.58%) 812ms (± 0.45%) +40ms (+ 5.14%) 806ms 823ms
Req 3 - references 67ms (± 2.13%) 66ms (± 2.61%) -0ms (- 0.30%) 64ms 71ms
Req 4 - navto 228ms (± 0.53%) 229ms (± 0.82%) +1ms (+ 0.57%) 225ms 234ms
Req 5 - completionInfo count 3,301 (± 0.00%) 3,301 (± 0.00%) 0 ( 0.00%) 3,301 3,301
Req 5 - completionInfo 276ms (± 0.62%) 278ms (± 0.83%) +2ms (+ 0.65%) 274ms 284ms
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 (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Compiler-UnionsTSServer - node (v10.16.3, x64)
  • Compiler-UnionsTSServer - node (v12.1.0, x64)
  • Compiler-UnionsTSServer - node (v14.15.1, x64)
  • CompilerTSServer - node (v10.16.3, x64)
  • CompilerTSServer - node (v12.1.0, x64)
  • CompilerTSServer - node (v14.15.1, x64)
  • xstateTSServer - node (v10.16.3, x64)
  • xstateTSServer - node (v12.1.0, x64)
  • xstateTSServer - node (v14.15.1, x64)
Benchmark Name Iterations
Current 49886 10
Baseline main 10
Developer Information:

Download Benchmark

typescript-bot avatar Aug 31 '22 19:08 typescript-bot

Looks like some pretty dramatic performance overhead.

ahejlsberg avatar Aug 31 '22 21:08 ahejlsberg

@typescript-bot user test this inline @typescript-bot test this

Looks like some pretty dramatic performance overhead.

Some of the union construction work to support both kinds of null/undefined simultaneously may be more costly than I thought, I'll have to see where the time is going.

weswigham avatar Aug 31 '22 23:08 weswigham

Heya @weswigham, I've started to run the diff-based user code test suite on this PR at b18eca0f207d65f60338e403170e1cdfd5453633. You can monitor the build here.

Update: The results are in!

typescript-bot avatar Aug 31 '22 23:08 typescript-bot

Heya @weswigham, I've started to run the extended test suite on this PR at b18eca0f207d65f60338e403170e1cdfd5453633. You can monitor the build here.

typescript-bot avatar Aug 31 '22 23:08 typescript-bot

@weswigham Here are the results of running the user test suite comparing main and refs/pull/49886/merge:

Something interesting changed - please have a look.

Details

webpack

tsconfig.json

tsconfig.types.json

  • [NEW] error TS2322: Type 'undefined' is not assignable to type 'Pick<ArgumentConfig, "values" | "type">'.
  • [NEW] error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Record<"filter" | "sort" | "result" | "extract" | "filterSorted" | "groupResults" | "sortResults" | "filterResults" | "merge" | "getItemName" | "getItemFactory", Map<string, SyncBailHook<[...], any, UnsetAdditionalOptions>[]>>'.
  • [MISSING] error TS2322: Type 'undefined' is not assignable to type 'Pick<ArgumentConfig, "type" | "values">'.
  • [MISSING] error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Record<"sort" | "filter" | "result" | "extract" | "filterSorted" | "groupResults" | "sortResults" | "filterResults" | "merge" | "getItemName" | "getItemFactory", Map<string, SyncBailHook<[...], any, UnsetAdditionalOptions>[]>>'.

typescript-bot avatar Sep 01 '22 00:09 typescript-bot

Heya @weswigham, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here.

typescript-bot avatar Sep 01 '22 00:09 typescript-bot

@typescript-bot user test this inline @typescript-bot test this

again - I think the merge conflict (I'm going to keep getting so many of those on this PR) was preventing the merge ref from updating, since some of the failures reported I already fixed locally...

weswigham avatar Sep 01 '22 00:09 weswigham

Heya @weswigham, I'm starting to run the diff-based user code test suite on this PR at 5173a07ba7a5e5eb3f09049f0d9aa69c7b72330b. Hold tight - I'll update this comment with the log link once the build has been queued.

Update: The results are in!

typescript-bot avatar Sep 01 '22 00:09 typescript-bot

Heya @weswigham, I'm starting to run the extended test suite on this PR at 5173a07ba7a5e5eb3f09049f0d9aa69c7b72330b. Hold tight - I'll update this comment with the log link once the build has been queued.

typescript-bot avatar Sep 01 '22 00:09 typescript-bot

@weswigham Here are the results of running the user test suite comparing main and refs/pull/49886/merge:

Something interesting changed - please have a look.

Details

webpack

tsconfig.json

tsconfig.types.json

  • [NEW] error TS2322: Type 'undefined' is not assignable to type 'Pick<ArgumentConfig, "values" | "type">'.
  • [NEW] error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Record<"filter" | "sort" | "result" | "extract" | "filterSorted" | "groupResults" | "sortResults" | "filterResults" | "merge" | "getItemName" | "getItemFactory", Map<string, SyncBailHook<[...], any, UnsetAdditionalOptions>[]>>'.
  • [MISSING] error TS2322: Type 'undefined' is not assignable to type 'Pick<ArgumentConfig, "type" | "values">'.
  • [MISSING] error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Record<"sort" | "filter" | "result" | "extract" | "filterSorted" | "groupResults" | "sortResults" | "filterResults" | "merge" | "getItemName" | "getItemFactory", Map<string, SyncBailHook<[...], any, UnsetAdditionalOptions>[]>>'.

typescript-bot avatar Sep 01 '22 00:09 typescript-bot

Heya @weswigham, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here.

typescript-bot avatar Sep 01 '22 00:09 typescript-bot