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

Switch to new source of DefinitelyTyped data? #1090

Closed
karlhorky opened this issue Dec 6, 2022 · 5 comments · Fixed by #1140
Closed

Switch to new source of DefinitelyTyped data? #1090

karlhorky opened this issue Dec 6, 2022 · 5 comments · Fixed by #1140

Comments

@karlhorky
Copy link

karlhorky commented Dec 6, 2022

It appears that Microsoft deleted the "create a search index" function in June:

microsoft/DefinitelyTyped-tools#456 (comment)

Maybe a new method is needed for determining this information:

export async function loadTypesIndex(): Promise<void> {
const start = Date.now();
const { body } = await request<TypeList[]>(config.typescriptTypesIndex, {
decompress: true,
responseType: 'json',
});
log.info(`📦 Typescript preload, found ${body.length} @types`);
// m = modules associated
// t = @types/<name>
body.forEach((type) => {
typesCache[unmangle(type.t)] = type.t;
});
datadog.timing('typescript.loadTypesIndex', Date.now() - start);
}

One option:

Using the same algorithm that ATA uses, as mentioned by Orta https://twitter.com/orta/status/1600084654895267842

https://github.com/microsoft/TypeScript-Website/blob/f905e795350720b4a906b00155e95f370734f63c/packages/ata/src/index.ts#L63-L92

@Haroenv
Copy link
Collaborator

Haroenv commented Dec 6, 2022

Thanks for opening this issue. Are you interested in contributing the change in source?

@jablko
Copy link

jablko commented Dec 6, 2022

Is pkgs a list of all npm packages? If so, could we look there for a @types/package

/**
* Check if packages have Typescript definitions.
*/
export async function getTSSupport(
pkgs: Array<Pick<RawPkg, 'name' | 'types' | 'version'>>,
filelists: File[][]
): Promise<Array<Pick<RawPkg, 'types'>>> {
instead of in the obsolete

npm-search/src/config.ts

Lines 161 to 162 in d99c31f

typescriptTypesIndex:
'https://typespublisher.blob.core.windows.net/typespublisher/data/search-index-min.json',

@jablko
Copy link

jablko commented Dec 6, 2022

Alternatively there's all-the-package-names: https://unpkg.com/all-the-package-names@2.0.476/names.json

@Haroenv
Copy link
Collaborator

Haroenv commented Dec 6, 2022

pkgs is the current batch. All-the-package-names could be good enough for this use case. Maybe npm has a separate api to request packages of a certain owner?

@karlhorky
Copy link
Author

Thanks so much @MartinKolarik and reviewers @pixelastic and @bodinsamuel for the considerable effort in #1140 🙌

Updated the thread on Twitter:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants