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

Support for TS 3.7 (Optional Chaining, Nullish Coalescing) #906

Closed
GuillaumeSpera opened this issue Nov 8, 2019 · 8 comments
Closed

Support for TS 3.7 (Optional Chaining, Nullish Coalescing) #906

GuillaumeSpera opened this issue Nov 8, 2019 · 8 comments
Labels

Comments

@GuillaumeSpera
Copy link

Hi there,

I just tried to upgrade my app to TypeScript 3.7 but I just got stuck on ts-node (8.4.1) not recognising the syntax of both Optional Chaining (obj?.prop) and Nullish Coalescing (const value = val1 ?? val2).

Since I didn't see any issue related to this, do you know if there is someone already working on it ?
I could try to help with this, even though I don't have any experience with ts-node code base.

@blakeembrey
Copy link
Member

What’s the error? It’s most likely your configuration, this package supports any typescript version you’re using.

@GuillaumeSpera
Copy link
Author

`const data = result?.rows;

SyntaxError: Unexpected token .
at Module._compile (internal/modules/cjs/loader.js:703:23)
at Module.m._compile (./node_modules/ts-node/src/index.ts:493:23)
at Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Object.require.extensions. [as .ts] (./node_modules/ts-node/src/index.ts:496:12)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Module.require (internal/modules/cjs/loader.js:666:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object. (./service/markerService.ts:27:1)
at Module._compile (internal/modules/cjs/loader.js:759:30)`

I use nodemon with this config :
{ "watch": [ "src" ], "ext": "ts,json,d.ts,js", "delay": "3", "execMap": { "ts": "ts-node --files src/server.ts" }, "ignore": [ "src/**/*.spec.ts" ] }

image

Same error with Nullish Coalescing syntax.

@blakeembrey
Copy link
Member

This is a runtime error, not a TypeScript error. Duplicate of #903.

@cmosgh
Copy link

cmosgh commented Sep 30, 2020

If someone get to this the problem is in tsconfig , namely you've chosen "target":"esnext" it should be "es2020" or "es2019"

@clairefro
Copy link

I am also having trouble getting optional chaining to work with ES2020, but it does work with ES2019. Problem is I need Promise.settleAll() which doesn't work with ES2019, only ES 2020, so I'm in cacth 22

node ver: 12.18

"typescript": "4.0.2"
"ts-node": "9.0.0",

// tsconfig 
"compilerOptions": {
  "target": "ES2020"
}

Error:

const isOwner = context.getUserId() === kanban?.userId;

SyntaxError: Unexpected token '.'

@cspotcode
Copy link
Collaborator

@clairefro you should be able to set "lib" to include es2020 type declarations and "target" to downlevel to es2019.

If you have any more questions, I recommend asking on the TypeScript Community Discord. https://discord.com/invite/typescript

@normancarcamo
Copy link

@clairefro same thing March 13, 2021, I hope I could have time to provide a solution for this feature, but I don't, I got many things to do, kudos and thanks to all the people working hard on this, as a dev I appreciate the effort, but for now, I will wait for a solution using ES2020, my problem is fixed by using ES2019, but I don't know why yet, I am open to explanations ✌️.

@cspotcode
Copy link
Collaborator

Check out the configs from @tsconfig/bases. Look at the target and lib options.
https://github.com/tsconfig/bases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants