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 typings are not found #39

Closed
tjveldhuizen opened this issue Apr 4, 2021 · 4 comments · Fixed by #55
Closed

Typescript typings are not found #39

tjveldhuizen opened this issue Apr 4, 2021 · 4 comments · Fixed by #55

Comments

@tjveldhuizen
Copy link

Inspired by the SymfonyCasts series on Stimulus, I've started using it in my project. However, I'ld like to use Typescript. I can't get the @symfony/stimulus-bridge-types package to work. Since it's not in the @types -namespace, it's not automatically detected. Therefore I've adapted my typeRoots-property in tsconfig.json, but it's still not detected:

  "compilerOptions": {
    "target": "esnext",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "typeRoots": [
      "node_modules/@types",
      "node_modules/@symfony/stimulus-bridge-types"
    ]
  }
}

Is there a specific reason to put the index.d.ts in a separate package? Since it's so small, I think it can be bundled in the main package (https://www.typescriptlang.org/docs/handbook/2/type-declarations.html#external-definitions)

@cfoehrdes
Copy link

I can't find any information on how to get this @symfony/stimulus-bridge-types to work. Also tried the typeRoots etc.

@cfoehrdes
Copy link

I found out how to load the stimulus bridge types by the explanation in this issue comment.

"compilerOptions": {
        "target": "esnext",
        "moduleResolution": "node",
        "allowJs": true,
        "noEmit": true,
        "strict": true,
        "isolatedModules": true,
        "esModuleInterop": true,
        "baseUrl": "./",
        "paths": {
            "*": [
                "node_modules/@symfony/stimulus-bridge-types"
            ]
        }
    },

You have to add the package to the paths instead of typeRoots.

@Nek-
Copy link

Nek- commented Nov 19, 2021

I use this configuration otherwise I have problems with bootstrap types:

{
    "compilerOptions": {
        "outDir": "./dist/",
        "noImplicitAny": true,
        "module": "es6",
        "target": "es5",
        "jsx": "react",
        "allowJs": true,
        "moduleResolution": "node",
        "baseUrl": "./",
        "paths": {
            "@symfony/stimulus-bridge": [
                "node_modules/@symfony/stimulus-bridge-types"
            ]
        }
    }
}

@weaverryan
Copy link
Member

See #55 :)

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

Successfully merging a pull request may close this issue.

4 participants