I'm using Angular 8.2 and installed ts-nameof
4.2.2 for my project and ts-patch
1.0.5 globally.
I ran ts-patch install
and ts-patch check
shows:
Checking TypeScript v3.5.3 installation in [...]
[+] tsc.js is patched with ts-patch version 1.0.5.
[+] tsserverlibrary.js is patched with ts-patch version 1.0.5.
[+] typescript.js is patched with ts-patch version 1.0.5.
[+] typescriptServices.js is patched with ts-patch version 1.0.5.
So I added the following from the ts-patch
examples section to my tsconfig.json
:
{
"compilerOptions": {
"plugins": [
{ "transform": "ts-nameof", "type": "raw" }
]
}
}
and ran ng serve -o
.
It's still complaining about Cannot find name 'nameof'.
.
I don't see any additonal steps listed, so what am I doing wrong?
To fix compile time error Cannot find name 'nameof'
// tsconfig.json
{
"compilerOptions": {
...
"types": [..., "ts-nameof"]
}
}
To fix runtime error Uncaught ReferenceError: nameof is not defined
# install ts-patch
yarn add -D ts-patch
ts-patch install
// tsconfig.json
{
"compilerOptions": {
...
"plugins": [
{
"transform": "ts-nameof",
"type": "raw"
}
]
}
}
Tested with angular 10.1.6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With