Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ts-transform-paths] transformPaths types error #26

Open
jnguyenmt opened this issue Mar 6, 2020 · 2 comments
Open

[ts-transform-paths] transformPaths types error #26

jnguyenmt opened this issue Mar 6, 2020 · 2 comments

Comments

@jnguyenmt
Copy link

Followed all the instructions for tsconfig.ts and for rollup.config.ts for rollup-plugin-typescript.

tsconfig.json

{
    "compilerOptions": {
        "baseUrl": "src",
        "paths": {
            "*": ["*"],
            "@globals/*": ["globals/*"],
            "@components/*": ["components/*"],
            "@containers/*": ["containers/*"],
            "@utils/*": ["utils/*"]
        },
        "moduleResolution": "node",
        "target": "es5",
        "module": "es2015",
        "jsx": "react",
        "lib": ["es2015", "es2016", "es2017", "dom"],
        "strict": true,
        "sourceMap": true,
        "declaration": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "declarationDir": "dist/types",
        "outDir": "./dist/lib",
        "skipLibCheck": true,
        "plugins": [
            {
                "transform": "@zerollup/ts-transform-paths",
                "exclude": ["*"]
            }
        ]
    },
}

rollup.config.ts

  typescript({
         useTsconfigDeclarationDir: true,
         typescript: ttypescript,
         cacheRoot: ".cache",
         transformers: [(service) => transformPaths(service.getProgram())]
     }),

transformPaths(service.getProgram()) is returning this error.

Type '{ before(transformationContext: TransformationContext): Transformer<SourceFile>; afterDeclarations(transformationContext: TransformationContext): CustomTransformers | Transformer<...>; }' is not assignable to type 'CustomTransformers | ICustomTransformer'.
  Type '{ before(transformationContext: TransformationContext): Transformer<SourceFile>; afterDeclarations(transformationContext: TransformationContext): CustomTransformers | Transformer<...>; }' is not assignable to type 'ICustomTransformer'.
    The types returned by 'afterDeclarations(...)' are incompatible between these types.
      Type 'CustomTransformers | Transformer<SourceFile>' is not assignable to type 'Transformer<SourceFile | Bundle>'.
        Type 'CustomTransformers' is not assignable to type 'Transformer<SourceFile | Bundle>'.
          Type 'CustomTransformers' provides no match for the signature '(node: SourceFile | Bundle): SourceFile | Bundle'.ts(2322)
ioptions.d.ts(8, 49): The expected type comes from the return type of this signature.

Is there anyway to deal with this or is a fix needed?

@zerkalica
Copy link
Owner

Try ttypescript. I changed readme to setup rollup with ttypescript.

@jnguyenmt
Copy link
Author

Tried what was in the readme with ttypescript and it did not work.

(rpt2 plugin) TypeError: this.emitFile is not a function
TypeError: this.emitFile is not a function
    at emitDeclaration (/Users/justinnguyen/Projects/ui-design-components/node_modules/rollup-plugin-typescript2/src/index.ts:366:11)
    at /Users/justinnguyen/Projects/ui-design-components/node_modules/rollup-plugin-typescript2/src/index.ts:376:5
    at /Users/justinnguyen/Projects/ui-design-components/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:4905:15
    at baseForOwn (/Users/justinnguyen/Projects/ui-design-components/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:2990:24)
    at /Users/justinnguyen/Projects/ui-design-components/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:4874:18
    at _.each (/Users/justinnguyen/Projects/ui-design-components/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:9342:14)
    at Object._onwrite (/Users/justinnguyen/Projects/ui-design-components/node_modules/rollup-plugin-typescript2/src/index.ts:374:4)
    at Object.generateBundle (/Users/justinnguyen/Projects/ui-design-components/node_modules/rollup-plugin-typescript2/src/index.ts:279:18)
    at /Users/justinnguyen/Projects/ui-design-components/node_modules/rollup/dist/rollup.js:20962:25

With what is in my previous post, that setup does work, but it is just that type issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants