[英]Where is this VSCODE intellisense coming from?
In VSCODE I see the following intellisense: 在VSCODE中,我看到以下智能提示:
When exploring node_modules/sanctuary/index.js
, I find a function toMaybe
, but it doesn't appear the definition is coming from here because they do not match 在探索
node_modules/sanctuary/index.js
,我找到了一个toMaybe
函数,但是它似乎没有定义来自这里,因为它们不匹配
//# toMaybe :: a? -> Maybe a
//.
//. Takes a value and returns Nothing if the value is `null` or `undefined`;
//. Just the value otherwise.
//.
//. ```javascript
//. > S.toMaybe (null)
//. Nothing
//.
//. > S.toMaybe (42)
//. Just (42)
//. ```
This is in contrast to other functions that commonly display like this: 这与通常显示的其他功能相反:
Two questions: 两个问题:
UPDATE: 更新:
Lukas Bach and ippi have pointed out, one part, Sanctuary.Static.toMaybe<A>(p: A): Maybe<A>
comes from the Automatic type acquisition feature. Lukas Bach和ippi指出,
Sanctuary.Static.toMaybe<A>(p: A): Maybe<A>
来自自动类型获取功能。
Even after deleting all @types
from ~/Library/Caches/typescript/2.9/node_modules/types-registry
, I still see some docs. 即使从
~/Library/Caches/typescript/2.9/node_modules/types-registry
删除了所有@types
之后,我仍然看到一些文档。
I also was not able to find the text toMaybe :: a -> Maybe a
in the @types/sanctuary/index.d.ts
file or anywhere in the @types
directory. 我也无法在
@types/sanctuary/index.d.ts
文件或@types
目录中的任何位置找到文本toMaybe :: a -> Maybe a
。
The programming language TypeScript, a superset of JavaScript, allows definitions for proper types on functions and variables. 编程语言TypeScript是JavaScript的超集,它允许为函数和变量定义适当的类型。 TypeScript can be compiled down to JavaScript, which removes all type annotations, and a seperate type definition file (*.d.ts) can be exported during transpiliation.
可以将TypeScript编译为JavaScript,从而删除所有类型注释,并且可以在编译过程中导出单独的类型定义文件(* .d.ts)。 TypeScript type definitions are nowadays commonly provided for JS modules either directly in the module repository itself or as part of the DefinitelyTyped repository.
如今,通常直接在模块存储库本身中或作为DefinitelyTyped存储库的一部分为JS模块提供TypeScript类型定义。
To get such type annotations for your own code, you can either write your code in TypeScript in the first place or write additional custom type definition files by yourself. 要为您自己的代码获取此类类型注释,您可以首先在TypeScript中编写代码,也可以自己编写其他自定义类型定义文件。
This is not the only way to write type definitions, but at the moment the most prominent one. 这不是编写类型定义的唯一方法,而是目前最突出的方法。
Edit: Ok, I did not really look into the package that you've mentioned earlier. 编辑:好的,我没有真正调查您之前提到的软件包。 But I've tried it out, and this is the IntelliSense annotation, which it gives to me.
但是我已经尝试过了,这就是它给我的IntelliSense批注。
And this seems to be coming from the TS typing: 这似乎来自TS键入:
toMaybe<A>(p: A | null | undefined): Maybe<A>;
These typings are located at https://www.npmjs.com/package/@types/sanctuary . 这些类型位于https://www.npmjs.com/package/@types/sanctuary 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.