-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(types): handle non-null assertion #222
Conversation
I'd prefer something like |
This way works, what do you think? const headElement = document.getElementsByTagName('head')[0]
if (!headElement) return;
headElement.appendChild(script) |
I tend to believe that's a possibility. My developer tools show that Do you only get the linter issue in projects depending on this module? As I don't get any errors linting this module itself.
Wow, why does it 😂 Do brackets help by any chance? Like |
Yes! The issue happens only in projects depending on this module, not the module itself 😂
It seems like it does not, it's a strange ts check behavior |
Let's wait for a few days and see if some update to |
Just wondering, do you still see this issue occur in v8.4.4 released yesterday? |
Yes! I still do after v8.4.4, updated the reproduction |
Ok, so I see two issues:
Maybe the first issue should be reported in the nuxt repo so it is resolved before v4? |
I think this is the corresponding issue: Also potentially related: |
Please also try to override the typescript version to be
Then delete the lockfile and reinstall all dependencies (seems like override wouldn't downgrade all typescript versions in the lockfile without deleting it first). That might also be a workaround for now. |
Hi, |
@Reeska have you set the |
## [8.4.11](8.4.10...8.4.11) (2024-09-13) ### Bug Fixes * **types:** handle non-null assertion ([#222](#222)) ([2b59576](2b59576))
🎉 This PR is included in version 8.4.11 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No, I didn't |
📚 Description
Hello!, I started type-checking one of my projects which makes use of this module and I noticed that my
vue-tsc --noEmit
command complains about two type-check errors coming from this module, the 1st one is about plugin types not being injected (I opened #221 solving the issue) and the 2nd one indicates that line below is possiblyundefined
nuxt-cookie-control/src/runtime/components/CookieControl.vue
Line 380 in a54e6cb
This PR suggests that if we know that the head array will never be
undefined
, then add a non-null assertion (!
) to indicate it to the ts-pluginReproduction
I created a minimal reproduction here: https://stackblitz.com/edit/github-rdlsvu-jmfrqy?file=package.json
Adding the non-null assertion seems to work, I tested it locally on my vscode, no errors showing up

📝 Checklist