12

I upgraded TypeScript to 3.7.2 from 3.6.x. And write code using optional chaining. But get strange error

Expression expected.ts(1109)

in (vim, VSCode) IDE, even when build was successful.

enter image description here

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Edgaras Karka
  • 7,400
  • 15
  • 61
  • 115
  • "I upgraded typescript to 3.7.2" from...? – spender Nov 12 '19 at 14:43
  • 1
    I believe the answer you're looking for can be found here: https://stackoverflow.com/questions/39668731/what-typescript-version-is-visual-studio-code-using-how-to-update-it – Reed Anderson Nov 13 '19 at 17:11

4 Answers4

18

Click the version in the bottom right of VS Code.

TS Version

A dropdown will appear at the top with a few options such as "Use VS Code's Version" and "Use Workspace Version".

Select "Use Workspace Version" which will select the version of typescript that tsc is using, typically installed in your devDependencies.

This will automatically add a line to your Workspace Configuration File that looks something like the following:

{
   "typescript.tsdk": "node_modules/typescript/lib"
}
styfle
  • 22,361
  • 27
  • 86
  • 128
1

It could be that your editor isn't using TypeScript 3.7 yet - see if there are options for using the TypeScript version in the TSServer from from your node_modules.

orta
  • 4,225
  • 1
  • 26
  • 34
1

You can start using TypeScript 3.7 features in VS Code today by installing the JavaScript and TypeScript Nightly extension.

laogui
  • 31
  • 3
0
import React, { useState } from 'react'
import DatePicker from 'react-native-date-picker'
import newdate 

export default () ={'>'} {
  const [date, setDate] = useState(new Date())

  return <DatePicker date={date} onDateChange={setDate} />
}
Plamen Nikolov
  • 2,643
  • 1
  • 13
  • 24
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 17 '22 at 18:21