Skip to content
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

Incorrect warning of globally declared namespace not defined ('gapi' is not defined) #1106

Closed
jacob-8 opened this issue Jul 18, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@jacob-8
Copy link

jacob-8 commented Jul 18, 2021

Describe the bug
When using gapi via global script, and then type definitions are added to the global.d.ts file, gapi is recognized as a valid namespace in the script block but language tools gives an error when used in the template (like an await block or on:click inline function. Things still work as expected, but there is a warning, 'gapi' is not defined svelte(missing-declaration)

To Reproduce

  • add <script src="https://apis.google.com/js/api.js" type="text/javascript"></script> to app.html
  • npm i -D @types/gapi.auth2 @types/gapi.client.calendar
  • add /// <reference types="gapi.client.calendar" /> to global.d.ts
  • Use await gapi.client.calendar.calendarList.list() in script block and inline {#await} block to see warning in just latter case.

Expected behavior
No warning.

Screenshots
image

System (please complete the following information):

  • OS: Windows
  • IDE: VSCode
  • Plugin: "Svelte for VSCode"

Additional context
Low priority as the typings still work and I can just use <!-- svelte-ignore missing-declaration --> but I thought you should know.

@jacob-8 jacob-8 added the bug Something isn't working label Jul 18, 2021
@dummdidumm
Copy link
Member

This is a warning from the Svelte compiler. It doesn't know that there's a global with that name. Currently (and I guess there won't be) there's no way to tell the compiler about additional globals, so ignoring/silencing the error is the best option. Once #855 is tackled that would be a way to deal with it globally.

@AlexGalays
Copy link

Just in case, I have the same issue and it only does it in the template part, not in the scripts.

@jacob-8 jacob-8 closed this as completed Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants