microsoft / microsoft/TypeScript
Mechanism to specify input source location to find `package.json` instead of output source location when determining module format
Abierto
Nadie ha tomado este issue todavía.
Needs Proposal
Suggestion
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
🔎 Search Terms
nodenext, ts2351, construct
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about "A default import of a commonjs module with a default in a esm file doesn't seem to be the default export of that module when module is node16 or nodenext".
⏯ Playground Link
N/A
💻 Code
git clone https://github.com/monsanto/typescript-nodenext-bug
cd typescript-nodenext-bug
npm install
npm run tsc
🙁 Actual behavior
foo/index.ts:6:5 - error TS2351: This expression is not constructable.
Type 'typeof import("<dir>/typescript-nodenext-bug/.cache/foolib/class")' has no construct signatures.
6 new CBad();
~~~~
Found 1 error.
🙂 Expected behavior
It succeeds.
Additional information about the issue
- This issue requires a composite project,
NodeNext, a package boundary, a default export, and a parent directory with a file package.{json, json5, yaml} withouttype:module.- Please note that import default inside
foo's package boundary works. - One can delete the provided package.json after installing and run
node_modules/typescript/bin/tsc --build tsconfig-base.jsonto test withoutpackage.jsonpresent. - One can see other package extensions trigger the bug by
mv package.json package.yamlandpnpm run tsc.
- Please note that import default inside
- This is not a CommonJS project. It doesn't matter that there is a parent
package.jsonwithout it. Node doesn't even readpackage.yaml.- This is from a real-world monorepo where there is a root pnpm
package.json5for cross-package scripts.
- This is from a real-world monorepo where there is a root pnpm
Cross-ref for #62200
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la reproducción vinculada de typescript-nodenext-bug: ejecuta npm install y npm run tsc, y luego inspecciona tsconfig-base.json y las variantes de package.json, package.json5 y package.yaml descritas en el issue. Compara el resultado del formato de módulo NodeNext cuando los metadatos del paquete principal están presentes o ausentes; se considera terminado cuando la reproducción tiene éxito sin TS2351.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- node.js, typescript
- Área
- build-system, compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100