I have a error with VSCode. It show me an error when I use a new method for "string":
When I run with npx ts-node, there is not error. How fix VsCode?
I look for VSCode not to show those errors.
Here the code:
//types.d.ts
interface String {
test: () => string
}
//tscongig.json
{
"compilerOptions": {
"target": "ESNext",
"moduleResolution": "NodeNext",
"baseUrl": ".",
"paths": {
"@tools/*": [
"tools/*"
],
"@core/*": [
"core/*"
]
}
},
"files": [
"types.d.ts"
]
}
//index.ts
String.prototype.test = () => 'hola!'
console.log('prueba'.test())
And a settings file for VSCode:
//settings.json
{
"typescript.tsdk": "node_modules\\typescript\\lib"
}
I am executing with npx ts-node .