You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried out the typings is 2.0.0, but it seems like the typings aren't usable except for a very limited use case. Typescript version 3.2.2 reported in Visual Studio Code.
For instance, I can do the following:
import { parse } from 'bowser';
// browser.os.name autocompletes here in Code.
const browser = parse(window.navigator.userAgent);
but I cannot type the variables themselves:
// Errors out because Parser.ParsedDetail is not available.
const browser: Parser.ParsedDetail = parse(window.navigator.userAgent);
This may not seem important in that example, but it is important in a class context:
class Blah {
// This cannot be assigned a type because Parser is not available as an export.
// Leaving it as "any" means that no type completion is available in a IDE so a
// developer has to memorize the API.
browser: Parser.ParsedDetail;
constructor() {
this.browser = parse(window.navigator.userAgent);
}
}
Basically anything other than getParser and parse cannot be used as types. This seems to correspond to comment in #277:
I think and I've tried 😂 this should be the stable version, but the only thing I don't know yet is if through these typings, users could maybe access to Parser as definition even if they cannot in real. I have to test this aspect.
I tried hacking in export as namespace Parser;, but I couldn't import it. I'm not really good at creating typings so I had to take all the Parser namespace and paste it into my typings.d.ts file to workaround this.
The text was updated successfully, but these errors were encountered:
Hi, @mradcliffe. I'm not that good at typings either to answer correctly, but I'm diving into TypeScript nowadays, so, I hope, I'll be able to improve it exporting all the needed types :)
Ok, now I see the problem. We don't export those auxiliary types from the typing declaration file. So, it seems that we can do that. And, actually, namespaces seem a bit useless. I'll try to review the typings this weekend and hopefully come up with a bulletproof solution.
This is a follow-up from #272.
I tried out the typings is 2.0.0, but it seems like the typings aren't usable except for a very limited use case. Typescript version 3.2.2 reported in Visual Studio Code.
For instance, I can do the following:
but I cannot type the variables themselves:
This may not seem important in that example, but it is important in a class context:
Basically anything other than getParser and parse cannot be used as types. This seems to correspond to comment in #277:
I tried hacking in
export as namespace Parser;
, but I couldn't import it. I'm not really good at creating typings so I had to take all the Parser namespace and paste it into my typings.d.ts file to workaround this.The text was updated successfully, but these errors were encountered: