TypeScript Cordova Case Sensitive tip

Posted on 6/1/2016 @ 2:14 AM in #Vanilla .NET by | Feedback | 3252 views

This tip also applies if you are using Electron with Linux.

If you are using Cordova with TypeScript, here is a tip that’ll save you hours of head scratching. This is especially if you are planning on reusing web based code with cordova.

The issue is, Cordova, Android, requires case specific file naming. So, “myFile.js” and “MyFile.js” are different. Now, as it happens, TypeScript tries to infer the JavaScript file case naming based on what you specify in the input filename.

So, MyFile.ts will yield myFile.js.

BUT – if you are importing the MyFile.ts as follows

import MyFileComponent from ‘./myFile.ts’  ..

guess what! .. the generated file is no myFile.js – EVEN THOUGH – the input was MyFile.ts

Wow so sucky!

Luckily there is help. In your tsConfig.json just write "forceConsistentCasingInFileNames": true .. and the TypeScript compiler will allow you to shoot yourself in the foot, but will at least warn you with errors. This will prevent case specific errors from happening when you move from Web –> Cordova, or Cordova (iOS) –> Cordova (Android).

Sound off but keep it civil:

Older comments..