webpack-bem-loader icon indicating copy to clipboard operation
webpack-bem-loader copied to clipboard

TypeScript support

Open awinogradov opened this issue 8 years ago • 4 comments

Now it works only by this way:

import * as Search from 'b:Search';

console.log(Search);

Because we transpile it to:

const Search = ((
(__webpack_require__(2).default || __webpack_require__(2)).applyDecls()
));

// ts use it like this
console.log(Search);

But! If we want use default export only:

import Search from 'b:Search';

console.log(Search);
const Search = ((
(__webpack_require__(2).default || __webpack_require__(2)).applyDecls()
));

// ts use it like this
console.log(Search.default); // .default -> undefined

We need to transpile it like this:

const Search = {
  default: ((
    (__webpack_require__(2).default || __webpack_require__(2)).applyDecls()
  ))
};

awinogradov avatar Dec 26 '17 13:12 awinogradov

Lisp (no):

const Search = {
  default: ((
    ( (x=>(x.default||x))(__webpack_require__(2)) ).applyDecls()
  ))
};

qfox avatar Dec 28 '17 00:12 qfox

@zxqfox what?

veged avatar Dec 28 '17 10:12 veged

we don't work with import we work with require

Yeti-or avatar Dec 29 '17 09:12 Yeti-or

IT DOES WORK!!!

Guys, why not to use:

declare module 'b:button m:type:radio' {
  etc.
}

qfox avatar Dec 30 '17 00:12 qfox