TypeScript scratch files: TS2304: Cannot find name Record
Hi all,
I'm a long-time WebStorm user, but unfortunately of recent memory, I can't seem to run TypeScript scratch files, and I get various errors with JavaScript too.
Consider the following code:
type Handler = () => Promise<true>
type Handlers = Record<string, Handler>
const handlers: Handlers = {
foo: () => true
}
The first line errors:
TS2583: Cannot find name Promise. Do you need to change your target library? Try changing the lib compiler option to es2015 or later.
The second line errors:
TS2304: Cannot find name Record
I'm already running in a TypeScript Project, but I'm 99% sure I used to write and run big complex TypeScript scratch files, pretty much anywhere.
Thanks,
Dave
Please sign in to leave a comment.
Hi Dave,
Thank you for reaching out to us!
Unfortunately this is a known issue: https://youtrack.jetbrains.com/issue/WEB-64148/TS-scratch-files-unable-to-use-basic-structures-like-Map. Please subscribe to it to get notified when it's fixed.
OK, Thanks Elena.
At the very least, I know I'm not going mad now!