Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instantiation expressions inconsistently trigger incorrect error messages in editor contexts #50161

Closed
ZachHaber opened this issue Aug 3, 2022 · 13 comments · Fixed by #52373
Closed
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@ZachHaber
Copy link

Type: Bug

  1. Attempt to use the Instantiation Expressions in VSCode typescript language
function makeBox<T>(value: T){
  return {value};
}

const makeStringBox = makeBox<string>;
const stringBox = makeStringBox('abc');
  1. Observe Red squiggly lines that shouldn't be there.

image

VS Code version: Code - Insiders 1.70.0-insider (e9bda7aa4ff76648cfccc1a7bde465443803da71, 2022-08-02T16:56:25.649Z)
OS version: Windows_NT x64 10.0.19044
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (16 x 3600)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.92GB (17.88GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30422396
pythontb:30258533
pythonptprofiler:30281269
vsdfh931:30280409
vshan820:30294714
pythondataviewer:30285072
vscod805:30301674
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30404738
wslgetstarted:30449409
vscscmwlcmt:30465136
cppdebug:30492333
vscaac:30438845
pylanb8912:30522163
vsclangdf:30492506
c4g48928:30535728

I've had this issue with both no npm packages installed. With typescript installed only. And with typescript and a tsconfig.json file.

Note: It is incredibly inconsistent. Sometimes it doesn't happen. Other times changing from the built-in version of typescript to the local version fixes it, sometimes just waiting fixes it. Until you change the code at all (adding/removing whitespace for example) and then it comes back. Installing a different version of typescript removes the error until you change the code as well.

I believe that this is a VSCode centric issue and not a Typescript issue for 2 reasons.

  1. Running npx tsc builds the package just fine without any issues from type errors.
  2. As seen in this comment, the typescript playground doesn't show any errors with this. Instantiation expressions #47607 (comment) TS Playground
@IllusionMH
Copy link
Contributor

What TS version is reported if you hover over TS language details in status bar?

Built-in TS version in VS Code insiders is 4.7.3 which doesn't report error in this case.

@ZachHaber
Copy link
Author

ZachHaber commented Aug 3, 2022

I've tested it with the built in 4.7.3, local 4.7.4, 4.7.3, 4.7.2, and 4.8-beta.

I also tested it on a fresh insiders install. Literally minutes before I made the issue.

@ZachHaber
Copy link
Author

To show what I mean by the inconsistency with this bug. Randomly, it won't complain about the error until you modify the code, in which case it'll realize that it forgot to complain.
https://user-images.githubusercontent.com/19843782/182628692-1d72352c-ceba-4c94-ba62-30e196e2be8c.mp4

The really weird thing about it is that the typescript language server both knows its fine and reports that error. For example, you can see that the type of makeStringBox is correct:
image

In addition to that, it appears that running the "Typescript: Reload Project" command fixes it until you change the code.

@mjbvz mjbvz transferred this issue from microsoft/vscode Aug 3, 2022
@mjbvz
Copy link
Contributor

mjbvz commented Aug 3, 2022

Here's the TS Server log for this case (using TS 4.8.0-dev.20220801):

Info 0    [07:57:45.529] Starting TS Server
Info 1    [07:57:45.530] Version: 4.8.0-dev.20220801
Info 2    [07:57:45.530] Arguments: /Users/matb/projects/vscode/.build/electron/Code - OSS.app/Contents/Frameworks/Code - OSS Helper.app/Contents/MacOS/Code - OSS Helper /Users/matb/projects/vscode/extensions/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /var/folders/5d/nlg411_s0570wmycdwkgqrf40000gn/T/vscode-typescript501/69dc17d2e6e9be1beef0/tscancellation-1e03ba7132e3cd66760f.tmp* --logVerbosity verbose --logFile /Users/matb/Library/Application Support/code-oss-dev/logs/20220802T162301/exthost1/vscode.typescript-language-features/tsserver-log-yNpitt/tsserver.log --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc
Info 3    [07:57:45.530] Platform: darwin NodeVersion: 16 CaseSensitive: false
Info 4    [07:57:45.530] ServerMode: undefined syntaxOnly: false hasUnknownServerMode: undefined
Info 5    [07:57:45.546] Binding...
Info 6    [07:57:45.551] request:
    {
      "seq": 0,
      "type": "request",
      "command": "configure",
      "arguments": {
        "hostInfo": "vscode",
        "preferences": {
          "providePrefixAndSuffixTextForRename": true,
          "allowRenameOfImportPath": true,
          "includePackageJsonAutoImports": "auto"
        },
        "watchOptions": {}
      }
    }
Info 7    [07:57:45.552] Host information vscode
Info 8    [07:57:45.552] Host watch options changed to undefined, it will be take effect for next watches.
Info 9    [07:57:45.552] response:
    {"seq":0,"type":"response","command":"configure","request_seq":0,"success":true}
Perf 10   [07:57:45.552] 0::configure: async elapsed time (in milliseconds) 1.0075
Info 11   [07:57:45.552] request:
    {
      "seq": 1,
      "type": "request",
      "command": "compilerOptionsForInferredProjects",
      "arguments": {
        "options": {
          "module": "ESNext",
          "moduleResolution": "Node",
          "target": "ES2020",
          "jsx": "react",
          "strictNullChecks": true,
          "strictFunctionTypes": true,
          "sourceMap": true,
          "allowJs": true,
          "allowSyntheticDefaultImports": true,
          "allowNonTsExtensions": true,
          "resolveJsonModule": true
        }
      }
    }
Perf 12   [07:57:45.553] 1::compilerOptionsForInferredProjects: elapsed time (in milliseconds) 0.2830
Info 13   [07:57:45.553] response:
    {"seq":0,"type":"response","command":"compilerOptionsForInferredProjects","request_seq":1,"success":true,"body":true}
Info 14   [07:57:45.553] request:
    {
      "seq": 2,
      "type": "request",
      "command": "updateOpen",
      "arguments": {
        "changedFiles": [],
        "closedFiles": [],
        "openFiles": [
          {
            "file": "/Users/matb/projects/san/x.ts",
            "fileContent": "function makeBox<T>(value: T){\n  return {value};\n}\n\nconst makeStringBox = makeBox<string>;\nconst stringBox = makeStringBox('abc');  ",
            "projectRootPath": "/Users/matb/projects/san",
            "scriptKindName": "TS"
          }
        ]
      }
    }
Info 15   [07:57:45.554] Search path: /Users/matb/projects/san
Info 16   [07:57:45.554] For info: /Users/matb/projects/san/x.ts :: No config files found.
Info 17   [07:57:45.556] FileWatcher:: Added:: WatchInfo: /Users/matb/projects/san/tsconfig.json 2000 undefined WatchType: Config file for the inferred project root
Info 18   [07:57:45.557] FileWatcher:: Added:: WatchInfo: /Users/matb/projects/san/jsconfig.json 2000 undefined WatchType: Config file for the inferred project root
Info 19   [07:57:45.557] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
Info 20   [07:57:45.568] DirectoryWatcher:: Added:: WatchInfo: /users/matb/projects/vscode/extensions/node_modules 1 undefined WatchType: node_modules for closed script infos and package.jsons affecting module specifier cache
Info 21   [07:57:45.569] Elapsed:: 0.984017014503479ms DirectoryWatcher:: Added:: WatchInfo: /users/matb/projects/vscode/extensions/node_modules 1 undefined WatchType: node_modules for closed script infos and package.jsons affecting module specifier cache
Info 22   [07:57:45.985] DirectoryWatcher:: Added:: WatchInfo: /Users/matb/projects/san/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
Info 23   [07:57:45.986] Elapsed:: 0.41756999492645264ms DirectoryWatcher:: Added:: WatchInfo: /Users/matb/projects/san/node_modules/@types 1 undefined Project: /dev/null/inferredProject1* WatchType: Type roots
Info 24   [07:57:45.986] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* Version: 1 structureChanged: true structureIsReused:: Not Elapsed: 428.54748606681824ms
Info 25   [07:57:45.986] Project '/dev/null/inferredProject1*' (Inferred)
Info 26   [07:57:45.989] 	Files (45)
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es5.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2016.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2017.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2018.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2019.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2020.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.dom.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.dom.iterable.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.webworker.importscripts.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.scripthost.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2015.core.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2015.collection.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2015.generator.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2015.iterable.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2015.promise.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2015.proxy.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2015.reflect.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2015.symbol.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2016.array.include.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2017.object.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2017.string.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2017.intl.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2018.intl.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2018.promise.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2018.regexp.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2019.array.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2019.object.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2019.string.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2019.symbol.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2020.bigint.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2020.date.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2020.promise.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2020.string.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2020.intl.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2020.number.d.ts
	/Users/matb/projects/vscode/extensions/node_modules/typescript/lib/lib.es2020.full.d.ts
	/Users/matb/projects/san/x.ts


	../vscode/extensions/node_modules/typescript/lib/lib.es5.d.ts
	  Library referenced via 'es5' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts
	  Library referenced via 'es2015' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2016.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2016.d.ts
	  Library referenced via 'es2016' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2017.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2017.d.ts
	  Library referenced via 'es2017' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2018.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2018.d.ts
	  Library referenced via 'es2018' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2019.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2019.d.ts
	  Library referenced via 'es2019' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2020.d.ts
	  Library referenced via 'es2020' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.full.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.dom.d.ts
	  Library referenced via 'dom' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.full.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.dom.iterable.d.ts
	  Library referenced via 'dom.iterable' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.full.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.webworker.importscripts.d.ts
	  Library referenced via 'webworker.importscripts' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.full.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.scripthost.d.ts
	  Library referenced via 'scripthost' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.full.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2015.core.d.ts
	  Library referenced via 'es2015.core' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2015.collection.d.ts
	  Library referenced via 'es2015.collection' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2015.generator.d.ts
	  Library referenced via 'es2015.generator' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2015.iterable.d.ts
	  Library referenced via 'es2015.iterable' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts'
	  Library referenced via 'es2015.iterable' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.generator.d.ts'
	  Library referenced via 'es2015.iterable' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts'
	  Library referenced via 'es2015.iterable' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2019.object.d.ts'
	  Library referenced via 'es2015.iterable' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.string.d.ts'
	  Library referenced via 'es2015.iterable' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2015.promise.d.ts
	  Library referenced via 'es2015.promise' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2015.proxy.d.ts
	  Library referenced via 'es2015.proxy' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2015.reflect.d.ts
	  Library referenced via 'es2015.reflect' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2015.symbol.d.ts
	  Library referenced via 'es2015.symbol' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.iterable.d.ts'
	  Library referenced via 'es2015.symbol' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts'
	  Library referenced via 'es2015.symbol' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts'
	  Library referenced via 'es2015.symbol' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts'
	  Library referenced via 'es2015.symbol' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts'
	  Library referenced via 'es2015.symbol' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts
	  Library referenced via 'es2015.symbol.wellknown' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2015.d.ts'
	  Library referenced via 'es2015.symbol.wellknown' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2016.array.include.d.ts
	  Library referenced via 'es2016.array.include' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2016.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2017.object.d.ts
	  Library referenced via 'es2017.object' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2017.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts
	  Library referenced via 'es2017.sharedmemory' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2017.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2017.string.d.ts
	  Library referenced via 'es2017.string' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2017.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2017.intl.d.ts
	  Library referenced via 'es2017.intl' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2017.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts
	  Library referenced via 'es2017.typedarrays' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2017.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts
	  Library referenced via 'es2018.asyncgenerator' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2018.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts
	  Library referenced via 'es2018.asynciterable' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2018.d.ts'
	  Library referenced via 'es2018.asynciterable' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2018.intl.d.ts
	  Library referenced via 'es2018.intl' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2018.d.ts'
	  Library referenced via 'es2018.intl' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.intl.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2018.promise.d.ts
	  Library referenced via 'es2018.promise' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2018.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2018.regexp.d.ts
	  Library referenced via 'es2018.regexp' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2018.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2019.array.d.ts
	  Library referenced via 'es2019.array' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2019.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2019.object.d.ts
	  Library referenced via 'es2019.object' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2019.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2019.string.d.ts
	  Library referenced via 'es2019.string' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2019.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2019.symbol.d.ts
	  Library referenced via 'es2019.symbol' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2019.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2020.bigint.d.ts
	  Library referenced via 'es2020.bigint' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2020.date.d.ts
	  Library referenced via 'es2020.date' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2020.promise.d.ts
	  Library referenced via 'es2020.promise' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts
	  Library referenced via 'es2020.sharedmemory' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2020.string.d.ts
	  Library referenced via 'es2020.string' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts
	  Library referenced via 'es2020.symbol.wellknown' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2020.intl.d.ts
	  Library referenced via 'es2020.intl' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.bigint.d.ts'
	  Library referenced via 'es2020.intl' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.date.d.ts'
	  Library referenced via 'es2020.intl' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.number.d.ts'
	  Library referenced via 'es2020.intl' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2020.number.d.ts
	  Library referenced via 'es2020.number' from file '../vscode/extensions/node_modules/typescript/lib/lib.es2020.d.ts'
	../vscode/extensions/node_modules/typescript/lib/lib.es2020.full.d.ts
	  Default library for target 'es2020'
	x.ts
	  Root file specified for compilation

Info 27   [07:57:45.990] -----------------------------------------------
Info 28   [07:57:45.992] FileWatcher:: Added:: WatchInfo: /users/matb/package.json 250 undefined WatchType: package.json file
Info 29   [07:57:45.996] AutoImportProviderProject: found 1 root files in 1 dependencies in 5.217698931694031 ms
Info 30   [07:57:45.997] DirectoryWatcher:: Added:: WatchInfo: /users/matb/node_modules 1 undefined WatchType: node_modules for closed script infos and package.jsons affecting module specifier cache
Info 31   [07:57:45.997] Elapsed:: 0.23093509674072266ms DirectoryWatcher:: Added:: WatchInfo: /users/matb/node_modules 1 undefined WatchType: node_modules for closed script infos and package.jsons affecting module specifier cache
Info 32   [07:57:45.997] Starting updateGraphWorker: Project: /dev/null/autoImportProviderProject1*
Info 33   [07:57:46.137] Finishing updateGraphWorker: Project: /dev/null/autoImportProviderProject1* Version: 1 structureChanged: true structureIsReused:: Not Elapsed: 140.38813495635986ms
Info 34   [07:57:46.138] Project '/dev/null/autoImportProviderProject1*' (AutoImportProvider)
Info 35   [07:57:46.138] 	Files (1)
	/Users/matb/node_modules/typescript/lib/typescript.d.ts


	../../node_modules/typescript/lib/typescript.d.ts
	  Root file specified for compilation

Info 36   [07:57:46.138] -----------------------------------------------
Info 37   [07:57:46.138] Project '/dev/null/inferredProject1*' (Inferred)
Info 37   [07:57:46.138] 	Files (45)

Info 37   [07:57:46.138] -----------------------------------------------
Info 37   [07:57:46.138] Project '/dev/null/autoImportProviderProject1*' (AutoImportProvider)
Info 37   [07:57:46.138] 	Files (1)

Info 37   [07:57:46.138] -----------------------------------------------
Info 37   [07:57:46.138] Open files: 
Info 37   [07:57:46.138] 	FileName: /Users/matb/projects/san/x.ts ProjectRootPath: /Users/matb/projects/san
Info 37   [07:57:46.138] 		Projects: /dev/null/inferredProject1*
Perf 37   [07:57:46.138] 2::updateOpen: elapsed time (in milliseconds) 585.5729
Info 38   [07:57:46.138] response:
    {"seq":0,"type":"response","command":"updateOpen","request_seq":2,"success":true,"performanceData":{"updateGraphDurationMs":568.9356210231781,"createAutoImportProviderProgramDurationMs":147.24544203281403},"body":true}
Info 39   [07:57:46.139] event:
    {"seq":0,"type":"event","event":"typingsInstallerPid","body":{"pid":72814}}
Info 40   [07:57:46.873] request:
    {
      "seq": 3,
      "type": "request",
      "command": "projectInfo",
      "arguments": {
        "file": "/Users/matb/projects/san/x.ts",
        "needFileNameList": false
      }
    }
Perf 41   [07:57:46.874] 3::projectInfo: elapsed time (in milliseconds) 0.3697
Info 42   [07:57:46.874] response:
    {"seq":0,"type":"response","command":"projectInfo","request_seq":3,"success":true,"body":{"configFileName":"/dev/null/inferredProject1*","languageServiceDisabled":false}}
Info 43   [07:57:46.879] request:
    {
      "seq": 4,
      "type": "request",
      "command": "configure",
      "arguments": {
        "file": "/Users/matb/projects/san/x.ts",
        "formatOptions": {
          "tabSize": 2,
          "indentSize": 2,
          "convertTabsToSpaces": true,
          "newLineCharacter": "\n",
          "insertSpaceAfterCommaDelimiter": true,
          "insertSpaceAfterConstructor": false,
          "insertSpaceAfterSemicolonInForStatements": true,
          "insertSpaceBeforeAndAfterBinaryOperators": true,
          "insertSpaceAfterKeywordsInControlFlowStatements": true,
          "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
          "insertSpaceBeforeFunctionParenthesis": false,
          "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
          "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
          "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
          "insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": true,
          "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
          "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
          "insertSpaceAfterTypeAssertion": false,
          "placeOpenBraceOnNewLineForFunctions": false,
          "placeOpenBraceOnNewLineForControlBlocks": false,
          "semicolons": "ignore"
        },
        "preferences": {
          "quotePreference": "auto",
          "importModuleSpecifierEnding": "auto",
          "jsxAttributeCompletionStyle": "auto",
          "allowTextChangesInNewFiles": true,
          "providePrefixAndSuffixTextForRename": true,
          "allowRenameOfImportPath": true,
          "includeAutomaticOptionalChainCompletions": true,
          "provideRefactorNotApplicableReason": true,
          "generateReturnInDocTemplate": true,
          "includeCompletionsForImportStatements": true,
          "includeCompletionsWithSnippetText": true,
          "includeCompletionsWithClassMemberSnippets": true,
          "includeCompletionsWithObjectLiteralMethodSnippets": true,
          "autoImportFileExcludePatterns": [],
          "useLabelDetailsInCompletionEntries": true,
          "allowIncompleteCompletions": true,
          "displayPartsForJSDoc": true,
          "includeInlayParameterNameHints": "all",
          "includeInlayParameterNameHintsWhenArgumentMatchesName": false,
          "includeInlayFunctionParameterTypeHints": true,
          "includeInlayVariableTypeHints": true,
          "includeInlayVariableTypeHintsWhenTypeMatchesName": false,
          "includeInlayPropertyDeclarationTypeHints": true,
          "includeInlayFunctionLikeReturnTypeHints": true,
          "includeInlayEnumMemberValueHints": true
        }
      }
    }
Info 44   [07:57:46.880] Host configuration update for file /Users/matb/projects/san/x.ts
Info 45   [07:57:46.880] response:
    {"seq":0,"type":"response","command":"configure","request_seq":4,"success":true}
Perf 46   [07:57:46.880] 4::configure: async elapsed time (in milliseconds) 0.3984
Info 47   [07:57:46.881] request:
    {
      "seq": 5,
      "type": "request",
      "command": "geterr",
      "arguments": {
        "delay": 0,
        "files": [
          "/Users/matb/projects/san/x.ts"
        ]
      }
    }
Perf 48   [07:57:46.881] 5::geterr: async elapsed time (in milliseconds) 0.4889
Info 49   [07:57:46.881] request:
    {
      "seq": 6,
      "type": "request",
      "command": "encodedSemanticClassifications-full",
      "arguments": {
        "file": "/Users/matb/projects/san/x.ts",
        "start": 0,
        "length": 132,
        "format": "2020"
      }
    }
Perf 50   [07:57:46.895] 6::encodedSemanticClassifications-full: elapsed time (in milliseconds) 13.9447
Info 51   [07:57:46.895] response:
    {"seq":0,"type":"response","command":"encodedSemanticClassifications-full","request_seq":6,"success":true,"body":{"spans":[9,7,2817,17,1,1281,20,5,1793,27,1,1280,41,5,2561,58,13,2825,74,7,2816,97,9,2057,109,13,2824],"endOfLineState":0}}
Info 52   [07:57:46.896] event:
    {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/Users/matb/projects/san/x.ts","diagnostics":[]}}
Info 53   [07:57:46.897] request:
    {
      "seq": 7,
      "type": "request",
      "command": "provideInlayHints",
      "arguments": {
        "file": "/Users/matb/projects/san/x.ts",
        "start": 0,
        "length": 132
      }
    }
Perf 54   [07:57:46.911] 7::provideInlayHints: elapsed time (in milliseconds) 14.3380
Info 55   [07:57:46.911] response:
    {"seq":0,"type":"response","command":"provideInlayHints","request_seq":7,"success":true,"body":[{"text":": { value: T; }","position":{"line":1,"offset":30},"kind":"Type","whitespaceBefore":true},{"text":": (value: string) => { value:...","position":{"line":5,"offset":20},"kind":"Type","whitespaceBefore":true},{"text":": { value: string; }","position":{"line":6,"offset":16},"kind":"Type","whitespaceBefore":true},{"text":"value:","position":{"line":6,"offset":33},"kind":"Parameter","whitespaceAfter":true}]}
Info 56   [07:57:46.922] event:
    {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/Users/matb/projects/san/x.ts","diagnostics":[{"start":{"line":5,"offset":23},"end":{"line":5,"offset":30},"text":"'makeBox' refers to a value, but is being used as a type here. Did you mean 'typeof makeBox'?","code":2749,"category":"error"}]}}
Info 57   [07:57:46.925] event:
    {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/Users/matb/projects/san/x.ts","diagnostics":[]}}
Info 58   [07:57:46.925] event:
    {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":5}}
Info 59   [07:57:49.963] request:
    {
      "seq": 8,
      "type": "request",
      "command": "updateOpen",
      "arguments": {
        "changedFiles": [
          {
            "fileName": "/Users/matb/projects/san/x.ts",
            "textChanges": [
              {
                "newText": " ",
                "start": {
                  "line": 6,
                  "offset": 42
                },
                "end": {
                  "line": 6,
                  "offset": 42
                }
              }
            ]
          }
        ],
        "closedFiles": [],
        "openFiles": []
      }
    }
Perf 60   [07:57:49.964] 8::updateOpen: elapsed time (in milliseconds) 0.6148
Info 61   [07:57:49.964] response:
    {"seq":0,"type":"response","command":"updateOpen","request_seq":8,"success":true,"body":true}
Info 62   [07:57:50.175] request:
    {
      "seq": 9,
      "type": "request",
      "command": "encodedSemanticClassifications-full",
      "arguments": {
        "file": "/Users/matb/projects/san/x.ts",
        "start": 0,
        "length": 133,
        "format": "2020"
      }
    }
Info 63   [07:57:50.175] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
Info 64   [07:57:50.181] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* Version: 2 structureChanged: false structureIsReused:: Completely Elapsed: 6.144600987434387ms
Info 65   [07:57:50.181] Different program with same set of files
Perf 66   [07:57:50.183] 9::encodedSemanticClassifications-full: elapsed time (in milliseconds) 7.5944
Info 67   [07:57:50.183] response:
    {"seq":0,"type":"response","command":"encodedSemanticClassifications-full","request_seq":9,"success":true,"performanceData":{"updateGraphDurationMs":6.144600987434387},"body":{"spans":[9,7,2817,17,1,1281,20,5,1793,27,1,1280,41,5,2561,58,13,2825,74,7,2816,97,9,2057,109,13,2824],"endOfLineState":0}}
Info 68   [07:57:50.183] request:
    {
      "seq": 10,
      "type": "request",
      "command": "provideInlayHints",
      "arguments": {
        "file": "/Users/matb/projects/san/x.ts",
        "start": 0,
        "length": 133
      }
    }
Perf 69   [07:57:50.184] 10::provideInlayHints: elapsed time (in milliseconds) 1.0911
Info 70   [07:57:50.184] response:
    {"seq":0,"type":"response","command":"provideInlayHints","request_seq":10,"success":true,"body":[{"text":": { value: T; }","position":{"line":1,"offset":30},"kind":"Type","whitespaceBefore":true},{"text":": (value: string) => { value:...","position":{"line":5,"offset":20},"kind":"Type","whitespaceBefore":true},{"text":": { value: string; }","position":{"line":6,"offset":16},"kind":"Type","whitespaceBefore":true},{"text":"value:","position":{"line":6,"offset":33},"kind":"Parameter","whitespaceAfter":true}]}
Info 71   [07:57:50.264] request:
    {
      "seq": 11,
      "type": "request",
      "command": "geterr",
      "arguments": {
        "delay": 0,
        "files": [
          "/Users/matb/projects/san/x.ts"
        ]
      }
    }
Perf 72   [07:57:50.264] 11::geterr: async elapsed time (in milliseconds) 0.1467
Info 73   [07:57:50.266] event:
    {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/Users/matb/projects/san/x.ts","diagnostics":[]}}
Info 74   [07:57:50.266] event:
    {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/Users/matb/projects/san/x.ts","diagnostics":[{"start":{"line":5,"offset":23},"end":{"line":5,"offset":30},"text":"'makeBox' refers to a value, but is being used as a type here. Did you mean 'typeof makeBox'?","code":2749,"category":"error"}]}}
Info 75   [07:57:50.267] event:
    {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/Users/matb/projects/san/x.ts","diagnostics":[]}}
Info 76   [07:57:50.267] event:
    {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":11}}
Info 77   [07:57:50.804] request:
    {
      "seq": 12,
      "type": "request",
      "command": "provideInlayHints",
      "arguments": {
        "file": "/Users/matb/projects/san/x.ts",
        "start": 0,
        "length": 133
      }
    }
Perf 78   [07:57:50.805] 12::provideInlayHints: elapsed time (in milliseconds) 1.3292
Info 79   [07:57:50.806] response:
    {"seq":0,"type":"response","command":"provideInlayHints","request_seq":12,"success":true,"body":[{"text":": { value: T; }","position":{"line":1,"offset":30},"kind":"Type","whitespaceBefore":true},{"text":": (value: string) => { value:...","position":{"line":5,"offset":20},"kind":"Type","whitespaceBefore":true},{"text":": { value: string; }","position":{"line":6,"offset":16},"kind":"Type","whitespaceBefore":true},{"text":"value:","position":{"line":6,"offset":33},"kind":"Parameter","whitespaceAfter":true}]}
Info 80   [07:57:52.611] request:
    {
      "seq": 13,
      "type": "request",
      "command": "updateOpen",
      "arguments": {
        "changedFiles": [
          {
            "fileName": "/Users/matb/projects/san/x.ts",
            "textChanges": [
              {
                "newText": " ",
                "start": {
                  "line": 6,
                  "offset": 43
                },
                "end": {
                  "line": 6,
                  "offset": 43
                }
              }
            ]
          }
        ],
        "closedFiles": [],
        "openFiles": []
      }
    }
Perf 81   [07:57:52.611] 13::updateOpen: elapsed time (in milliseconds) 0.2625
Info 82   [07:57:52.611] response:
    {"seq":0,"type":"response","command":"updateOpen","request_seq":13,"success":true,"body":true}
Info 83   [07:57:52.611] request:
    {
      "seq": 14,
      "type": "request",
      "command": "geterr",
      "arguments": {
        "delay": 0,
        "files": [
          "/Users/matb/projects/san/x.ts"
        ]
      }
    }
Perf 84   [07:57:52.611] 14::geterr: async elapsed time (in milliseconds) 0.2281
Info 85   [07:57:52.613] Starting updateGraphWorker: Project: /dev/null/inferredProject1*
Info 86   [07:57:52.618] Finishing updateGraphWorker: Project: /dev/null/inferredProject1* Version: 3 structureChanged: false structureIsReused:: Completely Elapsed: 4.62771999835968ms
Info 87   [07:57:52.618] Different program with same set of files
Info 88   [07:57:52.618] event:
    {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/Users/matb/projects/san/x.ts","diagnostics":[]}}
Info 89   [07:57:52.619] event:
    {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/Users/matb/projects/san/x.ts","diagnostics":[]}}
Info 90   [07:57:52.619] event:
    {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/Users/matb/projects/san/x.ts","diagnostics":[]}}
Info 91   [07:57:52.619] event:
    {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":14}}
Info 92   [07:57:52.797] request:
    {
      "seq": 15,
      "type": "request",
      "command": "encodedSemanticClassifications-full",
      "arguments": {
        "file": "/Users/matb/projects/san/x.ts",
        "start": 0,
        "length": 134,
        "format": "2020"
      }
    }
Perf 93   [07:57:52.798] 15::encodedSemanticClassifications-full: elapsed time (in milliseconds) 0.9757
Info 94   [07:57:52.798] response:
    {"seq":0,"type":"response","command":"encodedSemanticClassifications-full","request_seq":15,"success":true,"body":{"spans":[9,7,2817,17,1,1281,20,5,1793,27,1,1280,41,5,2561,58,13,2825,74,7,2816,97,9,2057,109,13,2824],"endOfLineState":0}}
Info 95   [07:57:53.553] request:
    {
      "seq": 16,
      "type": "request",
      "command": "provideInlayHints",
      "arguments": {
        "file": "/Users/matb/projects/san/x.ts",
        "start": 0,
        "length": 134
      }
    }
Perf 96   [07:57:53.573] 16::provideInlayHints: elapsed time (in milliseconds) 20.4340
Info 97   [07:57:53.573] response:
    {"seq":0,"type":"response","command":"provideInlayHints","request_seq":16,"success":true,"body":[{"text":": { value: T; }","position":{"line":1,"offset":30},"kind":"Type","whitespaceBefore":true},{"text":": (value: string) => { value:...","position":{"line":5,"offset":20},"kind":"Type","whitespaceBefore":true},{"text":": { value: string; }","position":{"line":6,"offset":16},"kind":"Type","whitespaceBefore":true},{"text":"value:","position":{"line":6,"offset":33},"kind":"Parameter","whitespaceAfter":true}]

Notice how semanticDiag returns an error in on initial load, but then doesn't once I type a space at the end of the file

@xiaoxiangmoe
Copy link
Contributor

Temporary solution:

function makeBox<T>(value: T){
  return {value};
}

const makeStringBox = (makeBox)<string>;
const stringBox = makeStringBox('abc');

@jakebailey
Copy link
Member

I was able to reproduce this on the TS compiler itself, but only within the editor. In fact, building the project sometimes fixed the issue. Restarting TS does too.

export function instantiateIsNodeArray<T extends Node>() {
    return isNodeArray<T>;
}

@jakebailey
Copy link
Member

jakebailey commented Sep 19, 2022

I've had no success in making a test that reproduces it, though. I did a little debugging, and I feel like the problem is in getSymbolOfNameOrPropertyAccessExpression, for this name, isHeritageClauseElementIdentifier returns true, but then things go wrong beacuse ExpressionWithTypeArguments are no longer things that can only appear in type space (and so the decision about meaning appears to be wrong).

@BrendanKelowna
Copy link

I was having this problem until I ran npm ci

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Dec 16, 2022

The repro we had today was

export function foo<U>() {
    /*$*/return bar<U>;
}

export function bar<T>(x: T) {
    return x;
}

let x = foo()(42);
  1. Insert // at the /*$*/ cursor.
  2. Remove the //

Expected: No errors.
Actual: 'bar' refers to a value, but is being used as a type here. Did you mean 'typeof bar'?

@DanielRosenwasser DanielRosenwasser changed the title Typescript Instantiation Expressions are failing Instantiation expressions inconsistently trigger incorrect error messages in editor contexts Dec 16, 2022
@DanielRosenwasser
Copy link
Member

As @jakebailey has mentioned, I do feel like this is not a parsing bug. If you hover over foo in my example, it correctly displays the following:

function foo<U>(): <U>(x: U) => U

@DanielRosenwasser
Copy link
Member

SEMANTIC HIGHLIGHTING!!!!!

@jakebailey
Copy link
Member

That's one thing I suspect, but I tested with it disabled and also hit it, so I think there may be more (but maybe I'm wrong).

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Dec 16, 2022

Okay, here's what I believe happens - you can notice in in two ways:

  1. You have semantic highlighting enabled (the default in VS Code) or you have inlay hints enabled. These (sometimes) get requested before diagnostics. However, the way semantic classifier queries entities asks for its meaning as a type instead of a value. That triggers an error, and that error gets cached for the subsequent getErr request.
  2. The first thing you do after the language server has loaded or after an edit is you try to get quick info on the usage of bar. That triggers the same bad lookup behavior, which reports an error which gets reported in any following diagnostics request.

@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants