0
I am having several problems converting this chunk of code with jQuery using only Typescript.
function addTourOverlay() {
if ($('#tour-overlay').length === 0) {
$('body').prepend('<div id="tour-overlay"></div>');
}
resizeOverlay();
}
function resizeOverlay() {
var window_height = $(window).height;
var window_width = $(window).width;
$('#tour-overlay').height(window_height).width(window_width);
}
Currently the conversion is like this:
addTourOverlay2() {
if (document.querySelectorAll('#tour-overlay').length === 0) {
let newDiv = document.createElement('div');
newDiv.id = 'tour-overlay';
let body = document.getElementsByTagName('body');
newDiv.appendChild(body);
}
this.resizeOverlay();
}
resizeOverlay() {
let window_height = screen.height;
let window_width = screen.width;
document.getElementById('#tour-overlay').style.height = window_height;
document.getElementById('#tour-overlay').style.width = window_width;
}
I am getting the following errors: The number type cannot be assigned to the string type. (lines 36 and 37)
The argument of type 'Nodelistof' is not attributable to the parameter of type 'Node'. The property 'baseURI' is missing in type 'Nodelistof'. (line 28)
Already corrected the post, it is clearer and correct now
– Samu F. Botelho
Given the absence of the word
function
to define the function and use ofthis
I suspect you’re setting this within a class, correct?– Woss
Yes, it’s a class
– Samu F. Botelho
Calm down, now that I’ve seen... you’re using Typescript then?
– Woss