-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
ResizeObserver API declarations missing #28502
Comments
I think it is intentional that the standard type definitions don't come with experimental APIs, especially if browser support is nearly not existing. |
We generate the lib over at https://github.com/Microsoft/TSJS-lib-generator from the standarized web IDL files now. This file contains the list of IDLs we generate the lib from. Once the feature hits, eg, the whatwg common dom interfaces IDL, we'll sync and have it. It's going to be some time (and probably much better browser support) until that happens. I'd recommend just adding the extra declarations locally to your project in the meantime, as I don't think we'd take a PR for an override for something that's still experimental. |
@weswigham good to know! Thank you.
What is the correct place to put these declarations from Typescript perspective? Taking into account the code of resize-observer-polyfill |
Any file in your project will do. Many people would recommend a separate |
@weswigham This seemingly should be revisited these days? All major browsers support it with the evergreen model in mind: Firefox (68-69), Safari (Tech Preview for availability in next Safari to launch alongside MacOS Catalina without a doubt), Chrome, Edge w/ Chromium, & so on. There's also updated CaniUse data on the matter now, IIRC: https://caniuse.com/#search=ResizeObserver |
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow. |
This should re-open; I’m of the opinion the reason it’s closed is questionable. The premise of not adding interface for /cc @weswigham |
@weswigham Any update on this? |
@weswigham MDN no longer lists this API as experimental. Currently getting "Cannot find name 'ResizeObserver'" when trying to use the API with TypeScript 3.7.2 |
This issue should be reopened as it is no longer experimental and all major browsers support it. |
According to MDN it's still only part of an Editor's Draft, and not all major browsers support it. |
I imagine what’s holding things up is Safari that won’t support it until
2020 being on their 2020 roadmap; Edge support for it is guaranteed
~January 15th when Edge Chromium is set to launch for the public w/ it’s
support for ResizeObserver.
On Wed, Nov 13, 2019 at 1:00 AM Martin Johns ***@***.***> wrote:
According to MDN it's still only part of an Editor's Draft, and not all
major browsers support it.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#28502?email_source=notifications&email_token=AAJKUOAOKN35DZEYT26M6VLQTO6ZVA5CNFSM4GDOB24KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED5MEZQ#issuecomment-553304678>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJKUODKUSZ7BORN3AUGNKLQTO6ZVANCNFSM4GDOB24A>
.
--
Kevin Lozandier
[email protected] <[email protected]>
|
Any updates here? |
that's one of the more bizarre issues I encountered. i've heard way much about this API the past year for it to be unfamiliar by typescript |
Almost to 80% https://caniuse.com/#search=ResizeObserver |
Time to add it, it has shipped to Safari last month. This means literally all browsers support it. |
Up |
@weswigham, create issue microsoft/TypeScript-DOM-lib-generator#908 |
While the typings aren't merged into typescript yet, you can use a package from npm with ResizeObserver typings: https://www.npmjs.com/package/@types/resize-observer-browser |
To add to @denexapp's response:
|
As discussed in sveltejs#4233, ResizeObserver is now widely available (>90% as of 15/01/2021) so we can use it instead of a custom-built solution to listen to resizes. I also needed to add @types/resize-observer-browser because the type definition for `ResizeObserver` hasn't landed in TS yet (see microsoft/TypeScript#28502). Closes sveltejs#4233.
As discussed in sveltejs#4233, ResizeObserver is now widely available (~90% as of 15/01/2021, [source](http://caniuse.com/?search=ResizeObserver)) so we can use it instead of a custom-built solution to listen to resizes. I also needed to add @types/resize-observer-browser because the type definition for `ResizeObserver` hasn't landed in TS yet (see microsoft/TypeScript#28502). Closes sveltejs#4233.
To me, the solution is:
Just like: {
"compilerOptions": {
"types": ["@types/resize-observer-browser"],
...
},
...
}
|
@vimcaw , they already merged types in microsoft/TypeScript-DOM-lib-generator#948 |
@wKich Thanks for letting me know this, but I have included My {
"compilerOptions": {
"target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"types": ["vite/client"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": "src"
},
"include": ["./src"]
} |
@vimcaw Because your TypeScript version is outdated. |
@MartinJohns Yeah, after upgrading to |
This PR adds the navigation component, and also reworks the react-router usage into a Page and Layout system. For the Navigation resizing, I tried to use resize observer, first with https://www.npmjs.com/package/@react-hook/resize-observer and then with ResizeObserver directly. The third party hook did not seem to work well for our use case, and for using ResizeObserver directly, it turns out the TypeScript types for ResizeObserver are not included by default, and I felt a little apprehensive to include third party types for it, though it would probably be fine. microsoft/TypeScript#28502 J=SLAP-1558 TEST=manual test resizing the page and seeing tabs appear and disappear test that switching tabs will run searches
Search Terms
ResizeObserver
Suggestion
lib.dom.ts
does not include ResizeObserver API declarations.Use Cases
ResizeObserver is a thing that is getting some support in 2018 and I've found no mention about ResizeObserver here.
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: