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

Did not get 1 of 2 expected type errors during a fatal error #272

Closed
beruic opened this issue Jun 15, 2021 · 3 comments
Closed

Did not get 1 of 2 expected type errors during a fatal error #272

beruic opened this issue Jun 15, 2021 · 3 comments
Labels
kind: feature New feature or request kind: support Asking for support with something or a specific use case problem: removed issue template OP removed the issue template without good cause problem: stale Issue has not been responded to in some time solution: can't repro An attempt to reproduce has been tried and failed solution: duplicate This issue or pull request already exists

Comments

@beruic
Copy link

beruic commented Jun 15, 2021

What happens and why it is wrong

I expected to get TS2322: Type 'number' is not assignable to type 'string' for the below code, but the error does not show:

interface Alpha {
  x: number
}
interface Beta {
  x: string
}
interface Iota extends Beta, Alpha {}

export const f: Iota = {
  x: 1,
}

Environment

Rollup + Vue + TypeScript

Versions
  npmPackages:
    rollup: ^2.42.3 => 2.45.1 
    rollup-plugin-typescript2: ^0.30.0 => 0.30.0 
    typescript: ^4.2.3 => 4.2.4 

rollup.config.js

`rollup.config.js`:
import peerDepsExternal from "rollup-plugin-peer-deps-external"
import nodeResolve from "@rollup/plugin-node-resolve"
import commonjs from "@rollup/plugin-commonjs"
import vue from "rollup-plugin-vue"
import postcss from "rollup-plugin-postcss"
import replace from "@rollup/plugin-replace"
import typescript from "rollup-plugin-typescript2"
import alias from "@rollup/plugin-alias"
import nodePolyfills from "rollup-plugin-node-polyfills"

export default {
  input: "src-vue/index.ts",
  output: [
    {
      format: "umd",
      file: "www/mobile/js/compiled/vue.bundle.js",
      sourcemap: true,
    },
  ],
  plugins: [
    alias({
      resolve: [".vue", ".ts"],
      entries: [
        { find: "~", replacement: `${__dirname}/src-vue` },
        { find: "~modules", replacement: `${__dirname}/src-vue/modules` },
      ],
    }),
    replace({
      preventAssignment: true,
      "process.env.NODE_ENV": JSON.stringify("development"),
      "process.env.VUE_ENV": JSON.stringify("browser"),
    }),
    peerDepsExternal(),
    nodeResolve({
      browser: true,
      preferBuiltins: false,
    }),
    commonjs({
      include: /node_modules/,
    }),
    vue({
      preprocessStyles: true,
    }),
    postcss(),
    typescript({ tsconfig: "tsconfig.json" }),
    nodePolyfills(),
  ],
}

tsconfig.json

`tsconfig.json`:
{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [],
    "paths": {
      "~/*": ["src-vue/*"],
      "~modules/*": ["src-vue/modules/*"]
    },
    "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
  },
  "include": ["src-vue/**/*.ts", "src-vue/**/*.tsx", "src-vue/**/*.vue"],
  "exclude": ["node_modules"]
}
@ezolenko
Copy link
Owner

Does that error show if you just run tsc directly?

@agilgur5 agilgur5 changed the title Missing type error output Did not get expected type error Apr 23, 2022
@agilgur5 agilgur5 added problem: stale Issue has not been responded to in some time problem: needs more info This issue needs more information in order to handle it solution: tsc behavior This is tsc's behavior as well, so this is not a bug with this plugin kind: support Asking for support with something or a specific use case problem: removed issue template OP removed the issue template without good cause and removed problem: needs more info This issue needs more information in order to handle it solution: tsc behavior This is tsc's behavior as well, so this is not a bug with this plugin kind: support Asking for support with something or a specific use case labels Apr 23, 2022
@agilgur5
Copy link
Collaborator

This was a good minimal code sample, so I just threw it into the TS Playground, and it gives two errors, including the one mentioned.

So it sounds like a potential bug, but no verbosity: 3 log was provided. TS does still output JS despite the errors though.

@agilgur5
Copy link
Collaborator

agilgur5 commented Jun 8, 2022

I created a minimal reproduction here and was unable to reproduce this issue.

Both tsc and rpt2 give the same error in their latest versions (4.7.3 for TS, 0.32.1 for rpt2):

❯ npm run tsc
$ tsc
src/index.ts:10:11 - error TS2320: Interface 'Iota' cannot simultaneously extend types 'Beta' and 'Alpha'.
  Named property 'x' of types 'Beta' and 'Alpha' are not identical.

10 interface Iota extends Beta, Alpha {}
             ~~~~

src/index.ts:13:3 - error TS2322: Type 'number' is not assignable to type 'string'.

13   x: 1,
     ~

  src/index.ts:8:3
    8   x: string;
        ~
    The expected type comes from property 'x' which is declared here on type 'Iota'


Found 2 errors in the same file, starting at: src/index.ts:10```

❯ npm run build
$ rollup -c

./src/index.ts → ./dist/index.ts...
[!] (plugin rpt2) Error: /home/projects/rpt2-issue-272/src/index.ts(10,11): semantic error TS2320: Interface 'Iota' cannot simultaneously extend types 'Beta' and 'Alpha'.
  Named property 'x' of types 'Beta' and 'Alpha' are not identical.
src/index.ts
Error: /home/projects/rpt2-issue-272/src/index.ts(10,11): semantic error TS2320: Interface 'Iota' cannot simultaneously extend types 'Beta' and 'Alpha'.
  Named property 'x' of types 'Beta' and 'Alpha' are not identical.
    at error (/home/projects/rpt2-issue-272/node_modules/rollup/dist/shared/rollup.js:198:30)
    at throwPluginError (/home/projects/rpt2-issue-272/node_modules/rollup/dist/shared/rollup.js:21936:12)
    at Object.error (/home/projects/rpt2-issue-272/node_modules/rollup/dist/shared/rollup.js:22659:20)
    at Object.error (/home/projects/rpt2-issue-272/node_modules/rollup/dist/shared/rollup.js:22113:42)
    at RollupContext.error (/home/projects/rpt2-issue-272/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:20259:30)
    at eval (/home/projects/rpt2-issue-272/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29527:23)
    at Array.forEach (<anonymous>)
    at printDiagnostics (/home/projects/rpt2-issue-272/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29500:17)
    at Object.transform (/home/projects/rpt2-issue-272/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:29785:17)
    at eval (/home/projects/rpt2-issue-272/node_modules/rollup/dist/shared/rollup.js:22868:37)

So if you're not getting any error at all with rpt2, that would likely be due to a problem in your environment, and not a bug in rpt2.

If what you meant was that you only got 1 error instead of 2 errors reported by rpt2 (which is not really written in your opening comment, and per my previous comment, no log was provided), then the reason for that is likely because rpt2 only reports the first error when it comes to a fatal error.
#168 is a feature request to change that behavior so it outputs all errors on a fatal error.

@agilgur5 agilgur5 closed this as completed Jun 8, 2022
@agilgur5 agilgur5 added solution: duplicate This issue or pull request already exists kind: support Asking for support with something or a specific use case solution: can't repro An attempt to reproduce has been tried and failed labels Jun 8, 2022
@agilgur5 agilgur5 changed the title Did not get expected type error Did not get 1 of 2 expected type error during a fatal error Jun 8, 2022
@agilgur5 agilgur5 changed the title Did not get 1 of 2 expected type error during a fatal error Did not get 1 of 2 expected type errors during a fatal error Jun 8, 2022
@agilgur5 agilgur5 added the kind: feature New feature or request label Jun 8, 2022
Repository owner locked as resolved and limited conversation to collaborators Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind: feature New feature or request kind: support Asking for support with something or a specific use case problem: removed issue template OP removed the issue template without good cause problem: stale Issue has not been responded to in some time solution: can't repro An attempt to reproduce has been tried and failed solution: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants