- 
                Notifications
    You must be signed in to change notification settings 
- Fork 16
Can not apply transform with ts-loader. #43
Description
Hello there
I'm trying to use your transformer to get simple output instead of nested proxy-objects, but I struggle with that error now:
Module build failed (from ./node_modules/ts-loader/index.js):
TypeError: Cannot read property 'getTypeChecker' of undefined
    at visitNode (C:\Users\Foo\Desktop\vue-project\node_modules\ts-optchain\dist\transform\transform.js:22:31)
    at visitNodeAndChildren (C:\Users\Foo\Desktop\vue-project\node_modules\ts-optchain\dist\transform\transform
.js:19:30)
    at C:\Users\Foo\Desktop\vue-project\node_modules\ts-optchain\dist\transform\transform.js:15:65
    at C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:1390:86
    at reduceLeft (C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:1102:30)
    at C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:1390:42
    at transformRoot (C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:81154:82)
    at Object.map (C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:429:29)
    at Object.transformNodes (C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:81141:
30)
    at emitJsFileOrBundle (C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:81497:32)
    at emitSourceFileOrBundle (C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:81465
:13)
    at forEachEmittedFile (C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:81373:30)
    at Object.emitFiles (C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:81454:9)
    at emitWorker (C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:86927:33)
    at C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:86887:66
    at runWithCancellationToken (C:\Users\Foo\Desktop\vue-project\node_modules\typescript\lib\typescript.js:869
79:24)
I tried to integrate your transform fn into my webpack config which I used to build vue based project, so I just wanted to utilize that getCustomTransformers option so after the edits config looks like that:
const optChainTransform = require('ts-optchain/transform').default
module.exports = {
    /*...*/
    rules: [
      {
        test: /\.ts$/,
        loader: 'ts-loader',
        exclude: /node_modules/,
        options: {
          transpileOnly: true,
          getCustomTransformers: (program) => ({
              after: [optChainTransform(program)]
          }),
          appendTsSuffixTo: [/\.vue$/]
        }
      }
      /*...*/
    ],
    plugins: [new VueLoaderPlugin(), new ForkTsCheckerWebpackPlugin()],tsconfig:
{
  "compilerOptions": {
    "allowJs": true,
    "baseUrl": ".",
    "downlevelIteration": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "inlineSources": true,
    "jsx": "preserve",
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ],
    "module": "esnext",
    "moduleResolution": "node",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "outDir": "./compiled/",
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "resolveJsonModule": true,
    "sourceMap": true,
    "strict": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": false,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types",
      "src/shims"
    ],
    "types": [
      "webpack-env",
      "jest"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue"
  ]
}I use common typescript compiler, because I couldn't make it done with ttsc - output bundle still have not-replaced oc() calls so it's still just recursive-proxy objects which I want to avoid. I thought maybe the problem in transpileOnly but I can't refuse from it, project builds too long without it - so I started to search a way how to utilize this transform thing with my current config and I believed the code I provided above should work, but it doesn't. So I just wanted to ask maybe you have some ideas why, because I have no idea at the moment.
Thanks in advance.
upd: Tried it both with typescript 3.2.4 and 3.5.2