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

semantic error TS2339: Property 'name' does not exist on type 'User' with rpt2 but not tsc when using Vite -- can't repro #297

Closed
yarinsa opened this issue Feb 17, 2022 · 5 comments
Labels
kind: support Asking for support with something or a specific use case problem: stale Issue has not been responded to in some time scope: integration Related to an integration, not necessarily to core (but could influence core) scope: upstream Issue in upstream dependency scope: Vite Related to integration with Vite, not Rollup, which this plugin was designed for solution: can't repro An attempt to reproduce has been tried and failed solution: invalid This doesn't seem right solution: out-of-scope This is out of scope for this project

Comments

@yarinsa
Copy link

yarinsa commented Feb 17, 2022

What happens and why it is wrong

When defining class property in the constructor for example:

class User {
  constructor(private name: string) {}
}

Result => build fails with following error: semantic error TS2339: Property 'name' does not exist on type 'User'.

When doing the same thing but defining the property as a class member

class User {
  name: string

  constructor(name: string) {}
}

Result => build pass.

When defining as class property in the constructor and trying to access

class User {
  constructor(private name: string) {
    this.name
  }
}

Result => build fails with the same error.

For all cases, running tsc -b works great.

I am having trouble believing it never happened to anyone as this package is popular. Couldn't find any open issue about this. The parsed ts-config seems fine in the logs.

Environment

MacOS Monterey
VS-Code
Node 17.3.1

Versions
 npmPackages:
    rollup-plugin-typescript2: 0.31.2 => 0.31.2 
    typescript: ^4.4.4 => 4.5.5 

rollup.config.js

I don't use one

tsconfig.json

`tsconfig.json`:
{
  "compilerOptions": {
    "target": "es5",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "declaration": true,
    "moduleResolution": "node",
    "inlineSourceMap": true,
    "downlevelIteration": true
  },
  "exclude": ["./__tests__", "dist", "**/__mocks__/**"],
  "include": ["src"]
}

plugin output with verbosity 3 - failure case

plugin output with verbosity 3:
$ rm -rf dist && yarn vite build
$ /Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.bin/vite build
vite v2.8.3 building for production...
rpt2: built-in options overrides: {
    "noEmitHelpers": false,
    "importHelpers": true,
    "noResolve": false,
    "noEmit": false,
    "inlineSourceMap": false,
    "outDir": "/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/placeholder",
    "moduleResolution": 2,
    "allowNonTsExtensions": true,
    "module": 5
}
rpt2: parsed tsconfig: {
    "options": {
        "target": 1,
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "declaration": true,
        "moduleResolution": 2,
        "inlineSourceMap": false,
        "downlevelIteration": true,
        "configFilePath": "/Users/yarinsasson/Documents/Work/user-management-service/sdk/tsconfig.json",
        "noEmitHelpers": false,
        "importHelpers": true,
        "noResolve": false,
        "noEmit": false,
        "outDir": "/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/placeholder",
        "allowNonTsExtensions": true,
        "module": 5
    },
    "fileNames": [
        "/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/authClient.ts",
        "/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/index.ts",
        "/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/storage.ts",
        "/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/types.ts"
    ],
    "typeAcquisition": {
        "enable": false,
        "include": [],
        "exclude": []
    },
    "raw": {
        "compilerOptions": {
            "target": "es5",
            "allowSyntheticDefaultImports": true,
            "esModuleInterop": true,
            "declaration": true,
            "moduleResolution": "node",
            "inlineSourceMap": true,
            "downlevelIteration": true
        },
        "exclude": [
            "./__tests__",
            "dist",
            "**/__mocks__/**"
        ],
        "include": [
            "src"
        ],
        "compileOnSave": false
    },
    "errors": [],
    "wildcardDirectories": {
        "/users/yarinsasson/documents/work/user-management-service/sdk/src": 1
    },
    "compileOnSave": false
}
rpt2: typescript version: 4.5.5
rpt2: tslib version: 2.3.1
rpt2: rollup version: 2.67.2
rpt2: rollup-plugin-typescript2 version: 0.31.2
rpt2: plugin options:
{
    "verbosity": 3,
    "check": true,
    "clean": false,
    "cacheRoot": "/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2",
    "include": [
        "*.ts+(|x)",
        "**/*.ts+(|x)"
    ],
    "exclude": [
        "*.d.ts",
        "**/*.d.ts"
    ],
    "abortOnError": true,
    "rollupCommonJSResolveHack": false,
    "useTsconfigDeclarationDir": false,
    "tsconfigOverride": {},
    "transformers": [],
    "tsconfigDefaults": {},
    "objectHashIgnoreUnknownHack": false,
    "cwd": "/Users/yarinsasson/Documents/Work/user-management-service/sdk",
    "typescript": "version 4.5.5"
}
rpt2: rollup config:
{
    "input": "/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/index.ts",
    "context": "globalThis",
    "preserveEntrySignatures": "strict",
    "plugins": [
        {
            "name": "alias"
        },
        {
            "name": "vite:modulepreload-polyfill"
        },
        {
            "name": "vite:resolve"
        },
        {
            "name": "vite:html-inline-proxy"
        },
        {
            "name": "vite:css"
        },
        {
            "name": "vite:esbuild"
        },
        {
            "name": "vite:json"
        },
        {
            "name": "vite:wasm"
        },
        {
            "name": "vite:worker"
        },
        {
            "name": "vite:worker-import-meta-url"
        },
        {
            "name": "vite:asset"
        },
        {
            "name": "sourcemaps"
        },
        {
            "name": "rpt2"
        },
        {
            "name": "vite:define"
        },
        {
            "name": "vite:css-post"
        },
        {
            "name": "vite:watch-package-data"
        },
        {
            "name": "vite:build-html"
        },
        {
            "name": "commonjs"
        },
        {
            "name": "vite:data-uri"
        },
        {
            "name": "rollup-plugin-dynamic-import-variables"
        },
        {
            "name": "vite:asset-import-meta-url"
        },
        {
            "name": "vite:build-import-analysis"
        },
        {
            "name": "vite:esbuild-transpile"
        },
        {
            "name": "vite:terser"
        },
        {
            "name": "vite:reporter"
        },
        {
            "name": "vite:load-fallback"
        }
    ]
}
rpt2: tsconfig path: /Users/yarinsasson/Documents/Work/user-management-service/sdk/tsconfig.json
rpt2: included:
[
    "*.ts+(|x)",
    "**/*.ts+(|x)"
]
rpt2: excluded:
[
    "*.d.ts",
    "**/*.d.ts"
]
rpt2: Ambient types:
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/@types/estree/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/@types/semver/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/faker/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/js-yaml/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/json-schema/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/json-stable-stringify/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/json5/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/jsonwebtoken/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/minimatch/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/minimist/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/node/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/normalize-package-data/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/parse-json/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/websocket/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/ws/index.d.ts
rpt2: transpiling '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/index.ts'
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/code/cache/8661eed392c11e612e9472818fb33610261775b5'
rpt2:     cache hit
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/syntacticDiagnostics/cache/8661eed392c11e612e9472818fb33610261775b5'
rpt2:     cache hit
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/semanticDiagnostics/cache/8661eed392c11e612e9472818fb33610261775b5'
rpt2:     cache hit
rpt2: generated declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/index.ts'
transforming (1) src/index.tsrpt2: transpiling '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/authClient.ts'
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/code/cache/4926919e7c8797b34661afb3926fead78e96e050'
rpt2:     cache miss
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/syntacticDiagnostics/cache/4926919e7c8797b34661afb3926fead78e96e050'
rpt2:     cache miss
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/semanticDiagnostics/cache/4926919e7c8797b34661afb3926fead78e96e050'
rpt2:     cache miss
✓ 1 modules transformed.
[rpt2] /Users/yarinsasson/Documents/Work/user-management-service/sdk/src/authClient.ts(3,10): semantic error TS2339: Property 'options' does not exist on type 'AuthClient'.
file: /Users/yarinsasson/Documents/Work/user-management-service/sdk/src/authClient.ts
error during build:
Error: /Users/yarinsasson/Documents/Work/user-management-service/sdk/src/authClient.ts(3,10): semantic error TS2339: Property 'options' does not exist on type 'AuthClient'.
    at error (/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/rollup/dist/shared/rollup.js:160:30)
    at throwPluginError (/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/rollup/dist/shared/rollup.js:21831:12)
    at Object.error (/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/rollup/dist/shared/rollup.js:22556:20)
    at Object.error (/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/rollup/dist/shared/rollup.js:22008:42)
    at RollupContext.error (/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:17311:30)
    at /Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25144:23
    at arrayEach (/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:585:11)
    at Function.forEach (/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:9465:14)
    at printDiagnostics (/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25117:14)
    at Object.transform (/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:30271:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

plugin output with verbosity 3 - success case

plugin output with verbosity 3:
command.
➜  sdk git:(develop) ✗ yarn build
yarn run v1.22.17
$ rm -rf dist && yarn vite build
$ /Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.bin/vite build
vite v2.8.3 building for production...
rpt2: built-in options overrides: {
    "noEmitHelpers": false,
    "importHelpers": true,
    "noResolve": false,
    "noEmit": false,
    "inlineSourceMap": false,
    "outDir": "/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/placeholder",
    "moduleResolution": 2,
    "allowNonTsExtensions": true,
    "module": 5
}
rpt2: parsed tsconfig: {
    "options": {
        "target": 1,
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "declaration": true,
        "moduleResolution": 2,
        "inlineSourceMap": false,
        "downlevelIteration": true,
        "configFilePath": "/Users/yarinsasson/Documents/Work/user-management-service/sdk/tsconfig.json",
        "noEmitHelpers": false,
        "importHelpers": true,
        "noResolve": false,
        "noEmit": false,
        "outDir": "/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/placeholder",
        "allowNonTsExtensions": true,
        "module": 5
    },
    "fileNames": [
        "/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/authClient.ts",
        "/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/index.ts",
        "/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/storage.ts",
        "/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/types.ts"
    ],
    "typeAcquisition": {
        "enable": false,
        "include": [],
        "exclude": []
    },
    "raw": {
        "compilerOptions": {
            "target": "es5",
            "allowSyntheticDefaultImports": true,
            "esModuleInterop": true,
            "declaration": true,
            "moduleResolution": "node",
            "inlineSourceMap": true,
            "downlevelIteration": true
        },
        "exclude": [
            "./__tests__",
            "dist",
            "**/__mocks__/**"
        ],
        "include": [
            "src"
        ],
        "compileOnSave": false
    },
    "errors": [],
    "wildcardDirectories": {
        "/users/yarinsasson/documents/work/user-management-service/sdk/src": 1
    },
    "compileOnSave": false
}
rpt2: typescript version: 4.5.5
rpt2: tslib version: 2.3.1
rpt2: rollup version: 2.67.2
rpt2: rollup-plugin-typescript2 version: 0.31.2
rpt2: plugin options:
{
    "verbosity": 3,
    "check": true,
    "clean": false,
    "cacheRoot": "/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2",
    "include": [
        "*.ts+(|x)",
        "**/*.ts+(|x)"
    ],
    "exclude": [
        "*.d.ts",
        "**/*.d.ts"
    ],
    "abortOnError": true,
    "rollupCommonJSResolveHack": false,
    "useTsconfigDeclarationDir": false,
    "tsconfigOverride": {},
    "transformers": [],
    "tsconfigDefaults": {},
    "objectHashIgnoreUnknownHack": false,
    "cwd": "/Users/yarinsasson/Documents/Work/user-management-service/sdk",
    "typescript": "version 4.5.5"
}
rpt2: rollup config:
{
    "input": "/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/index.ts",
    "context": "globalThis",
    "preserveEntrySignatures": "strict",
    "plugins": [
        {
            "name": "alias"
        },
        {
            "name": "vite:modulepreload-polyfill"
        },
        {
            "name": "vite:resolve"
        },
        {
            "name": "vite:html-inline-proxy"
        },
        {
            "name": "vite:css"
        },
        {
            "name": "vite:esbuild"
        },
        {
            "name": "vite:json"
        },
        {
            "name": "vite:wasm"
        },
        {
            "name": "vite:worker"
        },
        {
            "name": "vite:worker-import-meta-url"
        },
        {
            "name": "vite:asset"
        },
        {
            "name": "sourcemaps"
        },
        {
            "name": "rpt2"
        },
        {
            "name": "vite:define"
        },
        {
            "name": "vite:css-post"
        },
        {
            "name": "vite:watch-package-data"
        },
        {
            "name": "vite:build-html"
        },
        {
            "name": "commonjs"
        },
        {
            "name": "vite:data-uri"
        },
        {
            "name": "rollup-plugin-dynamic-import-variables"
        },
        {
            "name": "vite:asset-import-meta-url"
        },
        {
            "name": "vite:build-import-analysis"
        },
        {
            "name": "vite:esbuild-transpile"
        },
        {
            "name": "vite:terser"
        },
        {
            "name": "vite:reporter"
        },
        {
            "name": "vite:load-fallback"
        }
    ]
}
rpt2: tsconfig path: /Users/yarinsasson/Documents/Work/user-management-service/sdk/tsconfig.json
rpt2: included:
[
    "*.ts+(|x)",
    "**/*.ts+(|x)"
]
rpt2: excluded:
[
    "*.d.ts",
    "**/*.d.ts"
]
rpt2: Ambient types:
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/@types/estree/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/@types/semver/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/faker/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/js-yaml/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/json-schema/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/json-stable-stringify/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/json5/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/jsonwebtoken/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/minimatch/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/minimist/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/node/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/normalize-package-data/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/parse-json/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/websocket/index.d.ts
rpt2:     /Users/yarinsasson/Documents/Work/user-management-service/node_modules/@types/ws/index.d.ts
rpt2: transpiling '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/index.ts'
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/code/cache/8661eed392c11e612e9472818fb33610261775b5'
rpt2:     cache hit
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/syntacticDiagnostics/cache/8661eed392c11e612e9472818fb33610261775b5'
rpt2:     cache hit
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/semanticDiagnostics/cache/8661eed392c11e612e9472818fb33610261775b5'
rpt2:     cache hit
rpt2: generated declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/index.ts'
transforming (1) src/index.tsrpt2: transpiling '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/authClient.ts'
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/code/cache/65f0e23b922100607ae070f3b9ae38c383a98f98'
rpt2:     cache hit
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/syntacticDiagnostics/cache/65f0e23b922100607ae070f3b9ae38c383a98f98'
rpt2:     cache hit
rpt2:     cache: '/Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.cache/rollup-plugin-typescript2/rpt2_78d7eb8a74b0b6f25c11de8eecad86647833265f/semanticDiagnostics/cache/65f0e23b922100607ae070f3b9ae38c383a98f98'
rpt2:     cache hit
rpt2: generated declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/authClient.ts'
✓ 2 modules transformed.
rendering chunks (1)...rpt2: generating target 1
rpt2: rolling caches
rpt2: generating missed declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/storage.ts'
rpt2: generating missed declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/types.ts'
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/index.ts' to 'index.d.ts'
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/authClient.ts' to 'authClient.d.ts'
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/storage.ts' to 'storage.d.ts'
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/types.ts' to 'types.d.ts'
dist/index.d.ts        0.01 KiB
dist/authClient.d.ts   0.11 KiB
dist/storage.d.ts      0.06 KiB
dist/types.d.ts        0.11 KiB
dist/sdk.umd.js        0.30 KiB / gzip: 0.20 KiB
rendering chunks (1)...rpt2: generating target 2
rpt2: rolling caches
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/index.ts' to 'index.d.ts'
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/authClient.ts' to 'authClient.d.ts'
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/storage.ts' to 'storage.d.ts'
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/types.ts' to 'types.d.ts'
dist/index.d.ts        0.01 KiB
dist/authClient.d.ts   0.11 KiB
dist/storage.d.ts      0.06 KiB
dist/types.d.ts        0.11 KiB
dist/sdk.cjs.js        0.22 KiB / gzip: 0.17 KiB
rendering chunks (1)...rpt2: generating target 3
rpt2: rolling caches
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/index.ts' to 'index.d.ts'
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/authClient.ts' to 'authClient.d.ts'
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/storage.ts' to 'storage.d.ts'
rpt2: emitting declarations for '/Users/yarinsasson/Documents/Work/user-management-service/sdk/src/types.ts' to 'types.d.ts'
dist/index.d.ts        0.01 KiB
dist/authClient.d.ts   0.11 KiB
dist/storage.d.ts      0.06 KiB
dist/types.d.ts        0.11 KiB
dist/sdk.es.js         0.33 KiB / gzip: 0.19 KiB
@yarinsa yarinsa changed the title Bug: class constructor property are not transpiled correctly bug: semantic error TS2339: Property 'x' does not exist on type 'y'. Feb 17, 2022
@yarinsa yarinsa changed the title bug: semantic error TS2339: Property 'x' does not exist on type 'y'. bug: Typescript check doesn't work as expected. Feb 22, 2022
@yarinsa
Copy link
Author

yarinsa commented Feb 22, 2022

It seems like I am gonna have to set the check flag to false.
I have tried to run the build without cache. I also tried running tsc -b. tsc doesn't emit any problems (and static tslint).
I also supplied my instance of 'typescript'. None of the above seems to work.

I think it's a major feature since failing the build if the type checking failed is a core feature of TS.
I have no problem tracking down the issue and contributing, but I need some guidance @ezolenko

@yarinsa yarinsa changed the title bug: Typescript check doesn't work as expected. bug: type check doesn't work as expected. Feb 22, 2022
@ezolenko
Copy link
Owner

ezolenko commented Mar 5, 2022

That supposed to work I think -- rpt2 uses this syntax itself in host.ts for example, and it builds itself with an older version of itself...

@agilgur5 agilgur5 changed the title bug: type check doesn't work as expected. class constructor throws type error with rpt2 but not tsc Apr 23, 2022
@yarinsa
Copy link
Author

yarinsa commented Apr 25, 2022

Just an update in case someone runs into this issue.
I deep-dived into the plugin code. Few configurations that I didn't have in my tsconfig and the Plugin 'added' (checked by comparing the resolved config vs provided one) are these ones:

    noEmitHelpers: false,
    importHelpers: true,
    noResolve: false,
    inlineSourceMap: false,
    allowNonTsExtensions: true,
    module: 5,

I am not sure if this is the problem , but It might save some debugging for someone.
I ended up removing this plugin and checking my types using vite-plugin-checker and generating declarations using vite-plugin-dts.

@yarinsa yarinsa closed this as completed Apr 25, 2022
@agilgur5 agilgur5 added the solution: unresolved Issue has been closed by OP but root cause has not necessarily been resolved label Apr 26, 2022
@agilgur5
Copy link
Collaborator

agilgur5 commented Apr 26, 2022

Few configurations that I didn't have in my tsconfig and the Plugin 'added' (checked by comparing the resolved config vs provided one) are these ones:

It is explicitly mentioned in the docs that some options are forced as they're required for rpt2 / Rollup compat

I am not sure if this is the problem , but It might save some debugging for someone.

Probably not, but there's some head-scratching issues where the output is not equivalent to tsc that are very confusing as this plugin is intentionally simple in how it wraps the TS API.
My guess is that they might be caused by other plugins on the chain but I really don't know

@agilgur5 agilgur5 changed the title class constructor throws type error with rpt2 but not tsc class constructor throws type error with rpt2 but not tsc when using Vite Jun 8, 2022
@agilgur5 agilgur5 added the scope: integration Related to an integration, not necessarily to core (but could influence core) label Jun 8, 2022
@agilgur5 agilgur5 changed the title class constructor throws type error with rpt2 but not tsc when using Vite semantic error TS2339: Property 'name' does not exist on type 'User' with rpt2 but not tsc when using Vite Jun 8, 2022
@agilgur5 agilgur5 added kind: support Asking for support with something or a specific use case solution: out-of-scope This is out of scope for this project solution: can't repro An attempt to reproduce has been tried and failed labels Jun 8, 2022
@agilgur5
Copy link
Collaborator

agilgur5 commented Jun 8, 2022

Ok, so I looked into this and created a minimal repro here and was unable to reproduce this.

It took me a bit to even create the reproduction as OP's first edit broke all the code examples, causing errors in both tsc and rpt2. It also made the first two examples duplicates of each other. And it removed the error message from the comment and, after that, the title was changed as well to remove the error message.
So that was incredibly confusing.
I've edited it myself to merge the first edit with the original version to something that actually works and makes sense.

In any case, the minimal environment linked above has all 3 examples and rpt2 passes on all 3 of them. So the issue you're having is not due to rpt2, but your configuration.

Specifically, you wrote:

rollup.config.js

I don't use one

But left out a very important detail, that you're using Vite to build instead of Rollup. And then you did not provide your vite.config.js either...

I had to interpret your logs and your previous comment to figure out that you were using Vite:

$ /Users/yarinsasson/Documents/Work/user-management-service/sdk/node_modules/.bin/vite build

checking my types using vite-plugin-checker and generating declarations using vite-plugin-dts.

Vite already supports TypeScript out-of-the-box with esbuild. So if you wanted to use rpt2 for type-checking, you'd have to either disable that support or run rpt2 first, before esbuild. Running it after esbuild would mean rpt2 is actually reading the untyped compiled JS results.
I'm not sure if Vite even supports that and this plugin was built for Rollup before Vite even existed. EDIT: It does support disabling esbuild by configuring it with exclude: /\.tsx?$/. Not sure about ordering. EDIT: Can use enforce: 'pre' to run rpt2 before esbuild
The Vite team should probably have reached out here to make sure the integration (mentioned in their docs) works instead of ad-hoc issues by users who wouldn't know the implementation details... 😕

The error you're getting is also similar to #235, which is due to a bug within rollup-plugin-vue vuejs/rollup-plugin-vue#311 (not this plugin). It's possible Vite has a similar bug. #352 experienced a similar error with Vite as well.

So this either a bug in Vite itself or a misconfiguration. But as it's not reproducible with just rpt2 and Rollup, it's not a bug in this library.

@agilgur5 agilgur5 added scope: upstream Issue in upstream dependency and removed solution: unresolved Issue has been closed by OP but root cause has not necessarily been resolved labels Jun 8, 2022
@agilgur5 agilgur5 added the problem: stale Issue has not been responded to in some time label Jun 23, 2022
@agilgur5 agilgur5 changed the title semantic error TS2339: Property 'name' does not exist on type 'User' with rpt2 but not tsc when using Vite semantic error TS2339: Property 'name' does not exist on type 'User' with rpt2 but not tsc when using Vite Jul 30, 2022
@agilgur5 agilgur5 added the solution: invalid This doesn't seem right label Jul 30, 2022
@agilgur5 agilgur5 changed the title semantic error TS2339: Property 'name' does not exist on type 'User' with rpt2 but not tsc when using Vite semantic error TS2339: Property 'name' does not exist on type 'User' with rpt2 but not tsc when using Vite -- can't repro Jul 30, 2022
@agilgur5 agilgur5 added the scope: Vite Related to integration with Vite, not Rollup, which this plugin was designed for label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: support Asking for support with something or a specific use case problem: stale Issue has not been responded to in some time scope: integration Related to an integration, not necessarily to core (but could influence core) scope: upstream Issue in upstream dependency scope: Vite Related to integration with Vite, not Rollup, which this plugin was designed for solution: can't repro An attempt to reproduce has been tried and failed solution: invalid This doesn't seem right solution: out-of-scope This is out of scope for this project
Projects
None yet
Development

No branches or pull requests

3 participants