microsoft / microsoft/TypeScript
tsc and tsserver have different ideas of excessively deep types
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.3k
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 132
Description
TypeScript Version:
typescript-3.6.0-insiders.20190725
Taken from,
https://github.com/microsoft/TypeScript/pull/32028#issuecomment-515234327
Search Terms:
max instantiation count, max instantiation depth, tsc, tsserver
Code
I've reduced the 40-subproject monorepo to just small parts of 2 subprojects.
Here is a snippet of the problem,
/**
*
* ```json
* //tsconfig-base.json
* "disableSourceOfProjectReferenceRedirect": true,
* ```
*
* ```json
* //package.json
* "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/37759/artifacts?artifactName=tgz&fileId=2A7E3F3E93DD6F833D63A63F3A7A21707B3F57B08FCA5C93A8F1848556D8141F02&fileName=/typescript-3.6.0-insiders.20190725.tgz"
* ```
*
* -----
*
* VS Code: OK!
* Type inference OK!
*
* -----
*
* `tsc` gives me,
*
* ```js
* src/blah.ts:11:21 - error TS2589: Type instantiation is excessively deep and possibly infinite.
*
* 11 export const json = tm.deepMerge(
* ~~~~~~~~~~~~~
* 12 base.json,
* ~~~~~~~~~~~~~~
* ...
* 31 s.convertBlahType.toStr.BLAH
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 32 );
* ~
* ```
*/
export const json = tm.deepMerge(
/*snip*/
);
const x = json("", "");
if (x.foo != undefined) {
if (x.foo.bar != undefined) {
//Correctly infers `string`
//So, 14M type instantiations is okay with VS code
x.foo.bar.baz
}
}
Expected behavior:
If tsc gets the error,
TS2589: Type instantiation is excessively deep and possibly infinite.
Then tsserver should also get the error
Actual behavior:
tsc gets the error, but tsserver does not (or at least VS code infers the type correctly without errors)
Playground Link:
-None-
@sheetalkamat
The project involved contains code related to a company project.
So, I really do not want to upload it publicly, if possible.
I could mangle the variable names so that they're meaningless but if I can just email the parts of the project that are involved, that would be nice.
Repro steps:
npm installnpm run build- See
TS2589: Type instantiation is excessively deep and possibly infinite. - Open VS code
- Navigate to file
tscsays contains errors - Notice no errors
- Play with return type of function
- Notice inference works correctly
Related Issues:
The merged PR that introduced the error,
https://github.com/microsoft/TypeScript/pull/32079#issuecomment-515334873
The build I am testing,
https://github.com/microsoft/TypeScript/pull/32028
Also relevant, https://github.com/microsoft/TypeScript/issues/29511
It seems like every few versions, there ends up being a difference between tsc and tsserver, regarding the max instantiation depth
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par les étapes de reproduction fournies pour npm install/build et VS Code, puis comparez les diagnostics de tsc et tsserver. Consultez le comportement décrit dans PR 32079 et dans l’issue associée 29511 ; le travail est terminé lorsque les deux outils signalent systématiquement l’erreur de type « excessively deep » pour le même projet.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- compilers
- Type d'issue
- Bug
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100