Skip to content

allowArbitraryExtensions does not work as expected #55507

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

Closed
indooorsman opened this issue Aug 25, 2023 · 4 comments
Closed

allowArbitraryExtensions does not work as expected #55507

indooorsman opened this issue Aug 25, 2023 · 4 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@indooorsman
Copy link

indooorsman commented Aug 25, 2023

🔎 Search Terms

allowArbitraryExtensions

🕗 Version & Regression Information

⏯ Playground Link

https://codesandbox.io/p/sandbox/typescript-playground-export-forked-mfz7rg?file=/index.ts:10,28

💻 Code

import {} from "./app.css";

export {};

my tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "module": "ESNext",
    "target": "ESNext",
    "lib": [
      "ESNext",
      "DOM",
      "DOM.Iterable"
    ],
    "moduleResolution": "bundler",
    "customConditions": [
      "dev"
    ],
    "jsx": "react-jsx",
    "declaration": true,
    "emitDeclarationOnly": true,
    "isolatedModules": true,
    "strict": true,
    "allowJs": true,
    "skipDefaultLibCheck": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "allowArbitraryExtensions": true,
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "sourceMap": false,
    "rootDirs": [
      "./src",
      "./esm"
    ],
    "outDir": "./esm"
  },
  "include": [
    "./src/**/*"
  ]
}

🙁 Actual behavior

I have set allowArbitraryExtensions to true, but it still throw error when import a .css file.
As mentioned in document:

you can suppress the error with the new --allowArbitraryExtensions compiler option.

🙂 Expected behavior

should not throw error

Additional information about the issue

issue

@MartinJohns
Copy link
Contributor

You're missing the app.d.css.ts file.

@indooorsman
Copy link
Author

indooorsman commented Aug 25, 2023 via email

@fatcerberus
Copy link

Not sure where you got that idea.

#51435, where this was implemented:

Add --allowArbitraryExtensions, a flag for allowing arbitrary extensions on import paths

And, correspondingly, the .d.ext.ts files needed to describe the shape of whatever it is [you’re] importing.

You still need types for the file you’re importing, as with any other import. The flag just prevents the import from failing on the basis of the file extension alone.

@indooorsman
Copy link
Author

indooorsman commented Aug 25, 2023 via email

@andrewbranch andrewbranch added the Working as Intended The behavior described is the intended behavior; this is not a bug label Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants