typescript-transform-paths: Typings fails during "afterDeclarations" transform

I have code which compiles without issue using tsc and used to work fine with ttsc and in Rollup with the ttypscript replacement and using the “typescript-transform-paths” plugin.

For context, my tsconfig.json file is:

{
  "compilerOptions": {
    "declaration": false,
    "module": "esnext",
    "target": "es2018",
    "lib": ["es2015.reflect", "DOM"],
    "moduleResolution": "node",
    "sourceMap": true,
    "noImplicitAny": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "noEmit": true,
    "removeComments": false,
    "strictNullChecks": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    },
    "plugins": [
      { "transform": "typescript-transform-paths" },
      { "transform": "typescript-transform-paths", "afterDeclarations": true }
    ]
  },

  "include": ["src"]
}

This same repo and tsconfig used to compile but after updating a number of requirements (including Typescript to 4.1.3) it now fails with:

Error: Debug Failure. False expression: Node must have a real position for this operation
    at NodeObject.assertHasRealPosition (/Volumes/Coding/forest-fire/vuex-plugin-firemodel/node_modules/typescript/lib/typescript.js:146074:22)
    at NodeObject.getFullText (/Volumes/Coding/forest-fire/vuex-plugin-firemodel/node_modules/typescript/lib/typescript.js:146104:18)
    at getStatementTags (/Volumes/Coding/forest-fire/vuex-plugin-firemodel/node_modules/typescript-transform-paths/dist/utils/resolve-path-update-node.js:96:35)
    at Object.resolvePathAndUpdateNode (/Volumes/Coding/forest-fire/vuex-plugin-firemodel/node_modules/typescript-transform-paths/dist/utils/resolve-path-update-node.js:17:18)
    at Object.nodeVisitor (/Volumes/Coding/forest-fire/vuex-plugin-firemodel/node_modules/typescript-transform-paths/dist/visitor.js:76:24)
    at visitNodes (/Volumes/Coding/forest-fire/vuex-plugin-firemodel/node_modules/typescript/lib/typescript.js:80382:48)

I have gone into Typescript’s code and added code to pull out more information as I was completely confused by the message. When I hit an error condition, I now get a dump of the node’s context which looks like this:

NodeObject {
  pos: -1,
  end: -1,
  flags: 8,
  modifierFlagsCache: 0,
  transformFlags: 1,
  parent: undefined,
  kind: 195,
  argument: NodeObject {
    pos: -1,
    end: -1,
    flags: 8,
    modifierFlagsCache: 0,
    transformFlags: 1,
    parent: undefined,
    kind: 191,
    literal: TokenObject {
      pos: -1,
      end: -1,
      flags: 8,
      modifierFlagsCache: 0,
      transformFlags: 0,
      parent: undefined,
      kind: 10,
      text: '@firebase/auth-types',
      singleQuote: undefined,
      hasExtendedUnicodeEscape: undefined
    }
  },
  qualifier: IdentifierObject {
    pos: -1,
    end: -1,
    flags: 8,
    modifierFlagsCache: 0,
    transformFlags: 0,
    parent: undefined,
    kind: 78,
    originalKeywordKind: undefined,
    escapedText: 'FirebaseAuth',
    emitNode: { flags: 16777216 },
    symbol: SymbolObject {
      flags: 32,
      escapedName: 'FirebaseAuth',
      declarations: [Array],
      exports: [Map],
      members: [Map],
      valueDeclaration: [NodeObject],
      parent: [SymbolObject],
      id: 24262,
      isReferenced: 788968
    },
    typeArguments: undefined
  },
  typeArguments: undefined,
  isTypeOf: false,
  jsDocCache: []
}

With my someone low resolution understanding this seems to suggest it’s taking some issue with the FirebaseAuth symbol which is being imported from a package that does indeed export the given symbol but considering this repo hasn’t changed at all i’m surprised its not working. Further, if I go into the assertion in Typescript’s NodeObject.assertHasRealPosition and just remove the assertion, it goes back to transpiling successfully.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16

Commits related to this issue

Most upvoted comments

Sorted in v2.2.1

For me … all paths lead to success. @jacobbogers can you try re-diagnosing?

image

I am using 2.2.3 and i have he EXACT same issue as @ksnyde did previously