question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typings fails during "afterDeclarations" transform

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
nonaracommented, Jan 10, 2021

Sorted in v2.2.1

1reaction
yankeeinlondoncommented, Mar 19, 2021

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

image
Read more comments on GitHub >

github_iconTop Results From Across the Web

zerollup/ts-transform-paths/README.md - UNPKG
Why? Problem described [here](https://github.com/Microsoft/TypeScript/issues/23701): d.ts files not working, if absolute paths used in npm-packaged library.
Read more >
@zerollup/ts-transform-paths | Yarn - Package Manager
Works everywhere, no more tspath, rollup-plugin-alias or webpack resolve alias and other workarounds. Why? Problem described here: d.ts files ...
Read more >
Over TypeScript tool To Use Custom Transformers in ... - Morioh
Currently TypeScript doesn't support custom transformers in the tsconfig.json, but supports it programmatically. And there is no way to compile your files using ......
Read more >
TypeScript typings give me "index.d.ts is not a module"
Running tsc (or webpack with ts-loader ) fails with the error. I have tried npm i webrtc --save in a misguided attempt for...
Read more >
ts-jest@29.0.3 - jsDocs.io
transformOptions : TransformOptionsTsJest ... For typings in jest.config.ts ... Enable error reporting in type-checked JavaScript files.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found