underfin / vite-plugin-vue2

Vue2 plugin for Vite
620 stars 83 forks source link

Don't import from typescript source files #125

Closed shadow-light closed 3 years ago

shadow-light commented 3 years ago

Importing from typescript source files distributed with a module causes user projects to type check those source files using the tsconfig of the user project rather than that of the module, with stricter settings raising errors that are not actually errors but simply stricter type check settings.

See https://github.com/microsoft/TypeScript/issues/40426

shadow-light commented 3 years ago

The result of this issue is that when checking my project's types, it throws these errors simply because it followed the import paths to the module's typescript source. There is currently no way to silence these errors as tsconfig exclude and other settings have no effect.

app/node_modules/@vue/component-compiler-utils/lib/compileTemplate.ts:109:32 - error TS4111: Property 'NODE_ENV' comes from an index signature, so it must be accessed with ['NODE_ENV'].

109     isProduction = process.env.NODE_ENV === 'production',
                                   ~~~~~~~~

app/node_modules/@vue/component-compiler-utils/lib/compileTemplate.ts:182:15 - error TS2571: Object is of type 'unknown'.

182           if (e.code === 'MODULE_NOT_FOUND') {
                  ~

app/node_modules/@vue/component-compiler-utils/lib/templateCompilerModules/srcset.ts:37:15 - error TS2322: Type '{ require: string; descriptor: string | undefined; }[]' is not assignable to type 'ImageCandidate[]'.
  Type '{ require: string; descriptor: string | undefined; }' is not assignable to type 'ImageCandidate'.
    Types of property 'descriptor' are incompatible.
      Type 'string | undefined' is not assignable to type 'string'.
        Type 'undefined' is not assignable to type 'string'.

37         const imageCandidates: ImageCandidate[] = value
                 ~~~~~~~~~~~~~~~

app/node_modules/@vue/component-compiler-utils/lib/templateCompilerModules/srcset.ts:48:37 - error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.

48               require: urlToRequire(url, transformAssetUrlsOptions),
                                       ~~~