T
T
tarthur2017-08-05 13:39:12
JavaScript
tarthur, 2017-08-05 13:39:12

.ts in .js webpack?

Hello.
It is necessary that it would simply translate files with the .ts extension into .js correctly, despite the fact that vanilla javascript is in .ts files.
It gives a bunch of errors and doesn’t translate, apparently swears at data types or something else
xs inside .ts files like this javascript:

export class Word {
    constructor(englishWord = '', russianWord = '') {
        this.wordElement = document.createElement('div');
        this.wordElement.innerHTML = wordTemplate;
       ...
       ...
       this.init();
    }

    init() {
        this.wordElement.classList.add('word');
        this.getValues();
        this.initEvents();
        ....
        ....
    }
}

etc. files.
There is a "noImplicitAny" property here: https://www.typescriptlang.org/docs/handbook/tscon...
if set to false they say it helps, but it doesn't even want to compile with it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tarthur, 2017-08-05
@tarthur

Found the problem.
Errors are still issued, but nevertheless the files are compiled:
When connecting modules, I did not write the ts extension, such as:
import { Word } from "./Word.js"
:)
but it's better not to write the ./Word extension at all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question