ariovistus / aurelia-mask

port of ui-mask to aurelia
MIT License
7 stars 3 forks source link

Fixing a typescript compilation issue related to 'createTextRange' not existing on type 'HTMLInputElement' #13

Closed JPiers closed 6 years ago

JPiers commented 6 years ago

Including the "aurelia-mask" package in our (webpack 2-based) project resulted in packing problems due to the inclusion of typescript files in the "dist" folder. We decided to no longer exclude "node_modules" for the ts-loader, but we then ran into the following compilation errors:

ERROR in ./node_modules/aurelia-mask/dist/masked-input.ts
(563,36): error TS2339: Property 'createTextRange' does not exist on type 'HTMLInputElement'.

ERROR in ./node_modules/aurelia-mask/dist/masked-input.ts
(565,42): error TS2339: Property 'createTextRange' does not exist on type 'HTMLInputElement'.

The goal of this pull request is to resolve these compilation errors. I've mimicked the approach used to access ".selection" elsewhere in the file.

Our project uses typescript version 2.4.2, targetting "es5" with module code generation "es2015".

JPiers commented 6 years ago

@ariovistus Thanks for merging! Is there any chance of a new release containing this fix being released anytime soon?

ariovistus commented 6 years ago

1.4.2 released

jp7677 commented 6 years ago

@ariovistus Thanks a lot, though It seems that the dist folder of version 1.4.2 from mpnjs still contains the old typescript file from before this PR.

ariovistus commented 6 years ago

ugh, build artifacts in source control are the worst

ariovistus commented 6 years ago

1.4.3 released, did it work this time?

JPiers commented 6 years ago

@ariovistus Thanks! Version 1.4.3 compiles just fine for our project now. I did notice that the ".js" and ".map" files are no longer included in the "dist" folder in this release. For our project this is no issue, but I am not sure if this may be a problem for others. Thanks again!

ariovistus commented 6 years ago

yay, I fail again

ariovistus commented 6 years ago

1.4.4 is out, the js and js.map is back, which might break your particular case, sorry, not having it breaks my case.

JPiers commented 6 years ago

@ariovistus I've just tested 1.4.4, and this works fine for me! The "dist" folder contains ".js", ".map", ".ts" and ".d.ts" files in this release. Because the ".ts" files are there, I need to include the "node_modules" directory for the ts-loader in the webpack config however.

The presence of ".js", "d.ts" and ".map" files in the "dist" folder are not a problem for my case. Preferably, those would be the only files (i.e. leaving out the ".ts" files, what seems to be done currently in "master"), so "node_modules" can be excluded again for the ts-loader, but I do not know if this will cause problems for other cases.

In any case, we can still compile our project without problems, so thanks again for the quick responses and solutions!