在打字稿中键入引用是否区分大小写? [英] Typing References in typescript are case sensitive?

查看:90
本文介绍了在打字稿中键入引用是否区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在带有打字稿的项目中使用Visual Studio 2015,并且文件使用小写和大写字母命名,例如"project/Models/myFile.ts".当我想从另一个模块/文件导入某些东西时,我在Visual Studio中使用drag n drop来自动为我提供文件路径的引用,但是它忽略了大写字母,并以小写形式给出了路径.

I use visual studio 2015 in a project with typescript and the files are named using lower and capital letters like this "project/Models/myFile.ts". When I want to import something from another module/file I use drag n drop in Visual studio so as to provide me automatically the reference with the path of the file, but it ignores capital letters and gives a path all in lowercase.

问题1:这是否意味着在引用或导入打字稿中的文件时,Visual Studio不区分大小写?

Question 1: Does this means that Visual studio is not case sensitive when referencing or importing files in typescript?

问题2:是否建议使用所有小写字母命名文件夹和文件,以便与不同的操作系统兼容?

Question 2: Is it recommended to use all lowercase letters for naming folders and files, in order to be compatible with different Operating Systems?

更新参考注释///< reference path ="jquery"/> 中给出的路径似乎不区分大小写,因此此///< reference path ="JQuery"/> 的工作原理相同,但是使用import关键字时,该路径必须与包含该模块的文件的命名完全相同.

UPDATE The path given in the reference comments /// <reference path="jquery" /> seems to be case insensitive so this /// <reference path="JQuery" /> works the same, but when using the import keyword, the path must much the exact naming of the file containing the module.

推荐答案

问题1:这是否表示在引用或导入打字稿中的文件时Visual Studio不区分大小写?

Question 1: Does this means that Visual studio is not case sensitive when referencing or importing files in typescript?

在Windows上不区分大小写;但是,我发现它仅在某些其他操作系统(如Linux)上在运行时区分大小写.在更改应用程序中的套管标准时,我曾遇到此问题,直到代码在Linux CI上运行.

It's case insensitive on Windows; however, I have found it's case sensitive at run-time only on some other operating systems like Linux. I ran into this problem one time when changing the casing standards in an application and everything worked fine until the code was run on the Linux CI.

为了使代码可移植,重要的是要确保模块说明符中的大小写与引用的文件名完全匹配.

In order to make code portable, it's important to make sure the casing in a module specifier matches the referenced file name exactly.

问题2:是否建议使用所有小写字母命名文件夹和文件,以便与不同的操作系统兼容?

Question 2: Is it recommended to use all lowercase letters for naming folders and files, in order to be compatible with different Operating Systems?

这是个人喜好.例如,我更喜欢使文件名与导出的文件名具有相同的大小写,这是

This is a personal preference. For example, I prefer to make my file names have the same casing as the name of what is exported and this is what is recommend in some style guides. Some other people prefer to use kebab casing (ex. some-file-name.ts) while others prefer to use some other casing style.

这篇关于在打字稿中键入引用是否区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆