[英]TSLint No Reference Rule Alternative
I'm currently using Angular 9 and Google API to log application users in with the Google credentials.我目前正在使用 Angular 9 和 Google API 来使用 Google 凭据登录应用程序用户。 The gapi and gapi.auth2 definitions are in place under "@types" in "node_modules", and I added them under "types" in "tsconfig.js" I've written a service that imports the Google API JS library at run-time, and I've also added the following to make it work in Angular:
gapi 和 gapi.auth2 定义位于“node_modules”中的“@types”下,我将它们添加到“tsconfig.js”中的“types”下我编写了一个在运行时导入 Google API JS 库的服务-时间,我还添加了以下内容以使其在 Angular 中工作:
/// <reference path="../../../node_modules/@types/gapi/index.d.ts" />
/// <reference path="../../../node_modules/@types/gapi.auth2/index.d.ts" />
They are properly pathed and working fine.它们路径正确并且工作正常。 However, when using WebStorm as my IDE instead of Visual Studio Code, I get a TSLint warning that this is not permitted as is documented here: https://palantir.github.io/tslint/rules/no-reference/ .
但是,当使用 WebStorm 作为我的 IDE 而不是 Visual Studio Code 时,我收到一条 TSLint 警告,指出这是不允许的,如此处所述: https ://palantir.github.io/tslint/rules/no-reference/。
Using import as I would normally doesn't seem to work either.像我通常那样使用 import 似乎也不起作用。
Since everything works just fine, I suppose I could just ignore it.由于一切正常,我想我可以忽略它。 But to be honest, it is an unusual way to do things and I'm wondering if anyone here can show me a proper method for including these definitions so that I car refer to them without error from Angular.
但老实说,这是一种不寻常的做事方式,我想知道这里是否有人可以向我展示包含这些定义的正确方法,以便我在 Angular 中引用它们而不会出错。
Thanks!谢谢!
In further research, and in updating to the latest version of ng-gapi, I discovered that there are modules and services already available that do what my custom service was doing.在进一步的研究中,并在更新到最新版本的 ng-gapi 时,我发现已经有一些模块和服务可以完成我的自定义服务正在做的事情。 It's possible the solutions I found online that suggested using references in this manner were already obsolete, or I simply did not see that ng-gapi was more than just a way to avoid errors when referencing Google API objects and methods.
我在网上找到的建议以这种方式使用引用的解决方案可能已经过时了,或者我只是没有看到 ng-gapi 不仅仅是一种在引用 Google API 对象和方法时避免错误的方法。
If you run into this issue and are wondering the same thing, I advise to not worry about it and just use the available services and modules in ng-gapi rather than re-invent the wheel.如果您遇到这个问题并且想知道同样的事情,我建议不要担心,只需使用 ng-gapi 中的可用服务和模块,而不是重新发明轮子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.