dtslint | utility built on TSLint for linting TypeScript declaration | Code Analyzer library
kandi X-RAY | dtslint Summary
kandi X-RAY | dtslint Summary
dtslint tests a TypeScript declaration file for style and correctness. It will install typescript and tslint for you, so this is the only tool you need to test a type definition. Lint rules new to dtslint are documented in the docs directory.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dtslint
dtslint Key Features
dtslint Examples and Code Snippets
Community Discussions
Trending Discussions on dtslint
QUESTION
I am receiving error: Expected 1 arguments, but got 2.ts(2554)
when I place uncurried definition of method above the curried definition.
Failing dtslint
test:
ANSWER
Answered 2020-Jul-05 at 16:57Typescript checks overloaded signatures (which are internally intersection types) in top to bottom order. When throttle
chooses which signature to use to infer generic parameters (almost same as conditional types), it always selects last signature.
Closely related feature of TS type system is described here:
When inferring from a type with multiple call signatures (such as the type of an overloaded function), inferences are made from the last signature (which, presumably, is the most permissive catch-all case). It is not possible to perform overload resolution based on a list of argument types (this would require us to support typeof for arbitrary expressions, as suggested in #6606, or something similar).
QUESTION
I'm working on improving typings for @testing-library/cypress
in DefinitelyTyped
after some feedback from my last PR.
I've added cypress
as a dependency as its typings is not defined in DefinitelyTyped, but running dtslint
fails because it runs with typescript@next
. If I run dtslint --localTs
with typescript@3.5.3
there is no error.
dtslint
results in the following error:
ANSWER
Answered 2019-Sep-09 at 08:13Seems like it needs to be fixed in the bundled typings in Cypress. Cypress issue #5065
QUESTION
I'm trying to create types for an existing module that has module.exports =
. I also want to create a custom type (interface) that corresponds to the object returned by the exported function:
ANSWER
Answered 2019-Apr-30 at 00:49You can use Declaration Merging to handle situations like these.
Using your example code you can move Color
into a namespace
that matches the exported function's name:
QUESTION
new to typescript, I need help creating type definition for a 3rd party module that exports as a function that has additional functions as properties.
...ANSWER
Answered 2019-Jan-02 at 08:16Ended up just skipping the module declaration wrap.
QUESTION
I'm trying to write a typescript definition file for an already existing library. This library (react-filepond) exports an object called File
(as can be seen in the usage example in the README).
The problem with that is that another one of the interfaces that this library creates utilizes the JS File interface.
So now in my typescript definition file I have to somehow manage two definitions of the type File
. My solution to this was to declare the object that the library creates as a different name in my definition file, and simply export it as "File".
ANSWER
Answered 2018-Dec-21 at 16:33This error message:
A 'declare' modifier is required for a top level declaration in a .d.ts file.
is displayed when a declaration file doesn't export anything. The declare
keyword is redundant because it's assumed in *.d.ts
files already.
The purpose of having declaration files is describing exactly what's going on in the corresponding JavaScript module. At the time of writing this post, react-filepond
contains 3 named exports: const registerPlugin
, class FilePond
, and class File
. This means your declaration could look like this:
types/react-filepond/index.d.ts
QUESTION
I made a change to a file for Definitely Typed, and when I created a pull request, it failed because of a formatting error. I'm assuming this is TsLint. I've never set it up before. How do I get it setup locally so I can catch these errors before committing using VSCode?
Currently I've installed TSLint Globally:
npm install -g tslint typescript
and I've installed the TSLint extension... but I don't see any errors show up when I save my file. Do I need to tell it to start working?
I'm new to VSCode and TSLint and Node, so the more specific, the better.
UpdateI am seeing this error now:
...vscode-tslint: Cannot read tslint configuration - 'Failed to load c:\Users\dlabar\Documents\GitHub\DefinitelyTyped\types\xrm\tslint.json: Invalid "extends" configuration value - could not require "dtslint/dt.json". Review the Node lookup algorithm (https://nodejs.org/api/modules.html#modules_all_together) for the approximate method TSLint uses to find the referenced configuration file.'
ANSWER
Answered 2017-May-05 at 17:54Apparently node 7+ is required: https://github.com/Microsoft/dtslint/issues/29
Upgraded and everything worked.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install dtslint
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page