我正在尝试将属性添加到'Passport-linkedin-oauth2'声明文件中的'strategyOption'接口。它不会声明任何模块或接口。只需导出界面和类
....
export interface StrategyOption {
clientID: string;
clientSecret: string;
callbackURL: string;
scopeSeparator?: string;
enableProof?: boolean;
profileFields?: string[];
}
....
export class Strategy extends passportStrategy {...}
我已经尝试了以下方法。但是所有这些都是失败的
/// <reference types="passport-linkedin-oauth2" />
export {}
declare global {
export interface StrategyOption {
scope?: string[] // does not work
}
}
和
export interface StrategyOption {
scope?: string[] // does not work
}
和
interface StrategyOption {
scope?: string[] // does not work
}
有什么方法可以添加此类声明文件?
我找到了这个想法。这都是关于augmetation
所以我的代码应为
import 'passport-linkedin-oauth2'
declare module 'passport-linkedin-oauth2' {
interface StrategyOption {
scope?: string[]
}
}
,但我不确定重要性有以下配置
在tsconfig.json
"compilerOptions": {
....
"baseUrl": ".",
"paths": {
"*": ["/src/types/*", "node_modules/*"]
}
}
需要扩展声明文件在我的情况下,在/src/types/
目录中,而没有任何子目录。