Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated dtslint #30081

Open
MikeMcC399 opened this issue Aug 22, 2024 · 12 comments
Open

Replace deprecated dtslint #30081

MikeMcC399 opened this issue Aug 22, 2024 · 12 comments
Labels
process: dependencies Related to internal dependencies type: chore Work is required w/ no deliverable to end user

Comments

@MikeMcC399
Copy link
Contributor

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."

"dtslint": "4.0.7",

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

lint-types:
<<: *defaults
parallelism: 1
steps:
- restore_cached_workspace
- run:
command: ls -la types
working_directory: cli
- run:
command: ls -la chai
working_directory: cli/types
- run:
name: "Lint types 🧹"
command: yarn workspace cypress dtslint
- store-npm-logs

Other

@jennifer-shehane
Copy link
Member

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

@jennifer-shehane jennifer-shehane added type: chore Work is required w/ no deliverable to end user process: dependencies Related to internal dependencies labels Aug 22, 2024
@jennifer-shehane
Copy link
Member

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

@MikeMcC399
Copy link
Contributor Author

@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
Copy link
Member

@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
Copy link
Contributor Author

@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
Copy link
Contributor Author

@jennifer-shehane

  • None of the remaining deprecations in the list on Dependency Dashboard #3777 are simple updates. They either require dependent version updates or complete migrations, so at this time I don't expect to tackle any of the others on this list as I am lacking the background experience with the modules concerned. If it would be helpful I could submit a separate single issue with the consolidated findings for necessary steps or I could add a separate commented issue for each deprecation. Let me know if you want this or if I should just leave it to you.

@jennifer-shehane
Copy link
Member

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
Copy link
Contributor Author

@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.

@MikeMcC399 MikeMcC399 changed the title Replace deprecated dtslint Replace deprecated dtslint Aug 28, 2024
@mrazauskas
Copy link
Contributor

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: tsdjs/tsd#141. The solution is also known and was mentioned here: tsdjs/tsd#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: mrazauskas/tsd-lite#364


This is how TSTyche was born.

  • It loads TypeScript that is already installed, so the install size is only 219kB;
  • Allows testing on specific versions of Typescript: tstyche --target 5.0,latest;
  • Has test() and describe() to organize larger tests and makes it easy to debug using .only and .skip.

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 (immutable-js/immutable-js#1985), but after I have pointed to some oddities (immutable-js/immutable-js#1986) they decided to use TSTyche (immutable-js/immutable-js#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
Copy link
Contributor Author

@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
Copy link
Contributor

mrazauskas commented Sep 2, 2024

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

"tsd": "yarn build && yarn tsc -p test-tsd/tsconfig.tsd.json",

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:

"include": [
"../dist",
"../test-dts"
]

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
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
process: dependencies Related to internal dependencies type: chore Work is required w/ no deliverable to end user
Projects
None yet
Development

No branches or pull requests

3 participants