When I run the code below, I encounter this Error:
let foo = ' foo '
console.log(foo.trimLeft())
//foo.trimStart() works neither
I've noticed that many online solutions suggest editing my tsconfig.json
to include es20whatever.
What's puzzling is that I can use ES2018 features like Promise.prototype.finally and rest spread. My VSCode even auto completes trimStart()
for me, despite the fact that both the project and editor should be using the same tsconfig.json
. However, this specific code snippet fails to compile.
Below is my tsconfig.json file:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "./",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "dom"],
"plugins": [
{
"name": "tslint-language-service",
"configFile": "./tslint.json"
}
],
"paths": {
"foo": ["projects/foo/src/public_api.ts"],
"bar": ["projects/bar/src/public_api.ts"],
"baz": ["dist/baz"]
}
}
}
This issue arises within a monorepo angular folder (as indicated above). It's possible that there could be an issue related to that structure, but I'm uncertain.