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

isolatedModules option is not work in ^5.0.0 version #53683

Closed
winterlood opened this issue Apr 6, 2023 · 4 comments
Closed

isolatedModules option is not work in ^5.0.0 version #53683

winterlood opened this issue Apr 6, 2023 · 4 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@winterlood
Copy link

Bug Report

πŸ”Ž Search Terms

isolatedModules

πŸ•— Version & Regression Information

This changed between versions 4.9.5 and 5.0.3

⏯ Playground Link

https://www.typescriptlang.org/play?isolatedModules=true#code/PTAEEsGcHsBsEMAuBTAJgWWqgrrZlRoAHRcaAO1EmUVAHJEAnbZOgKBFHnNVHOlDIAHkWiNaYiAFtR40AGtkATwDuY1BzAAjbLW5LBjRpP56iRZPEabQASQBmoJdGygAxgAtuAc2ShEHn4AbsiMkGSUiAIALAB0AJyxAKwANP6BkYGGxoygKuCwsFzmlrkqyIVsbG4UkLQodaAAvPQNiHQA3FX22ORupBSg9uQAFACUoADeAL5AA

πŸ’» Code

tsconfig.json

{
  "compilerOptions": {
    "isolatedModules": true
  }
}

index.ts

const a = 1;

isolatedModules option set 'true'
and this code has no export or import keyword
but any error not appear

πŸ™ Actual behavior

it seems in 4.9.5 isolatedModules option work
but in 5.0.3 isolatedModules option not work

πŸ™‚ Expected behavior

I think the error should occur in 5.0.3, just like 4.9.5

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Apr 6, 2023
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.1.0 milestone Apr 6, 2023
@andrewbranch andrewbranch added Working as Intended The behavior described is the intended behavior; this is not a bug and removed Bug A bug in TypeScript labels Apr 6, 2023
@andrewbranch andrewbranch removed this from the TypeScript 5.1.0 milestone Apr 6, 2023
@andrewbranch andrewbranch removed their assignment Apr 6, 2023
@andrewbranch
Copy link
Member

Scripts are no longer errors in isolatedModules unless they use global namespace declarations, which is the only kind of construct that is not safe to single-file transpile. See the motivating issue #46295, design discussion in #51813, and implementation at cf5c284 as part of #52203.

@fatcerberus
Copy link

@andrewbranch Somewhat related, is there a way to get TS to treat all files as modules regardless of whether they contain imports/exports or not? Or does verbatimModuleSyntax already do that?

@andrewbranch
Copy link
Member

--moduleDetection force

@typescript-bot
Copy link
Collaborator

This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

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

5 participants