简体   繁体   English

TSLint 无参考规则替代

[英]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.

相关问题 使用自定义tslint规则导致找不到实现 - Using custom tslint rule results in no implementation found 检查AST是否为TSLint自定义规则的@Injectable装饰器 - Checking the AST for @Injectable decorator for TSLint custom rule 带有 Angular 7 和 `ng lint` 的 TypeScript 中的自定义 TSLint 规则 - Custom TSLint Rule in TypeScript with Angular 7 and `ng lint` TSLint:警告:'no-use-before-declare'规则需要进行类型检查 - TSLint: Warning: The 'no-use-before-declare' rule requires type checking 打破 lambda 表达式箭头的 TsLint 规则名称是什么? - What is the TsLint rule name for breaking lambda expression arrow? 无法通过 Angular 模板上的 Codelyzer 禁用 tslint 规则 - Cannot disable tslint rule via Codelyzer on Angular Template no-unused-variable TSLint规则不适用于私有@HostBinding - no-unused-variable TSLint rule does not work with private @HostBinding 如何在Angular中定义枚举类型以不违反tslint typedef规则 - How to define enum type in Angular to not violating tslint typedef rule tslint的含义是什么:“警告:&#39;声明前不使用&#39;规则需要类型信息”? - what is the meaning of tslint: “Warning: The 'no-use-before-declare' rule requires type information”? 如何禁用 Angular 样式指南的 tslint 规则:“选择器应以<prefix> “?</prefix> - How to disable tslint rule for Angular style guide: "The selector should be prefixed by <prefix>"?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM