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

TypeScript Declarations not found when using export maps #363

Closed
TheComputerM opened this issue May 23, 2021 · 2 comments
Closed

TypeScript Declarations not found when using export maps #363

TheComputerM opened this issue May 23, 2021 · 2 comments

Comments

@TheComputerM
Copy link

Describe the bug
Suppose I have a npm package named package. The package.json of package looks like:

{
  "name": "package",
  "version": "1.0.0",
  "main": "index.js",
  "types": "./types/index.d.ts",
  "exports": {
    ".": {
      "default": "./index.js"
    },
    "./Component": {
      "default": "./Component.svelte"
    }
  }
}

The types directory in package looks like:

- index.d.ts
- Component.d.ts

The content of Component.d.ts is:

/// <reference types="svelte" />
import { SvelteComponentTyped } from 'svelte';

export interface Props {
  /**
   * @default "svelte"
   */
  prop?: string;
}

export default class Component extends SvelteComponentTyped<Props, {}, {}> {}

Now in my app where I have svelte with typescript with the content of the tsconfig.json as

{
  "extends": "@tsconfig/svelte/tsconfig.json",
  "compilerOptions": {
    "moduleResolution": "node",
    "module": "es2020",
    "lib": ["es2020"],
    "target": "es2019",
    "importsNotUsedAsValues": "error",
    "isolatedModules": true,
    "resolveJsonModule": true,
    "sourceMap": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": ".",
    "allowJs": true,
    "checkJs": true
  },
  "include": ["src/**/*"]
}

and my svelte.config.js is:

const sveltePreprocess = require('svelte-preprocess');

module.exports = {
  preprocess: sveltePreprocess(),
};

And in my Svelte file I import package/Component:

image

To Reproduce

Expected behavior
No ts error

Information about your project:

  • Windows 10
  • svelte-preprocess version 4.7.3
@TheComputerM
Copy link
Author

Hey I think this is a bug with language-tools and not svelte-preprocess, so transferring the issue.

@TheComputerM
Copy link
Author

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

No branches or pull requests

1 participant