-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
zh-CN: translate Svelte TypeScript tutorial #18276
Conversation
Preview URLs Flaws (15)URL:
External URLs (16)URL:
(comment last updated: 2024-03-08 04:23:36) |
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
Please convert this PR to ready when the upstream PRs have been merged |
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
…meworks/svelte_typescript/index.md
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
</h2> | ||
``` | ||
|
||
这样,TypeScript 可以防止我们错误地将其分配给字符串变量。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样,TypeScript 可以防止我们错误地将其分配给字符串变量。 | |
这样,TypeScript 可以防止我们将其错误地分配给字符串。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里说的是,防止将“字符串值”赋给“tabindex”这个属性(该属性接受的值是 Number 类型)。只是因为 HTML 允许使用字符串值,也允许使用数字(但实际该属性接受的字符串也应该表示一个数字)。
你建议的翻译并没有体现这个意思,请参考一下我上面给出的翻译。
一旦你配置好了 TypeScript,你就可以通过在组件的脚本部分开头添加 `<script lang='ts'>` 来在 Svelte 组件中使用它。要通过常规的 JavaScript 文件使用它,只需将文件扩展名从 `.js` 更改为 `.ts`。你还需要更新所有相应的导入语句,将 `import` 语句中的 `.ts` 文件扩展名删除。 | ||
|
||
> **备注:** 如果在 `import` 语句中使用 `.ts` 文件扩展名,TypeScript 会抛出错误,因此如果你有名为 `./foo.ts` 的文件,你必须将其导入为 `"./foo"`。 | ||
> 更多信息请参阅 TypeScript 手册中的[捆绑程序、TypeScript 运行时和 Node.js 加载器的模块解析](https://www.typescriptlang.org/docs/handbook/2/modules.html##module-resolution-for-bundlers-typescript-runtimes-and-nodejs-loaders)部分。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> 更多信息请参阅 TypeScript 手册中的[捆绑程序、TypeScript 运行时和 Node.js 加载器的模块解析](https://www.typescriptlang.org/docs/handbook/2/modules.html##module-resolution-for-bundlers-typescript-runtimes-and-nodejs-loaders)部分。 | |
> 更多信息请参阅 TypeScript 手册中的[捆绑程序、TypeScript 运行时和 Node.js 加载器的模块解析](https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution-for-bundlers-typescript-runtimes-and-nodejs-loaders)部分。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref: mdn/content#32606
Co-authored-by: A1lo <yin199909@aliyun.com>
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
</h2> | ||
``` | ||
|
||
这样,TypeScript 可以防止我们将其错误地分配给字符串。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样,TypeScript 可以防止我们将其错误地分配给字符串。 | |
这样,TypeScript 可以防止我们将其分配为错误的字符串。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里用“赋值”就行,分配我们一般用在“内存空间”的分配,而非“使得某个变量的值变成另一个”
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
…meworks/svelte_typescript/index.md
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
Should we convert this pr into draft and wait for upstream update? @yin1999 |
No. I believe the upstream PR will be merged shortly :) |
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
…meworks/svelte_typescript/index.md
...s/zh-cn/learn/tools_and_testing/client-side_javascript_frameworks/svelte_typescript/index.md
Outdated
Show resolved
Hide resolved
…meworks/svelte_typescript/index.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @hanyujie2002
Co-authored-by: A1lo <yin199909@aliyun.com>
Related issues and pull requests
Relates to #16965