0

Hi Im not using typescript or tsconfig.json but JSDoc types as understood by vscode // @tscheck I am looking for a Javscript-only solution with JSDoc type comments.

I followed the ideas in https://medium.com/@trukrs/type-safe-javascript-with-jsdoc-7a2a63209b76 and it's been working well generally but:

node v16.17.0, vscode 1.74.0

    // @tscheck 

    /** @type {string} myTestString */   
    const myTestString = ("2022-01-12").replaceAll("-", "")

Error: Property 'replaceAll' does not exist on type 'string'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later.ts(2550)

How to fix this message without a build step? First I removed the // tscheck. which killed the message, but want to keep the type checking if possible.

In pure typescript there seems to be this suggestion https://pinoria.com/how-to-fix-the-property-replaceall-does-not-exist-on-type-string-error-with-typescript/

but how to do similar without a build step?

datsunfun
  • 1
  • 2

0 Answers0