bem/webpack-bem-loader

TypeScript support

awinogradov opened this issue · 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()
  ))
};
qfox commented

Lisp (no):

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

we don't work with import we work with require

qfox commented

IT DOES WORK!!!

Guys, why not to use:

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