microsoft / microsoft/TypeScript

Document File name has a '.js' extension - stripping it

未关闭 适合新手
#41,952 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Docs
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

TypeScript Version: 4.2.0-dev.20201211

Search Terms: typescript File name has a '.js' extension - stripping it

Code

https://github.com/sguillia/ts-repro-III

other.ts

import * as index from "./index.js"

index.ts

export { }

Compile with:

tsc other.ts --traceResolution

Expected behavior:

Does not compile?

Actual behavior:

$ tsc other.ts --traceResolution
...
File name '/path/to/ts-repro-III/index.js' has a '.js' extension - stripping it.
...

This document is very good:
https://www.typescriptlang.org/docs/handbook/module-resolution.html

But it doesn't talk about resolution of modules with their extensions.

The actual behavior is fine but I did not manage to find its documentation

Same issue for jsx

$ tsc other.ts --traceResolution
...
File name '/path/to/ts-repro-III/index.jsx' has a '.jsx' extension - stripping it.
...

Would it be possible to document

  • which extension are trimmed?
  • what look-ups are performed based on the file name with extension stripped?

Playground Link: https://github.com/sguillia/ts-repro-III

Related Issues: no

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 issue 中链接的模块解析 handbook 页面开始,将其当前说明与 .js 和 .jsx 示例的 traceResolution 输出进行比较。记录哪些扩展名会被去除,以及接下来会执行哪些查找,然后确认该页面在不改变编译器行为的情况下回答了这两个问题。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
documentation
Issue 类型
文档
难度
2/5
预计耗时
1-3 小时
活跃度
冷清
描述清晰度
基本清楚
新手友好度
68/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。