cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.68k stars 3.16k forks source link

Replace deprecated `dtslint` #30081

Open MikeMcC399 opened 3 weeks ago

MikeMcC399 commented 3 weeks ago

What would you like?

Replace the use of the deprecated npm module dtslint "A utility built on TSLint for linting TypeScript declaration (.d.ts) files."

https://github.com/cypress-io/cypress/blob/6bf0257a226e88a8c98e32b9ad740b7549720a99/cli/package.json#L94

Why is this needed?

The npm module dtslint is deprecated and the source repo https://github.com/Microsoft/dtslint was archived on Nov 16, 2023.

See https://aka.ms/type-testing-tools which shows:

If you are just looking for a TypeScript type testing tool, use:

dtslint is used in Cypress CI workflows, in the job

lint-types

https://github.com/cypress-io/cypress/blob/6bf0257a226e88a8c98e32b9ad740b7549720a99/.circleci/workflows.yml#L1608-L1622

Other

jennifer-shehane commented 3 weeks ago

I vote for tsd with how we're using it. Seemed not too bad to replace to that one.

jennifer-shehane commented 3 weeks ago

@MikeMcC399 There's a lot of dep updates we need highlighted in this issue btw: https://github.com/cypress-io/cypress/issues/3777

MikeMcC399 commented 3 weeks ago

@jennifer-shehane

There's a lot of dep updates we need highlighted in this issue btw: #3777

I just looked at the first one on the list https://www.npmjs.com/package/@types/chalk which says:

This package has been deprecated

Author message:

This is a stub types definition for chalk (https://github.com/chalk/chalk). chalk provides its own type definitions, so you don't need @types/chalk installed!

so there may be scope for simplification / removal with other related packages.

jennifer-shehane commented 3 weeks ago

@MikeMcC399 Yah, open to any PRs from anything in there. I've been whittling away at the list as much as I have time.

MikeMcC399 commented 3 weeks ago

@jennifer-shehane

Yah, open to any PRs from anything in there. I've been whittling away at the list as much as I have time.

I guess I could take a look at these and see how I fare! 🙂

MikeMcC399 commented 2 weeks ago

@jennifer-shehane

jennifer-shehane commented 2 weeks ago

Yah, any ideas on updates could be helpful. A lot of us are relearning these deps use cases as well, so I do think you're likely as well positioned as we are to update.

MikeMcC399 commented 2 weeks ago

@jennifer-shehane

Yah, any ideas on updates could be helpful. A lot of us are relearning these deps use cases as well, so I do think you're likely as well positioned as we are to update.

OK. I'll do separate issues as they are easier to manage in terms of assignment, tracking, etc.

mrazauskas commented 1 week ago

I vote for tsd with how we're using it. Seemed not too bad to replace to that one.

@jennifer-shehane Just to draw your attention, the following test is passing:

import { expectType, expectNotType, expectAssignable, expectNotAssignable } from "tsd";

type Target = { a: { b: 1 } };

expectType<Target>({ a: { b: 1 } });
expectNotType<Target>({ a: { b: 1 } });

expectAssignable<Target>({ a: { b: 1 } });
expectNotAssignable<Target>({ a: { b: 1 } });

This issue is known for years, see: https://github.com/tsdjs/tsd/issues/141. The solution is also known and was mentioned here: https://github.com/tsdjs/tsd/issues/196. (By the way, there are many other improvements mention in this issue, but nothing was done for a year.)

I was maintaining forked tsd-lite. It was fixing several problems and limitations: monorepo support, testing on specific version of TypeScript, etc. Some things were not possible to improve and the reason was internal architecture of the library. For instance, @tsd/typescript is required. This is just a copy of TypeScript with few patched lines, but it makes the install size of tsd to reach 48.0MB.

So I decided to write a type testing tool from scratch: https://github.com/mrazauskas/tsd-lite/issues/364


This is how TSTyche was born.

And there is much more. For instance, documentation website: https://tstyche.org


By the way, immutable.js was recently migrating away from dtslint. Their first idea was to use tsd (https://github.com/immutable-js/immutable-js/issues/1985), but after I have pointed to some oddities (https://github.com/immutable-js/immutable-js/pull/1986) they decided to use TSTyche (https://github.com/immutable-js/immutable-js/pull/1988).

I was helping them with migration. I would be happy to migrate cypress type tests too. Let me know if that sounds interesting.

MikeMcC399 commented 1 week ago

@jennifer-shehane

Yah, any ideas on updates could be helpful. A lot of us are relearning these deps use cases as well, so I do think you're likely as well positioned as we are to update.

OK. I'll do separate issues as they are easier to manage in terms of assignment, tracking, etc.

mrazauskas commented 1 week ago

By the way, the following script is not working as intended:

https://github.com/cypress-io/cypress/blob/195cdb11a2af4b124bb15f8a38d62f058614a59d/npm/vue/package.json#L14

Just add --listFilesOnly to the command and you will see a list of .d.ts files, but none of the files within the npm/vue/test-tsd directory.

The culprit is here:

https://github.com/cypress-io/cypress/blob/195cdb11a2af4b124bb15f8a38d62f058614a59d/npm/vue/test-tsd/tsconfig.tsd.json#L12-L15

The directory name is test-tsd (not test-dts). This means that the mentioned script was never type checking the files within the test-tsd directory. If you fix this typo, the script will fail.


@lmiller1990 If I got it right, the typo was introduced in #22757.

MikeMcC399 commented 1 week ago

@mrazauskas

Thanks for your detective work regarding the vue package! Would you like to open a separate issue and/or PR for this, as it is not really well placed here.