mattpocock / ts-reset

A 'CSS reset' for TypeScript, improving types for common JavaScript API's
https://www.totaltypescript.com/ts-reset
MIT License
7.9k stars 124 forks source link

Import only one TS Reset doesn't work #195

Closed RodrigoTomeES closed 5 months ago

RodrigoTomeES commented 6 months ago

Import only one TS Reset as documented here https://www.totaltypescript.com/ts-reset doesn't work

https://github.com/total-typescript/ts-reset/assets/13077343/b2271413-f1af-4574-9aae-489b19be0630

alphakevin commented 6 months ago

Hi Rodrigo, have you try importing the entry in a *.ts but not *.d.ts declaration file?

mattpocock commented 6 months ago

What does your tsconfig.json look like? Which moduleResolution are you using?

RodrigoTomeES commented 5 months ago

@mattpocock this is our tsconfig

{
  "compilerOptions": {
    "baseUrl": ".",
    "target": "es6",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "downlevelIteration": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "paths": {
      "@/config": ["config"],
      "@/config/*": ["config/*"],
      "@/assets": ["public/assets"],
      "@/assets/*": ["public/assets/*"],
      "@/hoc": ["components/hoc"],
      "@/hoc/*": ["components/hoc/*"],
      "@/icons": ["components/icons"],
      "@/icons/*": ["components/icons/*"],
      "@/atoms": ["components/atoms"],
      "@/atoms/*": ["components/atoms/*"],
      "@/molecules": ["components/molecules"],
      "@/molecules/*": ["components/molecules/*"],
      "@/organisms": ["components/organisms"],
      "@/organisms/*": ["components/organisms/*"],
      "@/templates": ["components/templates"],
      "@/templates/*": ["components/templates/*"],
      "@/pages": ["components/pages"],
      "@/pages/*": ["components/pages/*"],
      "@/layouts": ["components/layouts"],
      "@/layouts/*": ["components/layouts/*"],
      "@/components": ["components"],
      "@/components/*": ["components/*"],
      "@/styles": ["styles"],
      "@/styles/*": ["styles/*"],
      "@/stories": ["stories"],
      "@/stories/*": ["stories/*"],
      "@/uikit": ["stories/uikit"],
      "@/uikit/*": ["stories/uikit/*"],
      "@/lib": ["lib"],
      "@/lib/*": ["lib/*"],
      "@/types": ["types"],
      "@/types/*": ["types/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules", "**/*.spec.ts", "stories/assets"]
}
RodrigoTomeES commented 5 months ago

@alphakevin yes, that works

mattpocock commented 5 months ago

@RodrigoTomeES As it says in the readme, your moduleResolution needs to be NodeNext or Bundler.

RodrigoTomeES commented 5 months ago

@mattpocock where? because I only saw this

Screenshot 2024-05-15 at 09 13 54

mattpocock commented 5 months ago

image

Added a PR to add 'Bundler' to this list, which is what you should have in your tsconfig. moduleResolution: 'node' is legacy.